From b760585571667f0e71d48ee074c5161a50548ca7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 6 Jul 2014 17:24:42 +0000 Subject: - fix for the auth url; - precompiled headers; - unused junk removed; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@9712 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Twitter/src/StringConv.cpp | 87 ----- protocols/Twitter/src/StringConv.h | 51 --- protocols/Twitter/src/StringUtil.h | 9 + protocols/Twitter/src/chat.cpp | 1 + protocols/Twitter/src/common.h | 99 ------ protocols/Twitter/src/connection.cpp | 4 +- protocols/Twitter/src/contacts.cpp | 2 +- protocols/Twitter/src/http.cpp | 5 +- protocols/Twitter/src/main.cpp | 3 +- protocols/Twitter/src/oauth.cpp | 4 +- protocols/Twitter/src/proto.cpp | 10 +- protocols/Twitter/src/proto.h | 4 - protocols/Twitter/src/stdafx.cpp | 18 + protocols/Twitter/src/stdafx.h | 85 ++++- protocols/Twitter/src/stubs.cpp | 1 + protocols/Twitter/src/theme.cpp | 1 + protocols/Twitter/src/theme.h | 2 - protocols/Twitter/src/twitter.cpp | 7 +- protocols/Twitter/src/twitter.h | 9 +- protocols/Twitter/src/ui.cpp | 473 +++++++++++---------------- protocols/Twitter/src/utility.cpp | 2 +- protocols/Twitter/src/utility.h | 1 - protocols/Twitter/src/version.h | 2 +- protocols/Twitter/twitter_10.vcxproj | 13 +- protocols/Twitter/twitter_10.vcxproj.filters | 12 +- protocols/Twitter/twitter_12.vcxproj | 13 +- protocols/Twitter/twitter_12.vcxproj.filters | 12 +- 27 files changed, 346 insertions(+), 584 deletions(-) delete mode 100644 protocols/Twitter/src/StringConv.cpp delete mode 100644 protocols/Twitter/src/StringConv.h delete mode 100644 protocols/Twitter/src/common.h create mode 100644 protocols/Twitter/src/stdafx.cpp (limited to 'protocols') diff --git a/protocols/Twitter/src/StringConv.cpp b/protocols/Twitter/src/StringConv.cpp deleted file mode 100644 index c0e4f9221c..0000000000 --- a/protocols/Twitter/src/StringConv.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - -Copyright (c) 2010 Brook Miles - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -*/ - -#include -#include -#include "StringConv.h" - -std::string WideToMB(const std::wstring& str, UINT codePage) -{ - std::string ret; - if(str.length() > 0) - { - DWORD mbChars = WideCharToMultiByte(codePage, 0, str.c_str(), -1, NULL, 0, NULL, NULL); - _ASSERTE(mbChars > 0); - if(mbChars > 0) - { - char* buf = new char[mbChars]; - _ASSERTE( buf != NULL ); - if( buf != NULL ) - { - ZeroMemory(buf, mbChars); - - DWORD charsConverted = WideCharToMultiByte(codePage, 0, str.c_str(), -1, buf, mbChars, NULL, NULL); - _ASSERTE( charsConverted > 0 ); - _ASSERTE( charsConverted <= mbChars ); - - buf[mbChars - 1] = 0; - ret = buf; - - delete[] buf; - } - } - } - return ret; -} - -std::wstring MBToWide(const std::string& str, UINT codePage) -{ - std::wstring ret; - if(str.length() > 0) - { - DWORD wChars = MultiByteToWideChar(codePage, 0, str.c_str(), -1, NULL, 0); - _ASSERTE(wChars > 0); - if(wChars > 0) - { - wchar_t* buf = new wchar_t[wChars]; - _ASSERTE( buf != NULL ); - if( buf != NULL ) - { - size_t bytesNeeded = sizeof(wchar_t)*wChars; - ZeroMemory(buf, bytesNeeded); - - DWORD charsConverted = MultiByteToWideChar(codePage, 0, str.c_str(), -1, buf, wChars); - _ASSERTE( charsConverted > 0 ); - _ASSERTE( charsConverted <= wChars ); - - buf[wChars - 1] = 0; - ret = buf; - - delete[] buf; - } - } - } - return ret; -} - diff --git a/protocols/Twitter/src/StringConv.h b/protocols/Twitter/src/StringConv.h deleted file mode 100644 index ec25c15ef7..0000000000 --- a/protocols/Twitter/src/StringConv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - -Copyright (c) 2010 Brook Miles - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -*/ - -#include - -#ifndef StringConv_h__ -#define StringConv_h__ - -#pragma once - - -std::string WideToMB(const std::wstring& str, UINT codePage = CP_ACP); -std::wstring MBToWide(const std::string& str, UINT codePage = CP_ACP); - -inline std::string WideToUTF8(const std::wstring& str) { return WideToMB(str, CP_UTF8); } -inline std::wstring UTF8ToWide(const std::string& str) { return MBToWide(str, CP_UTF8); } - -inline std::string ANSIToUTF8(const std::string& str, UINT codePage = CP_ACP) { return WideToUTF8(MBToWide(str, codePage)); } -inline std::string UTF8ToANSI(const std::string& str, UINT codePage = CP_ACP) { return WideToMB(UTF8ToWide(str), codePage); } - - -#define TCHARToUTF8 WideToUTF8 -#define UTF8ToTCHAR UTF8ToWide -#define TCHARToWide -#define WideToTCHAR -#define TCHARToMB WideToMB -#define MBToTCHAR MBToWide - - -#endif // StringConv_h__ diff --git a/protocols/Twitter/src/StringUtil.h b/protocols/Twitter/src/StringUtil.h index 902e262c02..ef88318446 100644 --- a/protocols/Twitter/src/StringUtil.h +++ b/protocols/Twitter/src/StringUtil.h @@ -30,6 +30,15 @@ tstring GetWord(const tstring& str, unsigned index, bool getRest = false); std::string& replaceAll(std::string& context, const std::string& from, const std::string& to); +inline std::string WideToUTF8(const std::wstring& str) +{ + return (char*)ptrA(mir_utf8encodeW(str.c_str())); +} + +inline std::wstring UTF8ToWide(const std::string& str) +{ + return (wchar_t*)ptrW(mir_utf8decodeW(str.c_str())); +} inline bool Compare(const tstring& one, const tstring& two, bool caseSensitive) { diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index d08e1c81e7..e94bdc40e3 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "proto.h" #include diff --git a/protocols/Twitter/src/common.h b/protocols/Twitter/src/common.h deleted file mode 100644 index d28a821032..0000000000 --- a/protocols/Twitter/src/common.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright © 2009 Jim Porter - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#include -using std::string; -using std::wstring; -#include -using std::map; -#include -using std::vector; -#include -using std::list; -#include -using std::min; - -#include -#include - -#include "resource.h" - -#pragma warning(push) -# pragma warning(disable:4312) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#pragma warning(pop) - -extern HINSTANCE g_hInstance; - -#define TWITTER_KEY_NICK "Nick" // we need one called Nick for the chat thingo to work -#define TWITTER_KEY_UN "Username" -#define TWITTER_KEY_PASS "Password" -#define TWITTER_KEY_OAUTH_PIN "OAuthPIN" -#define TWITTER_KEY_OAUTH_TOK "OAuthToken" -#define TWITTER_KEY_OAUTH_TOK_SECRET "OAuthTokenSecret" -#define TWITTER_KEY_OAUTH_ACCESS_TOK "OAuthAccessToken" -#define TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET "OAuthAccessTokenSecret" -#define TWITTER_KEY_BASEURL "BaseURL" -#define TWITTER_KEY_CHATFEED "ChatFeed" -#define TWITTER_KEY_POLLRATE "PollRate" -#define TWITTER_KEY_GROUP "DefaultGroup" - -#define TWITTER_KEY_POPUP_SHOW "Popup/Show" -#define TWITTER_KEY_POPUP_SIGNON "Popup/Signon" -#define TWITTER_KEY_POPUP_COLBACK "Popup/ColorBack" -#define TWITTER_KEY_POPUP_COLTEXT "Popup/ColorText" -#define TWITTER_KEY_POPUP_TIMEOUT "Popup/Timeout" - -#define TWITTER_KEY_TWEET_TO_MSG "TweetToMsg" - -#define TWITTER_KEY_SINCEID "SinceID" -#define TWITTER_KEY_DMSINCEID "DMSinceID" -#define TWITTER_KEY_NEW "NewAcc" - -#define TWITTER_KEY_AV_URL "AvatarURL" - -#define TWITTER_DB_EVENT_TYPE_TWEET 2718 - -#define WM_SETREPLY WM_APP+10 diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 783438280e..92b929ffc4 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -15,10 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "proto.h" -//#include "tc2.h" #include "twitter.h" -#include void CALLBACK TwitterProto::APC_callback(ULONG_PTR p) { @@ -148,7 +147,6 @@ bool TwitterProto::NegotiateConnection() http::response resp = twit_.request_token(); //wstring rdata_WSTR(resp.data.length(),L' '); - //std::copy(resp.data.begin(), resp.data.end(), rdata_WSTR.begin()); wstring rdata_WSTR = UTF8ToWide(resp.data); //debugLogW("**NegotiateConnection - REQUEST TOKEN IS %s", rdata_WSTR); diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index a6538af1df..9b74284170 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "proto.h" - void TwitterProto::AddToListWorker(void *p) { // TODO: what happens if there is an error? diff --git a/protocols/Twitter/src/http.cpp b/protocols/Twitter/src/http.cpp index 3d0414b7d5..2c07b80902 100644 --- a/protocols/Twitter/src/http.cpp +++ b/protocols/Twitter/src/http.cpp @@ -15,12 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "http.h" -#include -#include -#include - std::string http::url_encode(const std::string &s) { return (char*)ptrA( mir_urlEncode( s.c_str())); diff --git a/protocols/Twitter/src/main.cpp b/protocols/Twitter/src/main.cpp index e2c023bada..e4edf0beaa 100644 --- a/protocols/Twitter/src/main.cpp +++ b/protocols/Twitter/src/main.cpp @@ -15,13 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "common.h" +#include "stdafx.h" #include "version.h" #include "proto.h" #include "theme.h" - CLIST_INTERFACE* pcli; HINSTANCE g_hInstance; diff --git a/protocols/Twitter/src/oauth.cpp b/protocols/Twitter/src/oauth.cpp index 798f837499..82e409e5ac 100644 --- a/protocols/Twitter/src/oauth.cpp +++ b/protocols/Twitter/src/oauth.cpp @@ -3,11 +3,9 @@ * best way? */ +#include "stdafx.h" #include "twitter.h" -//#include "tc2.h" #include "utility.h" -#include "stdafx.h" -#include "common.h" OAuthParameters mir_twitter::BuildSignedOAuthParameters( const OAuthParameters& requestParameters, const std::wstring& url, diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index b2e1bf021f..f90f6b504c 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "proto.h" #include "utility.h" @@ -22,13 +23,6 @@ along with this program. If not, see . #include "ui.h" #include "oauth.dev.h" -#include "m_folders.h" - -#include -#include -#include -#include - static volatile LONG g_msgid = 1; TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) : @@ -69,7 +63,7 @@ TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) : ConsumerKey = OAUTH_CONSUMER_KEY; ConsumerSecret = OAUTH_CONSUMER_SECRET; - AuthorizeUrl = _T("http://api.twitter.com/oauth/authorize?oauth_token=%s"); + AuthorizeUrl = _T("https://api.twitter.com/oauth/authorize?oauth_token=%s"); } TwitterProto::~TwitterProto() diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 7c0207d78b..e19d1578ad 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -17,11 +17,7 @@ along with this program. If not, see . #pragma once -#include "common.h" #include "utility.h" -#include "stdafx.h" - -#include class TwitterProto : public PROTO { diff --git a/protocols/Twitter/src/stdafx.cpp b/protocols/Twitter/src/stdafx.cpp new file mode 100644 index 0000000000..058bd215c8 --- /dev/null +++ b/protocols/Twitter/src/stdafx.cpp @@ -0,0 +1,18 @@ +/* +Copyright © 2009 Jim Porter + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "stdafx.h" \ No newline at end of file diff --git a/protocols/Twitter/src/stdafx.h b/protocols/Twitter/src/stdafx.h index 5297006d94..7fffc2807d 100644 --- a/protocols/Twitter/src/stdafx.h +++ b/protocols/Twitter/src/stdafx.h @@ -13,18 +13,93 @@ #include #include #include +#include #include #include +#include +#include +#include #include -#include -#include +using std::string; +using std::wstring; #include -#include +using std::map; +#include +using std::vector; +#include +using std::list; +#include +using std::min; +#include typedef std::basic_string tstring; -#include "StringConv.h" +#include "resource.h" + +#pragma warning(push) +# pragma warning(disable:4312) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#pragma warning(pop) + #include "StringUtil.h" -#include "win2k.h" +extern HINSTANCE g_hInstance; + +#define TWITTER_KEY_NICK "Nick" // we need one called Nick for the chat thingo to work +#define TWITTER_KEY_UN "Username" +#define TWITTER_KEY_PASS "Password" +#define TWITTER_KEY_OAUTH_PIN "OAuthPIN" +#define TWITTER_KEY_OAUTH_TOK "OAuthToken" +#define TWITTER_KEY_OAUTH_TOK_SECRET "OAuthTokenSecret" +#define TWITTER_KEY_OAUTH_ACCESS_TOK "OAuthAccessToken" +#define TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET "OAuthAccessTokenSecret" +#define TWITTER_KEY_BASEURL "BaseURL" +#define TWITTER_KEY_CHATFEED "ChatFeed" +#define TWITTER_KEY_POLLRATE "PollRate" +#define TWITTER_KEY_GROUP "DefaultGroup" + +#define TWITTER_KEY_POPUP_SHOW "Popup/Show" +#define TWITTER_KEY_POPUP_SIGNON "Popup/Signon" +#define TWITTER_KEY_POPUP_COLBACK "Popup/ColorBack" +#define TWITTER_KEY_POPUP_COLTEXT "Popup/ColorText" +#define TWITTER_KEY_POPUP_TIMEOUT "Popup/Timeout" + +#define TWITTER_KEY_TWEET_TO_MSG "TweetToMsg" + +#define TWITTER_KEY_SINCEID "SinceID" +#define TWITTER_KEY_DMSINCEID "DMSinceID" +#define TWITTER_KEY_NEW "NewAcc" + +#define TWITTER_KEY_AV_URL "AvatarURL" + +#define TWITTER_DB_EVENT_TYPE_TWEET 2718 + +#define WM_SETREPLY WM_APP+10 diff --git a/protocols/Twitter/src/stubs.cpp b/protocols/Twitter/src/stubs.cpp index 2fc9aebacc..d40d814521 100644 --- a/protocols/Twitter/src/stubs.cpp +++ b/protocols/Twitter/src/stubs.cpp @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "proto.h" MCONTACT TwitterProto::AddToListByEvent(int flags,int iContact,HANDLE hDbEvent) diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp index 7b0a6a6eac..f2abf6ab71 100644 --- a/protocols/Twitter/src/theme.cpp +++ b/protocols/Twitter/src/theme.cpp @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "theme.h" #include "proto.h" diff --git a/protocols/Twitter/src/theme.h b/protocols/Twitter/src/theme.h index fd331236fe..e74f5da2e3 100644 --- a/protocols/Twitter/src/theme.h +++ b/protocols/Twitter/src/theme.h @@ -17,8 +17,6 @@ along with this program. If not, see . #pragma once -#include "common.h" - void InitIcons(void); HANDLE GetIconHandle(const char *name); diff --git a/protocols/Twitter/src/twitter.cpp b/protocols/Twitter/src/twitter.cpp index f5157b8caf..504ec20206 100644 --- a/protocols/Twitter/src/twitter.cpp +++ b/protocols/Twitter/src/twitter.cpp @@ -15,13 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "twitter.h" -//#include "tc2.h" - -#include -#include -#include -#include #include "tinyjson.hpp" #include diff --git a/protocols/Twitter/src/twitter.h b/protocols/Twitter/src/twitter.h index b087643ee8..96aee77cdc 100644 --- a/protocols/Twitter/src/twitter.h +++ b/protocols/Twitter/src/twitter.h @@ -17,22 +17,15 @@ along with this program. If not, see . #pragma once -#include -#include -#include - using std::string; using std::wstring; using std::map; using std::vector; #include "http.h" -#include "StringConv.h" -#include "stdafx.h" #define tstring wstring - typedef unsigned long long twitter_id; typedef std::map OAuthParameters; @@ -113,4 +106,4 @@ protected: std::wstring oauthAccessToken_; std::wstring oauthAccessTokenSecret_; std::wstring pin_; -}; \ No newline at end of file +}; diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp index 9d8dfdd924..7f9a582836 100644 --- a/protocols/Twitter/src/ui.cpp +++ b/protocols/Twitter/src/ui.cpp @@ -15,11 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "ui.h" -#include -#include - #include "proto.h" #include "twitter.h" @@ -28,101 +26,68 @@ static const TCHAR *sites[] = { _T("https://identi.ca/api/") }; -INT_PTR CALLBACK first_run_dialog(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TwitterProto *proto; - switch(msg) - { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); proto = reinterpret_cast(lParam); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); DBVARIANT dbv; - - if(!db_get_ts(0,proto->ModuleName(),TWITTER_KEY_GROUP,&dbv)) - { - SetDlgItemText(hwndDlg,IDC_GROUP,dbv.ptszVal); + if (!db_get_ts(0, proto->ModuleName(), TWITTER_KEY_GROUP, &dbv)) { + SetDlgItemText(hwndDlg, IDC_GROUP, dbv.ptszVal); db_free(&dbv); } - else - { - SetDlgItemText(hwndDlg,IDC_GROUP,L"Twitter"); - } + else SetDlgItemText(hwndDlg, IDC_GROUP, L"Twitter"); - if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv)) - { - SetDlgItemTextA(hwndDlg,IDC_USERNAME,dbv.pszVal); + if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_UN, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal); db_free(&dbv); } - /*if ( !db_get_s(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv)) - { - CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1, - reinterpret_cast(dbv.pszVal)); - SetDlgItemTextA(hwndDlg,IDC_PW,dbv.pszVal); - db_free(&dbv); - }*/ + for (size_t i = 0; i < SIZEOF(sites); i++) + SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, reinterpret_cast(sites[i])); - for(size_t i=0; i(sites[i])); - } - if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv)) - { - SetDlgItemTextA(hwndDlg,IDC_SERVER,dbv.pszVal); + if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_SERVER, dbv.pszVal); db_free(&dbv); } - else - { - SendDlgItemMessage(hwndDlg,IDC_SERVER,CB_SETCURSEL,0,0); - } - + else SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_SETCURSEL, 0, 0); return true; + case WM_COMMAND: - if(LOWORD(wParam) == IDC_NEWACCOUNTLINK) - { - CallService(MS_UTILS_OPENURL,1,reinterpret_cast("https://twitter.com/signup")); + if (LOWORD(wParam) == IDC_NEWACCOUNTLINK) { + CallService(MS_UTILS_OPENURL, 1, reinterpret_cast("https://twitter.com/signup")); return true; } - if(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)) // Window is done initializing - { - switch(HIWORD(wParam)) - { + if (GetWindowLongPtr(hwndDlg, GWLP_USERDATA)) { // Window is done initializing + switch (HIWORD(wParam)) { case EN_CHANGE: case CBN_EDITCHANGE: case CBN_SELCHANGE: - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case WM_NOTIFY: // might be able to get rid of this bit? - if(reinterpret_cast(lParam)->code == PSN_APPLY) - { - proto = reinterpret_cast(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)); + if (reinterpret_cast(lParam)->code == PSN_APPLY) { + proto = reinterpret_cast(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); char str[128]; TCHAR tstr[128]; - - /* - GetDlgItemTextA(hwndDlg,IDC_UN,str,sizeof(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_UN,str); - - GetDlgItemTextA(hwndDlg,IDC_PW,str,sizeof(str)); - CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_PASS,str); - */ - GetDlgItemTextA(hwndDlg,IDC_SERVER,str,sizeof(str)-1); - if(str[strlen(str)-1] != '/') - strncat(str,"/",sizeof(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str); + GetDlgItemTextA(hwndDlg, IDC_SERVER, str, sizeof(str) - 1); + if (str[strlen(str) - 1] != '/') + strncat(str, "/", sizeof(str)); + db_set_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, str); - GetDlgItemText(hwndDlg,IDC_GROUP,tstr,SIZEOF(tstr)); - db_set_ts(0,proto->ModuleName(),TWITTER_KEY_GROUP,tstr); + GetDlgItemText(hwndDlg, IDC_GROUP, tstr, SIZEOF(tstr)); + db_set_ts(0, proto->ModuleName(), TWITTER_KEY_GROUP, tstr); return true; } @@ -132,181 +97,155 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPa return false; } -INT_PTR CALLBACK tweet_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK tweet_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TwitterProto *proto; - switch(msg) - { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); proto = reinterpret_cast(lParam); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); - SendDlgItemMessage(hwndDlg,IDC_TWEETMSG,EM_LIMITTEXT,140,0); - SetDlgItemText(hwndDlg,IDC_CHARACTERS,_T("140")); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + SendDlgItemMessage(hwndDlg, IDC_TWEETMSG, EM_LIMITTEXT, 140, 0); + SetDlgItemText(hwndDlg, IDC_CHARACTERS, _T("140")); // Set window title TCHAR title[512]; - mir_sntprintf(title,SIZEOF(title),_T("Send Tweet for %s"),proto->m_tszUserName); - SendMessage(hwndDlg,WM_SETTEXT,0,(LPARAM)title); - + mir_sntprintf(title, SIZEOF(title), _T("Send Tweet for %s"), proto->m_tszUserName); + SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title); return true; + case WM_COMMAND: - if(LOWORD(wParam) == IDOK) - { + if (LOWORD(wParam) == IDOK) { TCHAR msg[141]; - proto = reinterpret_cast(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)); + proto = reinterpret_cast(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); - GetDlgItemText(hwndDlg,IDC_TWEETMSG,msg,SIZEOF(msg)); - ShowWindow(hwndDlg,SW_HIDE); + GetDlgItemText(hwndDlg, IDC_TWEETMSG, msg, SIZEOF(msg)); + ShowWindow(hwndDlg, SW_HIDE); - char *narrow = mir_t2a_cp(msg,CP_UTF8); + char *narrow = mir_t2a_cp(msg, CP_UTF8); proto->ForkThread(&TwitterProto::SendTweetWorker, narrow); - EndDialog(hwndDlg, wParam); + EndDialog(hwndDlg, wParam); return true; } - else if(LOWORD(wParam) == IDCANCEL) - { + else if (LOWORD(wParam) == IDCANCEL) { EndDialog(hwndDlg, wParam); return true; } - else if(LOWORD(wParam) == IDC_TWEETMSG && HIWORD(wParam) == EN_CHANGE) - { - size_t len = SendDlgItemMessage(hwndDlg,IDC_TWEETMSG,WM_GETTEXTLENGTH,0,0); + else if (LOWORD(wParam) == IDC_TWEETMSG && HIWORD(wParam) == EN_CHANGE) { + size_t len = SendDlgItemMessage(hwndDlg, IDC_TWEETMSG, WM_GETTEXTLENGTH, 0, 0); char str[4]; - mir_snprintf(str,sizeof(str),"%d",140-len); - SetDlgItemTextA(hwndDlg,IDC_CHARACTERS,str); + mir_snprintf(str, sizeof(str), "%d", 140 - len); + SetDlgItemTextA(hwndDlg, IDC_CHARACTERS, str); return true; } break; case WM_SETREPLY: - { - char foo[512]; - mir_snprintf(foo,sizeof(foo),"@%s ",(char*)wParam); - size_t len = strlen(foo); + char foo[512]; + mir_snprintf(foo, sizeof(foo), "@%s ", (char*)wParam); + size_t len = strlen(foo); - SetDlgItemTextA(hwndDlg,IDC_TWEETMSG,foo); - SendDlgItemMessage(hwndDlg,IDC_TWEETMSG,EM_SETSEL,len,len); + SetDlgItemTextA(hwndDlg, IDC_TWEETMSG, foo); + SendDlgItemMessage(hwndDlg, IDC_TWEETMSG, EM_SETSEL, len, len); - char str[4]; - mir_snprintf(str,sizeof(str),"%d",140-len); - SetDlgItemTextA(hwndDlg,IDC_CHARACTERS,str); + char str[4]; + mir_snprintf(str, sizeof(str), "%d", 140 - len); + SetDlgItemTextA(hwndDlg, IDC_CHARACTERS, str); - return true; - } - break; + return true; } return false; } -INT_PTR CALLBACK options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TwitterProto *proto; - switch(msg) - { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); proto = reinterpret_cast(lParam); DBVARIANT dbv; - if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_UN,&dbv)) - { - SetDlgItemTextA(hwndDlg,IDC_UN,dbv.pszVal); + if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_UN, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_UN, dbv.pszVal); db_free(&dbv); } - /*if( !db_get_s(0,proto->ModuleName(),TWITTER_KEY_PASS,&dbv)) - { - CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1, - reinterpret_cast(dbv.pszVal)); - SetDlgItemTextA(hwndDlg,IDC_PW,dbv.pszVal); - db_free(&dbv); - }*/ + CheckDlgButton(hwndDlg, IDC_CHATFEED, db_get_b(0, proto->ModuleName(), TWITTER_KEY_CHATFEED, 0)); - CheckDlgButton(hwndDlg,IDC_CHATFEED,db_get_b(0,proto->ModuleName(),TWITTER_KEY_CHATFEED,0)); + for (size_t i = 0; i < SIZEOF(sites); i++) + SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_ADDSTRING, 0, reinterpret_cast(sites[i])); - for(size_t i=0; i(sites[i])); - } - - if(!db_get_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,&dbv)) - { - SetDlgItemTextA(hwndDlg,IDC_BASEURL,dbv.pszVal); + if (!db_get_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_BASEURL, dbv.pszVal); db_free(&dbv); } - else - { - SendDlgItemMessage(hwndDlg,IDC_BASEURL,CB_SETCURSEL,0,0); - } - + else SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_SETCURSEL, 0, 0); + char pollrate_str[32]; - mir_snprintf(pollrate_str,sizeof(pollrate_str),"%d",db_get_dw(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,80)); - SetDlgItemTextA(hwndDlg,IDC_POLLRATE,pollrate_str); + mir_snprintf(pollrate_str, sizeof(pollrate_str), "%d", db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POLLRATE, 80)); + SetDlgItemTextA(hwndDlg, IDC_POLLRATE, pollrate_str); - CheckDlgButton(hwndDlg,IDC_TWEET_MSG,db_get_b(0,proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,0)); + CheckDlgButton(hwndDlg, IDC_TWEET_MSG, db_get_b(0, proto->ModuleName(), TWITTER_KEY_TWEET_TO_MSG, 0)); // Do this last so that any events propagated by pre-filling the form don't // instigate a PSM_CHANGED message - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); break; case WM_COMMAND: - if(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)) // Window is done initializing + if (GetWindowLongPtr(hwndDlg, GWLP_USERDATA)) // Window is done initializing { - switch(HIWORD(wParam)) - { + switch (HIWORD(wParam)) { case EN_CHANGE: case BN_CLICKED: case CBN_EDITCHANGE: case CBN_SELCHANGE: - switch(LOWORD(wParam)) - { + switch (LOWORD(wParam)) { case IDC_UN: case IDC_PW: case IDC_BASEURL: - ShowWindow(GetDlgItem(hwndDlg,IDC_RECONNECT),SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_RECONNECT), SW_SHOW); } - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } - + break; case WM_NOTIFY: - if(reinterpret_cast(lParam)->code == PSN_APPLY) - { - proto = reinterpret_cast(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)); + if (reinterpret_cast(lParam)->code == PSN_APPLY) { + proto = reinterpret_cast(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); char str[128]; - GetDlgItemTextA(hwndDlg,IDC_UN,str,sizeof(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_UN,str); + GetDlgItemTextA(hwndDlg, IDC_UN, str, sizeof(str)); + db_set_s(0, proto->ModuleName(), TWITTER_KEY_UN, str); /*GetDlgItemTextA(hwndDlg,IDC_PW,str,sizeof(str)); CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast(str)); db_set_s(0,proto->ModuleName(),TWITTER_KEY_PASS,str);*/ - GetDlgItemTextA(hwndDlg,IDC_BASEURL,str,sizeof(str)-1); - if(str[strlen(str)-1] != '/') - strncat(str,"/",sizeof(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_BASEURL,str); + GetDlgItemTextA(hwndDlg, IDC_BASEURL, str, sizeof(str) - 1); + if (str[strlen(str) - 1] != '/') + strncat(str, "/", sizeof(str)); + db_set_s(0, proto->ModuleName(), TWITTER_KEY_BASEURL, str); - db_set_b(0,proto->ModuleName(),TWITTER_KEY_CHATFEED,IsDlgButtonChecked(hwndDlg,IDC_CHATFEED)); + db_set_b(0, proto->ModuleName(), TWITTER_KEY_CHATFEED, IsDlgButtonChecked(hwndDlg, IDC_CHATFEED)); - GetDlgItemTextA(hwndDlg,IDC_POLLRATE,str,sizeof(str)); + GetDlgItemTextA(hwndDlg, IDC_POLLRATE, str, sizeof(str)); int rate = atoi(str); - if(rate == 0) + if (rate == 0) rate = 80; - db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POLLRATE,rate); + db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POLLRATE, rate); - db_set_b(0,proto->ModuleName(),TWITTER_KEY_TWEET_TO_MSG,IsDlgButtonChecked(hwndDlg,IDC_TWEET_MSG)); + db_set_b(0, proto->ModuleName(), TWITTER_KEY_TWEET_TO_MSG, IsDlgButtonChecked(hwndDlg, IDC_TWEET_MSG)); proto->UpdateSettings(); return true; @@ -320,44 +259,41 @@ namespace popup_options { static int get_timeout(HWND hwndDlg) { - if(IsDlgButtonChecked(hwndDlg,IDC_TIMEOUT_PERMANENT)) + if (IsDlgButtonChecked(hwndDlg, IDC_TIMEOUT_PERMANENT)) return -1; - else if(IsDlgButtonChecked(hwndDlg,IDC_TIMEOUT_CUSTOM)) - { + else if (IsDlgButtonChecked(hwndDlg, IDC_TIMEOUT_CUSTOM)) { char str[32]; - GetDlgItemTextA(hwndDlg,IDC_TIMEOUT,str,sizeof(str)); + GetDlgItemTextA(hwndDlg, IDC_TIMEOUT, str, sizeof(str)); return atoi(str); } else // Default checked (probably) return 0; } - static COLORREF get_text_color(HWND hwndDlg,bool for_db) + static COLORREF get_text_color(HWND hwndDlg, bool for_db) { - if(IsDlgButtonChecked(hwndDlg,IDC_COL_WINDOWS)) - { - if(for_db) + if (IsDlgButtonChecked(hwndDlg, IDC_COL_WINDOWS)) { + if (for_db) return -1; else return GetSysColor(COLOR_WINDOWTEXT); } - else if(IsDlgButtonChecked(hwndDlg,IDC_COL_CUSTOM)) - return (COLORREF)SendDlgItemMessage(hwndDlg,IDC_COLTEXT,CPM_GETCOLOUR,0,0); + else if (IsDlgButtonChecked(hwndDlg, IDC_COL_CUSTOM)) + return (COLORREF)SendDlgItemMessage(hwndDlg, IDC_COLTEXT, CPM_GETCOLOUR, 0, 0); else // Default checked (probably) return 0; } - static COLORREF get_back_color(HWND hwndDlg,bool for_db) + static COLORREF get_back_color(HWND hwndDlg, bool for_db) { - if(IsDlgButtonChecked(hwndDlg,IDC_COL_WINDOWS)) - { - if(for_db) + if (IsDlgButtonChecked(hwndDlg, IDC_COL_WINDOWS)) { + if (for_db) return -1; else return GetSysColor(COLOR_WINDOW); } - else if(IsDlgButtonChecked(hwndDlg,IDC_COL_CUSTOM)) - return (COLORREF)SendDlgItemMessage(hwndDlg,IDC_COLBACK,CPM_GETCOLOUR,0,0); + else if (IsDlgButtonChecked(hwndDlg, IDC_COL_CUSTOM)) + return (COLORREF)SendDlgItemMessage(hwndDlg, IDC_COLBACK, CPM_GETCOLOUR, 0, 0); else // Default checked (probably) return 0; } @@ -367,17 +303,18 @@ namespace popup_options TCHAR *name; TCHAR *text; } const quotes[] = { - { _T("Dorothy Parker"), _T("If, with the literate, I am\n") - _T("Impelled to try an epigram,\n") - _T("I never seek to take the credit;\n") - _T("We all assume that Oscar said it.") }, - { _T("Steve Ballmer"), _T("I have never, honestly, thrown a chair in my life.") }, - { _T("James Joyce"), _T("I think I would know Nora's fart anywhere. I think ") - _T("I could pick hers out in a roomful of farting women.") }, + { + _T("Dorothy Parker"), _T("If, with the literate, I am\n") + _T("Impelled to try an epigram,\n") + _T("I never seek to take the credit;\n") + _T("We all assume that Oscar said it.") }, + { _T("Steve Ballmer"), _T("I have never, honestly, thrown a chair in my life.") }, + { _T("James Joyce"), _T("I think I would know Nora's fart anywhere. I think ") + _T("I could pick hers out in a roomful of farting women.") }, { _T("Brooke Shields"), _T("Smoking kills. If you're killed, you've lost a very ") - _T("important part of your life.") }, - { _T("Yogi Berra"), _T("Always go to other peoples' funerals, otherwise ") - _T("they won't go to yours.") }, + _T("important part of your life.") }, + { _T("Yogi Berra"), _T("Always go to other peoples' funerals, otherwise ") + _T("they won't go to yours.") }, }; static void preview(HWND hwndDlg) @@ -386,121 +323,114 @@ namespace popup_options // Pick a random contact MCONTACT hContact = 0; - int n_contacts = (int)CallService(MS_DB_CONTACT_GETCOUNT,0,0); + int n_contacts = (int)CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); - if(n_contacts != 0) - { + if (n_contacts != 0) { int contact = rand() % n_contacts; hContact = db_find_first(); - for(int i=0; i(lParam); - CheckAndUpdateDlgButton(hwndDlg,IDC_SHOWPOPUPS,db_get_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SHOW,0)); - CheckDlgButton(hwndDlg,IDC_NOSIGNONPOPUPS,!db_get_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SIGNON,0)); - + CheckAndUpdateDlgButton(hwndDlg, IDC_SHOWPOPUPS, db_get_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SHOW, 0)); + CheckDlgButton(hwndDlg, IDC_NOSIGNONPOPUPS, !db_get_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SIGNON, 0)); // ***** Get color information - back_color = db_get_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLBACK,0); - text_color = db_get_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLTEXT,0); - - SendDlgItemMessage(hwndDlg,IDC_COLBACK,CPM_SETCOLOUR,0,RGB(255,255,255)); - SendDlgItemMessage(hwndDlg,IDC_COLTEXT,CPM_SETCOLOUR,0,RGB( 0, 0, 0)); - - if(back_color == -1 && text_color == -1) // Windows defaults - CheckAndUpdateDlgButton(hwndDlg,IDC_COL_WINDOWS,true); - else if(back_color == 0 && text_color == 0) // Popup defaults - CheckAndUpdateDlgButton(hwndDlg,IDC_COL_POPUP,true); - else // Custom colors - { - CheckAndUpdateDlgButton(hwndDlg,IDC_COL_CUSTOM,true); - SendDlgItemMessage(hwndDlg,IDC_COLBACK,CPM_SETCOLOUR,0,back_color); - SendDlgItemMessage(hwndDlg,IDC_COLTEXT,CPM_SETCOLOUR,0,text_color); + back_color = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLBACK, 0); + text_color = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLTEXT, 0); + + SendDlgItemMessage(hwndDlg, IDC_COLBACK, CPM_SETCOLOUR, 0, RGB(255, 255, 255)); + SendDlgItemMessage(hwndDlg, IDC_COLTEXT, CPM_SETCOLOUR, 0, RGB(0, 0, 0)); + + if (back_color == -1 && text_color == -1) // Windows defaults + CheckAndUpdateDlgButton(hwndDlg, IDC_COL_WINDOWS, true); + else if (back_color == 0 && text_color == 0) // Popup defaults + CheckAndUpdateDlgButton(hwndDlg, IDC_COL_POPUP, true); + else { // Custom colors + CheckAndUpdateDlgButton(hwndDlg, IDC_COL_CUSTOM, true); + SendDlgItemMessage(hwndDlg, IDC_COLBACK, CPM_SETCOLOUR, 0, back_color); + SendDlgItemMessage(hwndDlg, IDC_COLTEXT, CPM_SETCOLOUR, 0, text_color); } // ***** Get timeout information - timeout = db_get_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_TIMEOUT,0); - SetDlgItemTextA(hwndDlg,IDC_TIMEOUT,"5"); - - if(timeout == 0) - CheckAndUpdateDlgButton(hwndDlg,IDC_TIMEOUT_DEFAULT,true); - else if(timeout < 0) - CheckAndUpdateDlgButton(hwndDlg,IDC_TIMEOUT_PERMANENT,true); - else - { + timeout = db_get_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_TIMEOUT, 0); + SetDlgItemTextA(hwndDlg, IDC_TIMEOUT, "5"); + + if (timeout == 0) + CheckAndUpdateDlgButton(hwndDlg, IDC_TIMEOUT_DEFAULT, true); + else if (timeout < 0) + CheckAndUpdateDlgButton(hwndDlg, IDC_TIMEOUT_PERMANENT, true); + else { char str[32]; - mir_snprintf(str,sizeof(str),"%d",timeout); - SetDlgItemTextA(hwndDlg,IDC_TIMEOUT,str); - CheckAndUpdateDlgButton(hwndDlg,IDC_TIMEOUT_CUSTOM,true); + mir_snprintf(str, sizeof(str), "%d", timeout); + SetDlgItemTextA(hwndDlg, IDC_TIMEOUT, str); + CheckAndUpdateDlgButton(hwndDlg, IDC_TIMEOUT_CUSTOM, true); } - SendDlgItemMessage(hwndDlg,IDC_TIMEOUT_SPIN,UDM_SETRANGE32,1,INT_MAX); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); + SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_SPIN, UDM_SETRANGE32, 1, INT_MAX); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); return true; case WM_COMMAND: - switch(HIWORD(wParam)) - { + switch (HIWORD(wParam)) { case BN_CLICKED: - switch(LOWORD(wParam)) - { + switch (LOWORD(wParam)) { case IDC_SHOWPOPUPS: - EnableWindow(GetDlgItem(hwndDlg,IDC_NOSIGNONPOPUPS),IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS)); + EnableWindow(GetDlgItem(hwndDlg, IDC_NOSIGNONPOPUPS), IsDlgButtonChecked(hwndDlg, IDC_SHOWPOPUPS)); break; case IDC_COL_CUSTOM: - EnableWindow(GetDlgItem(hwndDlg,IDC_COLBACK),true); - EnableWindow(GetDlgItem(hwndDlg,IDC_COLTEXT),true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLBACK), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLTEXT), true); break; case IDC_COL_WINDOWS: case IDC_COL_POPUP: - EnableWindow(GetDlgItem(hwndDlg,IDC_COLBACK),false); - EnableWindow(GetDlgItem(hwndDlg,IDC_COLTEXT),false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLBACK), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLTEXT), false); break; case IDC_TIMEOUT_CUSTOM: - EnableWindow(GetDlgItem(hwndDlg,IDC_TIMEOUT),true); - EnableWindow(GetDlgItem(hwndDlg,IDC_TIMEOUT_SPIN),true); + EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEOUT), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEOUT_SPIN), true); break; case IDC_TIMEOUT_DEFAULT: case IDC_TIMEOUT_PERMANENT: - EnableWindow(GetDlgItem(hwndDlg,IDC_TIMEOUT),false); - EnableWindow(GetDlgItem(hwndDlg,IDC_TIMEOUT_SPIN),false); + EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEOUT), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEOUT_SPIN), false); break; case IDC_PREVIEW: @@ -509,24 +439,24 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l } case EN_CHANGE: - if(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)) // Window is done initializing - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + if (GetWindowLongPtr(hwndDlg, GWLP_USERDATA)) // Window is done initializing + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; + case WM_NOTIFY: - if(reinterpret_cast(lParam)->code == PSN_APPLY) - { - proto = reinterpret_cast(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)); + if (reinterpret_cast(lParam)->code == PSN_APPLY) { + proto = reinterpret_cast(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); - db_set_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SHOW,IsDlgButtonChecked(hwndDlg,IDC_SHOWPOPUPS)); - db_set_b(0,proto->ModuleName(),TWITTER_KEY_POPUP_SIGNON,!IsDlgButtonChecked(hwndDlg,IDC_NOSIGNONPOPUPS)); + db_set_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SHOW, IsDlgButtonChecked(hwndDlg, IDC_SHOWPOPUPS)); + db_set_b(0, proto->ModuleName(), TWITTER_KEY_POPUP_SIGNON, !IsDlgButtonChecked(hwndDlg, IDC_NOSIGNONPOPUPS)); // ***** Write color settings - db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLBACK,get_back_color(hwndDlg,true)); - db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_COLTEXT,get_text_color(hwndDlg,true)); + db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLBACK, get_back_color(hwndDlg, true)); + db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_COLTEXT, get_text_color(hwndDlg, true)); // ***** Write timeout setting - db_set_dw(0,proto->ModuleName(),TWITTER_KEY_POPUP_TIMEOUT,get_timeout(hwndDlg)); + db_set_dw(0, proto->ModuleName(), TWITTER_KEY_POPUP_TIMEOUT, get_timeout(hwndDlg)); return true; } @@ -536,37 +466,32 @@ INT_PTR CALLBACK popup_options_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l return false; } - -INT_PTR CALLBACK pin_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK pin_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TwitterProto *proto; - switch(msg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + return true; - return true; - case WM_COMMAND: - if(LOWORD(wParam) == IDOK) - { - proto = reinterpret_cast(GetWindowLongPtr(hwndDlg,GWLP_USERDATA)); - char str[128]; + case WM_COMMAND: + if (LOWORD(wParam) == IDOK) { + proto = reinterpret_cast(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); + char str[128]; - GetDlgItemTextA(hwndDlg,IDC_PIN,str,sizeof(str)); + GetDlgItemTextA(hwndDlg, IDC_PIN, str, sizeof(str)); - db_set_s(0,proto->ModuleName(),TWITTER_KEY_OAUTH_PIN,str); - EndDialog(hwndDlg, wParam); - return true; - } - else if(LOWORD(wParam) == IDCANCEL) - { - EndDialog(hwndDlg, wParam); - return true; - } - break; + db_set_s(0, proto->ModuleName(), TWITTER_KEY_OAUTH_PIN, str); + EndDialog(hwndDlg, wParam); + return true; + } + else if (LOWORD(wParam) == IDCANCEL) { + EndDialog(hwndDlg, wParam); + return true; + } + break; } return false; diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp index 7d91be4f67..d7ed48d108 100644 --- a/protocols/Twitter/src/utility.cpp +++ b/protocols/Twitter/src/utility.cpp @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdafx.h" #include "utility.h" -//#include "tc2.h" #include diff --git a/protocols/Twitter/src/utility.h b/protocols/Twitter/src/utility.h index ba6ecc3651..a74ec25c36 100644 --- a/protocols/Twitter/src/utility.h +++ b/protocols/Twitter/src/utility.h @@ -17,7 +17,6 @@ along with this program. If not, see . #pragma once -#include "common.h" #include "http.h" #include "twitter.h" diff --git a/protocols/Twitter/src/version.h b/protocols/Twitter/src/version.h index 28503b3ce5..dd0a05f28e 100644 --- a/protocols/Twitter/src/version.h +++ b/protocols/Twitter/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include diff --git a/protocols/Twitter/twitter_10.vcxproj b/protocols/Twitter/twitter_10.vcxproj index 44004d9c36..dc64df99e2 100644 --- a/protocols/Twitter/twitter_10.vcxproj +++ b/protocols/Twitter/twitter_10.vcxproj @@ -79,6 +79,7 @@ MultiThreadedDebugDLL Level3 EditAndContinue + Use true @@ -100,6 +101,7 @@ EnableFastChecks MultiThreadedDebugDLL Level3 + Use true @@ -121,6 +123,7 @@ Full OnlyExplicitInline Size + Use true @@ -145,6 +148,7 @@ Full OnlyExplicitInline Size + Use true @@ -169,7 +173,12 @@ - + + Create + Create + Create + Create + @@ -178,12 +187,10 @@ - - diff --git a/protocols/Twitter/twitter_10.vcxproj.filters b/protocols/Twitter/twitter_10.vcxproj.filters index 456b7c0539..7541fa2ec6 100644 --- a/protocols/Twitter/twitter_10.vcxproj.filters +++ b/protocols/Twitter/twitter_10.vcxproj.filters @@ -48,20 +48,17 @@ Source Files - - Source Files - Source Files Source Files + + Source Files + - - Header Files - Header Files @@ -92,9 +89,6 @@ Header Files - - Header Files - Header Files diff --git a/protocols/Twitter/twitter_12.vcxproj b/protocols/Twitter/twitter_12.vcxproj index 832f760f6b..b85a3f06c7 100644 --- a/protocols/Twitter/twitter_12.vcxproj +++ b/protocols/Twitter/twitter_12.vcxproj @@ -83,6 +83,7 @@ MultiThreadedDebugDLL Level3 EditAndContinue + Use true @@ -105,6 +106,7 @@ EnableFastChecks MultiThreadedDebugDLL Level3 + Use true @@ -126,6 +128,7 @@ Full OnlyExplicitInline Size + Use true @@ -149,6 +152,7 @@ Full OnlyExplicitInline Size + Use true @@ -172,7 +176,12 @@ - + + Create + Create + Create + Create + @@ -181,12 +190,10 @@ - - diff --git a/protocols/Twitter/twitter_12.vcxproj.filters b/protocols/Twitter/twitter_12.vcxproj.filters index 456b7c0539..7541fa2ec6 100644 --- a/protocols/Twitter/twitter_12.vcxproj.filters +++ b/protocols/Twitter/twitter_12.vcxproj.filters @@ -48,20 +48,17 @@ Source Files - - Source Files - Source Files Source Files + + Source Files + - - Header Files - Header Files @@ -92,9 +89,6 @@ Header Files - - Header Files - Header Files -- cgit v1.2.3