From 66b61f42871089f3962920924f9030cd6dff2ad8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Apr 2018 13:37:13 +0300 Subject: CLIST_INTERFACE: - unused members removed (requires new History++ for people who compile Miranda themselves); - useless helpers Proto_IsAccountEnabled & Proto_IsProtocolLocked replaced with direct calls of PROTOACCOUNT members IsEnabled & IsLocked respectively; - static interface member pfnGetProtocolVisibility replaced with static function Clist_GetProtocolVisibility or PROTOACCOUNT::IsVisible when possible --- include/delphi/m_clistint.inc | 11 +- include/delphi/m_protocols.inc | 16 -- include/m_clist.h | 7 +- include/m_clistint.h | 59 +++--- include/m_protocols.h | 49 ++--- libs/win32/mir_app.lib | Bin 143728 -> 145472 bytes libs/win64/mir_app.lib | Bin 139670 -> 141436 bytes plugins/AddContactPlus/src/addcontact.cpp | 4 +- plugins/AddContactPlus/src/main.cpp | 2 +- plugins/AvatarHistory/src/utils.cpp | 2 +- plugins/Clist_blind/src/clistopts.cpp | 2 +- plugins/Clist_modern/src/modern_clcopts.cpp | 12 +- plugins/Clist_modern/src/modern_clisttray.cpp | 8 +- plugins/Clist_modern/src/modern_clui.cpp | 2 +- plugins/Clist_modern/src/modern_statusbar.cpp | 4 +- plugins/Clist_nicer/src/clistopts.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 2 +- plugins/Clist_nicer/src/cluiservices.cpp | 8 +- plugins/CrashDumper/src/dumper.cpp | 2 +- plugins/DbEditorPP/src/main.cpp | 2 +- plugins/MenuItemEx/src/main.cpp | 4 +- plugins/NewXstatusNotify/src/main.cpp | 2 +- plugins/SMS/src/functions.cpp | 2 +- plugins/SimpleStatusMsg/src/main.cpp | 289 ++++++++++++++------------ plugins/SimpleStatusMsg/src/msgbox.cpp | 54 ++--- plugins/SimpleStatusMsg/src/options.cpp | 79 +++---- plugins/SmileyAdd/src/smileys.cpp | 2 +- plugins/StatusManager/src/commonstatus.cpp | 2 +- plugins/StopSpamPlus/src/options.cpp | 2 +- plugins/TipperYM/src/popwin.cpp | 16 +- src/core/stdautoaway/src/autoaway.cpp | 2 +- src/core/stdaway/src/sendmsg.cpp | 6 +- src/core/stdclist/src/clistopts.cpp | 2 +- src/core/stduseronline/src/useronline.cpp | 4 +- src/mir_app/src/clc.cpp | 4 +- src/mir_app/src/clc.h | 1 - src/mir_app/src/clistcore.cpp | 1 - src/mir_app/src/clisttray.cpp | 12 +- src/mir_app/src/clui.cpp | 2 +- src/mir_app/src/findadd.cpp | 8 +- src/mir_app/src/menu_clist.cpp | 37 ++-- src/mir_app/src/mir_app.def | 9 +- src/mir_app/src/mir_app64.def | 9 +- src/mir_app/src/proto_accs.cpp | 14 +- src/mir_app/src/proto_chains.cpp | 2 +- src/mir_app/src/proto_opts.cpp | 2 +- src/mir_app/src/proto_order.cpp | 4 +- src/mir_app/src/protocols.cpp | 24 ++- src/mir_app/src/searchresults.cpp | 2 +- 49 files changed, 397 insertions(+), 394 deletions(-) diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 1c04a491cb..699b138f4f 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -298,7 +298,6 @@ type (* clc.h *) pfnClcOptionsChanged : procedure; cdecl; - unused3 : procedure; cdecl; pfnBuildGroupPopupMenu : function (_para1:PClcGroup):HMENU; cdecl; pfnContactListControlWndProc:function(hwnd:HWND; msg:uint; wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall; @@ -423,11 +422,6 @@ type (* docking.c *) pfnDocking_ProcessWindowMessage : function (wParam:WPARAM; lParam:LPARAM):int; cdecl; - blablabla1 : procedure; cdecl; - blablabla2 : procedure; cdecl; - blablabla3 : procedure; cdecl; - blablabla4 : procedure; cdecl; - (************************************************************************************* * version 2 - events processing *************************************************************************************) @@ -459,10 +453,7 @@ type bDisplayLocked : bool; bAutoRebuild : bool; - pfnGetProtocolMenu : function (_para1:PAnsiChar):HGENMENU; cdecl; - pfnStub2 : function (_para1:int):int; cdecl; - - pfnGetProtocolVisibility : function (_para1:PAnsiChar):int; cdecl; + pfnGetProtocolMenu : function (_para1:PAnsiChar):HGENMENU; cdecl; pfnGetProtoIndexByPos : function (var proto:PPROTOCOLDESCRIPTOR; protoCnt:int; Pos:int):int; cdecl; pfnReloadProtoMenus : procedure ; cdecl; diff --git a/include/delphi/m_protocols.inc b/include/delphi/m_protocols.inc index 83deebaf44..c4038e9600 100644 --- a/include/delphi/m_protocols.inc +++ b/include/delphi/m_protocols.inc @@ -311,22 +311,6 @@ const } MS_PROTO_SHOWACCMGR:PAnsiChar = 'Protos/ShowAccountManager'; -{ - determines if an account is enabled or not - Returns 1 if an account is valid and enabled, 0 otherwise -} - -function Proto_IsAccountEnabled(proto:PPROTOACCOUNT) : byte; stdcall; external AppDLL; - -{ - determines if an account is locked or not - wParam = 0 - lParam = PAnsiChar szAccountName - Returns 1 if an account is locked and not supposed to change status, 0 otherwise -} - -function Proto_IsAccountLocked(proto:PPROTOACCOUNT) : byte; stdcall; external AppDLL; - { gets the account associated with a contact Returns a PAnsiChar pointing to the asciiz name of the protocol or NULL if the diff --git a/include/m_clist.h b/include/m_clist.h index b3eb928deb..a35d4680e1 100644 --- a/include/m_clist.h +++ b/include/m_clist.h @@ -49,10 +49,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// // force a change of status mode -// wParam = new status, from statusmodes.h +// iStatus = new status, from statusmodes.h EXTERN_C MIR_APP_DLL(void) Clist_SetStatusMode(int iStatus); +///////////////////////////////////////////////////////////////////////////////////////// +// detects whether a protocol is visible or not + +EXTERN_C MIR_APP_DLL(bool) Clist_GetProtocolVisibility(const char *szModuleName); + ///////////////////////////////////////////////////////////////////////////////////////// // get the current status mode // wParam = lParam = 0 diff --git a/include/m_clistint.h b/include/m_clistint.h index 3e145fa977..6a58baf1c1 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -285,7 +285,6 @@ struct CLIST_INTERFACE /* clc.h */ void (*pfnClcOptionsChanged)(void); - void (*pfnUnused1)(); HMENU (*pfnBuildGroupPopupMenu)(struct ClcGroup*); // unused LRESULT (CALLBACK *pfnContactListControlWndProc)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -409,11 +408,6 @@ struct CLIST_INTERFACE /* docking.c */ int (*pfnDocking_ProcessWindowMessage)(WPARAM wParam, LPARAM lParam); - int (*blablabla1)(); - int (*blablabla2)(); - int (*blablabla3)(); - int (*blablabla4)(); - /************************************************************************************* * version 2 - events processing *************************************************************************************/ @@ -439,16 +433,13 @@ struct CLIST_INTERFACE MenuProto* menuProtos; int menuProtoCount; - HANDLE hPreBuildStatusMenuEvent; - int currentStatusMenuItem, currentDesiredStatusMode; - BOOL bDisplayLocked, bAutoRebuild; + HANDLE hPreBuildStatusMenuEvent; + int currentStatusMenuItem, currentDesiredStatusMode; + BOOL bDisplayLocked, bAutoRebuild; HGENMENU (*pfnGetProtocolMenu)(const char*); - int (*pfnStub2)(int); - - int (*pfnGetProtocolVisibility)(const char*); - int (*pfnGetProtoIndexByPos)(PROTOCOLDESCRIPTOR** proto, int protoCnt, int Pos); - void (*pfnReloadProtoMenus)(void); + int (*pfnGetProtoIndexByPos)(PROTOCOLDESCRIPTOR **proto, int protoCnt, int Pos); + void (*pfnReloadProtoMenus)(void); /************************************************************************************* * version 5 additions (0.7.0.x) - tray icons @@ -459,44 +450,44 @@ struct CLIST_INTERFACE int shellVersion; UINT_PTR cycleTimerId; int cycleStep; - wchar_t* szTip; + wchar_t* szTip; BOOL bTrayMenuOnScreen; - HICON (*pfnGetIconFromStatusMode)(MCONTACT hContact, const char *szProto, int status); + HICON (*pfnGetIconFromStatusMode)(MCONTACT hContact, const char *szProto, int status); - void (*pfnInitTray)(void); - void (*pfnUninitTray)(void); + void (*pfnInitTray)(void); + void (*pfnUninitTray)(void); - int (*pfnTrayIconAdd)(HWND hwnd, const char *szProto, const char *szIconProto, int status); - int (*pfnTrayIconDestroy)(HWND hwnd); - int (*pfnTrayIconInit)(HWND hwnd); + int (*pfnTrayIconAdd)(HWND hwnd, const char *szProto, const char *szIconProto, int status); + int (*pfnTrayIconDestroy)(HWND hwnd); + int (*pfnTrayIconInit)(HWND hwnd); wchar_t* (*pfnTrayIconMakeTooltip)(const wchar_t *szPrefix, const char *szProto); - void (*pfnTrayIconRemove)(HWND hwnd, const char *szProto); - int (*pfnTrayIconSetBaseInfo)(HICON hIcon, const char *szPreferredProto); - void (*pfnTrayIconTaskbarCreated)(HWND hwnd); - int (*pfnTrayIconUpdate)(HICON hNewIcon, const wchar_t *szNewTip, const char *szPreferredProto, int isBase); + void (*pfnTrayIconRemove)(HWND hwnd, const char *szProto); + int (*pfnTrayIconSetBaseInfo)(HICON hIcon, const char *szPreferredProto); + void (*pfnTrayIconTaskbarCreated)(HWND hwnd); + int (*pfnTrayIconUpdate)(HICON hNewIcon, const wchar_t *szNewTip, const char *szPreferredProto, int isBase); - VOID (CALLBACK *pfnTrayCycleTimerProc)(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); + VOID (CALLBACK *pfnTrayCycleTimerProc)(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); /************************************************************************************* * version 6 additions (0.8.0.x) - accounts *************************************************************************************/ - int (*pfnGetAccountIndexByPos)(int pos); + int (*pfnGetAccountIndexByPos)(int pos); /************************************************************************************* * version 7 additions (0.11.0.x) - extra images *************************************************************************************/ - void (*pfnReloadExtraIcons)(void); - void (*pfnSetAllExtraIcons)(MCONTACT hContact); + void (*pfnReloadExtraIcons)(void); + void (*pfnSetAllExtraIcons)(MCONTACT hContact); /************************************************************************************* * Miranda NG additions *************************************************************************************/ - int (*pfnGetContactIcon)(MCONTACT hContact); - int (*pfnTrayCalcChanged)(const char *szChangedProto, int averageMode, int iProtoCount); - int (*pfnGetAverageMode)(int *pNetProtoCount); - void (*pfnInitAutoRebuild)(HWND hwnd); - void (*pfnSetContactCheckboxes)(ClcContact *cc, int checked); + int (*pfnGetContactIcon)(MCONTACT hContact); + int (*pfnTrayCalcChanged)(const char *szChangedProto, int averageMode, int iProtoCount); + int (*pfnGetAverageMode)(int *pNetProtoCount); + void (*pfnInitAutoRebuild)(HWND hwnd); + void (*pfnSetContactCheckboxes)(ClcContact *cc, int checked); }; // retrieves the pointer to a CLIST_INTERFACE structure diff --git a/include/m_protocols.h b/include/m_protocols.h index cee4513363..537cb5308d 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -276,27 +276,30 @@ EXTERN_C MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char * // -------------- accounts support --------------------- 0.8.0+ -typedef struct tagACCOUNT +struct MIR_APP_EXPORT PROTOACCOUNT { - int cbSize; // sizeof this structure - char* szModuleName; // unique physical account name (matches database module name) + int cbSize; // sizeof this structure + char* szModuleName; // unique physical account name (matches database module name) wchar_t* tszAccountName; // user-defined account name - char* szProtoName; // physical protocol name - bool bIsEnabled; // is account enabled? - bool bIsVisible; // is account visible? - bool bIsVirtual; // is account virtual? - bool bOldProto; // old-styled account (one instance per dll) - bool bDynDisabled; // dynamic disable flag, is never written to db + char* szProtoName; // physical protocol name + bool bIsEnabled; // is account enabled? + bool bIsVisible; // is account visible? + bool bIsVirtual; // is account virtual? + bool bOldProto; // old-styled account (one instance per dll) + bool bDynDisabled; // dynamic disable flag, is never written to db - bool bAccMgrUIChanged; - HWND hwndAccMgrUI; + bool bAccMgrUIChanged; + HWND hwndAccMgrUI; - int iOrder; // account order in various menus & lists + int iOrder; // account order in various menus & lists PROTO_INTERFACE *ppro; // pointer to the underlying object - char* szUniqueId; // setting's unique id for any contact in the account -} - PROTOACCOUNT; + char* szUniqueId; // setting's unique id for any contact in the account + + bool IsEnabled(void) const; + bool IsLocked(void) const; + bool IsVisible(void) const; +}; ///////////////////////////////////////////////////////////////////////////////////////// // account enumeration service @@ -343,22 +346,6 @@ EXTERN_C MIR_APP_DLL(PROTOACCOUNT*) Proto_GetAccount(const char *pszModuleName); #define MS_PROTO_SHOWACCMGR "Protos/ShowAccountManager" -///////////////////////////////////////////////////////////////////////////////////////// -// determines if an account is enabled or not -// wParam = 0 -// lParam = (LPARAM)(PROTOACCOUNT*) -// Returns 1 if an account is valid and enabled, 0 otherwise - -EXTERN_C MIR_APP_DLL(bool) Proto_IsAccountEnabled(const PROTOACCOUNT *pa); - -///////////////////////////////////////////////////////////////////////////////////////// -// determines if an account is locked or not -// wParam = 0 -// lParam = (LPARAM)(char*)szAccountName -// Returns 1 if an account is locked and not supposed to change status, 0 otherwise - -EXTERN_C MIR_APP_DLL(bool) Proto_IsAccountLocked(const PROTOACCOUNT *pa); - ///////////////////////////////////////////////////////////////////////////////////////// // gets the account associated with a contact // Returns a char* pointing to the asciiz name of the protocol or NULL if the diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 7ce264876d..11d890bcb3 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 547147bfd8..0c9196c201 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp index fdd5c6dafc..479dfd3fed 100644 --- a/plugins/AddContactPlus/src/addcontact.cpp +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -84,7 +84,7 @@ bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs) Proto_EnumAccounts(&iRealAccCount, &pAccounts); for (int i = 0; i < iRealAccCount; i++) { - if (!Proto_IsAccountEnabled(pAccounts[i])) + if (!pAccounts[i]->IsEnabled()) continue; DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); @@ -113,7 +113,7 @@ bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs) HDC hdc = GetDC(hdlg); SelectObject(hdc, (HFONT)SendDlgItemMessage(hdlg, IDC_PROTO, WM_GETFONT, 0, 0)); for (int i = 0; i < iRealAccCount; i++) { - if (!Proto_IsAccountEnabled(pAccounts[i])) continue; + if (!pAccounts[i]->IsEnabled()) continue; DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (!(dwCaps & PF1_BASICSEARCH) && !(dwCaps & PF1_EXTSEARCH) && !(dwCaps & PF1_SEARCHBYEMAIL) && !(dwCaps & PF1_SEARCHBYNAME)) continue; diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp index ea7a8cc5db..9c80075431 100644 --- a/plugins/AddContactPlus/src/main.cpp +++ b/plugins/AddContactPlus/src/main.cpp @@ -79,7 +79,7 @@ static int OnAccListChanged(WPARAM, LPARAM) Proto_EnumAccounts(&iRealAccCount, &pAccounts); for (int i = 0; i < iRealAccCount; i++) { - if (!Proto_IsAccountEnabled(pAccounts[i])) + if (!pAccounts[i]->IsEnabled()) continue; DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); diff --git a/plugins/AvatarHistory/src/utils.cpp b/plugins/AvatarHistory/src/utils.cpp index 71214413a2..f390b3463f 100644 --- a/plugins/AvatarHistory/src/utils.cpp +++ b/plugins/AvatarHistory/src/utils.cpp @@ -26,7 +26,7 @@ Avatar History Plugin bool ProtocolEnabled(const char *proto) { - return Proto_IsAccountEnabled(Proto_GetAccount(proto)); + return Proto_GetAccount(proto)->IsEnabled(); } bool ContactEnabled(MCONTACT hContact, char *setting, int def) diff --git a/plugins/Clist_blind/src/clistopts.cpp b/plugins/Clist_blind/src/clistopts.cpp index 43af2f4867..05423af61c 100644 --- a/plugins/Clist_blind/src/clistopts.cpp +++ b/plugins/Clist_blind/src/clistopts.cpp @@ -94,7 +94,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { - if (!Proto_IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName); diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 3ec5ff83e4..56b9b2ace6 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -470,14 +470,14 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar static int _GetNetVisibleProtoCount() { - int i, count, netProtoCount; + int count, netProtoCount; PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); - for (i = 0, netProtoCount = 0; i < count; i++) { - if (pcli->pfnGetProtocolVisibility(accs[i]->szModuleName) == 0) - continue; - netProtoCount++; - } + + for (int i = 0, netProtoCount = 0; i < count; i++) + if (accs[i]->IsVisible()) + netProtoCount++; + return netProtoCount; } diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index cc56258329..49d924a24b 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -90,7 +90,7 @@ INT_PTR CListTray_GetGlobalStatus(WPARAM, LPARAM) int connectingCount = 0; for (int i = 0; i < pcli->hClcProtoCount; i++) { ClcProtoStatus &p = pcli->clcProto[i]; - if (!pcli->pfnGetProtocolVisibility(p.szProto)) + if (!Clist_GetProtocolVisibility(p.szProto)) continue; if (IsStatusConnecting(p.dwStatus)) { @@ -285,7 +285,7 @@ static int GetGoodAccNum(bool *bDiffers, bool *bConn = nullptr) int iPrevStatus = 0, res = 0; while (AccNum--) { PROTOACCOUNT *pa = acc[AccNum]; - if (!pcli->pfnGetProtocolVisibility(pa->szModuleName)) + if (!pa->IsVisible()) continue; res++; @@ -379,7 +379,7 @@ int cliTrayIconInit(HWND hwnd) for (int i = AccNum; i--;) { PROTOACCOUNT *pa = acc[i]; - if (pcli->pfnGetProtocolVisibility(pa->szModuleName) && pa->ppro != nullptr) + if (pa->IsVisible() && pa->ppro != nullptr) pcli->pfnTrayIconAdd(hwnd, pa->szModuleName, nullptr, pa->ppro->m_iStatus); } break; @@ -396,7 +396,7 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int) if (!pcli->trayIconCount) return -1; - if (!pcli->pfnGetProtocolVisibility(szChangedProto)) + if (!Clist_GetProtocolVisibility(szChangedProto)) return -1; bool bDiffers, bConn; diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 1ebb35d4e7..7763e5c34a 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -1058,7 +1058,7 @@ void CLUI_DisconnectAll() Proto_EnumAccounts(&nProtoCount, &accs); for (int nProto = 0; nProto < nProtoCount; nProto++) - if (Proto_IsAccountEnabled(accs[nProto])) + if (accs[nProto]->IsEnabled()) CallProtoService(accs[nProto]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0); } diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 678faaa1cd..ccb7808d7b 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -179,10 +179,10 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) if (i == -1) continue; - char *szProto = accs[i]->szModuleName; - if (!pcli->pfnGetProtocolVisibility(szProto)) + if (!accs[i]->IsVisible()) continue; + char *szProto = accs[i]->szModuleName; char buf[256]; mir_snprintf(buf, "SBarAccountIsCustom_%s", szProto); diff --git a/plugins/Clist_nicer/src/clistopts.cpp b/plugins/Clist_nicer/src/clistopts.cpp index 19a31cd3c7..d713c58080 100644 --- a/plugins/Clist_nicer/src/clistopts.cpp +++ b/plugins/Clist_nicer/src/clistopts.cpp @@ -93,7 +93,7 @@ INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { - if (!Proto_IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName); diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index c58002ab00..bf76dfffae 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -263,7 +263,7 @@ static void InitIcoLib() int p_count = 0; Proto_EnumAccounts(&p_count, &accs); for (int k = 0; k < p_count; k++) { - if (!Proto_IsAccountEnabled(accs[k]) || CallProtoService(accs[k]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + if (!accs[k]->IsEnabled() || CallProtoService(accs[k]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; wchar_t szDescr[128]; diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp index 4d81e16761..2e84ed6039 100644 --- a/plugins/Clist_nicer/src/cluiservices.cpp +++ b/plugins/Clist_nicer/src/cluiservices.cpp @@ -79,12 +79,12 @@ void CluiProtocolStatusChanged(int, const char*) rc.right -= borders[0] * 2; int toshow = 0; for (int i = 0; i < protoCount; i++) - if (pcli->pfnGetProtocolVisibility(accs[i]->szModuleName)) + if (accs[i]->IsVisible()) toshow++; if (toshow > 0) { for (int part = 0, i = 0; i < protoCount; i++) { - if (!pcli->pfnGetProtocolVisibility(accs[i]->szModuleName)) + if (!accs[i]->IsVisible()) continue; partWidths[part] = ((rc.right - rc.left - rdelta) / toshow)*(part + 1) + cfg::dat.bCLeft; @@ -112,7 +112,7 @@ void CluiProtocolStatusChanged(int, const char*) continue; PROTOACCOUNT *pa = accs[idx]; - if (!pcli->pfnGetProtocolVisibility(pa->szModuleName)) + if (!pa->IsVisible()) continue; int x = 2; @@ -157,7 +157,7 @@ void CluiProtocolStatusChanged(int, const char*) continue; PROTOACCOUNT *pa = accs[idx]; - if (!pcli->pfnGetProtocolVisibility(pa->szModuleName)) + if (!pa->IsVisible()) continue; int status = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index d77853da59..f3c32a4037 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -303,7 +303,7 @@ static void GetProtocolStrings(CMStringW &buffer) for (int i = 0; i < protoCountMy; i++) if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) { protos[i].nloaded = accList[j]->bDynDisabled != 0; - if (Proto_IsAccountEnabled(accList[j])) + if (accList[j]->IsEnabled()) ++protos[i].countse; else ++protos[i].countsd; diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index cc855a2cfc..e54b484de5 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -495,7 +495,7 @@ int GetContactName(MCONTACT hContact, const char *proto, wchar_t *value, int max else mir_wstrncpy(value, name, maxlen); PROTOACCOUNT *pa = Proto_GetAccount(szProto); - if (!Proto_IsAccountEnabled(pa)) { + if (!pa->IsEnabled()) { mir_wstrncat(value, L" ", maxlen); mir_wstrncat(value, TranslateT("[UNLOADED]"), maxlen); } diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 067857dd7b..1637f3223e 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -814,8 +814,8 @@ static int BuildMenu(WPARAM wparam, LPARAM) } else Menu_ShowItem(hmenuProto, false); - Menu_ShowItem(hmenuAdded, (bShowAll || (flags & VF_ADD)) && bIsOnline && Proto_IsAccountEnabled(pa)); - Menu_ShowItem(hmenuAuthReq, (bShowAll || (flags & VF_REQ)) && bIsOnline && Proto_IsAccountEnabled(pa)); + Menu_ShowItem(hmenuAdded, (bShowAll || (flags & VF_ADD)) && bIsOnline && pa->IsEnabled()); + Menu_ShowItem(hmenuAuthReq, (bShowAll || (flags & VF_REQ)) && bIsOnline && pa->IsEnabled()); bEnabled = bShowAll || (flags & VF_CID); Menu_ShowItem(hmenuCopyID, bEnabled); diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 7345ebb3e0..46660e1545 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -1140,7 +1140,7 @@ int ModulesLoaded(WPARAM, LPARAM) PROTOACCOUNT **accounts = nullptr; Proto_EnumAccounts(&count, &accounts); for (int i = 0; i < count; i++) - if (Proto_IsAccountEnabled(accounts[i])) + if (accounts[i]->IsEnabled()) db_set_b(NULL, MODULE, accounts[i]->szModuleName, 0); return 0; diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp index 81406f3ed8..cbebb2bcf2 100644 --- a/plugins/SMS/src/functions.cpp +++ b/plugins/SMS/src/functions.cpp @@ -499,7 +499,7 @@ int RefreshAccountList(WPARAM, LPARAM) ssSMSSettings.ppaSMSAccounts = (PROTOACCOUNT**)MEMALLOC((dwAccCount*sizeof(LPVOID))); if (ssSMSSettings.ppaSMSAccounts) for (int i = 0; i < dwAccCount; i++) - if (Proto_IsAccountEnabled(ppaAccounts[i])) + if (ppaAccounts[i]->IsEnabled()) if (ProtoServiceExists(ppaAccounts[i]->szModuleName, MS_ICQ_SENDSMS)) ssSMSSettings.ppaSMSAccounts[dwSMSAccountsCount++] = ppaAccounts[i]; diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 0a9807348d..5782e39cb2 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -460,22 +460,23 @@ void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat) { for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(szSetting, bIsFormat ? "FCur%sMsg" : "Cur%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, bIsFormat ? "FCur%sMsg" : "Cur%sMsg", pa->szModuleName); DBWriteMessage(szSetting, tszMsg); #ifdef _DEBUG if (bIsFormat) - log2file("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, accounts->pa[i]->szModuleName); + log2file("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, pa->szModuleName); else - log2file("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, accounts->pa[i]->szModuleName); + log2file("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, pa->szModuleName); #endif } } @@ -655,43 +656,44 @@ INT_PTR SetStatusModeFromExtern(WPARAM wParam, LPARAM lParam) for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - if (db_get_b(NULL, accounts->pa[i]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; if (wParam == ID_STATUS_CURRENT || wParam == 0) - newStatus = GetCurrentStatus(accounts->pa[i]->szModuleName); + newStatus = GetCurrentStatus(pa->szModuleName); - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) { - CallProtoService(accounts->pa[i]->szModuleName, PS_SETSTATUS, newStatus, 0); + CallProtoService(pa->szModuleName, PS_SETSTATUS, newStatus, 0); continue; } - int status_modes_msg = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + int status_modes_msg = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); if ((Proto_Status2Flag(newStatus) & status_modes_msg) || (newStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & status_modes_msg))) { wchar_t *msg = nullptr; - if (HasProtoStaticStatusMsg(accounts->pa[i]->szModuleName, GetCurrentStatus(accounts->pa[i]->szModuleName), newStatus)) + if (HasProtoStaticStatusMsg(pa->szModuleName, GetCurrentStatus(pa->szModuleName), newStatus)) continue; if (lParam) - msg = InsertVarsIntoMsg((wchar_t *)lParam, accounts->pa[i]->szModuleName, newStatus, NULL); + msg = InsertVarsIntoMsg((wchar_t *)lParam, pa->szModuleName, newStatus, NULL); - SaveMessageToDB(accounts->pa[i]->szModuleName, (wchar_t *)lParam, TRUE); - SaveMessageToDB(accounts->pa[i]->szModuleName, msg, FALSE); - Proto_SetStatus(accounts->pa[i]->szModuleName, GetCurrentStatus(accounts->pa[i]->szModuleName), newStatus, msg /*? msg : L""*/); + SaveMessageToDB(pa->szModuleName, (wchar_t *)lParam, TRUE); + SaveMessageToDB(pa->szModuleName, msg, FALSE); + Proto_SetStatus(pa->szModuleName, GetCurrentStatus(pa->szModuleName), newStatus, msg /*? msg : L""*/); mir_free(msg); } else - CallProtoService(accounts->pa[i]->szModuleName, PS_SETSTATUS, newStatus, 0); + CallProtoService(pa->szModuleName, PS_SETSTATUS, newStatus, 0); } return 0; @@ -712,19 +714,20 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha int status; for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - status = iStatus == ID_STATUS_CURRENT ? GetStartupStatus(accounts->pa[i]->szModuleName) : iStatus; + status = iStatus == ID_STATUS_CURRENT ? GetStartupStatus(pa->szModuleName) : iStatus; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || - !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || + !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) { - if (!(bOnStartup && status == ID_STATUS_OFFLINE) && GetCurrentStatus(accounts->pa[i]->szModuleName) != status) - CallProtoService(accounts->pa[i]->szModuleName, PS_SETSTATUS, (WPARAM)status, 0); + if (!(bOnStartup && status == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != status) + CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)status, 0); } } } @@ -749,59 +752,60 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - if (!bOnStartup && db_get_b(NULL, accounts->pa[i]->szModuleName, "LockMainStatus", 0)) + if (!bOnStartup && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; if (iProfileStatus) { int iProfileNumber = iStatus - 40083; char szSetting[128]; - mir_snprintf(szSetting, "%d_%s", iProfileNumber, accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "%d_%s", iProfileNumber, pa->szModuleName); iStatus = db_get_w(NULL, "StartupStatus", szSetting, ID_STATUS_OFFLINE); if (iStatus == ID_STATUS_IDLE) // the same as ID_STATUS_LAST in StartupStatus { - mir_snprintf(szSetting, "last_%s", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "last_%s", pa->szModuleName); iStatus = db_get_w(NULL, "StartupStatus", szSetting, ID_STATUS_OFFLINE); } else if (iStatus == ID_STATUS_CURRENT) - iStatus = GetCurrentStatus(accounts->pa[i]->szModuleName); + iStatus = GetCurrentStatus(pa->szModuleName); } if (bIsStatusCurrent) - iStatus = bOnStartup ? GetStartupStatus(accounts->pa[i]->szModuleName) : GetCurrentStatus(accounts->pa[i]->szModuleName); + iStatus = bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); if (bIsInitialStatusCurrent) - iInitialStatus = bOnStartup ? ID_STATUS_OFFLINE : GetCurrentStatus(accounts->pa[i]->szModuleName); + iInitialStatus = bOnStartup ? ID_STATUS_OFFLINE : GetCurrentStatus(pa->szModuleName); - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus)) || - !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus)) || + !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) { - if (!(bOnStartup && iStatus == ID_STATUS_OFFLINE) && GetCurrentStatus(accounts->pa[i]->szModuleName) != iStatus && iStatus != iInitialStatus) + if (!(bOnStartup && iStatus == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != iStatus && iStatus != iInitialStatus) { - CallProtoService(accounts->pa[i]->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0); + CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0); #ifdef _DEBUG - log2file("SetStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), accounts->pa[i]->szModuleName); + log2file("SetStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), pa->szModuleName); #endif } continue; } - if (HasProtoStaticStatusMsg(accounts->pa[i]->szModuleName, iInitialStatus, iStatus)) + if (HasProtoStaticStatusMsg(pa->szModuleName, iInitialStatus, iStatus)) continue; if (message) - msg = InsertVarsIntoMsg(message, accounts->pa[i]->szModuleName, iStatus, NULL); + msg = InsertVarsIntoMsg(message, pa->szModuleName, iStatus, NULL); - SaveMessageToDB(accounts->pa[i]->szModuleName, message, TRUE); - SaveMessageToDB(accounts->pa[i]->szModuleName, msg, FALSE); + SaveMessageToDB(pa->szModuleName, message, TRUE); + SaveMessageToDB(pa->szModuleName, msg, FALSE); - Proto_SetStatus(accounts->pa[i]->szModuleName, iInitialStatus, iStatus, msg); + Proto_SetStatus(pa->szModuleName, iInitialStatus, iStatus, msg); mir_free(msg); } @@ -833,18 +837,19 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) { for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - box_data->m_szProto = accounts->pa[i]->szModuleName; - box_data->m_iStatusModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); - box_data->m_iStatusMsgModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + box_data->m_szProto = pa->szModuleName; + box_data->m_iStatusModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); + box_data->m_iStatusMsgModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); break; } } @@ -852,23 +857,24 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) { for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - if (!accounts->pa[i]->bIsVisible) + if (!pa->bIsVisible) continue; if (hProtoStatusMenuItem[i] == (HANDLE)lParam) { - box_data->m_szProto = accounts->pa[i]->szModuleName; - box_data->m_iStatusModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); - box_data->m_iStatusMsgModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + box_data->m_szProto = pa->szModuleName; + box_data->m_iStatusModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); + box_data->m_iStatusMsgModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); idvstatusmsg = TRUE; break; @@ -902,23 +908,24 @@ INT_PTR ShowStatusMessageDialog(WPARAM, LPARAM lParam) for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - if (!accounts->pa[i]->bIsVisible) + if (!pa->bIsVisible) continue; - if (!mir_strcmp(accounts->pa[i]->szModuleName, (char *)lParam)) + if (!mir_strcmp(pa->szModuleName, (char *)lParam)) { - box_data->m_szProto = accounts->pa[i]->szModuleName; - box_data->m_iStatusModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); - box_data->m_iStatusMsgModes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + box_data->m_szProto = pa->szModuleName; + box_data->m_iStatusModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); + box_data->m_iStatusMsgModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); idvstatusmsg = TRUE; break; @@ -958,18 +965,19 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) if (accounts->statusMsgCount == 1 && !szProto) { for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - szProto = accounts->pa[i]->szModuleName; + szProto = pa->szModuleName; if (bOnStartup && iStatus == ID_STATUS_CURRENT) { - iStatus = GetStartupStatus(accounts->pa[i]->szModuleName); + iStatus = GetStartupStatus(pa->szModuleName); bGlobalStartupStatus = FALSE; } break; @@ -1058,30 +1066,31 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT); if (!bShowDlg || bScreenSaverRunning || (iProtoFlags & PROTO_NOCHANGE && !bOnStartup)) { for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - if (db_get_b(NULL, accounts->pa[i]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus)) || - !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus)) || + !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; wchar_t *msg; if (iProtoFlags & PROTO_NOCHANGE) { - mir_snprintf(szSetting, "FCur%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "FCur%sMsg", pa->szModuleName); msg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting); } else msg = GetAwayMessageFormat(iStatus, nullptr); #ifdef _DEBUG - log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, accounts->pa[i]->szModuleName); + log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, pa->szModuleName); #endif - SetStatusMessage(accounts->pa[i]->szModuleName, iStatus, iStatus, msg, FALSE); + SetStatusMessage(pa->szModuleName, iStatus, iStatus, msg, FALSE); if (msg) mir_free(msg); } @@ -1133,49 +1142,51 @@ int SetStartupStatus(int i) { char szSetting[80]; wchar_t *fmsg, *msg = nullptr; - int iStatus = GetStartupStatus(accounts->pa[i]->szModuleName); + + auto *pa = accounts->pa[i]; + int iStatus = GetStartupStatus(pa->szModuleName); if (iStatus == ID_STATUS_OFFLINE) return -1; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || - !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || + !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) { - CallProtoService(accounts->pa[i]->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0); + CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0); return -1; } - mir_snprintf(szSetting, "Proto%sFlags", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName); int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT); if (flags & PROTO_NO_MSG || flags & PROTO_THIS_MSG) { - if (HasProtoStaticStatusMsg(accounts->pa[i]->szModuleName, ID_STATUS_OFFLINE, iStatus)) + if (HasProtoStaticStatusMsg(pa->szModuleName, ID_STATUS_OFFLINE, iStatus)) return 0; else fmsg = nullptr; } else if (flags & PROTO_NOCHANGE) { - mir_snprintf(szSetting, "FCur%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "FCur%sMsg", pa->szModuleName); fmsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting); } else - fmsg = GetAwayMessageFormat(iStatus, accounts->pa[i]->szModuleName); + fmsg = GetAwayMessageFormat(iStatus, pa->szModuleName); #ifdef _DEBUG - log2file("SetStartupStatus(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), fmsg, accounts->pa[i]->szModuleName); + log2file("SetStartupStatus(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), fmsg, pa->szModuleName); #endif if (fmsg) - msg = InsertVarsIntoMsg(fmsg, accounts->pa[i]->szModuleName, iStatus, NULL); + msg = InsertVarsIntoMsg(fmsg, pa->szModuleName, iStatus, NULL); - SaveMessageToDB(accounts->pa[i]->szModuleName, fmsg, TRUE); - SaveMessageToDB(accounts->pa[i]->szModuleName, msg, FALSE); + SaveMessageToDB(pa->szModuleName, fmsg, TRUE); + SaveMessageToDB(pa->szModuleName, msg, FALSE); if (fmsg) mir_free(fmsg); - Proto_SetStatus(accounts->pa[i]->szModuleName, ID_STATUS_OFFLINE, iStatus, msg /*? msg : L""*/); + Proto_SetStatus(pa->szModuleName, ID_STATUS_OFFLINE, iStatus, msg /*? msg : L""*/); mir_free(msg); return 0; @@ -1191,13 +1202,14 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) // is global status mode going to be set? for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - status_mode = GetStartupStatus(accounts->pa[i]->szModuleName); + status_mode = GetStartupStatus(pa->szModuleName); if (status_mode != ID_STATUS_OFFLINE) temp_status_mode = status_mode; @@ -1226,10 +1238,11 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; SetStartupStatus(i); @@ -1243,10 +1256,11 @@ VOID CALLBACK SetStartupStatusProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) for (; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; if (g_uSetStatusTimer[i] == idEvent) @@ -1279,28 +1293,29 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - iCurrentStatus = CallProtoService(accounts->pa[i]->szModuleName, PS_GETSTATUS, 0, 0); + iCurrentStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); if (iCurrentStatus < ID_STATUS_ONLINE) continue; - mir_snprintf(szBuffer, "FCur%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(szBuffer, "FCur%sMsg", pa->szModuleName); wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szBuffer); if (tszStatusMsg == nullptr) continue; - tszMsg = InsertVarsIntoMsg(tszStatusMsg, accounts->pa[i]->szModuleName, iCurrentStatus, NULL); + tszMsg = InsertVarsIntoMsg(tszStatusMsg, pa->szModuleName, iCurrentStatus, NULL); mir_free(tszStatusMsg); - mir_snprintf(szBuffer, "Cur%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(szBuffer, "Cur%sMsg", pa->szModuleName); tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szBuffer); if ((tszMsg && tszStatusMsg && !mir_wstrcmp(tszMsg, tszStatusMsg)) || (!tszMsg && !tszStatusMsg)) @@ -1315,10 +1330,10 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) if (tszMsg && mir_wstrlen(tszMsg)) { #ifdef _DEBUG - log2file("UpdateMsgTimerProc(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iCurrentStatus, ""), tszMsg, accounts->pa[i]->szModuleName); + log2file("UpdateMsgTimerProc(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iCurrentStatus, ""), tszMsg, pa->szModuleName); #endif - Proto_SetStatus(accounts->pa[i]->szModuleName, iCurrentStatus, iCurrentStatus, tszMsg); - SaveMessageToDB(accounts->pa[i]->szModuleName, tszMsg, FALSE); + Proto_SetStatus(pa->szModuleName, iCurrentStatus, iCurrentStatus, tszMsg); + SaveMessageToDB(pa->szModuleName, tszMsg, FALSE); } mir_free(tszMsg); } @@ -1363,7 +1378,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) hProtoStatusMenuItem = (HANDLE *)mir_realloc(hProtoStatusMenuItem, sizeof(HANDLE) * count); for (int i = 0; i < count; ++i) { - if (!Proto_IsAccountEnabled(pa[i])) + if (!pa[i]->IsEnabled()) continue; if (CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) @@ -1393,7 +1408,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) for (int i = 0; i < count; ++i) { - if (!Proto_IsAccountEnabled(pa[i])) + if (!pa[i]->IsEnabled()) continue; if (!CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) @@ -1411,7 +1426,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG) continue; - if (Proto_IsAccountLocked(pa[i])) + if (pa[i]->IsLocked()) { wchar_t szBuffer[256]; mir_snwprintf(szBuffer, TranslateT("%s (locked)"), pa[i]->tszAccountName); @@ -1446,13 +1461,14 @@ static int OnIdleChanged(WPARAM, LPARAM lParam) for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (db_get_b(NULL, accounts->pa[i]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; - int iStatusBits = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + int iStatusBits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); int iStatus = mii.aaStatus; if (!(iStatusBits & Proto_Status2Flag(iStatus))) { @@ -1462,20 +1478,20 @@ static int OnIdleChanged(WPARAM, LPARAM lParam) continue; } - int iCurrentStatus = CallProtoService(accounts->pa[i]->szModuleName, PS_GETSTATUS, 0, 0); + int iCurrentStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); if (iCurrentStatus < ID_STATUS_ONLINE || iCurrentStatus == ID_STATUS_INVISIBLE) continue; - if ((lParam & IDF_ISIDLE && (db_get_b(NULL, "AutoAway", accounts->pa[i]->szModuleName, 0) || + if ((lParam & IDF_ISIDLE && (db_get_b(NULL, "AutoAway", pa->szModuleName, 0) || iCurrentStatus == ID_STATUS_ONLINE || iCurrentStatus == ID_STATUS_FREECHAT)) || (!(lParam & IDF_ISIDLE) && !mii.aaLock)) { if (!(lParam & IDF_ISIDLE)) iStatus = ID_STATUS_ONLINE; - wchar_t *tszMsg = GetAwayMessage(iStatus, accounts->pa[i]->szModuleName, FALSE, NULL); - wchar_t *tszVarsMsg = InsertVarsIntoMsg(tszMsg, accounts->pa[i]->szModuleName, iStatus, NULL); - SaveMessageToDB(accounts->pa[i]->szModuleName, tszMsg, TRUE); - SaveMessageToDB(accounts->pa[i]->szModuleName, tszVarsMsg, FALSE); + wchar_t *tszMsg = GetAwayMessage(iStatus, pa->szModuleName, FALSE, NULL); + wchar_t *tszVarsMsg = InsertVarsIntoMsg(tszMsg, pa->szModuleName, iStatus, NULL); + SaveMessageToDB(pa->szModuleName, tszMsg, TRUE); + SaveMessageToDB(pa->szModuleName, tszVarsMsg, FALSE); mir_free(tszMsg); mir_free(tszVarsMsg); } @@ -1646,23 +1662,24 @@ static int OnAccListChanged(WPARAM, LPARAM) Proto_EnumAccounts(&accounts->count, &accounts->pa); for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!mir_strcmp(accounts->pa[i]->szProtoName, "ICQ")) - HookProtoEvent(accounts->pa[i]->szModuleName, ME_ICQ_STATUSMSGREQ, OnICQStatusMsgRequest); + if (!mir_strcmp(pa->szProtoName, "ICQ")) + HookProtoEvent(pa->szModuleName, ME_ICQ_STATUSMSGREQ, OnICQStatusMsgRequest); - accounts->statusFlags |= (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)); + accounts->statusFlags |= (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)); - if (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)) + if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)) accounts->statusCount++; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - accounts->statusMsgFlags |= CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3,0); + accounts->statusMsgFlags |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3,0); - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; accounts->statusMsgCount++; @@ -1729,14 +1746,15 @@ static int OnModulesLoaded(WPARAM, LPARAM) else { g_uSetStatusTimer = (UINT_PTR *)mir_alloc(sizeof(UINT_PTR) * accounts->count); for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; char szSetting[80]; - mir_snprintf(szSetting, "Set%sStatusDelay", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Set%sStatusDelay", pa->szModuleName); g_uSetStatusTimer[i] = SetTimer(nullptr, 0, db_get_w(NULL, "SimpleStatusMsg", szSetting, 300), SetStartupStatusProc); } } @@ -1751,14 +1769,15 @@ static int OnOkToExit(WPARAM, LPARAM) char szSetting[80]; for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - mir_snprintf(szSetting, "Last%sStatus", accounts->pa[i]->szModuleName); - db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)CallProtoService(accounts->pa[i]->szModuleName, PS_GETSTATUS, 0, 0)); + mir_snprintf(szSetting, "Last%sStatus", pa->szModuleName); + db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)); } if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, L"SimpleStatusMsg") /*&& db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1)*/) diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index d4d6232f16..cab220a553 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -644,16 +644,17 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) } db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); for (i = 0; i < accounts->count; i++) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, "Last%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, ""); } db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)data->max_hist_msgs); @@ -1136,23 +1137,24 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA else { db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); for (int j = 0; j < accounts->count; j++) { - if (!Proto_IsAccountEnabled(accounts->pa[j])) + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (db_get_b(NULL, accounts->pa[j]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; - if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(szSetting, "Last%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(szSetting, "Last%sMsg", pa->szModuleName); db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); - mir_snprintf(szSetting, "%sMsg", accounts->pa[j]->szModuleName); - iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(accounts->pa[j]->szModuleName) : GetCurrentStatus(accounts->pa[j]->szModuleName); + mir_snprintf(szSetting, "%sMsg", pa->szModuleName); + iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting), L""); } @@ -1186,23 +1188,24 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA else { db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); for (int j = 0; j < accounts->count; j++) { - if (!Proto_IsAccountEnabled(accounts->pa[j])) + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (db_get_b(NULL, accounts->pa[j]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; - if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, "Last%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, "%sMsg", accounts->pa[j]->szModuleName); - iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(accounts->pa[j]->szModuleName) : GetCurrentStatus(accounts->pa[j]->szModuleName); + mir_snprintf(buff2, "%sMsg", pa->szModuleName); + iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } } @@ -1234,23 +1237,24 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA else { db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); for (int j = 0; j < accounts->count; j++) { - if (!Proto_IsAccountEnabled(accounts->pa[j])) + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (db_get_b(NULL, accounts->pa[j]->szModuleName, "LockMainStatus", 0)) + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) continue; - if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, "Last%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, "%sMsg", accounts->pa[j]->szModuleName); - iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(accounts->pa[j]->szModuleName) : GetCurrentStatus(accounts->pa[j]->szModuleName); + mir_snprintf(buff2, "%sMsg", pa->szModuleName); + iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } } diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index 8bc927a164..22dcf788f7 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -143,13 +143,14 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l for (j = 0; j < accounts->count; j++) { - if (!Proto_IsAccountEnabled(accounts->pa[j]) || !CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled() || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(setting, "%sFlags", accounts->pa[j]->szModuleName); + mir_snprintf(setting, "%sFlags", pa->szModuleName); val = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(i, setting), STATUS_DEFAULT); data->status_msg[j+1].flags[i-ID_STATUS_ONLINE] = val; - mir_snprintf(setting, "%sDefault", accounts->pa[j]->szModuleName); + mir_snprintf(setting, "%sDefault", pa->szModuleName); text = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, setting)); mir_wstrncpy(data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024); } @@ -190,26 +191,27 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l for (i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i]) - || !CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) - || !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled() + || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) + || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) { data->proto_msg[i+1].msg = nullptr; continue; } - index = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_ADDSTRING, 0, (LPARAM)accounts->pa[i]->tszAccountName); + index = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName); // SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, index, (LPARAM)i + 1); if (index != CB_ERR && index != CB_ERRSPACE) { - mir_snprintf(setting, "Proto%sDefault", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Proto%sDefault", pa->szModuleName); data->proto_msg[i+1].msg = db_get_wsa(NULL, "SimpleStatusMsg", setting); - mir_snprintf(setting, "Proto%sFlags", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Proto%sFlags", pa->szModuleName); val = db_get_b(NULL, "SimpleStatusMsg", setting, PROTO_DEFAULT); data->proto_msg[i+1].flags = val; - mir_snprintf(setting, "Proto%sMaxLen", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Proto%sMaxLen", pa->szModuleName); val = db_get_w(NULL, "SimpleStatusMsg", setting, 1024); data->proto_msg[i+1].max_length = val; SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i + 1); @@ -918,7 +920,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l for (int k = 0; k < accounts->count; k++) { - if (!Proto_IsAccountEnabled(accounts->pa[k]) || !CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + auto *pa = accounts->pa[k]; + if (!pa->IsEnabled() || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; if (k != j - 1) @@ -953,7 +956,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l { for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { - if (CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) + if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) { data->status_msg[k + 1].flags[i - ID_STATUS_ONLINE] = data->status_msg[j].flags[i - ID_STATUS_ONLINE]; if (data->status_msg[j].flags[i - ID_STATUS_ONLINE] & STATUS_THIS_MSG) @@ -1004,18 +1007,19 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l for (int j = 0; j < accounts->count; j++) { - if (!Proto_IsAccountEnabled(accounts->pa[j])) + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) continue; - if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - if (CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) + if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) { - mir_snprintf(szSetting, "%sDefault", accounts->pa[j]->szModuleName); + mir_snprintf(szSetting, "%sDefault", pa->szModuleName); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(i, szSetting), data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE]); - mir_snprintf(szSetting, "%sFlags", accounts->pa[j]->szModuleName); + mir_snprintf(szSetting, "%sFlags", pa->szModuleName); db_set_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(i, szSetting), (BYTE)data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE]); } } @@ -1030,25 +1034,26 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l for (int i = 0; i < accounts->count; i++) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(szSetting, "Proto%sDefault", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Proto%sDefault", pa->szModuleName); if (data->proto_msg[i+1].msg && (data->proto_msg[i+1].flags & PROTO_THIS_MSG)) db_set_ws(NULL, "SimpleStatusMsg", szSetting, data->proto_msg[i+1].msg); // else // db_unset(NULL, "SimpleStatusMsg", szSetting); - mir_snprintf(szSetting, "Proto%sMaxLen", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Proto%sMaxLen", pa->szModuleName); db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->proto_msg[i+1].max_length); - mir_snprintf(szSetting, "Proto%sFlags", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName); db_set_b(NULL, "SimpleStatusMsg", szSetting, (BYTE)data->proto_msg[i+1].flags); } } @@ -1336,17 +1341,18 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); for (int i = 0; i < accounts->count; i++) { - if (!Proto_IsAccountEnabled(accounts->pa[i])) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled()) continue; - if (!CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) continue; - if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; char setting[80]; - mir_snprintf(setting, "Last%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Last%sMsg", pa->szModuleName); db_set_s(NULL, "SimpleStatusMsg", setting, ""); } db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)max_hist_msgs); @@ -1433,16 +1439,17 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa data->setdelay = (int *)mir_alloc(sizeof(int) * accounts->count); for (int i = 0; i < accounts->count; ++i) { - if (!Proto_IsAccountEnabled(accounts->pa[i]) || !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled() || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; - int index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)accounts->pa[i]->tszAccountName); + int index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)pa->tszAccountName); if (index != LB_ERR && index != LB_ERRSPACE) { char setting[80]; - mir_snprintf(setting, "Startup%sStatus", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Startup%sStatus", pa->szModuleName); data->status[i] = db_get_w(NULL, "SimpleStatusMsg", setting, ID_STATUS_CURRENT); - mir_snprintf(setting, "Set%sStatusDelay", accounts->pa[i]->szModuleName); + mir_snprintf(setting, "Set%sStatusDelay", pa->szModuleName); data->setdelay[i] = db_get_w(NULL, "SimpleStatusMsg", setting, 300); SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i); } @@ -1565,7 +1572,8 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa int newindex = 0; int i = SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0), 0); - int status_modes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); + auto *pa = accounts->pa[i]; + int status_modes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0); SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_RESETCONTENT, 0, 0); for (int l = ID_STATUS_OFFLINE; l <= ID_STATUS_OUTTOLUNCH; l++) @@ -1618,14 +1626,15 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa { for (int i = 0; i < accounts->count; i++) { - if (!Proto_IsAccountEnabled(accounts->pa[i]) || !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) + auto *pa = accounts->pa[i]; + if (!pa->IsEnabled() || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))) continue; char szSetting[80]; - mir_snprintf(szSetting, "Startup%sStatus", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Startup%sStatus", pa->szModuleName); db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->status[i]); - mir_snprintf(szSetting, "Set%sStatusDelay", accounts->pa[i]->szModuleName); + mir_snprintf(szSetting, "Set%sStatusDelay", pa->szModuleName); db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->setdelay[i]); } db_set_w(NULL, "SimpleStatusMsg", "SetStatusDelay", (WORD)data->setglobaldelay); diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 7559abaea1..6c061d5fab 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -681,7 +681,7 @@ bool SmileyCategoryListType::DeleteCustomCategory(int index) void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStringW &defaultFile) { - if (Proto_IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName)) { + if (acc->IsEnabled() && acc->szProtoName && IsSmileyProto(acc->szModuleName)) { CMStringW displayName(acc->tszAccountName ? acc->tszAccountName : _A2T(acc->szModuleName)); CMStringW PhysProtoName, paths; DBVARIANT dbv; diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp index a0e7e0f7a4..a35b8496da 100644 --- a/plugins/StatusManager/src/commonstatus.cpp +++ b/plugins/StatusManager/src/commonstatus.cpp @@ -308,7 +308,7 @@ static INT_PTR GetProtocolCountService(WPARAM, LPARAM) bool IsSuitableProto(PROTOACCOUNT *pa) { - return (pa == nullptr) ? false : (pcli->pfnGetProtocolVisibility(pa->szModuleName) != 0); + return (pa == nullptr) ? false : pa->IsVisible(); } static int CreateServices() diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp index da64a57d50..158f0f5acd 100644 --- a/plugins/StopSpamPlus/src/options.cpp +++ b/plugins/StopSpamPlus/src/options.cpp @@ -121,7 +121,7 @@ public: for (int i = 0; i < n; i++) { PROTOACCOUNT *p = pa[i]; - if (!Proto_IsAccountEnabled(p) || p->bIsVirtual) + if (!p->IsEnabled() || p->bIsVirtual) continue; item.lParam = (LPARAM)p->szModuleName; diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 5425e098aa..9fa2057686 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -72,14 +72,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa pwd->iSidebarWidth = opt.iSidebarWidth; PROTOACCOUNT *pa = Proto_GetAccount(pwd->clcit.szProto); - if (pa) + if (pa) { mir_wstrcpy(pwd->swzTitle, pa->tszAccountName); - - if (mir_wstrlen(pwd->swzTitle) == 0) - a2t(pwd->clcit.szProto, pwd->swzTitle, TITLE_TEXT_LEN); - - if (Proto_IsAccountLocked(pa)) - mir_snwprintf(pwd->swzTitle, TranslateT("%s (locked)"), pwd->swzTitle); + if (pa->IsLocked()) + mir_snwprintf(pwd->swzTitle, TranslateT("%s (locked)"), pwd->swzTitle); + } + else a2t(pwd->clcit.szProto, pwd->swzTitle, TITLE_TEXT_LEN); // protocol status WORD wStatus = (WORD)CallProtoService(pwd->clcit.szProto, PS_GETSTATUS, 0, 0); @@ -1465,7 +1463,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if (opt.bHideOffline && wStatus == ID_STATUS_OFFLINE) continue; - if (!Proto_IsAccountEnabled(pa) || !IsTrayProto(pa->tszAccountName, (BOOL)wParam)) + if (!pa->IsEnabled() || !IsTrayProto(pa->tszAccountName, (BOOL)wParam)) continue; if (dwItems & TRAYTIP_NUMCONTACTS) { @@ -1482,7 +1480,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa wchar_t swzProto[256]; mir_wstrcpy(swzProto, pa->tszAccountName); if (dwItems & TRAYTIP_LOCKSTATUS) - if (Proto_IsAccountLocked(pa)) + if (pa->IsLocked()) mir_snwprintf(swzProto, TranslateT("%s (locked)"), pa->tszAccountName); AddRow(pwd, swzProto, buff, nullptr, false, false, !bFirstItem, true, Skin_LoadProtoIcon(pa->szModuleName, wStatus)); diff --git a/src/core/stdautoaway/src/autoaway.cpp b/src/core/stdautoaway/src/autoaway.cpp index bf783cc3a1..27531d2b2b 100644 --- a/src/core/stdautoaway/src/autoaway.cpp +++ b/src/core/stdautoaway/src/autoaway.cpp @@ -63,7 +63,7 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) for (int i = 0; i < numAccounts; i++) { PROTOACCOUNT *pa = accounts[i]; - if (!Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) + if (!pa->IsEnabled() || pa->IsLocked()) continue; int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp index 14ec7baffb..52b727f8fe 100644 --- a/src/core/stdaway/src/sendmsg.cpp +++ b/src/core/stdaway/src/sendmsg.cpp @@ -178,10 +178,10 @@ void ChangeAllProtoMessages(char *szProto, int statusMode, wchar_t *msg) for (int i = 0; i < nAccounts; i++) { PROTOACCOUNT *pa = accounts[i]; - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; - if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && !Proto_IsAccountLocked(pa)) + if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && !pa->IsLocked()) CallProtoService(pa->szModuleName, PS_SETAWAYMSG, statusMode, (LPARAM)msg); } } @@ -540,7 +540,7 @@ static int AwayMsgSendAccountsChanged(WPARAM, LPARAM) PROTOACCOUNT **accounts; Proto_EnumAccounts(&nAccounts, &accounts); for (int i = 0; i < nAccounts; i++) { - if (!Proto_IsAccountEnabled(accounts[i])) + if (!accounts[i]->IsEnabled()) continue; protoModeMsgFlags |= CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp index 873ebb6f3e..d17b469d1a 100644 --- a/src/core/stdclist/src/clistopts.cpp +++ b/src/core/stdclist/src/clistopts.cpp @@ -107,7 +107,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { - if (!Proto_IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName); diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index 1077defd18..2a3c16d49f 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -90,7 +90,7 @@ static int UserOnlineModulesLoaded(WPARAM, LPARAM) // reset the counter for (int i = 0; i < numAccounts; i++) - if (Proto_IsAccountEnabled(accounts[i])) + if (accounts[i]->IsEnabled()) db_set_dw(NULL, "UserOnline", accounts[i]->szModuleName, GetTickCount()); return 0; @@ -104,7 +104,7 @@ static int UserOnlineAccountsChanged(WPARAM eventCode, LPARAM lParam) case PRAC_ADDED: case PRAC_CHECKED: // reset the counter - if (Proto_IsAccountEnabled(pa)) + if (pa->IsEnabled()) db_set_dw(NULL, "UserOnline", pa->szModuleName, GetTickCount()); break; } diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 6fb781a2b8..d35e8478d2 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -128,7 +128,7 @@ static int ClcAccountsChanged(WPARAM, LPARAM) { int cnt = 0; for (auto &pa : accounts) - if (Proto_IsAccountEnabled(pa)) + if (pa->IsEnabled()) cnt++; cli.hClcProtoCount = cnt; @@ -136,7 +136,7 @@ static int ClcAccountsChanged(WPARAM, LPARAM) cnt = 0; for (auto &pa : accounts) { - if (Proto_IsAccountEnabled(pa)) { + if (pa->IsEnabled()) { cli.clcProto[cnt].szProto = pa->szModuleName; cli.clcProto[cnt].dwStatus = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0); ++cnt; diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index c61a246dc3..2a99f96aff 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -113,7 +113,6 @@ int ClcOptInit(WPARAM wParam, LPARAM lParam); /* clistmenus.c */ HGENMENU fnGetProtocolMenu(const char*); -int fnGetProtocolVisibility(const char* accName); int fnGetAverageMode(int *pNetProtoCount); int fnGetAccountIndexByPos(int Pos); diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp index 99e4af117f..1eb461121b 100644 --- a/src/mir_app/src/clistcore.cpp +++ b/src/mir_app/src/clistcore.cpp @@ -188,7 +188,6 @@ void InitClistCore() cli.pfnShowHide = fnShowHide; cli.pfnGetStatusModeDescription = fnGetStatusModeDescription; - cli.pfnGetProtocolVisibility = fnGetProtocolVisibility; cli.pfnGetProtoIndexByPos = fnGetProtoIndexByPos; cli.pfnReloadProtoMenus = fnReloadProtoMenus; cli.pfnGetAccountIndexByPos = fnGetAccountIndexByPos; diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 6fb2866dc1..ade51e63f5 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -97,7 +97,7 @@ wchar_t* fnTrayIconMakeTooltip(const wchar_t *szPrefix, const char *szProto) continue; PROTOACCOUNT *pa = accounts[i]; - if (!cli.pfnGetProtocolVisibility(pa->szModuleName)) + if (!pa->IsVisible()) continue; wchar_t *szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0), 0); @@ -252,7 +252,7 @@ int fnTrayIconInit(HWND hwnd) int j = cli.pfnGetAccountIndexByPos(i); if (j >= 0) { PROTOACCOUNT *pa = accounts[j]; - if (cli.pfnGetProtocolVisibility(pa->szModuleName)) + if (pa->IsVisible()) cli.pfnTrayIconAdd(hwnd, pa->szModuleName, nullptr, CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0)); } } @@ -407,7 +407,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) cli.trayIcon[i].hBaseIcon = hIcon; return i; } - if ((cli.pfnGetProtocolVisibility(szPreferredProto)) && + if ((Clist_GetProtocolVisibility(szPreferredProto)) && (cli.pfnGetAverageMode(nullptr) == -1) && (db_get_b(0, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) && !(db_get_b(0, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) @@ -442,7 +442,7 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD) int i; for (i = accounts.getCount() + 1; --i;) { cli.cycleStep = (cli.cycleStep + 1) % accounts.getCount(); - if (cli.pfnGetProtocolVisibility(accounts[cli.cycleStep]->szModuleName)) + if (accounts[cli.cycleStep]->IsVisible()) break; } @@ -459,7 +459,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto) { initcheck; if (szChangedProto == nullptr) return; - if (!cli.pfnGetProtocolVisibility(szChangedProto)) return; + if (!Clist_GetProtocolVisibility(szChangedProto)) return; int netProtoCount; mir_cslock lck(trayLockCS); @@ -693,7 +693,7 @@ INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam) break; } - if (cli.pfnGetProtocolVisibility(accounts[k]->szModuleName)) + if (accounts[k]->IsVisible()) ++ind; } } diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 9e12baa282..493ed1ce8a 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -963,7 +963,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - g_IconHeight) >> 1, hIcon, g_IconWidth, g_IconHeight, 0, nullptr, DI_NORMAL); IcoLib_ReleaseIcon(hIcon); - if (Proto_IsAccountLocked(Proto_GetAccount(szProto))) { + if (Proto_GetAccount(szProto)->IsLocked()) { hIcon = Skin_LoadIcon(SKINICON_OTHER_STATUS_LOCKED); if (hIcon != nullptr) { DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - g_IconHeight) >> 1, hIcon, diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index 5ec97ddbb6..19caaf101a 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -370,7 +370,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP int index = 0, cbwidth = 0, netProtoCount = 0; for (auto &pa : accounts) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; DWORD caps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); @@ -397,7 +397,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } for (auto &pa : accounts) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; DWORD caps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); @@ -473,7 +473,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; if (szProto == nullptr) { for (auto &pa : accounts) { - if (Proto_IsAccountEnabled(pa)) { + if (pa->IsEnabled()) { DWORD protoCaps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (protoCaps & PF1_SEARCHBYEMAIL) dat->showEmail = 1; if (protoCaps & PF1_SEARCHBYNAME) dat->showName = 1; @@ -980,7 +980,7 @@ static INT_PTR FindAddCommand(WPARAM, LPARAM) // protocols loaded but that would delay the creation until MODULE_LOADED and // that is not good either... for (auto &pa : accounts) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; int protoCaps = CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 4c196c231a..598f7a5f99 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -118,7 +118,7 @@ int fnGetAverageMode(int *pNetProtoCount) int netProtoCount = 0, averageMode = 0; for (auto &pa : accounts) { - if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0 || Proto_IsAccountLocked(pa)) + if (!pa->IsVisible() || pa->IsLocked()) continue; netProtoCount++; @@ -570,7 +570,7 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) char *prot = smep->szProto; char szHumanName[64] = { 0 }; PROTOACCOUNT *acc = Proto_GetAccount(smep->szProto); - bool bIsLocked = !Proto_IsAccountLocked(acc); + bool bIsLocked = !acc->IsLocked(); db_set_b(0, prot, "LockMainStatus", bIsLocked); CallProtoServiceInt(0, smep->szProto, PS_GETNAME, _countof(szHumanName), (LPARAM)szHumanName); @@ -610,15 +610,15 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) int MenusProtoCount = 0; for (auto &pa : accounts) - if (cli.pfnGetProtocolVisibility(pa->szModuleName)) + if (pa->IsVisible()) MenusProtoCount++; cli.currentDesiredStatusMode = smep->status; for (auto &pa : accounts) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; - if (MenusProtoCount > 1 && Proto_IsAccountLocked(pa)) + if (MenusProtoCount > 1 && pa->IsLocked()) continue; Proto_SetStatus(pa->szModuleName, cli.currentDesiredStatusMode); @@ -728,20 +728,13 @@ MIR_APP_DLL(void) Clist_SetStatusMode(int iStatus) prochotkey = false; } -int fnGetProtocolVisibility(const char *accName) +MIR_APP_DLL(bool) Clist_GetProtocolVisibility(const char *szModuleName) { - if (accName) { - PROTOACCOUNT *pa = Proto_GetAccount(accName); - if (pa && pa->bIsVisible && Proto_IsAccountEnabled(pa) && pa->ppro) { - PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName); - if (pd == nullptr || pd->type != PROTOTYPE_PROTOCOL) - return FALSE; - - return (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0)); - } - } + if (szModuleName == nullptr) + return false; - return FALSE; + PROTOACCOUNT *pa = Proto_GetAccount(szModuleName); + return (pa) ? pa->IsVisible() : false; } int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR **proto, int protoCnt, int Pos) @@ -805,7 +798,7 @@ void RebuildMenuOrder(void) PROTOACCOUNT *pa = accounts[i]; int pos = 0; - if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName)) + if (!bHideStatusMenu && !pa->IsVisible()) continue; DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0); @@ -818,7 +811,7 @@ void RebuildMenuOrder(void) mi.position = pos++; mi.hIcon = ic = (HICON)CallProtoServiceInt(0, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); - if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) { + if (pa->IsLocked() && cli.bDisplayLocked) { mir_snwprintf(tbuf, TranslateT("%s (locked)"), pa->tszAccountName); mi.name.w = tbuf; } @@ -839,7 +832,7 @@ void RebuildMenuOrder(void) smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam)); smep->szProto = mir_strdup(pa->szModuleName); - if (Proto_IsAccountLocked(pa)) + if (pa->IsLocked()) mi.flags |= CMIF_CHECKED; if ((mi.flags & CMIF_CHECKED) && cli.bDisplayLocked) { @@ -903,7 +896,7 @@ void RebuildMenuOrder(void) // add to root menu for (int j = 0; j < _countof(statusModeList); j++) { for (auto &pa : accounts) { - if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName)) + if (!bHideStatusMenu && !pa->IsVisible()) continue; DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0); @@ -981,7 +974,7 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) if (ack->type != ACKTYPE_STATUS) return 0; if (ack->result != ACKRESULT_SUCCESS) return 0; if (hStatusMainMenuHandles == nullptr) return 0; - if (cli.pfnGetProtocolVisibility(ack->szModule) == 0) return 0; + if (Clist_GetProtocolVisibility(ack->szModule) == 0) return 0; int overallStatus = cli.pfnGetAverageMode(nullptr); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 922fd0e0b5..bcfd2f2387 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -124,8 +124,6 @@ GetPluginLangId @129 Proto_GetAccount @130 Proto_EnumProtocols @131 Proto_EnumAccounts @132 -Proto_IsAccountEnabled @133 -Proto_IsAccountLocked @134 Proto_GetBaseAccountName @135 GetContactProto @136 Proto_AddToContact @137 @@ -529,3 +527,10 @@ Proto_ActivateAccount @512 ?RegisterProtocol@CMPluginBase@@IAEXHP6APAUPROTO_INTERFACE@@PBDPB_W@ZP6AHPAU2@@Z@Z @547 NONAME Proto_GetUniqueId @548 Proto_SetUniqueId @549 +??4PROTOACCOUNT@@QAEAAU0@$$QAU0@@Z @550 NONAME +??4PROTOACCOUNT@@QAEAAU0@ABU0@@Z @551 NONAME +?IsEnabled@PROTOACCOUNT@@QBE_NXZ @552 NONAME +?IsLocked@PROTOACCOUNT@@QBE_NXZ @553 NONAME +?IsVisible@PROTOACCOUNT@@QBE_NXZ @554 NONAME +?SetUniqueId@CMPluginBase@@IAEXPBD@Z @555 NONAME +Clist_GetProtocolVisibility @556 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 8456025d4e..a95dca797e 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -124,8 +124,6 @@ GetPluginLangId @129 Proto_GetAccount @130 Proto_EnumProtocols @131 Proto_EnumAccounts @132 -Proto_IsAccountEnabled @133 -Proto_IsAccountLocked @134 Proto_GetBaseAccountName @135 GetContactProto @136 Proto_AddToContact @137 @@ -529,3 +527,10 @@ Proto_ActivateAccount @512 ?RegisterProtocol@CMPluginBase@@IEAAXHP6APEAUPROTO_INTERFACE@@PEBDPEB_W@ZP6AHPEAU2@@Z@Z @547 NONAME Proto_GetUniqueId @548 Proto_SetUniqueId @549 +??4PROTOACCOUNT@@QEAAAEAU0@$$QEAU0@@Z @550 NONAME +??4PROTOACCOUNT@@QEAAAEAU0@AEBU0@@Z @551 NONAME +?IsEnabled@PROTOACCOUNT@@QEBA_NXZ @552 NONAME +?IsLocked@PROTOACCOUNT@@QEBA_NXZ @553 NONAME +?IsVisible@PROTOACCOUNT@@QEBA_NXZ @554 NONAME +?SetUniqueId@CMPluginBase@@IEAAXPEBD@Z @555 NONAME +Clist_GetProtocolVisibility @556 diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 163e693527..e23ae1296d 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -192,7 +192,7 @@ static int OnContactDeleted(WPARAM hContact, LPARAM lParam) { if (hContact) { PROTOACCOUNT *pa = Proto_GetAccount(hContact); - if (Proto_IsAccountEnabled(pa) && pa->ppro) + if (pa->IsEnabled() && pa->ppro) pa->ppro->OnEvent(EV_PROTO_ONCONTACTDELETED, hContact, lParam); } return 0; @@ -202,7 +202,7 @@ static int OnDbSettingsChanged(WPARAM hContact, LPARAM lParam) { if (hContact) { PROTOACCOUNT *pa = Proto_GetAccount(hContact); - if (Proto_IsAccountEnabled(pa) && pa->ppro) + if (pa->IsEnabled() && pa->ppro) pa->ppro->OnEvent(EV_PROTO_DBSETTINGSCHANGED, hContact, lParam); } return 0; @@ -213,7 +213,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) int count = 0; for (auto &pa : accounts) { - if (!pa->ppro || !Proto_IsAccountEnabled(pa)) + if (!pa->ppro || !pa->IsEnabled()) continue; pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); @@ -240,13 +240,13 @@ static int UninitializeStaticAccounts(WPARAM, LPARAM) { // request permission to exit first for (auto &pa : accounts) - if (pa->ppro && Proto_IsAccountEnabled(pa)) + if (pa->ppro && pa->IsEnabled()) if (pa->ppro->OnEvent(EV_PROTO_ONREADYTOEXIT, 0, 0) != TRUE) return 1; // okay, all protocols are ready, exiting for (auto &pa : accounts) - if (pa->ppro && Proto_IsAccountEnabled(pa)) + if (pa->ppro && pa->IsEnabled()) pa->ppro->OnEvent(EV_PROTO_ONEXIT, 0, 0); return 0; @@ -261,7 +261,7 @@ int LoadAccountsModule(void) if (pa->ppro) continue; - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; if (!Proto_ActivateAccount(pa)) @@ -425,7 +425,7 @@ void UnloadAccountsModule() void BuildProtoMenus() { for (auto &pa : accounts) { - if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0) + if (!pa->IsVisible()) continue; if (pa->ppro) diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index 8ca44c145a..65a1e462ae 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -149,7 +149,7 @@ PROTOACCOUNT* __fastcall Proto_GetAccount(MCONTACT hContact) MIR_APP_DLL(char*) GetContactProto(MCONTACT hContact) { PROTOACCOUNT *pa = Proto_GetAccount(hContact); - return Proto_IsAccountEnabled(pa) ? pa->szModuleName : nullptr; + return pa->IsEnabled() ? pa->szModuleName : nullptr; } MIR_APP_DLL(char*) Proto_GetBaseAccountName(MCONTACT hContact) diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 4f39719228..7d6553f804 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -492,7 +492,7 @@ public: AppendMenu(hMenu, MF_STRING, 3, TranslateT("Delete")); - if (Proto_IsAccountEnabled(pa)) + if (pa->IsEnabled()) AppendMenu(hMenu, MF_STRING, 4, TranslateT("Configure")); if (pa->bOldProto || pa->bDynDisabled) diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index 76797e6d73..738a5129dd 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -98,7 +98,7 @@ bool CheckProtocolOrder(void) static bool ProtoToInclude(PROTOACCOUNT *pa) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) return false; PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName); @@ -129,7 +129,7 @@ class CProtocolOrderOpts : public CDlgBase ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData)); PD->RealName = pa->szModuleName; - PD->enabled = Proto_IsAccountEnabled(pa) && isProtoSuitable(pa->ppro); + PD->enabled = pa->IsEnabled() && isProtoSuitable(pa->ppro); tvis.item.lParam = (LPARAM)PD; tvis.item.pszText = pa->tszAccountName; diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 2d00516820..9699129981 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -303,7 +303,6 @@ HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex) } ///////////////////////////////////////////////////////////////////////////////////////// -// 0.8.0+ - accounts MIR_APP_DLL(PROTOACCOUNT*) Proto_GetAccount(const char *accName) { @@ -325,14 +324,29 @@ MIR_APP_DLL(void) Proto_EnumAccounts(int *nAccs, PROTOACCOUNT ***pAccs) if (pAccs) *pAccs = accounts.getArray(); } -MIR_APP_DLL(bool) Proto_IsAccountEnabled(const PROTOACCOUNT *pa) +///////////////////////////////////////////////////////////////////////////////////////// + +bool PROTOACCOUNT::IsEnabled() const +{ + return (this != nullptr) && ((bIsEnabled && !bDynDisabled) || bOldProto); +} + +bool PROTOACCOUNT::IsLocked() const { - return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto); + return (this != nullptr) && db_get_b(0, szModuleName, "LockMainStatus", 0) != 0; } -MIR_APP_DLL(bool) Proto_IsAccountLocked(const PROTOACCOUNT *pa) +bool PROTOACCOUNT::IsVisible() const { - return pa && db_get_b(0, pa->szModuleName, "LockMainStatus", 0) != 0; + if (this != nullptr && bIsVisible && IsEnabled() && ppro) { + PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(szProtoName); + if (pd == nullptr || pd->type != PROTOTYPE_PROTOCOL) + return false; + + return (ppro->GetCaps(PFLAGNUM_2, 0) & ~ppro->GetCaps(PFLAGNUM_5, 0)); + } + + return false; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp index d7eb8c090e..7b8ba22fdd 100644 --- a/src/mir_app/src/searchresults.cpp +++ b/src/mir_app/src/searchresults.cpp @@ -200,7 +200,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha dat->searchCount = 0; dat->search = (struct ProtoSearchInfo*)mir_calloc(sizeof(struct ProtoSearchInfo) * accounts.getCount()); for (auto &pa : accounts) { - if (!Proto_IsAccountEnabled(pa)) + if (!pa->IsEnabled()) continue; DWORD caps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); -- cgit v1.2.3