summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-03 13:37:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-03 13:37:13 +0300
commit66b61f42871089f3962920924f9030cd6dff2ad8 (patch)
treebfa19d1db1c84a841dd1e6ea258ae1d9212d2ada /src
parentdfe4c13573386072b6fcf177e8f52fafc81891f1 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/stdautoaway/src/autoaway.cpp2
-rw-r--r--src/core/stdaway/src/sendmsg.cpp6
-rw-r--r--src/core/stdclist/src/clistopts.cpp2
-rw-r--r--src/core/stduseronline/src/useronline.cpp4
-rw-r--r--src/mir_app/src/clc.cpp4
-rw-r--r--src/mir_app/src/clc.h1
-rw-r--r--src/mir_app/src/clistcore.cpp1
-rw-r--r--src/mir_app/src/clisttray.cpp12
-rw-r--r--src/mir_app/src/clui.cpp2
-rw-r--r--src/mir_app/src/findadd.cpp8
-rw-r--r--src/mir_app/src/menu_clist.cpp37
-rw-r--r--src/mir_app/src/mir_app.def9
-rw-r--r--src/mir_app/src/mir_app64.def9
-rw-r--r--src/mir_app/src/proto_accs.cpp14
-rw-r--r--src/mir_app/src/proto_chains.cpp2
-rw-r--r--src/mir_app/src/proto_opts.cpp2
-rw-r--r--src/mir_app/src/proto_order.cpp4
-rw-r--r--src/mir_app/src/protocols.cpp24
-rw-r--r--src/mir_app/src/searchresults.cpp2
19 files changed, 80 insertions, 65 deletions
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);