From bf8ad124d03b4fd059318d9ba8889b11faaf5b53 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Wed, 24 Jan 2018 19:47:13 +0100 Subject: Gadu-Gadu: partial move to UI classes * advanced options form refactored * move to options class * const correctness * code cleaning --- protocols/Gadu-Gadu/gadugadu.vcxproj.filters | 6 + protocols/Gadu-Gadu/res/resource.rc | 216 ++++++++++++++++++--------- protocols/Gadu-Gadu/src/avatar.cpp | 32 ++-- protocols/Gadu-Gadu/src/core.cpp | 66 ++++---- protocols/Gadu-Gadu/src/dialogs.cpp | 149 +++--------------- protocols/Gadu-Gadu/src/filetransfer.cpp | 44 +++--- protocols/Gadu-Gadu/src/gg.cpp | 30 ++-- protocols/Gadu-Gadu/src/gg.h | 49 ++---- protocols/Gadu-Gadu/src/gg_proto.cpp | 117 ++++++++------- protocols/Gadu-Gadu/src/gg_proto.h | 21 +-- protocols/Gadu-Gadu/src/groupchat.cpp | 30 ++-- protocols/Gadu-Gadu/src/image.cpp | 46 +++--- protocols/Gadu-Gadu/src/import.cpp | 26 ++-- protocols/Gadu-Gadu/src/keepalive.cpp | 12 +- protocols/Gadu-Gadu/src/links.cpp | 4 +- protocols/Gadu-Gadu/src/oauth.cpp | 4 +- protocols/Gadu-Gadu/src/options.cpp | 103 +++++++++++++ protocols/Gadu-Gadu/src/options.h | 57 +++++++ protocols/Gadu-Gadu/src/ownerinfo.cpp | 8 +- protocols/Gadu-Gadu/src/popups.cpp | 8 +- protocols/Gadu-Gadu/src/resource.h | 44 ++---- protocols/Gadu-Gadu/src/services.cpp | 22 +-- protocols/Gadu-Gadu/src/sessions.cpp | 16 +- protocols/Gadu-Gadu/src/token.cpp | 2 +- protocols/Gadu-Gadu/src/userutils.cpp | 10 +- 25 files changed, 605 insertions(+), 517 deletions(-) create mode 100644 protocols/Gadu-Gadu/src/options.cpp create mode 100644 protocols/Gadu-Gadu/src/options.h (limited to 'protocols') diff --git a/protocols/Gadu-Gadu/gadugadu.vcxproj.filters b/protocols/Gadu-Gadu/gadugadu.vcxproj.filters index e8dad6977f..4140991326 100644 --- a/protocols/Gadu-Gadu/gadugadu.vcxproj.filters +++ b/protocols/Gadu-Gadu/gadugadu.vcxproj.filters @@ -114,6 +114,9 @@ Source Files + + Source Files + Source Files @@ -182,6 +185,9 @@ Header Files + + Header Files + Header Files diff --git a/protocols/Gadu-Gadu/res/resource.rc b/protocols/Gadu-Gadu/res/resource.rc index c187d6df73..07a29a61b4 100644 --- a/protocols/Gadu-Gadu/res/resource.rc +++ b/protocols/Gadu-Gadu/res/resource.rc @@ -1,43 +1,69 @@ -//////////////////////////////////////////////////////////////////////////////// -// Gadu-Gadu Plugin for Miranda NG +// Microsoft Visual C++ generated resource script. // -// Copyright (c) 2003-2006 Adam Strzelecki +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// // -// 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. +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Polish (Poland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT +#pragma code_page(1250) + +///////////////////////////////////////////////////////////////////////////// // -// 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. +// Icon // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//////////////////////////////////////////////////////////////////////////////// -#include -#include "..\src\resource.h" +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_GG ICON "gg.ico" + +IDI_IMPORT_SERVER ICON "import_list_from_server.ico" + +IDI_IMPORT_TEXT ICON "import_list_from_txt_file.ico" + +IDI_REMOVE_SERVER ICON "remove_list_from_server.ico" + +IDI_EXPORT_SERVER ICON "export_list_to_server.ico" + +IDI_EXPORT_TEXT ICON "export_list_to_txt_file.ico" + +IDI_SETTINGS ICON "settings.ico" + +IDI_LIST ICON "list.ico" + +IDI_BLOCK ICON "block.ico" + +IDI_PREV ICON "previous.ico" -IDI_GG ICON "gg.ico" -IDI_IMPORT_SERVER ICON "import_list_from_server.ico" -IDI_IMPORT_TEXT ICON "import_list_from_txt_file.ico" -IDI_REMOVE_SERVER ICON "remove_list_from_server.ico" -IDI_EXPORT_SERVER ICON "export_list_to_server.ico" -IDI_EXPORT_TEXT ICON "export_list_to_txt_file.ico" -IDI_SETTINGS ICON "settings.ico" -IDI_LIST ICON "list.ico" -IDI_BLOCK ICON "block.ico" -IDI_PREV ICON "previous.ico" -IDI_NEXT ICON "next.ico" -IDI_IMAGE ICON "image.ico" -IDI_SAVE ICON "save.ico" -IDI_DELETE ICON "delete.ico" -IDI_CONFERENCE ICON "conference.ico" -IDI_CLEAR_CONFERENCE ICON "clear_ignored_conference.ico" -IDI_SESSIONS ICON "sessions.ico" +IDI_NEXT ICON "next.ico" + +IDI_IMAGE ICON "image.ico" + +IDI_SAVE ICON "save.ico" + +IDI_DELETE ICON "delete.ico" + +IDI_CONFERENCE ICON "conference.ico" + +IDI_CLEAR_CONFERENCE ICON "clear_ignored_conference.ico" + +IDI_SESSIONS ICON "sessions.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// IDD_OPT_GG_GENERAL DIALOGEX 0, 0, 304, 207 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD @@ -55,7 +81,6 @@ BEGIN CONTROL "Remove account",IDC_REMOVEACCOUNT,"Hyperlink",WS_TABSTOP,175,18,90,8 CONTROL "Change password",IDC_CHPASS,"Hyperlink",WS_TABSTOP,175,31,90,8 CONTROL "Retrieve password",IDC_LOSTPASS,"Hyperlink",WS_TABSTOP,175,44,90,8 -// CONTROL "Change e-mail",IDC_CHEMAIL,"Hyperlink",WS_TABSTOP,175,62,90,8 GROUPBOX "Options",IDC_STATIC,4,75,298,106 CONTROL "Friends only",IDC_FRIENDSONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,90,284,10 CONTROL "Show offline users with status message as invisible in contact list",IDC_SHOWINVISIBLE, @@ -65,7 +90,6 @@ BEGIN COMBOBOX IDC_LEAVESTATUS,210,118,84,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Receive image and after image is received use:",IDC_IMGRECEIVE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,135,177,10 -// CONTROL "Ignore incoming conference messages",IDC_IGNORECONF,"Button",BS_AUTOCHECKBOX|WS_TABSTOP,12,145,255,10 COMBOBOX IDC_IMGMETHOD,190,133,104,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Show links from unknown contacts",IDC_SHOWLINKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,150,284,10 CONTROL "Enable avatars",IDC_ENABLEAVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,165,284,10 @@ -102,22 +126,19 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,62,286,10 CONTROL "Manually specify connection servers' hosts",IDC_MANUALHOST, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,77,286,10 -// LTEXT "Host:",IDC_STATIC,31,97,26,8 - EDITTEXT IDC_HOST,22,91,144,36,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_DISABLED | WS_VSCROLL -// LTEXT "Port:",IDC_STATIC,161,97,21,8 -// EDITTEXT IDC_PORT,186,96,31,12,ES_AUTOHSCROLL|WS_DISABLED|WS_TABSTOP|ES_NUMBER + EDITTEXT IDC_HOST,22,91,144,39,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_DISABLED | WS_VSCROLL LTEXT "* new line is separator\n** hostname:port format",IDC_STATIC,174,92,119,32 CONTROL "Use SSL secure connection",IDC_SSLCONN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,132,286,10 - GROUPBOX "File Transfer",IDC_STATIC,4,150,297,72 - CONTROL "Use direct connections",IDC_DIRECTCONNS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,165,153,10 - LTEXT "Port:",IDC_STATIC,161,164,21,8 - EDITTEXT IDC_DIRECTPORT,186,165,31,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED - CONTROL "Use forwarding",IDC_FORWARDING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,178,286,10 + GROUPBOX "File Transfer",IDC_STATIC,4,150,297,58 + CONTROL "Use direct connections",IDC_DIRECTCONNS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,164,153,10 + LTEXT "Port:",IDC_STATIC,161,165,21,8 + EDITTEXT IDC_DIRECTPORT,186,163,31,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED + CONTROL "Use forwarding",IDC_FORWARDING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,178,153,10 LTEXT "Host:",IDC_STATIC,31,192,26,8 EDITTEXT IDC_FORWARDHOST,62,191,90,12,ES_AUTOHSCROLL | WS_DISABLED LTEXT "Port:",IDC_STATIC,161,192,21,8 EDITTEXT IDC_FORWARDPORT,186,191,31,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED - CTEXT "These changes will take effect the next time you connect to the GG network.",IDC_RELOADREQD,7,209,286,8,NOT WS_VISIBLE + CTEXT "These changes will take effect the next time you connect to the GG network.",IDC_RELOADREQD,7,213,286,8,NOT WS_VISIBLE END IDD_INFO_GG DIALOGEX 0, 0, 222, 132 @@ -126,31 +147,29 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN LTEXT "Number:",IDC_STATIC,5,5,61,8 - EDITTEXT IDC_UIN,74,5,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP -// LTEXT "Version:",IDC_STATIC,144,5,56,8 -// EDITTEXT IDC_VERSION,175,5,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + EDITTEXT IDC_UIN,74,5,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Internal IP:",IDC_STATIC,5,18,61,8 - EDITTEXT IDC_REALIP,74,18,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_REALIP,74,18,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Port:",IDC_STATIC,144,18,56,8 - EDITTEXT IDC_PORT,175,18,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PORT,175,18,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "First name:",IDC_STATIC,5,31,61,8 - EDITTEXT IDC_FIRSTNAME,74,31,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_FIRSTNAME,74,31,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Last name:",IDC_STATIC,5,44,61,8 - EDITTEXT IDC_LASTNAME,74,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_LASTNAME,74,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Family name:",IDC_STATIC,5,57,61,8 - EDITTEXT IDC_FAMILYNAME,74,57,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_FAMILYNAME,74,57,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Nickname:",IDC_STATIC,5,70,61,8 - EDITTEXT IDC_NICKNAME,74,70,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_NICKNAME,74,70,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Gender:",IDC_STATIC,144,70,56,8 - EDITTEXT IDC_GENDER,165,70,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_GENDER,165,70,60,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "City:",IDC_STATIC,5,83,61,8 - EDITTEXT IDC_CITY,74,83,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_CITY,74,83,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Origin city:",IDC_STATIC,5,96,61,8 - EDITTEXT IDC_CITYORIGIN,74,96,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_CITYORIGIN,74,96,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Birth year:",IDC_STATIC,5,109,61,8 - EDITTEXT IDC_BIRTHYEAR,74,109,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_BIRTHYEAR,74,109,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER LTEXT "Description:",IDC_STATIC,5,122,61,8 - EDITTEXT IDC_STATUSDESCR,74,122,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_TABSTOP + EDITTEXT IDC_STATUSDESCR,74,122,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER END IDD_CHINFO_GG DIALOGEX 0, 0, 222, 132 @@ -283,8 +302,6 @@ BEGIN CONTROL "",IDC_IMG_NEXT,"MButtonClass",WS_TABSTOP,167,4,16,14,WS_EX_NOACTIVATE | 0x10000000L CONTROL "",IDC_IMG_DELETE,"MButtonClass",WS_TABSTOP,187,4,16,14,WS_EX_NOACTIVATE | 0x10000000L CONTROL "",IDC_IMG_SAVE,"MButtonClass",WS_TABSTOP,207,4,16,15,WS_EX_NOACTIVATE | 0x10000000L -// CONTROL "",IDC_IMG_SCALE,"MButtonClass",WS_TABSTOP,207,4,16,15,0x18000000L -// LTEXT "",IDC_IMG_IMAGE,3,22,220,103,WS_BORDER CONTROL "",IDC_IMG_IMAGE,"Static",SS_GRAYFRAME,3,22,220,103 PUSHBUTTON "&Close",IDC_IMG_CANCEL,171,130,50,14 END @@ -295,11 +312,6 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN LTEXT "",IDC_IMG_NAME,3,7,200,8 -/* - CONTROL "",IDC_IMG_SAVE,"MButtonClass",WS_TABSTOP,187,4,16,15,0x18000000L - CONTROL "",IDC_IMG_SCALE,"MButtonClass",WS_TABSTOP,207,4,16,15,0x18000000L -*/ -// LTEXT "",IDC_IMG_IMAGE,3,22,220,103,WS_BORDER CONTROL "",IDC_IMG_IMAGE,"Static",SS_GRAYFRAME,3,22,220,103 DEFPUSHBUTTON "&Send",IDC_IMG_SEND,117,130,50,14 PUSHBUTTON "&Close",IDC_IMG_CANCEL,171,130,50,14 @@ -337,7 +349,75 @@ EXSTYLE WS_EX_CONTROLPARENT CAPTION "Concurrent %s Login Sessions" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "View information on active concurrent sessions",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,414,25 + CONTROL "View information on active concurrent sessions",IDC_HEADERBAR, + "MHeaderbarCtrl",0x0,0,0,414,25 CONTROL "",IDC_SESSIONS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,30,403,81 PUSHBUTTON "Sign out all sessions",IDC_SIGNOUTALL,317,116,91,15,WS_DISABLED END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_GG_ADVANCED, DIALOG + BEGIN + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_OPT_GG_ADVANCED AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +#endif // Polish (Poland) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 11b63d37ca..65e71a7456 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -26,7 +26,7 @@ ////////////////////////////////////////////////////////// // Avatars support // -void GGPROTO::getAvatarFilename(MCONTACT hContact, wchar_t *pszDest, int cbLen) +void GaduProto::getAvatarFilename(MCONTACT hContact, wchar_t *pszDest, int cbLen) { int tPathLen = mir_snwprintf(pszDest, cbLen, L"%s\\%S", VARSW(L"%miranda_avatarcache%"), m_szModuleName); @@ -56,7 +56,7 @@ void GGPROTO::getAvatarFilename(MCONTACT hContact, wchar_t *pszDest, int cbLen) else mir_snwprintf(pszDest + tPathLen, cbLen - tPathLen, L"\\%S avatar%s", m_szModuleName, avatartype); } -bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) +bool GaduProto::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) { *avatarurl = *avatarts = nullptr; @@ -139,7 +139,7 @@ char *gg_avatarhash(char *param) return bin2hex(digest, sizeof(digest), result); } -void GGPROTO::requestAvatarTransfer(MCONTACT hContact, char *szAvatarURL) +void GaduProto::requestAvatarTransfer(MCONTACT hContact, char *szAvatarURL) { if (pth_avatar.dwThreadId == NULL) { debugLogA("requestAvatarTransfer(): Can not list_add element to avatar_transfers list. No pth_avatar.dwThreadId"); @@ -156,7 +156,7 @@ void GGPROTO::requestAvatarTransfer(MCONTACT hContact, char *szAvatarURL) gg_LeaveCriticalSection(&avatar_mutex, "requestAvatarTransfer", 1, 1, "avatar_mutex", 1); } -void GGPROTO::requestAvatarInfo(MCONTACT hContact, int iWaitFor) +void GaduProto::requestAvatarInfo(MCONTACT hContact, int iWaitFor) { if (pth_avatar.dwThreadId == NULL) { debugLogA("requestAvatarInfo(): Can not list_add element to avatar_requests list. No pth_avatar.dwThreadId"); @@ -180,7 +180,7 @@ void GGPROTO::requestAvatarInfo(MCONTACT hContact, int iWaitFor) setByte(hContact, GG_KEY_AVATARREQUESTED, 1); } -void __cdecl GGPROTO::avatarrequestthread(void*) +void __cdecl GaduProto::avatarrequestthread(void*) { debugLogA("avatarrequestthread() started. Avatar Request Thread Starting"); while (pth_avatar.dwThreadId) @@ -302,7 +302,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) debugLogA("avatarrequestthread(): end. Avatar Request Thread Ending"); } -void GGPROTO::initavatarrequestthread() +void GaduProto::initavatarrequestthread() { DWORD exitCode = 0; @@ -311,13 +311,13 @@ void GGPROTO::initavatarrequestthread() avatar_requests.destroy(); avatar_transfers.destroy(); #ifdef DEBUGMODE - debugLogA("initavatarrequestthread(): ForkThreadEx 1 GGPROTO::avatarrequestthread"); + debugLogA("initavatarrequestthread(): ForkThreadEx 1 GaduProto::avatarrequestthread"); #endif - pth_avatar.hThread = ForkThreadEx(&GGPROTO::avatarrequestthread, nullptr, &pth_avatar.dwThreadId); + pth_avatar.hThread = ForkThreadEx(&GaduProto::avatarrequestthread, nullptr, &pth_avatar.dwThreadId); } } -void __cdecl GGPROTO::getOwnAvatarThread(void*) +void __cdecl GaduProto::getOwnAvatarThread(void*) { debugLogA("getOwnAvatarThread() started"); @@ -342,17 +342,17 @@ void __cdecl GGPROTO::getOwnAvatarThread(void*) #endif } -void GGPROTO::getOwnAvatar() +void GaduProto::getOwnAvatar() { if (getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS) && getDword(GG_KEY_UIN, 0)) { #ifdef DEBUGMODE - debugLogA("getOwnAvatar(): ForkThread 2 GGPROTO::getOwnAvatarThread"); + debugLogA("getOwnAvatar(): ForkThread 2 GaduProto::getOwnAvatarThread"); #endif - ForkThread(&GGPROTO::getOwnAvatarThread, nullptr); + ForkThread(&GaduProto::getOwnAvatarThread, nullptr); } } -void __cdecl GGPROTO::setavatarthread(void *param) +void __cdecl GaduProto::setavatarthread(void *param) { debugLogA("setavatarthread(): started. Trying to set user avatar."); @@ -508,10 +508,10 @@ void __cdecl GGPROTO::setavatarthread(void *param) } -void GGPROTO::setAvatar(const wchar_t *szFilename) +void GaduProto::setAvatar(const wchar_t *szFilename) { #ifdef DEBUGMODE - debugLogA("setAvatar(): ForkThread 3 GGPROTO::setavatarthread"); + debugLogA("setAvatar(): ForkThread 3 GaduProto::setavatarthread"); #endif - ForkThread(&GGPROTO::setavatarthread, mir_wstrdup(szFilename)); + ForkThread(&GaduProto::setavatarthread, mir_wstrdup(szFilename)); } diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 008a073aad..dcc51fc84e 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -37,7 +37,7 @@ uint32_t swap32(uint32_t x) //////////////////////////////////////////////////////////// // Is online function -int GGPROTO::isonline() +int GaduProto::isonline() { int isonline; @@ -50,7 +50,7 @@ int GGPROTO::isonline() //////////////////////////////////////////////////////////// // Send disconnect request and wait for server thread to die -void GGPROTO::disconnect() +void GaduProto::disconnect() { // If main loop then send disconnect request if (isonline()) @@ -149,7 +149,7 @@ void GGPROTO::disconnect() //////////////////////////////////////////////////////////// // DNS lookup function -uint32_t gg_dnslookup(GGPROTO *gg, char *host) +uint32_t gg_dnslookup(GaduProto *gg, const char *host) { uint32_t ip = inet_addr(host); if (ip != INADDR_NONE) @@ -228,7 +228,7 @@ int gg_decodehosts(char *var, GGHOST *hosts, int max) //////////////////////////////////////////////////////////// // Main connection session thread -void __cdecl GGPROTO::mainthread(void *) +void __cdecl GaduProto::mainthread(void *) { // Gadu-gadu login errors static const struct tagReason { int type; wchar_t *str; } reason[] = { @@ -297,10 +297,11 @@ void __cdecl GGPROTO::mainthread(void *) int hostcount = 0; GGHOST hosts[64]; - if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST)) { - if (!getString(GG_KEY_SERVERHOSTS, &dbv)) { - hostcount = gg_decodehosts(dbv.pszVal, hosts, 64); - db_free(&dbv); + if (m_gaduOptions.useManualHosts) { + CMStringW serverHosts = m_gaduOptions.serverHosts; + if (!serverHosts.IsEmpty()) { + ptrA pHostsList(mir_u2a(serverHosts.c_str())); + hostcount = gg_decodehosts(pHostsList, hosts, 64); } } @@ -330,7 +331,7 @@ void __cdecl GGPROTO::mainthread(void *) } // Readup SSL/TLS setting - if (p.tls = getByte(GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN)) + if (p.tls = m_gaduOptions.useSslConnection) debugLogA("mainthread() (%x): Using TLS/SSL for connections.", this); // Gadu-Gadu accepts image sizes upto 255 @@ -351,22 +352,19 @@ void __cdecl GGPROTO::mainthread(void *) } // Check if dcc is running and setup forwarding port - if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING)) { - if (!getString(GG_KEY_FORWARDHOST, &dbv)) { - if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal))) { - wchar_t error[128]; - wchar_t* forwardHostT = mir_a2u(dbv.pszVal); - mir_snwprintf(error, TranslateT("External direct connections hostname %s is invalid. Disabling external host forwarding."), forwardHostT); - mir_free(forwardHostT); - showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX); + if (dcc && m_gaduOptions.useForwarding) { + CMStringW forwardHost = m_gaduOptions.forwardHost; + ptrA pHost(mir_u2a(forwardHost.c_str())); + if (!forwardHost.IsEmpty()) { + if (!(p.external_addr = gg_dnslookup(this, pHost))) { + CMStringW error(FORMAT, TranslateT("External direct connections hostname %s is invalid. Disabling external host forwarding."), forwardHost.c_str()); + showpopup(m_tszUserName, error.c_str(), GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX); } else - debugLogA("mainthread() (%x): Loading forwarding host %s and port %d.", dbv.pszVal, p.external_port, this); + debugLogA("mainthread() (%x): Loading forwarding host %s and port %d.", pHost, p.external_port, this); if (p.external_addr) - p.external_port = getWord(GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT); - - db_free(&dbv); + p.external_port = m_gaduOptions.forwardPort; } } // Setup client port @@ -428,13 +426,13 @@ retry: perror = error; } debugLogW(L"mainthread() (%x): %s", this, perror); - if (getByte(GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS)) + if (m_gaduOptions.showConnectionErrors) showpopup(m_tszUserName, perror, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE); // Check if we should reconnect if ((gg_failno >= GG_FAILURE_RESOLVING && gg_failno != GG_FAILURE_PASSWORD && gg_failno != GG_FAILURE_INTRUDER && gg_failno != GG_FAILURE_UNAVAILABLE) && errno == EACCES - && (getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT) || (hostnum < hostcount - 1))) + && (m_gaduOptions.autoRecconect || (hostnum < hostcount - 1))) { DWORD dwInterval = getDword(GG_KEY_RECONNINTERVAL, GG_KEYDEF_RECONNINTERVAL); BOOL bRetry = TRUE; @@ -1179,7 +1177,7 @@ retry: // If it was unwanted disconnection reconnect if (m_iDesiredStatus != ID_STATUS_OFFLINE - && getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT)) + && m_gaduOptions.autoRecconect) { debugLogA("mainthread() (%x): Unintentional disconnection detected. Going to reconnect...", this); hostnum = 0; @@ -1222,7 +1220,7 @@ retry: //////////////////////////////////////////////////////////// // Change status function -void GGPROTO::broadcastnewstatus(int newStatus) +void GaduProto::broadcastnewstatus(int newStatus) { gg_EnterCriticalSection(&modemsg_mutex, "broadcastnewstatus", 24, "modemsg_mutex", 1); int oldStatus = m_iStatus; @@ -1241,7 +1239,7 @@ void GGPROTO::broadcastnewstatus(int newStatus) //////////////////////////////////////////////////////////// // When contact is deleted -int GGPROTO::contactdeleted(WPARAM hContact, LPARAM) +int GaduProto::contactdeleted(WPARAM hContact, LPARAM) { uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0); @@ -1289,7 +1287,7 @@ static wchar_t* sttSettingToTchar(DBVARIANT* value) return nullptr; } -int GGPROTO::dbsettingchanged(WPARAM hContact, LPARAM lParam) +int GaduProto::dbsettingchanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; @@ -1370,7 +1368,7 @@ int GGPROTO::dbsettingchanged(WPARAM hContact, LPARAM lParam) //////////////////////////////////////////////////////////// // All users set offline // -void GGPROTO::setalloffline() +void GaduProto::setalloffline() { debugLogA("setalloffline(): started. Setting buddies offline"); setWord(GG_KEY_STATUS, ID_STATUS_OFFLINE); @@ -1391,7 +1389,7 @@ void GGPROTO::setalloffline() //////////////////////////////////////////////////////////// // All users set offline // -void GGPROTO::notifyuser(MCONTACT hContact, int refresh) +void GaduProto::notifyuser(MCONTACT hContact, int refresh) { uin_t uin; if (!hContact) @@ -1433,7 +1431,7 @@ void GGPROTO::notifyuser(MCONTACT hContact, int refresh) } } -void GGPROTO::notifyall() +void GaduProto::notifyall() { MCONTACT hContact; debugLogA("notifyall(): Subscribing notification to all users"); @@ -1486,7 +1484,7 @@ void GGPROTO::notifyall() //////////////////////////////////////////////////////////// // Get contact by uin // -MCONTACT GGPROTO::getcontact(uin_t uin, int create, int inlist, wchar_t *szNick) +MCONTACT GaduProto::getcontact(uin_t uin, int create, int inlist, wchar_t *szNick) { #ifdef DEBUGMODE debugLogA("getcontact(): uin=%d create=%d inlist=%d", uin, create, inlist); @@ -1572,7 +1570,7 @@ MCONTACT GGPROTO::getcontact(uin_t uin, int create, int inlist, wchar_t *szNick) //////////////////////////////////////////////////////////// // Status conversion // -int GGPROTO::status_m2gg(int status, int descr) +int GaduProto::status_m2gg(int status, int descr) { // check frends only int mask = getByte(GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY) ? GG_STATUS_FRIENDS_MASK : 0; @@ -1601,7 +1599,7 @@ int GGPROTO::status_m2gg(int status, int descr) } } -int GGPROTO::status_gg2m(int status) +int GaduProto::status_gg2m(int status) { // ignore additional flags status = GG_S(status); @@ -1647,7 +1645,7 @@ int GGPROTO::status_gg2m(int status) //////////////////////////////////////////////////////////// // Called when contact status is changed // -void GGPROTO::changecontactstatus(uin_t uin, int status, const wchar_t *idescr, int, uint32_t remote_ip, uint16_t remote_port, uint32_t version) +void GaduProto::changecontactstatus(uin_t uin, int status, const wchar_t *idescr, int, uint32_t remote_ip, uint16_t remote_port, uint32_t version) { #ifdef DEBUGMODE debugLogA("changecontactstatus(): uin=%d status=%d", uin, status); diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index 96c272940f..694b1d6b80 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -162,7 +162,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule //////////////////////////////////////////////////////////////////////////////// // Check if new user data has been filled in for specified account // -void GGPROTO::checknewuser(uin_t uin, const char* passwd) +void GaduProto::checknewuser(uin_t uin, const char* passwd) { char oldpasswd[128]; DBVARIANT dbv; @@ -212,14 +212,14 @@ static void gg_optsdlgcheck(HWND hwndDlg) // static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + GaduProto *gg = (GaduProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { DBVARIANT dbv; DWORD num; - gg = (GGPROTO *)lParam; + gg = (GaduProto *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); @@ -499,12 +499,12 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, // static INT_PTR CALLBACK gg_confoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + GaduProto *gg = (GaduProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); DWORD num; switch (msg) { case WM_INITDIALOG: - gg = (GGPROTO *)lParam; + gg = (GaduProto *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); @@ -557,127 +557,11 @@ static INT_PTR CALLBACK gg_confoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam return FALSE; } -//////////////////////////////////////////////////////////////////////////////////////////// -// Proc: Advanced options dialog -// -static INT_PTR CALLBACK gg_advoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - DBVARIANT dbv; - DWORD num; - - switch (msg) { - case WM_INITDIALOG: - gg = (GGPROTO *)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - - TranslateDialogDefault(hwndDlg); - if (!gg->getString(GG_KEY_SERVERHOSTS, &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_HOST, dbv.pszVal); - db_free(&dbv); - } - else SetDlgItemTextA(hwndDlg, IDC_HOST, GG_KEYDEF_SERVERHOSTS); - - CheckDlgButton(hwndDlg, IDC_KEEPALIVE, gg->getByte(GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOWCERRORS, gg->getByte(GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ARECONNECT, gg->getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MSGACK, gg->getByte(GG_KEY_MSGACK, GG_KEYDEF_MSGACK) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MANUALHOST, gg->getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SSLCONN, gg->getByte(GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN) ? BST_CHECKED : BST_UNCHECKED); - - EnableWindow(GetDlgItem(hwndDlg, IDC_KEEPALIVE), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALHOST), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_SSLCONN), false); - - //EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST)); - //EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST)); - EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), false); - - CheckDlgButton(hwndDlg, IDC_DIRECTCONNS, gg->getByte(GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS) ? BST_CHECKED : BST_UNCHECKED); - if (num = gg->getWord(GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT)) - SetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, ditoa(num)); - CheckDlgButton(hwndDlg, IDC_FORWARDING, gg->getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING) ? BST_CHECKED : BST_UNCHECKED); - if (!gg->getString(GG_KEY_FORWARDHOST, &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, dbv.pszVal); - db_free(&dbv); - } - if (num = gg->getWord(GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT)) - SetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, ditoa(num)); - - EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - break; - - case WM_COMMAND: - if ((LOWORD(wParam) == IDC_DIRECTPORT || LOWORD(wParam) == IDC_FORWARDHOST || LOWORD(wParam) == IDC_FORWARDPORT) - && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) - return 0; - switch (LOWORD(wParam)) { - case IDC_MANUALHOST: - { - EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST)); - EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST)); - ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW); - break; - } - case IDC_DIRECTCONNS: - case IDC_FORWARDING: - { - EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW); - break; - } - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - { - char str[512]; - gg->setByte(GG_KEY_KEEPALIVE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE)); - gg->setByte(GG_KEY_SHOWCERRORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWCERRORS)); - gg->setByte(GG_KEY_ARECONNECT, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ARECONNECT)); - gg->setByte(GG_KEY_MSGACK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MSGACK)); - gg->setByte(GG_KEY_MANUALHOST, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST)); - gg->setByte(GG_KEY_SSLCONN, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SSLCONN)); - - // Transfer settings - gg->setByte(GG_KEY_DIRECTCONNS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS)); - gg->setByte(GG_KEY_FORWARDING, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FORWARDING)); - - // Write custom servers - GetDlgItemTextA(hwndDlg, IDC_HOST, str, _countof(str)); - gg->setString(GG_KEY_SERVERHOSTS, str); - - // Write direct port - GetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, str, _countof(str)); - gg->setWord(GG_KEY_DIRECTPORT, (WORD)atoi(str)); - // Write forwarding host - GetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, str, _countof(str)); - gg->setString(GG_KEY_FORWARDHOST, str); - GetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, str, _countof(str)); - gg->setWord(GG_KEY_FORWARDPORT, (WORD)atoi(str)); - break; - } - } - break; - } - return FALSE; -} - //////////////////////////////////////////////////////////////////////////////// // Info Page : Data struct GGDETAILSDLGDATA { - GGPROTO *gg; + GaduProto *gg; MCONTACT hContact; int disableUpdate; int updating; @@ -714,14 +598,14 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, case 0: switch (((LPNMHDR)lParam)->code) { case PSN_PARAMCHANGED: - dat->gg = (GGPROTO *)((LPPSHNOTIFY)lParam)->lParam; + dat->gg = (GaduProto *)((LPPSHNOTIFY)lParam)->lParam; break; case PSN_INFOCHANGED: if (dat) { MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - GGPROTO *gg = dat->gg; + GaduProto *gg = dat->gg; // Show updated message if (dat->updating) @@ -807,7 +691,7 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, break; { wchar_t text[256]; - GGPROTO *gg = dat->gg; + GaduProto *gg = dat->gg; if (!gg->isonline()) { @@ -884,11 +768,10 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE; } - //////////////////////////////////////////////////////////////////////////////// // Options Page : Init // -int GGPROTO::options_init(WPARAM wParam, LPARAM) +int GaduProto::options_init(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_UNICODE; @@ -910,9 +793,11 @@ int GGPROTO::options_init(WPARAM wParam, LPARAM) Options_AddPage(wParam, &odp); odp.szTab.w = LPGENW("Advanced"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_GG_ADVANCED); - odp.pfnDlgProc = gg_advoptsdlgproc; + odp.position = 2; + odp.pszTemplate = 0; + odp.pDialog = new GaduOptionsDlgAdvanced(this); Options_AddPage(wParam, &odp); + return 0; } @@ -920,7 +805,7 @@ int GGPROTO::options_init(WPARAM wParam, LPARAM) //////////////////////////////////////////////////////////////////////////////// // Info Page : Init // -int GGPROTO::details_init(WPARAM wParam, LPARAM lParam) +int GaduProto::details_init(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = lParam; char* pszTemplate; @@ -961,13 +846,13 @@ int GGPROTO::details_init(WPARAM wParam, LPARAM lParam) // INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + GaduProto *gg = (GaduProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { DBVARIANT dbv; - gg = (GGPROTO *)lParam; + gg = (GaduProto *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index 2876acea02..b02bdfaf9d 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -23,7 +23,7 @@ #include #include -void GGPROTO::dccstart() +void GaduProto::dccstart() { DWORD exitCode = 0; @@ -45,7 +45,7 @@ void GGPROTO::dccstart() } // Check if we wan't direct connections - if (!getByte(GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS)) + if (!m_gaduOptions.useDirectConnections) { debugLogA("dccstart(): No direct connections setup."); if (hEvent) @@ -55,12 +55,12 @@ void GGPROTO::dccstart() // Start thread #ifdef DEBUGMODE - debugLogA("dccstart(): ForkThreadEx 4 GGPROTO::dccmainthread"); + debugLogA("dccstart(): ForkThreadEx 4 GaduProto::dccmainthread"); #endif - pth_dcc.hThread = ForkThreadEx(&GGPROTO::dccmainthread, nullptr, &pth_dcc.dwThreadId); + pth_dcc.hThread = ForkThreadEx(&GaduProto::dccmainthread, nullptr, &pth_dcc.dwThreadId); } -void GGPROTO::dccconnect(uin_t uin) +void GaduProto::dccconnect(uin_t uin) { MCONTACT hContact = getcontact(uin, 0, 0, nullptr); @@ -97,7 +97,7 @@ struct ftfaildata ////////////////////////////////////////////////////////// // THREAD: File transfer fail // -void __cdecl GGPROTO::ftfailthread(void *param) +void __cdecl GaduProto::ftfailthread(void *param) { struct ftfaildata *ft = (struct ftfaildata *)param; debugLogA("ftfailthread(): started. Sending failed file transfer."); @@ -107,7 +107,7 @@ void __cdecl GGPROTO::ftfailthread(void *param) debugLogA("ftfailthread(): end."); } -HANDLE ftfail(GGPROTO *gg, MCONTACT hContact) +HANDLE ftfail(GaduProto *gg, MCONTACT hContact) { ftfaildata *ft = (ftfaildata*)malloc(sizeof(struct ftfaildata)); #ifdef DEBUGMODE @@ -117,9 +117,9 @@ HANDLE ftfail(GGPROTO *gg, MCONTACT hContact) ft->hProcess = (HANDLE)rand(); ft->hContact = hContact; #ifdef DEBUGMODE - gg->debugLogA("ftfail(): ForkThread 5 GGPROTO::ftfailthread"); + gg->debugLogA("ftfail(): ForkThread 5 GaduProto::ftfailthread"); #endif - gg->ForkThread(&GGPROTO::ftfailthread, ft); + gg->ForkThread(&GaduProto::ftfailthread, ft); return ft->hProcess; } @@ -129,7 +129,7 @@ HANDLE ftfail(GGPROTO *gg, MCONTACT hContact) //////////////////////////////////////////////////////////// // Main DCC connection session thread // -void __cdecl GGPROTO::dccmainthread(void*) +void __cdecl GaduProto::dccmainthread(void*) { // Zero up lists list_t l; @@ -150,7 +150,7 @@ void __cdecl GGPROTO::dccmainthread(void*) } // Create listen socket on config direct port - if (!(dcc = gg_dcc_socket_create(uin, (uint16_t)getWord(GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT)))) + if (!(dcc = gg_dcc_socket_create(uin, static_cast(m_gaduOptions.directConnectionPort)))) { debugLogA("dccmainthread(): Cannot create DCC listen socket. Exiting."); // Signalize mainthread we haven't start @@ -667,7 +667,7 @@ void __cdecl GGPROTO::dccmainthread(void*) debugLogA("dccmainthread(): end. DCC Server Thread Ending"); } -HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const wchar_t* szPath) +HANDLE GaduProto::dccfileallow(HANDLE hTransfer, const wchar_t* szPath) { struct gg_dcc *dcc = (struct gg_dcc *) hTransfer; char fileName[MAX_PATH], *path = mir_u2a(szPath); @@ -708,7 +708,7 @@ HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const wchar_t* szPath) return hTransfer; } -HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const wchar_t* szPath) +HANDLE GaduProto::dcc7fileallow(HANDLE hTransfer, const wchar_t* szPath) { gg_dcc7 *dcc7 = (gg_dcc7 *) hTransfer; char fileName[MAX_PATH], *path = mir_u2a(szPath); @@ -761,7 +761,7 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const wchar_t* szPath) return hTransfer; } -int GGPROTO::dccfiledeny(HANDLE hTransfer) +int GaduProto::dccfiledeny(HANDLE hTransfer) { gg_dcc *dcc = (gg_dcc *) hTransfer; @@ -785,7 +785,7 @@ int GGPROTO::dccfiledeny(HANDLE hTransfer) return 0; } -int GGPROTO::dcc7filedeny(HANDLE hTransfer) +int GaduProto::dcc7filedeny(HANDLE hTransfer) { gg_dcc7 *dcc7 = (gg_dcc7 *) hTransfer; @@ -809,7 +809,7 @@ int GGPROTO::dcc7filedeny(HANDLE hTransfer) return 0; } -int GGPROTO::dccfilecancel(HANDLE hTransfer) +int GaduProto::dccfilecancel(HANDLE hTransfer) { gg_dcc *dcc = (gg_dcc *) hTransfer; @@ -842,7 +842,7 @@ int GGPROTO::dccfilecancel(HANDLE hTransfer) return 0; } -int GGPROTO::dcc7filecancel(HANDLE hTransfer) +int GaduProto::dcc7filecancel(HANDLE hTransfer) { gg_dcc7 *dcc7 = (gg_dcc7 *) hTransfer; @@ -879,7 +879,7 @@ int GGPROTO::dcc7filecancel(HANDLE hTransfer) //////////////////////////////////////////////////////////// // File receiving allowed // -HANDLE GGPROTO::FileAllow(MCONTACT, HANDLE hTransfer, const wchar_t* szPath) +HANDLE GaduProto::FileAllow(MCONTACT, HANDLE hTransfer, const wchar_t* szPath) { // Check if its proper dcc gg_common *c = (gg_common *) hTransfer; @@ -895,7 +895,7 @@ HANDLE GGPROTO::FileAllow(MCONTACT, HANDLE hTransfer, const wchar_t* szPath) //////////////////////////////////////////////////////////// // File transfer canceled // -int GGPROTO::FileCancel(MCONTACT, HANDLE hTransfer) +int GaduProto::FileCancel(MCONTACT, HANDLE hTransfer) { // Check if its proper dcc gg_common *c = (gg_common *) hTransfer; @@ -911,7 +911,7 @@ int GGPROTO::FileCancel(MCONTACT, HANDLE hTransfer) //////////////////////////////////////////////////////////// // File receiving denied // -int GGPROTO::FileDeny(MCONTACT, HANDLE hTransfer, const wchar_t *) +int GaduProto::FileDeny(MCONTACT, HANDLE hTransfer, const wchar_t *) { // Check if its proper dcc gg_common *c = (gg_common *) hTransfer; @@ -927,7 +927,7 @@ int GGPROTO::FileDeny(MCONTACT, HANDLE hTransfer, const wchar_t *) //////////////////////////////////////////////////////////// // Called when received an file // -int GGPROTO::RecvFile(MCONTACT hContact, PROTORECVFILET* pre) +int GaduProto::RecvFile(MCONTACT hContact, PROTORECVFILET* pre) { return Proto_RecvFile(hContact, pre); } @@ -935,7 +935,7 @@ int GGPROTO::RecvFile(MCONTACT hContact, PROTORECVFILET* pre) //////////////////////////////////////////////////////////// // Called when user sends a file // -HANDLE GGPROTO::SendFile(MCONTACT hContact, const wchar_t *, wchar_t** ppszFiles) +HANDLE GaduProto::SendFile(MCONTACT hContact, const wchar_t *, wchar_t** ppszFiles) { char *bslash, *filename; diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index f437a5032a..1d7c253dc5 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -43,7 +43,7 @@ HINSTANCE hInstance; SSL_API sslApi; CLIST_INTERFACE *pcli; int hLangpack; -LIST g_Instances(1, PtrKeySortT); +LIST g_Instances(1, PtrKeySortT); static unsigned long crc_table[256]; @@ -159,7 +159,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCO ////////////////////////////////////////////////////////// // Cleanups from last plugin // -void GGPROTO::cleanuplastplugin(DWORD version) +void GaduProto::cleanuplastplugin(DWORD version) { // Store current plugin version setDword(GG_PLUGINVERSION, pluginInfo.version); @@ -192,10 +192,10 @@ void GGPROTO::cleanuplastplugin(DWORD version) //2. force SSL and keepalive; overwrite old server list; if (version < PLUGIN_MAKE_VERSION(0, 11, 0, 4)) { - setString(GG_KEY_SERVERHOSTS, GG_KEYDEF_SERVERHOSTS); - setByte(GG_KEY_MANUALHOST, 1); - setByte(GG_KEY_SSLCONN, 1); - setByte(GG_KEY_KEEPALIVE, 1); + setWString("ServerHosts", GG_KEYDEF_SERVERHOSTS); + m_gaduOptions.useManualHosts = 1; + m_gaduOptions.useSslConnection = 1; + m_gaduOptions.keepConnectionAlive = 1; } } @@ -216,7 +216,7 @@ static int gg_modulesloaded(WPARAM, LPARAM) ////////////////////////////////////////////////////////// // Gets protocol instance associated with a contact // -static GGPROTO* gg_getprotoinstance(MCONTACT hContact) +static GaduProto* gg_getprotoinstance(MCONTACT hContact) { char* szProto = GetContactProto(hContact); if (szProto == nullptr) @@ -234,7 +234,7 @@ static GGPROTO* gg_getprotoinstance(MCONTACT hContact) // static int gg_prebuildcontactmenu(WPARAM hContact, LPARAM) { - GGPROTO* gg = gg_getprotoinstance(hContact); + GaduProto* gg = gg_getprotoinstance(hContact); if (gg == nullptr) return 0; @@ -249,7 +249,7 @@ static int gg_prebuildcontactmenu(WPARAM hContact, LPARAM) ////////////////////////////////////////////////////////// // Contact block service function // -INT_PTR GGPROTO::blockuser(WPARAM hContact, LPARAM) +INT_PTR GaduProto::blockuser(WPARAM hContact, LPARAM) { setByte(hContact, GG_KEY_BLOCK, !getByte(hContact, GG_KEY_BLOCK, 0)); notifyuser(hContact, 1); @@ -262,7 +262,7 @@ INT_PTR GGPROTO::blockuser(WPARAM hContact, LPARAM) ////////////////////////////////////////////////////////// // Contact blocking initialization // -void GGPROTO::block_init() +void GaduProto::block_init() { CMenuItem mi; SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32); @@ -278,7 +278,7 @@ void GGPROTO::block_init() ////////////////////////////////////////////////////////// // Contact blocking uninitialization // -void GGPROTO::block_uninit() +void GaduProto::block_uninit() { Menu_RemoveItem(hBlockMenuItem); } @@ -286,7 +286,7 @@ void GGPROTO::block_uninit() ////////////////////////////////////////////////////////// // Menus initialization // -void GGPROTO::menus_init() +void GaduProto::menus_init() { HGENMENU hRoot = Menu_GetProtocolRoot(this); @@ -312,9 +312,9 @@ void GGPROTO::menus_init() ////////////////////////////////////////////////////////// // Module instance initialization // -static GGPROTO *gg_proto_init(const char* pszProtoName, const wchar_t* tszUserName) +static GaduProto *gg_proto_init(const char* pszProtoName, const wchar_t* tszUserName) { - GGPROTO *gg = new GGPROTO(pszProtoName, tszUserName); + GaduProto *gg = new GaduProto(pszProtoName, tszUserName); g_Instances.insert(gg); return gg; } @@ -324,7 +324,7 @@ static GGPROTO *gg_proto_init(const char* pszProtoName, const wchar_t* tszUserNa // static int gg_proto_uninit(PROTO_INTERFACE *proto) { - GGPROTO *gg = (GGPROTO *)proto; + GaduProto *gg = (GaduProto *)proto; g_Instances.remove(gg); delete gg; return 0; diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 5be2a69f04..c4f6f76c7b 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -68,9 +68,7 @@ #include #include #include - -// Plugin headers -#include "resource.h" +#include // libgadu headers #include "libgadu.h" @@ -115,12 +113,10 @@ struct GGGETAVATARDATA char *szAvatarURL; }; - // Wrappers of the old interface #define GGDEF_PROTO "GG" // Default Proto #define GGDEF_PROTONAME "Gadu-Gadu" // Default ProtoName - // Process handles / seqs #define GG_SEQ_INFO 100 #define GG_SEQ_SEARCH 200 @@ -138,7 +134,7 @@ struct GGGETAVATARDATA #define GGS_RECVIMAGE "/RecvImage" // Keys -#define GG_PLUGINVERSION "Version" // Plugin version.. user for cleanup from previous versions +#define GG_PLUGINVERSION "Version" // Plugin version.. used for cleanup from previous versions #define GG_KEY_UIN "UIN" // Uin - unique number #define GG_KEY_PASSWORD "Password" // Password @@ -150,15 +146,6 @@ struct GGGETAVATARDATA #define GG_KEY_TOKEN "Token" // OAuth Access Token #define GG_KEY_TOKENSECRET "TokenSecret" // OAuth Access Token Secret -#define GG_KEY_KEEPALIVE "KeepAlive" // Keep-alive support -#define GG_KEYDEF_KEEPALIVE 1 - -#define GG_KEY_SHOWCERRORS "ShowCErrors" // Show connection errors -#define GG_KEYDEF_SHOWCERRORS 1 - -#define GG_KEY_ARECONNECT "AReconnect" // Automatically reconnect -#define GG_KEYDEF_ARECONNECT 0 - #define GG_KEY_LEAVESTATUSMSG "LeaveStatusMsg"// Leave status msg when disconnected #define GG_KEYDEF_LEAVESTATUSMSG 0 #define GG_KEY_LEAVESTATUS "LeaveStatus" @@ -198,31 +185,13 @@ struct GGGETAVATARDATA #define GG_KEY_IMGMETHOD "PopupImg" // Popup image window automatically #define GG_KEYDEF_IMGMETHOD 1 -#define GG_KEY_MSGACK "MessageAck" // Acknowledge when sending msg -#define GG_KEYDEF_MSGACK 1 - -#define GG_KEY_MANUALHOST "ManualHost" // Specify by hand server host/port -#define GG_KEYDEF_MANUALHOST 1 -#define GG_KEY_SSLCONN "SSLConnection" // Use SSL/TLS for connections -#define GG_KEYDEF_SSLCONN 1 -#define GG_KEY_SERVERHOSTS "ServerHosts" // NL separated list of hosts for server connection -#define GG_KEYDEF_SERVERHOSTS "91.214.237.108\r\n91.214.237.112\r\n91.214.237.116\r\n91.214.237.120\r\n91.214.237.123" +// newline separated list of hosts for server connection +#define GG_KEYDEF_SERVERHOSTS L"91.214.237.108\r\n91.214.237.112\r\n91.214.237.116\r\n91.214.237.120\r\n91.214.237.123" #define GG_KEY_CLIENTIP "IP" // Contact IP (by notify) #define GG_KEY_CLIENTPORT "ClientPort" // Contact port #define GG_KEY_CLIENTVERSION "ClientVersion" // Contact app version -#define GG_KEY_DIRECTCONNS "DirectConns" // Use direct connections -#define GG_KEYDEF_DIRECTCONNS 1 -#define GG_KEY_DIRECTPORT "DirectPort" // Direct connections port -#define GG_KEYDEF_DIRECTPORT 1550 - -#define GG_KEY_FORWARDING "Forwarding" // Use forwarding -#define GG_KEYDEF_FORWARDING 0 -#define GG_KEY_FORWARDHOST "ForwardHost" // Forwarding host (firewall) -#define GG_KEY_FORWARDPORT "ForwardPort" // Forwarding port (firewall port) -#define GG_KEYDEF_FORWARDPORT 1550 // Forwarding port (firewall port) - #define GG_KEY_GC_POLICY_UNKNOWN "GCPolicyUnknown" #define GG_KEYDEF_GC_POLICY_UNKNOWN 1 @@ -286,13 +255,14 @@ struct GGGETAVATARDATA // Global variables ///////////////////////////////////////////////// -struct GGPROTO; +struct GaduProto; extern HINSTANCE hInstance; extern CLIST_INTERFACE *pcli; -extern LIST g_Instances; +extern LIST g_Instances; extern PLUGININFOEX pluginInfo; extern IconItem iconList[]; +extern SSL_API sslApi; ///////////////////////////////////////////////// // Methods @@ -326,8 +296,9 @@ void gg_links_init(); // Debug functions const char *ggdebug_eventtype(gg_event *e); +// Plugin headers +#include "options.h" //include before protocol declaration #include "gg_proto.h" - -extern SSL_API sslApi; +#include "resource.h" #endif diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index fbc1421b78..09502f85c3 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -21,10 +21,11 @@ #include "gg.h" -GGPROTO::GGPROTO(const char *pszProtoName, const wchar_t *tszUserName) : - PROTO(pszProtoName, tszUserName), +GaduProto::GaduProto(const char *pszProtoName, const wchar_t *tszUserName) : + PROTO(pszProtoName, tszUserName), avatar_requests(1, NumericKeySortT), - avatar_transfers(1, NumericKeySortT) + avatar_transfers(1, NumericKeySortT), + m_gaduOptions(this) { #ifdef DEBUGMODE extendedLogging = 0; @@ -50,15 +51,15 @@ GGPROTO::GGPROTO(const char *pszProtoName, const wchar_t *tszUserName) : m_hNetlibUser = Netlib_RegisterUser(&nlu); // Register services - CreateProtoService(PS_GETAVATARCAPS, &GGPROTO::getavatarcaps); - CreateProtoService(PS_GETAVATARINFO, &GGPROTO::getavatarinfo); - CreateProtoService(PS_GETMYAVATAR, &GGPROTO::getmyavatar); - CreateProtoService(PS_SETMYAVATAR, &GGPROTO::setmyavatar); + CreateProtoService(PS_GETAVATARCAPS, &GaduProto::getavatarcaps); + CreateProtoService(PS_GETAVATARINFO, &GaduProto::getavatarinfo); + CreateProtoService(PS_GETMYAVATAR, &GaduProto::getmyavatar); + CreateProtoService(PS_SETMYAVATAR, &GaduProto::setmyavatar); - CreateProtoService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg); - CreateProtoService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui); + CreateProtoService(PS_GETMYAWAYMSG, &GaduProto::getmyawaymsg); + CreateProtoService(PS_CREATEACCMGRUI, &GaduProto::get_acc_mgr_gui); - CreateProtoService(PS_LEAVECHAT, &GGPROTO::leavechat); + CreateProtoService(PS_LEAVECHAT, &GaduProto::leavechat); // Offline contacts and clear logon time setalloffline(); @@ -78,10 +79,10 @@ GGPROTO::GGPROTO(const char *pszProtoName, const wchar_t *tszUserName) : initavatarrequestthread(); } -GGPROTO::~GGPROTO() +GaduProto::~GaduProto() { #ifdef DEBUGMODE - debugLogA("~GGPROTO(): destroying protocol interface"); + debugLogA("~GaduProto(): destroying protocol interface"); #endif // Destroy modules @@ -104,7 +105,7 @@ GGPROTO::~GGPROTO() DeleteCriticalSection(&avatar_mutex); DeleteCriticalSection(&sessions_mutex); #ifdef DEBUGMODE - debugLogA("~GGPROTO(): DeleteCriticalSections. OK"); + debugLogA("~GaduProto(): DeleteCriticalSections. OK"); #endif // Free status messages @@ -119,7 +120,7 @@ GGPROTO::~GGPROTO() ////////////////////////////////////////////////////////// // when contact is added to list // -MCONTACT GGPROTO::AddToList(int flags, PROTOSEARCHRESULT *pmsr) +MCONTACT GaduProto::AddToList(int flags, PROTOSEARCHRESULT *pmsr) { #ifdef DEBUGMODE debugLogA("AddToList(): id=%s"); @@ -138,7 +139,7 @@ MCONTACT GGPROTO::AddToList(int flags, PROTOSEARCHRESULT *pmsr) ////////////////////////////////////////////////////////// // checks proto capabilities // -DWORD_PTR GGPROTO::GetCaps(int type, MCONTACT) +DWORD_PTR GaduProto::GetCaps(int type, MCONTACT) { switch (type) { case PFLAGNUM_1: @@ -164,7 +165,7 @@ DWORD_PTR GGPROTO::GetCaps(int type, MCONTACT) ////////////////////////////////////////////////////////// // user info request // -void __cdecl GGPROTO::cmdgetinfothread(void *hContact) +void __cdecl GaduProto::cmdgetinfothread(void *hContact) { debugLogA("cmdgetinfothread(): started. Failed info retreival."); gg_sleep(100, FALSE, "cmdgetinfothread", 103, 1); @@ -172,7 +173,7 @@ void __cdecl GGPROTO::cmdgetinfothread(void *hContact) debugLogA("cmdgetinfothread(): end."); } -int GGPROTO::GetInfo(MCONTACT hContact, int) +int GaduProto::GetInfo(MCONTACT hContact, int) { gg_pubdir50_t req; @@ -180,9 +181,9 @@ int GGPROTO::GetInfo(MCONTACT hContact, int) if (hContact) { if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH))) { #ifdef DEBUGMODE - debugLogA("GetInfo(): ForkThread 6 GGPROTO::cmdgetinfothread"); + debugLogA("GetInfo(): ForkThread 6 GaduProto::cmdgetinfothread"); #endif - ForkThread(&GGPROTO::cmdgetinfothread, (void*)hContact); + ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact); return 1; } @@ -196,9 +197,9 @@ int GGPROTO::GetInfo(MCONTACT hContact, int) if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 1, "sess_mutex", 1); #ifdef DEBUGMODE - debugLogA("GetInfo(): ForkThread 7 GGPROTO::cmdgetinfothread"); + debugLogA("GetInfo(): ForkThread 7 GaduProto::cmdgetinfothread"); #endif - ForkThread(&GGPROTO::cmdgetinfothread, (void*)hContact); + ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact); return 1; } gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 2, "sess_mutex", 1); @@ -208,9 +209,9 @@ int GGPROTO::GetInfo(MCONTACT hContact, int) else { if (!(req = gg_pubdir50_new(GG_PUBDIR50_READ))) { #ifdef DEBUGMODE - debugLogA("GetInfo(): ForkThread 8 GGPROTO::cmdgetinfothread"); + debugLogA("GetInfo(): ForkThread 8 GaduProto::cmdgetinfothread"); #endif - ForkThread(&GGPROTO::cmdgetinfothread, (void*)hContact); + ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact); return 1; } @@ -223,9 +224,9 @@ int GGPROTO::GetInfo(MCONTACT hContact, int) if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 49, 1, "sess_mutex", 1); #ifdef DEBUGMODE - debugLogA("GetInfo(): ForkThread 9 GGPROTO::cmdgetinfothread"); + debugLogA("GetInfo(): ForkThread 9 GaduProto::cmdgetinfothread"); #endif - ForkThread(&GGPROTO::cmdgetinfothread, (void*)hContact); + ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact); gg_pubdir50_free(req); return 1; } @@ -238,7 +239,7 @@ int GGPROTO::GetInfo(MCONTACT hContact, int) return 1; } -void __cdecl GGPROTO::searchthread(void *) +void __cdecl GaduProto::searchthread(void *) { debugLogA("searchthread(): started. Failed search."); gg_sleep(100, FALSE, "searchthread", 104, 1); @@ -251,7 +252,7 @@ void __cdecl GGPROTO::searchthread(void *) ////////////////////////////////////////////////////////// // when basic search // -HANDLE GGPROTO::SearchBasic(const wchar_t *id) +HANDLE GaduProto::SearchBasic(const wchar_t *id) { if (!isonline()) return nullptr; @@ -259,9 +260,9 @@ HANDLE GGPROTO::SearchBasic(const wchar_t *id) gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_SEARCH); if (!req) { #ifdef DEBUGMODE - debugLogA("SearchBasic(): ForkThread 10 GGPROTO::searchthread"); + debugLogA("SearchBasic(): ForkThread 10 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); return (HANDLE)1; } @@ -273,9 +274,9 @@ HANDLE GGPROTO::SearchBasic(const wchar_t *id) if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 1, "sess_mutex", 1); #ifdef DEBUGMODE - debugLogA("SearchBasic(): ForkThread 11 GGPROTO::searchthread"); + debugLogA("SearchBasic(): ForkThread 11 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); return (HANDLE)1; } gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 2, "sess_mutex", 1); @@ -288,7 +289,7 @@ HANDLE GGPROTO::SearchBasic(const wchar_t *id) ////////////////////////////////////////////////////////// // search by details // -HANDLE GGPROTO::SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) +HANDLE GaduProto::SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) { // Check if connected and if there's a search data if (!isonline()) @@ -300,9 +301,9 @@ HANDLE GGPROTO::SearchByName(const wchar_t *nick, const wchar_t *firstName, cons gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_SEARCH); if (req == nullptr) { #ifdef DEBUGMODE - debugLogA("SearchByName(): ForkThread 12 GGPROTO::searchthread"); + debugLogA("SearchByName(): ForkThread 12 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); return (HANDLE)1; } @@ -341,9 +342,9 @@ HANDLE GGPROTO::SearchByName(const wchar_t *nick, const wchar_t *firstName, cons if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "SearchByName", 51, 1, "sess_mutex", 1); #ifdef DEBUGMODE - debugLogA("SearchByName(): ForkThread 13 GGPROTO::searchthread"); + debugLogA("SearchByName(): ForkThread 13 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); } else { @@ -358,7 +359,7 @@ HANDLE GGPROTO::SearchByName(const wchar_t *nick, const wchar_t *firstName, cons ////////////////////////////////////////////////////////// // search by advanced // -HWND GGPROTO::SearchAdvanced(HWND hwndDlg) +HWND GaduProto::SearchAdvanced(HWND hwndDlg) { // Check if connected if (!isonline()) @@ -367,9 +368,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_SEARCH); if (!req) { #ifdef DEBUGMODE - debugLogA("SearchAdvanced(): ForkThread 14 GGPROTO::searchthread"); + debugLogA("SearchAdvanced(): ForkThread 14 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); return (HWND)1; } @@ -477,9 +478,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 1, "sess_mutex", 1); #ifdef DEBUGMODE - debugLogA("SearchAdvanced(): ForkThread 15 GGPROTO::searchthread"); + debugLogA("SearchAdvanced(): ForkThread 15 GaduProto::searchthread"); #endif - ForkThread(&GGPROTO::searchthread, nullptr); + ForkThread(&GaduProto::searchthread, nullptr); return (HWND)1; } gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 2, "sess_mutex", 1); @@ -506,7 +507,7 @@ static INT_PTR CALLBACK gg_advancedsearchdlgproc(HWND hwndDlg, UINT message, WPA return FALSE; } -HWND GGPROTO::CreateExtendedSearchUI(HWND owner) +HWND GaduProto::CreateExtendedSearchUI(HWND owner) { return CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_GGADVANCEDSEARCH), owner, gg_advancedsearchdlgproc, (LPARAM)this); @@ -518,7 +519,7 @@ struct GG_SEQ_ACK int seq; }; -void __cdecl GGPROTO::sendackthread(void *ack) +void __cdecl GaduProto::sendackthread(void *ack) { GG_SEQ_ACK *pAck = (GG_SEQ_ACK *)ack; gg_sleep(100, FALSE, "sendackthread", 105, 1); @@ -529,7 +530,7 @@ void __cdecl GGPROTO::sendackthread(void *ack) ////////////////////////////////////////////////////////// // when messsage sent // -int GGPROTO::SendMsg(MCONTACT hContact, int, const char *msg) +int GaduProto::SendMsg(MCONTACT hContact, int, const char *msg) { uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0); if (!isonline() || !uin) @@ -541,16 +542,16 @@ int GGPROTO::SendMsg(MCONTACT hContact, int, const char *msg) gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1); int seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg); gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1); - if (!getByte(GG_KEY_MSGACK, GG_KEYDEF_MSGACK)) { + if (!m_gaduOptions.useMsgDeliveryAcknowledge) { // Auto-ack message without waiting for server ack GG_SEQ_ACK *ack = (GG_SEQ_ACK*)mir_alloc(sizeof(GG_SEQ_ACK)); if (ack) { ack->seq = seq; ack->hContact = hContact; #ifdef DEBUGMODE - debugLogA("SendMsg(): ForkThread 16 GGPROTO::sendackthread"); + debugLogA("SendMsg(): ForkThread 16 GaduProto::sendackthread"); #endif - ForkThread(&GGPROTO::sendackthread, ack); + ForkThread(&GaduProto::sendackthread, ack); } } @@ -560,7 +561,7 @@ int GGPROTO::SendMsg(MCONTACT hContact, int, const char *msg) ////////////////////////////////////////////////////////// // visible lists // -int GGPROTO::SetApparentMode(MCONTACT hContact, int mode) +int GaduProto::SetApparentMode(MCONTACT hContact, int mode) { setWord(hContact, GG_KEY_APPARENT, (WORD)mode); notifyuser(hContact, 1); @@ -571,7 +572,7 @@ int GGPROTO::SetApparentMode(MCONTACT hContact, int mode) ////////////////////////////////////////////////////////// // sets protocol status // -int GGPROTO::SetStatus(int iNewStatus) +int GaduProto::SetStatus(int iNewStatus) { int nNewStatus = gg_normalizestatus(iNewStatus); @@ -589,7 +590,7 @@ int GGPROTO::SetStatus(int iNewStatus) return 0; } -void __cdecl GGPROTO::getawaymsgthread(void *arg) +void __cdecl GaduProto::getawaymsgthread(void *arg) { DBVARIANT dbv; @@ -610,12 +611,12 @@ void __cdecl GGPROTO::getawaymsgthread(void *arg) ////////////////////////////////////////////////////////// // when away message is requested // -HANDLE GGPROTO::GetAwayMsg(MCONTACT hContact) +HANDLE GaduProto::GetAwayMsg(MCONTACT hContact) { #ifdef DEBUGMODE - debugLogA("GetAwayMsg(): ForkThread 17 GGPROTO::getawaymsgthread"); + debugLogA("GetAwayMsg(): ForkThread 17 GaduProto::getawaymsgthread"); #endif - ForkThread(&GGPROTO::getawaymsgthread, (void*)hContact); + ForkThread(&GaduProto::getawaymsgthread, (void*)hContact); return (HANDLE)1; } @@ -623,7 +624,7 @@ HANDLE GGPROTO::GetAwayMsg(MCONTACT hContact) // when away message is being set // registered as ProtoService PS_SETAWAYMSGT // -int GGPROTO::SetAwayMsg(int iStatus, const wchar_t *newMsg) +int GaduProto::SetAwayMsg(int iStatus, const wchar_t *newMsg) { int status = gg_normalizestatus(iStatus); wchar_t **msgPtr; @@ -682,7 +683,7 @@ int GGPROTO::SetAwayMsg(int iStatus, const wchar_t *newMsg) ////////////////////////////////////////////////////////// // sends a notification that the user is typing a message // -int GGPROTO::UserIsTyping(MCONTACT hContact, int type) +int GaduProto::UserIsTyping(MCONTACT hContact, int type) { uin_t uin = getDword(hContact, GG_KEY_UIN, 0); if (!uin || !isonline()) @@ -700,12 +701,12 @@ int GGPROTO::UserIsTyping(MCONTACT hContact, int type) ////////////////////////////////////////////////////////// // Custom protocol event // -int GGPROTO::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) +int GaduProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) { switch (eventType) { case EV_PROTO_ONLOAD: - HookProtoEvent(ME_OPT_INITIALISE, &GGPROTO::options_init); - HookProtoEvent(ME_USERINFO_INITIALISE, &GGPROTO::details_init); + HookProtoEvent(ME_OPT_INITIALISE, &GaduProto::options_init); + HookProtoEvent(ME_USERINFO_INITIALISE, &GaduProto::details_init); // Init misc stuff gg_icolib_init(); diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h index f1ffb37947..361830b64a 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.h +++ b/protocols/Gadu-Gadu/src/gg_proto.h @@ -22,10 +22,10 @@ #ifndef GGPROTO_H #define GGPROTO_H -struct GGPROTO : public PROTO +struct GaduProto : public PROTO { - GGPROTO(const char*, const wchar_t*); - ~GGPROTO(); + GaduProto(const char*, const wchar_t*); + ~GaduProto(); //==================================================================================== // PROTO_INTERFACE @@ -216,6 +216,7 @@ struct GGPROTO : public PROTO void block_uninit(); ////////////////////////////////////////////////////////////////////////////////////// + GaduOptions m_gaduOptions; CRITICAL_SECTION ft_mutex, sess_mutex, img_mutex, modemsg_mutex, avatar_mutex, sessions_mutex; list_t watches, transfers, requests, chats, imagedlgs, sessions; @@ -258,14 +259,14 @@ struct GGUSERUTILDLGDATA uin_t uin; char *pass; char *email; - GGPROTO *gg; + GaduProto *gg; }; #ifdef DEBUGMODE -inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, char* mutexName, int logging) +inline void GaduProto::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, char* mutexName, int logging) #else -inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char*, int, char *, int) +inline void GaduProto::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char*, int, char *, int) #endif { #ifdef DEBUGMODE @@ -286,9 +287,9 @@ inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char*, int } #ifdef DEBUGMODE -inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging) /*0-never, 1-debug, 2-all*/ +inline void GaduProto::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging) /*0-never, 1-debug, 2-all*/ #else -inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char *, int, int, char *, int) /*0-never, 1-debug, 2-all*/ +inline void GaduProto::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char *, int, int, char *, int) /*0-never, 1-debug, 2-all*/ #endif { #ifdef DEBUGMODE @@ -299,9 +300,9 @@ inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char *, in } #ifdef DEBUGMODE -inline void GGPROTO::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging) { +inline void GaduProto::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging) { #else -inline void GGPROTO::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int, int) { +inline void GaduProto::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int, int) { #endif SleepEx(miliseconds, alterable); #ifdef DEBUGMODE diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 1736caf285..2126cfdb53 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -28,7 +28,7 @@ //////////////////////////////////////////////////////////////////////////////// // Inits Gadu-Gadu groupchat module using chat.dll // -int GGPROTO::gc_init() +int GaduProto::gc_init() { char service[64]; @@ -38,7 +38,7 @@ int GGPROTO::gc_init() gcr.pszModule = m_szModuleName; Chat_Register(&gcr); - HookProtoEvent(ME_GC_EVENT, &GGPROTO::gc_event); + HookProtoEvent(ME_GC_EVENT, &GaduProto::gc_event); gc_enabled = TRUE; // create & hook event @@ -51,7 +51,7 @@ int GGPROTO::gc_init() //////////////////////////////////////////////////////////////////////////////// // Groupchat menus initialization // -void GGPROTO::gc_menus_init(HGENMENU hRoot) +void GaduProto::gc_menus_init(HGENMENU hRoot) { if (gc_enabled) { CMenuItem mi; @@ -60,7 +60,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot) // Conferencing mi.pszService = GGS_OPEN_CONF; - CreateProtoService(mi.pszService, &GGPROTO::gc_openconf); + CreateProtoService(mi.pszService, &GaduProto::gc_openconf); mi.position = 2000050001; mi.hIcolibItem = iconList[14].hIcolib; mi.name.w = LPGENW("Open &conference..."); @@ -68,7 +68,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot) // Clear ignored conferences mi.pszService = GGS_CLEAR_IGNORED; - CreateProtoService(mi.pszService, &GGPROTO::gc_clearignored); + CreateProtoService(mi.pszService, &GaduProto::gc_clearignored); mi.position = 2000050002; mi.hIcolibItem = iconList[15].hIcolib; mi.name.w = LPGENW("&Clear ignored conferences"); @@ -79,7 +79,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot) //////////////////////////////////////////////////////////////////////////////// // Releases Gadu-Gadu groupchat module using chat.dll // -int GGPROTO::gc_destroy() +int GaduProto::gc_destroy() { list_t l; for (l = chats; l; l = l->next) @@ -92,7 +92,7 @@ int GGPROTO::gc_destroy() return 1; } -GGGC* GGPROTO::gc_lookup(const wchar_t *id) +GGGC* GaduProto::gc_lookup(const wchar_t *id) { GGGC *chat; list_t l; @@ -107,7 +107,7 @@ GGGC* GGPROTO::gc_lookup(const wchar_t *id) return nullptr; } -int GGPROTO::gc_event(WPARAM, LPARAM lParam) +int GaduProto::gc_event(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK *)lParam; GGGC *chat = nullptr; @@ -205,7 +205,7 @@ typedef struct _gg_gc_echat //////////////////////////////////////////////////////////////////////////////// // This is main groupchat initialization routine // -wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) +wchar_t* GaduProto::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) { list_t l; GGGC *chat; @@ -383,7 +383,7 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou return chat->id; } -static MCONTACT gg_getsubcontact(GGPROTO* gg, MCONTACT hContact) +static MCONTACT gg_getsubcontact(GaduProto* gg, MCONTACT hContact) { char* szProto = GetContactProto(hContact); if (szProto && !mir_strcmp(szProto, META_PROTO)) { @@ -445,7 +445,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa case IDOK: { HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST); - GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER); + GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER); int count = 0, i = 0; // Check if connected if (!gg->isonline()) @@ -502,7 +502,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa { char* szProto; uin_t uin; - GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER); + GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER); if (!gg) break; @@ -563,7 +563,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa return FALSE; } -INT_PTR GGPROTO::gc_clearignored(WPARAM, LPARAM) +INT_PTR GaduProto::gc_clearignored(WPARAM, LPARAM) { list_t l = chats; BOOL cleared = FALSE; @@ -588,7 +588,7 @@ INT_PTR GGPROTO::gc_clearignored(WPARAM, LPARAM) return 0; } -INT_PTR GGPROTO::gc_openconf(WPARAM, LPARAM) +INT_PTR GaduProto::gc_openconf(WPARAM, LPARAM) { // Check if connected if (!isonline()) @@ -604,7 +604,7 @@ INT_PTR GGPROTO::gc_openconf(WPARAM, LPARAM) return 1; } -int GGPROTO::gc_changenick(MCONTACT hContact, wchar_t *ptszNick) +int GaduProto::gc_changenick(MCONTACT hContact, wchar_t *ptszNick) { list_t l; uin_t uin = getDword(hContact, GG_KEY_UIN, 0); diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 3056ad8c3c..23c485b2ad 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -57,7 +57,7 @@ struct GGIMAGEDLGDATA GGIMAGEENTRY *lpImages; SIZE minSize; BOOL bReceiving; - GGPROTO *gg; + GaduProto *gg; }; // Prototypes @@ -66,7 +66,7 @@ int gg_img_remove(GGIMAGEDLGDATA *dat); //////////////////////////////////////////////////////////////////////////// // Image Module : Adding item to contact menu, creating sync objects // -int GGPROTO::img_init() +int GaduProto::img_init() { // Send image contact menu item CMenuItem mi; @@ -78,7 +78,7 @@ int GGPROTO::img_init() hImageMenuItem = Menu_AddContactMenuItem(&mi, m_szModuleName); // Receive image - CreateProtoService(GGS_RECVIMAGE, &GGPROTO::img_recvimage); + CreateProtoService(GGS_RECVIMAGE, &GaduProto::img_recvimage); return FALSE; } @@ -86,7 +86,7 @@ int GGPROTO::img_init() //////////////////////////////////////////////////////////////////////////// // Image Module : closing dialogs, sync objects // -int GGPROTO::img_shutdown() +int GaduProto::img_shutdown() { list_t l; #ifdef DEBUGMODE @@ -117,7 +117,7 @@ int GGPROTO::img_shutdown() //////////////////////////////////////////////////////////////////////////// // Image Module : destroying list // -int GGPROTO::img_destroy() +int GaduProto::img_destroy() { // Release all dialogs while (imagedlgs && gg_img_remove((GGIMAGEDLGDATA *)imagedlgs->data)); @@ -245,7 +245,7 @@ int gg_img_saveimage(HWND hwnd, GGIMAGEENTRY *dat) if (!dat) return FALSE; - GGPROTO* gg = ((GGIMAGEDLGDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->gg; + GaduProto* gg = ((GGIMAGEDLGDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->gg; wchar_t szFilter[128]; gg_img_getfilter(szFilter, _countof(szFilter)); @@ -516,7 +516,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { // Deleting all image entries GGIMAGEENTRY *temp, *img = dat->lpImages; - GGPROTO *gg = dat->gg; + GaduProto *gg = dat->gg; while (temp = img) { img = img->lpNext; @@ -606,7 +606,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { unsigned char format[20]; char *msg = "\xA0\0"; - GGPROTO *gg = dat->gg; + GaduProto *gg = dat->gg; if (dat->lpImages && gg->isonline()) { @@ -704,7 +704,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP //////////////////////////////////////////////////////////////////////////// // Image dialog call thread // -void __cdecl GGPROTO::img_dlgcallthread(void *param) +void __cdecl GaduProto::img_dlgcallthread(void *param) { debugLogA("img_dlgcallthread(): started."); @@ -721,7 +721,7 @@ void __cdecl GGPROTO::img_dlgcallthread(void *param) //////////////////////////////////////////////////////////////////////////// // Open dialog receive for specified contact // -GGIMAGEDLGDATA *gg_img_recvdlg(GGPROTO *gg, MCONTACT hContact) +GGIMAGEDLGDATA *gg_img_recvdlg(GaduProto *gg, MCONTACT hContact) { // Create dialog data GGIMAGEDLGDATA *dat = (GGIMAGEDLGDATA *)calloc(1, sizeof(GGIMAGEDLGDATA)); @@ -731,9 +731,9 @@ GGIMAGEDLGDATA *gg_img_recvdlg(GGPROTO *gg, MCONTACT hContact) dat->gg = gg; ResetEvent(dat->hEvent); #ifdef DEBUGMODE - gg->debugLogA("gg_img_recvdlg(): ForkThread 18 GGPROTO::img_dlgcallthread"); + gg->debugLogA("gg_img_recvdlg(): ForkThread 18 GaduProto::img_dlgcallthread"); #endif - gg->ForkThread(&GGPROTO::img_dlgcallthread, dat); + gg->ForkThread(&GaduProto::img_dlgcallthread, dat); return dat; } @@ -799,7 +799,7 @@ wchar_t *gg_img_hasextension(wchar_t *filename) //////////////////////////////////////////////////////////////////////////////// // Display received image using message with [img] BBCode // -int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img) +int GaduProto::img_displayasmsg(MCONTACT hContact, void *img) { wchar_t szPath[MAX_PATH], path[MAX_PATH]; size_t tPathLen; @@ -883,7 +883,7 @@ int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img) //////////////////////////////////////////////////////////////////////////// // Return if uin has it's window already opened // -BOOL GGPROTO::img_opened(uin_t uin) +BOOL GaduProto::img_opened(uin_t uin) { list_t l = imagedlgs; while (l) @@ -901,7 +901,7 @@ BOOL GGPROTO::img_opened(uin_t uin) //////////////////////////////////////////////////////////////////////////// // Image Module : Looking for window entry, create if not found // -int GGPROTO::img_display(MCONTACT hContact, void *img) +int GaduProto::img_display(MCONTACT hContact, void *img) { list_t l = imagedlgs; GGIMAGEDLGDATA *dat = nullptr; @@ -970,7 +970,7 @@ const wchar_t *gg_img_guessfileextension(const char *lpData) //////////////////////////////////////////////////////////////////////////// // Image Window : Loading picture and sending for display // -void* GGPROTO::img_loadpicture(gg_event* e, wchar_t *szFileName) +void* GaduProto::img_loadpicture(gg_event* e, wchar_t *szFileName) { if (!szFileName && (!e || !e->event.image_reply.size || !e->event.image_reply.image || !e->event.image_reply.filename)) @@ -1085,7 +1085,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, wchar_t *szFileName) //////////////////////////////////////////////////////////////////////////// // Image Recv : AddEvent proc // -INT_PTR GGPROTO::img_recvimage(WPARAM wParam, LPARAM lParam) +INT_PTR GaduProto::img_recvimage(WPARAM wParam, LPARAM lParam) { CLISTEVENT *cle = (CLISTEVENT *)lParam; GGIMAGEENTRY *img = (GGIMAGEENTRY *)cle->lParam; @@ -1109,7 +1109,7 @@ INT_PTR GGPROTO::img_recvimage(WPARAM wParam, LPARAM lParam) int gg_img_remove(GGIMAGEDLGDATA *dat) { GGIMAGEENTRY *temp = nullptr, *img = nullptr; - GGPROTO *gg; + GaduProto *gg; if (!dat) return FALSE; @@ -1137,7 +1137,7 @@ int gg_img_remove(GGIMAGEDLGDATA *dat) //////////////////////////////////////////////////////////////////////////// // -GGIMAGEDLGDATA* gg_img_find(GGPROTO *gg, uin_t uin, uint32_t crc32) +GGIMAGEDLGDATA* gg_img_find(GaduProto *gg, uin_t uin, uint32_t crc32) { list_t l = gg->imagedlgs; GGIMAGEDLGDATA *dat; @@ -1170,7 +1170,7 @@ GGIMAGEDLGDATA* gg_img_find(GGPROTO *gg, uin_t uin, uint32_t crc32) //////////////////////////////////////////////////////////////////////////// // Image Module : Send on Request // -BOOL GGPROTO::img_sendonrequest(gg_event* e) +BOOL GaduProto::img_sendonrequest(gg_event* e) { GGIMAGEDLGDATA *dat = gg_img_find(this, e->event.image_request.sender, e->event.image_request.crc32); if (!dat || !isonline()) @@ -1190,7 +1190,7 @@ BOOL GGPROTO::img_sendonrequest(gg_event* e) //////////////////////////////////////////////////////////////////////////// // Send Image : Run (Thread and main) // -INT_PTR GGPROTO::img_sendimg(WPARAM hContact, LPARAM) +INT_PTR GaduProto::img_sendimg(WPARAM hContact, LPARAM) { GGIMAGEDLGDATA *dat = nullptr; @@ -1205,9 +1205,9 @@ INT_PTR GGPROTO::img_sendimg(WPARAM hContact, LPARAM) // Create new dialog #ifdef DEBUGMODE - debugLogA("img_sendimg(): ForkThread 19 GGPROTO::img_dlgcallthread"); + debugLogA("img_sendimg(): ForkThread 19 GaduProto::img_dlgcallthread"); #endif - ForkThread(&GGPROTO::img_dlgcallthread, dat); + ForkThread(&GaduProto::img_dlgcallthread, dat); while (WaitForSingleObjectEx(dat->hEvent, INFINITE, TRUE) != WAIT_OBJECT_0); diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 076af51c6b..23c621ead5 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -20,7 +20,7 @@ #include "gg.h" -char *gg_makecontacts(GGPROTO *gg, int cr) +char *gg_makecontacts(GaduProto *gg, int cr) { string_t s = string_init(nullptr); @@ -124,7 +124,7 @@ char *strndup(char *str, int c) return ret; } -void GGPROTO::parsecontacts(char *contacts) +void GaduProto::parsecontacts(char *contacts) { char *p = strchr(contacts, ':'), *n = nullptr; char *strFirstName, *strLastName, *strNickname, *strNick, *strPhone, *strGroup, *strUin, *strMail; @@ -263,7 +263,7 @@ void GGPROTO::parsecontacts(char *contacts) ////////////////////////////////////////////////////////// // import from server // -INT_PTR GGPROTO::import_server(WPARAM, LPARAM) +INT_PTR GaduProto::import_server(WPARAM, LPARAM) { // Check if connected if (!isonline()) @@ -302,7 +302,7 @@ INT_PTR GGPROTO::import_server(WPARAM, LPARAM) ////////////////////////////////////////////////////////// // remove from server // -INT_PTR GGPROTO::remove_server(WPARAM, LPARAM) +INT_PTR GaduProto::remove_server(WPARAM, LPARAM) { // Check if connected if (!isonline()) { @@ -340,7 +340,7 @@ INT_PTR GGPROTO::remove_server(WPARAM, LPARAM) return 0; } -INT_PTR GGPROTO::import_text(WPARAM, LPARAM) +INT_PTR GaduProto::import_text(WPARAM, LPARAM) { wchar_t str[MAX_PATH]; wchar_t filter[512]; @@ -414,7 +414,7 @@ INT_PTR GGPROTO::import_text(WPARAM, LPARAM) } } -INT_PTR GGPROTO::export_text(WPARAM, LPARAM) +INT_PTR GaduProto::export_text(WPARAM, LPARAM) { wchar_t str[MAX_PATH]; @@ -484,7 +484,7 @@ INT_PTR GGPROTO::export_text(WPARAM, LPARAM) ////////////////////////////////////////////////////////// // export to server // -INT_PTR GGPROTO::export_server(WPARAM, LPARAM) +INT_PTR GaduProto::export_server(WPARAM, LPARAM) { // Check if connected if (!isonline()) @@ -533,7 +533,7 @@ INT_PTR GGPROTO::export_server(WPARAM, LPARAM) ////////////////////////////////////////////////////////// // Import menus and stuff // -void GGPROTO::import_init(HGENMENU hRoot) +void GaduProto::import_init(HGENMENU hRoot) { CMenuItem mi; mi.flags = CMIF_UNICODE; @@ -542,7 +542,7 @@ void GGPROTO::import_init(HGENMENU hRoot) // Import from server item SET_UID(mi, 0x50ea554c, 0x6371, 0x495c, 0x86, 0x7f, 0x28, 0x7, 0x47, 0x59, 0x20, 0x20); mi.pszService = GGS_IMPORT_SERVER; - CreateProtoService(mi.pszService, &GGPROTO::import_server); + CreateProtoService(mi.pszService, &GaduProto::import_server); mi.position = 2000500001; mi.hIcolibItem = iconList[1].hIcolib; mi.name.w = LPGENW("Import List From &Server"); @@ -551,7 +551,7 @@ void GGPROTO::import_init(HGENMENU hRoot) // Import from textfile SET_UID(mi, 0x39c036d5, 0x6eb5, 0x49ae, 0xa8, 0x78, 0x8a, 0x72, 0xeb, 0xf, 0x15, 0x3d); mi.pszService = GGS_IMPORT_TEXT; - CreateProtoService(mi.pszService, &GGPROTO::import_text); + CreateProtoService(mi.pszService, &GaduProto::import_text); mi.position = 2000500002; mi.hIcolibItem = iconList[2].hIcolib; mi.name.w = LPGENW("Import List From &Text File..."); @@ -560,7 +560,7 @@ void GGPROTO::import_init(HGENMENU hRoot) // Remove from server SET_UID(mi, 0x6bdbe700, 0xf240, 0x4ed8, 0x86, 0x26, 0x31, 0x85, 0xf8, 0x5, 0xe5, 0xb1); mi.pszService = GGS_REMOVE_SERVER; - CreateProtoService(mi.pszService, &GGPROTO::remove_server); + CreateProtoService(mi.pszService, &GaduProto::remove_server); mi.position = 2000500003; mi.hIcolibItem = iconList[3].hIcolib; mi.name.w = LPGENW("&Remove List From Server"); @@ -569,7 +569,7 @@ void GGPROTO::import_init(HGENMENU hRoot) // Export to server SET_UID(mi, 0xddb8e1f0, 0x7282, 0x4105, 0x90, 0x83, 0x92, 0x25, 0x21, 0x7d, 0xe2, 0x6a); mi.pszService = GGS_EXPORT_SERVER; - CreateProtoService(mi.pszService, &GGPROTO::export_server); + CreateProtoService(mi.pszService, &GaduProto::export_server); mi.position = 2005000001; mi.hIcolibItem = iconList[4].hIcolib; mi.name.w = LPGENW("Export List To &Server"); @@ -578,7 +578,7 @@ void GGPROTO::import_init(HGENMENU hRoot) // Export to textfile SET_UID(mi, 0x7ee0000b, 0xb202, 0x4fe4, 0xb3, 0x42, 0x3b, 0x39, 0xfb, 0x9d, 0x80, 0x5d); mi.pszService = GGS_EXPORT_TEXT; - CreateProtoService(mi.pszService, &GGPROTO::export_text); + CreateProtoService(mi.pszService, &GaduProto::export_text); mi.position = 2005000002; mi.hIcolibItem = iconList[5].hIcolib; mi.name.w = LPGENW("Export List To &Text File..."); diff --git a/protocols/Gadu-Gadu/src/keepalive.cpp b/protocols/Gadu-Gadu/src/keepalive.cpp index df01face9c..4d7a13acff 100644 --- a/protocols/Gadu-Gadu/src/keepalive.cpp +++ b/protocols/Gadu-Gadu/src/keepalive.cpp @@ -24,20 +24,20 @@ * does not get full pointer but just 2 byte lower bytes. */ #define MAX_TIMERS 8 -GGPROTO *g_timers[MAX_TIMERS] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; +GaduProto *g_timers[MAX_TIMERS] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; static VOID CALLBACK gg_keepalive(HWND, UINT, UINT_PTR idEvent, DWORD) { int i; - //Search for GGPROTO* context + //Search for GaduProto* context for (i = 0; i < MAX_TIMERS; i++) if (g_timers[i]->timer == idEvent) break; if (i < MAX_TIMERS) { - GGPROTO *gg = g_timers[i]; + GaduProto *gg = g_timers[i]; if (gg->isonline()) { #ifdef DEBUGMODE @@ -50,9 +50,9 @@ static VOID CALLBACK gg_keepalive(HWND, UINT, UINT_PTR idEvent, DWORD) } } -void GGPROTO::keepalive_init() +void GaduProto::keepalive_init() { - if (getByte(GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE)) + if (m_gaduOptions.keepConnectionAlive) { int i; for (i = 0; i < MAX_TIMERS && g_timers[i] != nullptr; i++); @@ -68,7 +68,7 @@ void GGPROTO::keepalive_init() } } -void GGPROTO::keepalive_destroy() +void GaduProto::keepalive_destroy() { #ifdef DEBUGMODE debugLogA("keepalive_destroy(): Killing Timer"); diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index e8622cad4b..02e4986236 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -58,7 +58,7 @@ static INT_PTR gg_parselink(WPARAM, LPARAM lParam) if (!uin) return 1; - GGPROTO *gg = nullptr; + GaduProto *gg = nullptr; int items = 0; for (int i = 0; i < g_Instances.getCount(); i++) { gg = g_Instances[i]; @@ -114,7 +114,7 @@ void gg_links_init() } } -void GGPROTO::links_instance_init() +void GaduProto::links_instance_init() { if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) { CMenuItem mi; diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index a38e3ad7d5..da0df144b6 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -291,7 +291,7 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD return res; } -int GGPROTO::oauth_receivetoken() +int GaduProto::oauth_receivetoken() { char szUrl[256], uin[32], *token = nullptr, *token_secret = nullptr; int res = 0; @@ -440,7 +440,7 @@ int GGPROTO::oauth_receivetoken() return res; } -int GGPROTO::oauth_checktoken(int force) +int GaduProto::oauth_checktoken(int force) { if (force) return oauth_receivetoken(); diff --git a/protocols/Gadu-Gadu/src/options.cpp b/protocols/Gadu-Gadu/src/options.cpp new file mode 100644 index 0000000000..c2e5a4dddd --- /dev/null +++ b/protocols/Gadu-Gadu/src/options.cpp @@ -0,0 +1,103 @@ +#include "gg.h" + +GaduOptions::GaduOptions(PROTO_INTERFACE *proto) : + autoRecconect(proto, "AReconnect", 0), + keepConnectionAlive(proto, "KeepAlive", 1), + showConnectionErrors(proto, "ShowCErrors", 0), + useDirectConnections(proto, "DirectConns", 1), + useForwarding(proto, "Forwarding", 0), + useManualHosts(proto, "ManualHost", 1), + useMsgDeliveryAcknowledge(proto, "MessageAck", 1), + useSslConnection(proto, "SSLConnection", 1), + directConnectionPort(proto, "DirectPort", 1550), + forwardPort(proto, "ForwardPort", 1550), + forwardHost(proto, "ForwardHost", L""), + serverHosts(proto, "ServerHosts", GG_KEYDEF_SERVERHOSTS) +{ +} + + +GaduOptionsDlgAdvanced::GaduOptionsDlgAdvanced(GaduProto * proto) : + GaduDlgBase(proto, IDD_OPT_GG_ADVANCED, false), + chkAutoReconnect(this, IDC_ARECONNECT), + chkKeepConnectionAlive(this, IDC_KEEPALIVE), + chkMsgAcknowledge(this, IDC_MSGACK), + chkShowConnectionErrors(this, IDC_SHOWCERRORS), + chkSslConnection(this, IDC_SSLCONN), + chkManualHosts(this, IDC_MANUALHOST), + edtServerHosts(this, IDC_HOST), + chkDirectConnections(this, IDC_DIRECTCONNS), + edtDirectPort(this, IDC_DIRECTPORT), + chkForwarding(this, IDC_FORWARDING), + edtForwardHost(this, IDC_FORWARDHOST), + edtForwardPort(this, IDC_FORWARDPORT), + txtReconnectRequired(this, IDC_RELOADREQD) +{ + CreateLink(chkAutoReconnect, proto->m_gaduOptions.autoRecconect); + CreateLink(chkKeepConnectionAlive, proto->m_gaduOptions.keepConnectionAlive); + CreateLink(chkMsgAcknowledge, proto->m_gaduOptions.useMsgDeliveryAcknowledge); + CreateLink(chkShowConnectionErrors, proto->m_gaduOptions.showConnectionErrors); + CreateLink(chkSslConnection, proto->m_gaduOptions.useSslConnection); + + CreateLink(chkManualHosts, proto->m_gaduOptions.useManualHosts); + CreateLink(edtServerHosts, proto->m_gaduOptions.serverHosts); + + CreateLink(chkDirectConnections, proto->m_gaduOptions.useDirectConnections); + CreateLink(edtDirectPort, proto->m_gaduOptions.directConnectionPort); + + CreateLink(chkForwarding, proto->m_gaduOptions.useForwarding); + CreateLink(edtForwardHost, proto->m_gaduOptions.forwardHost); + CreateLink(edtForwardPort, proto->m_gaduOptions.forwardPort); + + chkManualHosts.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_ManualHosts); + chkDirectConnections.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_DirectConnections); + chkForwarding.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_Forwarding); +} + +void GaduOptionsDlgAdvanced::OnInitDialog() +{ + chkKeepConnectionAlive.Disable(); + chkSslConnection.Disable(); + + chkManualHosts.Disable(); + edtServerHosts.Enable(chkManualHosts.GetState()); + edtServerHosts.Disable(); + + bool useDirectConnection = chkDirectConnections.GetState(); + edtDirectPort.Enable(useDirectConnection); + chkForwarding.Enable(useDirectConnection); + + bool useForwarding = chkForwarding.GetState(); + edtForwardHost.Enable(useDirectConnection && useForwarding); + edtForwardPort.Enable(useDirectConnection && useForwarding); +} + +void GaduOptionsDlgAdvanced::onCheck_ManualHosts(CCtrlCheck *) +{ + bool useManualHosts = chkManualHosts.GetState(); + edtServerHosts.Enable(useManualHosts); + + txtReconnectRequired.Show(); +} + +void GaduOptionsDlgAdvanced::onCheck_DirectConnections(CCtrlCheck *) +{ + bool useDirectConnection = chkDirectConnections.GetState(); + edtDirectPort.Enable(useDirectConnection); + chkForwarding.Enable(useDirectConnection); + + bool useForwarding = chkForwarding.GetState(); + edtForwardHost.Enable(useDirectConnection && useForwarding); + edtForwardPort.Enable(useDirectConnection && useForwarding); + + txtReconnectRequired.Show(); +} + +void GaduOptionsDlgAdvanced::onCheck_Forwarding(CCtrlCheck *) +{ + bool useForwarding = chkForwarding.GetState(); + edtForwardHost.Enable(useForwarding); + edtForwardPort.Enable(useForwarding); + + txtReconnectRequired.Show(); +} diff --git a/protocols/Gadu-Gadu/src/options.h b/protocols/Gadu-Gadu/src/options.h new file mode 100644 index 0000000000..c0eaecae75 --- /dev/null +++ b/protocols/Gadu-Gadu/src/options.h @@ -0,0 +1,57 @@ +#pragma once + +#include "gg.h" + +struct GaduOptions +{ + CMOption autoRecconect; + CMOption keepConnectionAlive; + CMOption showConnectionErrors; + CMOption useDirectConnections; + CMOption useForwarding; + CMOption useManualHosts; + CMOption useMsgDeliveryAcknowledge; + CMOption useSslConnection; + + CMOption directConnectionPort; + CMOption forwardPort; + + CMOption forwardHost; + CMOption serverHosts; + + GaduOptions(PROTO_INTERFACE *proto); +}; + +using GaduDlgBase = CProtoDlgBase; + +class GaduOptionsDlgAdvanced : public GaduDlgBase +{ +private: + CCtrlCheck chkAutoReconnect; + CCtrlCheck chkKeepConnectionAlive; + CCtrlCheck chkMsgAcknowledge; + CCtrlCheck chkShowConnectionErrors; + CCtrlCheck chkSslConnection; + + CCtrlCheck chkManualHosts; + CCtrlEdit edtServerHosts; + + CCtrlCheck chkDirectConnections; + CCtrlEdit edtDirectPort; + + CCtrlCheck chkForwarding; + CCtrlEdit edtForwardHost; + CCtrlEdit edtForwardPort; + + CCtrlBase txtReconnectRequired; + +public: + GaduOptionsDlgAdvanced(GaduProto *proto); + + void OnInitDialog() override; + +private: + void onCheck_ManualHosts(CCtrlCheck*); + void onCheck_DirectConnections(CCtrlCheck*); + void onCheck_Forwarding(CCtrlCheck*); +}; diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp index 86928a99e5..e1ac214e77 100644 --- a/protocols/Gadu-Gadu/src/ownerinfo.cpp +++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp @@ -29,7 +29,7 @@ struct GG_REMIND_PASS ////////////////////////////////////////////////////////// // remind password // -void __cdecl GGPROTO::remindpasswordthread(void *param) +void __cdecl GaduProto::remindpasswordthread(void *param) { // Connection handle GG_REMIND_PASS *rp = (GG_REMIND_PASS *)param; @@ -74,14 +74,14 @@ void __cdecl GGPROTO::remindpasswordthread(void *param) #endif } -void GGPROTO::remindpassword(uin_t uin, const char *email) +void GaduProto::remindpassword(uin_t uin, const char *email) { GG_REMIND_PASS *rp = (GG_REMIND_PASS*)malloc(sizeof(GG_REMIND_PASS)); rp->uin = uin; rp->email = email; #ifdef DEBUGMODE - debugLogA("remindpassword(): ForkThreadEx 20 GGPROTO::remindpasswordthread"); + debugLogA("remindpassword(): ForkThreadEx 20 GaduProto::remindpasswordthread"); #endif - ForkThread(&GGPROTO::remindpasswordthread, rp); + ForkThread(&GaduProto::remindpasswordthread, rp); } diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp index 2e3a7cb476..4863bbe9dc 100644 --- a/protocols/Gadu-Gadu/src/popups.cpp +++ b/protocols/Gadu-Gadu/src/popups.cpp @@ -25,7 +25,7 @@ struct PopupData unsigned flags; wchar_t* title; wchar_t* text; - GGPROTO* gg; + GaduProto* gg; }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar ///////////////////////////////////////////////////////////////////////////////////////// // Popup plugin class registration // -void GGPROTO::initpopups() +void GaduProto::initpopups() { wchar_t szDescr[256]; char szName[256]; @@ -106,7 +106,7 @@ void GGPROTO::initpopups() void CALLBACK sttMainThreadCallback(PVOID dwParam) { PopupData* puData = (PopupData*)dwParam; - GGPROTO* gg = puData->gg; + GaduProto* gg = puData->gg; if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { char szName[256]; @@ -149,7 +149,7 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) mir_free(puData); } -void GGPROTO::showpopup(const wchar_t* nickname, const wchar_t* msg, int flags) +void GaduProto::showpopup(const wchar_t* nickname, const wchar_t* msg, int flags) { if (Miranda_IsTerminated()) return; diff --git a/protocols/Gadu-Gadu/src/resource.h b/protocols/Gadu-Gadu/src/resource.h index 86ec31eadb..e1e7284225 100644 --- a/protocols/Gadu-Gadu/src/resource.h +++ b/protocols/Gadu-Gadu/src/resource.h @@ -1,33 +1,7 @@ -//////////////////////////////////////////////////////////////////////////////// -// Gadu-Gadu Plugin for Miranda IM +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by D:\Repozytoria\Miranda NG\protocols\Gadu-Gadu\res\resource.rc // -// Copyright (c) 2003-2006 Adam Strzelecki -// -// 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, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//////////////////////////////////////////////////////////////////////////////// - -#ifndef IDC_STATIC -#define IDC_STATIC -1 -#endif -#ifndef IDOK -#define IDOK 1 -#endif -#ifndef IDCANCEL -#define IDCANCEL 2 -#endif - #define IDI_GG 251 #define IDI_IMPORT_TEXT 252 #define IDI_IMPORT_SERVER 253 @@ -145,3 +119,15 @@ #define IDC_IMG_NAME 1018 #define IDC_CLIST 1200 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index 0947a24906..69bd73cd6d 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -50,7 +50,7 @@ char *gg_status2db(int status, const char *suffix) ////////////////////////////////////////////////////////// // gets protocol status // -wchar_t* GGPROTO::getstatusmsg(int status) +wchar_t* GaduProto::getstatusmsg(int status) { switch (status) { case ID_STATUS_ONLINE: @@ -74,7 +74,7 @@ wchar_t* GGPROTO::getstatusmsg(int status) ////////////////////////////////////////////////////////// // sets specified protocol status // -int GGPROTO::refreshstatus(int status) +int GaduProto::refreshstatus(int status) { if (status == ID_STATUS_OFFLINE) { @@ -94,9 +94,9 @@ int GGPROTO::refreshstatus(int status) threadwait(&pth_sess); #ifdef DEBUGMODE debugLogA("refreshstatus(): Waiting pth_sess thread - OK"); - debugLogA("refreshstatus(): ForkThreadEx 21 GGPROTO::mainthread"); + debugLogA("refreshstatus(): ForkThreadEx 21 GaduProto::mainthread"); #endif - pth_sess.hThread = ForkThreadEx(&GGPROTO::mainthread, nullptr, &pth_sess.dwThreadId); + pth_sess.hThread = ForkThreadEx(&GaduProto::mainthread, nullptr, &pth_sess.dwThreadId); } else { @@ -146,7 +146,7 @@ int gg_normalizestatus(int status) // gets avatar capabilities // registered as ProtoService PS_GETAVATARCAPS // -INT_PTR GGPROTO::getavatarcaps(WPARAM wParam, LPARAM lParam) +INT_PTR GaduProto::getavatarcaps(WPARAM wParam, LPARAM lParam) { switch (wParam) { case AF_MAXSIZE: @@ -172,7 +172,7 @@ INT_PTR GGPROTO::getavatarcaps(WPARAM wParam, LPARAM lParam) // gets avatar information // registered as ProtoService PS_GETAVATARINFO // -INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) +INT_PTR GaduProto::getavatarinfo(WPARAM wParam, LPARAM lParam) { PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION *)lParam; pai->filename[0] = 0; @@ -288,7 +288,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) // gets avatar // registered as ProtoService PS_GETMYAVATAR // -INT_PTR GGPROTO::getmyavatar(WPARAM wParam, LPARAM lParam) +INT_PTR GaduProto::getmyavatar(WPARAM wParam, LPARAM lParam) { wchar_t *szFilename = (wchar_t*)wParam; int len = (int)lParam; @@ -319,7 +319,7 @@ INT_PTR GGPROTO::getmyavatar(WPARAM wParam, LPARAM lParam) // sets avatar // registered as ProtoService PS_SETMYAVATAR // -INT_PTR GGPROTO::setmyavatar(WPARAM, LPARAM lParam) +INT_PTR GaduProto::setmyavatar(WPARAM, LPARAM lParam) { wchar_t *szFilename = (wchar_t*)lParam; @@ -358,7 +358,7 @@ INT_PTR GGPROTO::setmyavatar(WPARAM, LPARAM lParam) // gets protocol status message // registered as ProtoService PS_GETMYAWAYMSG // -INT_PTR GGPROTO::getmyawaymsg(WPARAM wParam, LPARAM lParam) +INT_PTR GaduProto::getmyawaymsg(WPARAM wParam, LPARAM lParam) { INT_PTR res = 0; @@ -377,7 +377,7 @@ extern INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwnd, UINT msg, WPARAM wParam // gets account manager GUI // registered as ProtoService PS_CREATEACCMGRUI // -INT_PTR GGPROTO::get_acc_mgr_gui(WPARAM, LPARAM lParam) +INT_PTR GaduProto::get_acc_mgr_gui(WPARAM, LPARAM lParam) { return (INT_PTR)CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this); } @@ -386,7 +386,7 @@ INT_PTR GGPROTO::get_acc_mgr_gui(WPARAM, LPARAM lParam) // leaves (terminates) conference // registered as ProtoService PS_LEAVECHAT // -INT_PTR GGPROTO::leavechat(WPARAM hContact, LPARAM) +INT_PTR GaduProto::leavechat(WPARAM hContact, LPARAM) { if (hContact) db_delete_contact(hContact); diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 5c3396d035..649032cd5a 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -83,7 +83,7 @@ static int gg_insertlistitem(HWND hList, gg_multilogon_id_t* id, const char* cli return index; } -static void gg_listsessions(GGPROTO* gg, HWND hwndDlg) +static void gg_listsessions(GaduProto* gg, HWND hwndDlg) { HWND hList = GetDlgItem(hwndDlg, IDC_SESSIONS); if (!hList) @@ -154,12 +154,12 @@ static HCURSOR hHandCursor = nullptr; static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { - GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER); + GaduProto* gg = (GaduProto*)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - gg = (GGPROTO*)lParam; + gg = (GaduProto*)lParam; gg->hwndSessionsDlg = hwndDlg; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); @@ -389,7 +389,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w return FALSE; } -INT_PTR GGPROTO::sessions_view(WPARAM, LPARAM) +INT_PTR GaduProto::sessions_view(WPARAM, LPARAM) { if (hwndSessionsDlg && IsWindow(hwndSessionsDlg)) { ShowWindow(hwndSessionsDlg, SW_SHOWNORMAL); @@ -402,13 +402,13 @@ INT_PTR GGPROTO::sessions_view(WPARAM, LPARAM) return 0; } -void GGPROTO::sessions_updatedlg() +void GaduProto::sessions_updatedlg() { if (hwndSessionsDlg && IsWindow(hwndSessionsDlg)) SendMessage(hwndSessionsDlg, WM_MULTILOGONINFO, 0, 0); } -BOOL GGPROTO::sessions_closedlg() +BOOL GaduProto::sessions_closedlg() { if (hwndSessionsDlg && IsWindow(hwndSessionsDlg)) return PostMessage(hwndSessionsDlg, WM_CLOSE, 0, 0); @@ -416,14 +416,14 @@ BOOL GGPROTO::sessions_closedlg() return FALSE; } -void GGPROTO::sessions_menus_init(HGENMENU hRoot) +void GaduProto::sessions_menus_init(HGENMENU hRoot) { CMenuItem mi; mi.flags = CMIF_UNICODE; mi.root = hRoot; mi.pszService = GGS_CONCUR_SESS; - CreateProtoService(mi.pszService, &GGPROTO::sessions_view); + CreateProtoService(mi.pszService, &GaduProto::sessions_view); mi.position = 200003; mi.hIcolibItem = iconList[16].hIcolib; mi.name.w = LPGENW("Concurrent &sessions"); diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp index 6dc91860ca..d38435afa2 100644 --- a/protocols/Gadu-Gadu/src/token.cpp +++ b/protocols/Gadu-Gadu/src/token.cpp @@ -106,7 +106,7 @@ INT_PTR CALLBACK gg_tokendlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l //////////////////////////////////////////////////////////////////////////////// // Gets GG token // -int GGPROTO::gettoken(GGTOKEN *token) +int GaduProto::gettoken(GGTOKEN *token) { // Zero tokens mir_strcpy(token->id, ""); diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index 6c5dec1799..dd3a8d5d7f 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// // Create New Account : Proc // -void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) +void *gg_doregister(GaduProto *gg, char *newPass, char *newEmail) { // Connection handles struct gg_http *h = nullptr; @@ -68,7 +68,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) //////////////////////////////////////////////////////////////////////////////// // Remove Account : Proc // -void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) +void *gg_dounregister(GaduProto *gg, uin_t uin, char *password) { // Connection handles struct gg_http *h; @@ -113,7 +113,7 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) //////////////////////////////////////////////////////////////////////////////// // Change Password Page : Proc // -void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) +void *gg_dochpass(GaduProto *gg, uin_t uin, char *password, char *newPass) { #ifdef DEBUGMODE gg->debugLogA("gg_dochpass(): Starting."); @@ -164,7 +164,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) //////////////////////////////////////////////////////////////////////////////// // Change E-mail Page : Proc // -void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *newEmail) +void *gg_dochemail(GaduProto *gg, uin_t uin, char *password, char *email, char *newEmail) { #ifdef DEBUGMODE gg->debugLogA("gg_dochemail(): Starting."); @@ -284,7 +284,7 @@ INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ////////////////////////////////////////////////////////// // Wait for thread to stop // -void GGPROTO::threadwait(GGTHREAD *thread) +void GaduProto::threadwait(GGTHREAD *thread) { if (!thread->hThread) return; -- cgit v1.2.3