diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdautoaway/src/autoaway.cpp | 5 | ||||
-rw-r--r-- | src/mir_app/src/clc.cpp | 10 | ||||
-rw-r--r-- | src/mir_app/src/clcidents.cpp | 23 | ||||
-rw-r--r-- | src/mir_app/src/clisttray.cpp | 9 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/proto_accs.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/proto_opts.cpp | 5 | ||||
-rw-r--r-- | src/mir_app/src/protocols.cpp | 1 |
8 files changed, 36 insertions, 37 deletions
diff --git a/src/core/stdautoaway/src/autoaway.cpp b/src/core/stdautoaway/src/autoaway.cpp index af0a60e441..3dda6e2d87 100644 --- a/src/core/stdautoaway/src/autoaway.cpp +++ b/src/core/stdautoaway/src/autoaway.cpp @@ -61,7 +61,6 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) if (!pa->IsEnabled() || pa->IsLocked())
continue;
- int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
int statusbits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
int status = mii.aaStatus;
if (!(statusbits & Proto_Status2Flag(status))) {
@@ -70,11 +69,11 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) status = ID_STATUS_AWAY;
}
if (lParam & IDF_ISIDLE) {
- if (currentstatus != ID_STATUS_ONLINE && currentstatus != ID_STATUS_FREECHAT)
+ if (pa->iRealStatus != ID_STATUS_ONLINE && pa->iRealStatus != ID_STATUS_FREECHAT)
continue;
// save old status of account and set to given status
- db_set_w(NULL, AA_MODULE, pa->szModuleName, currentstatus);
+ db_set_w(NULL, AA_MODULE, pa->szModuleName, pa->iRealStatus);
Proto_SetStatus(pa->szModuleName, status);
}
else {
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 8c0014d50d..5b72ddb2ab 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -152,12 +152,10 @@ static int ClcProtoAck(WPARAM, LPARAM lParam) WindowList_BroadcastAsync(hClcWindowList, INTM_INVALIDATE, 0, 0);
if (ack->result == ACKRESULT_SUCCESS) {
- for (auto &it : g_menuProtos) {
- if (!mir_strcmp(it->szProto, ack->szModule)) {
- it->iStatus = (WORD)ack->lParam;
- Clist_TrayIconUpdateBase(ack->szModule);
- break;
- }
+ PROTOACCOUNT *pa = Proto_GetAccount(ack->szModule);
+ if (pa) {
+ pa->iRealStatus = ack->lParam;
+ Clist_TrayIconUpdateBase(ack->szModule);
}
}
}
diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp index fbd5e8d245..0a56e15131 100644 --- a/src/mir_app/src/clcidents.cpp +++ b/src/mir_app/src/clcidents.cpp @@ -221,11 +221,9 @@ MIR_APP_DLL(HANDLE) Clist_ContactToItemHandle(ClcContact *cc, DWORD *nmFlags) MIR_APP_DLL(int) Clist_GetRealStatus(ClcContact *cc, int iDefaultValue)
{
- char *szProto = cc->proto;
- if (szProto != nullptr)
- for (auto &it : g_menuProtos)
- if (!mir_strcmp(it->szProto, szProto))
- return it->iStatus;
+ PROTOACCOUNT *pa = Proto_GetAccount(cc->proto);
+ if (pa)
+ return pa->iRealStatus;
return iDefaultValue;
}
@@ -237,12 +235,15 @@ MIR_APP_DLL(int) Clist_GetGeneralizedStatus(char **szProto) int status = ID_STATUS_OFFLINE;
int statusOnlineness = 0;
- for (auto &it : g_menuProtos) {
- if (it->iStatus == ID_STATUS_INVISIBLE)
+ for (auto &pa : accounts) {
+ if (!pa->IsVisible())
+ continue;
+
+ if (pa->iRealStatus == ID_STATUS_INVISIBLE)
return ID_STATUS_INVISIBLE;
int iStatusWeight;
- switch (it->iStatus) {
+ switch (pa->iRealStatus) {
case ID_STATUS_FREECHAT: iStatusWeight = 110; break;
case ID_STATUS_ONLINE: iStatusWeight = 100; break;
case ID_STATUS_OCCUPIED: iStatusWeight = 60; break;
@@ -253,14 +254,14 @@ MIR_APP_DLL(int) Clist_GetGeneralizedStatus(char **szProto) case ID_STATUS_NA: iStatusWeight = 10; break;
case ID_STATUS_INVISIBLE: iStatusWeight = 5; break;
default:
- iStatusWeight = IsStatusConnecting(it->iStatus) ? 120 : 0;
+ iStatusWeight = IsStatusConnecting(pa->iRealStatus) ? 120 : 0;
break;
}
if (iStatusWeight > statusOnlineness) {
if (szProto != nullptr)
- *szProto = it->szProto;
- status = it->iStatus;
+ *szProto = pa->szModuleName;
+ status = pa->iRealStatus;
statusOnlineness = iStatusWeight;
}
}
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 3789bd7ce3..202661df18 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -101,7 +101,7 @@ MIR_APP_DLL(wchar_t*) Clist_TrayIconMakeTooltip(const wchar_t *szPrefix, const c if (!pa->IsVisible())
continue;
- wchar_t *szStatus = Clist_GetStatusModeDescription(CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0), 0);
+ wchar_t *szStatus = Clist_GetStatusModeDescription(pa->iRealStatus, 0);
if (!szStatus)
continue;
@@ -126,7 +126,7 @@ MIR_APP_DLL(wchar_t*) Clist_TrayIconMakeTooltip(const wchar_t *szPrefix, const c PROTOACCOUNT *pa = Proto_GetAccount(szProto);
if (pa != nullptr) {
ptrW ProtoXStatus(sttGetXStatus(szProto));
- wchar_t *szStatus = Clist_GetStatusModeDescription(CallProtoServiceInt(0, szProto, PS_GETSTATUS, 0, 0), 0);
+ wchar_t *szStatus = Clist_GetStatusModeDescription(pa->iRealStatus, 0);
if (szPrefix && szPrefix[0]) {
if (db_get_b(0, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT)) {
if (hasTips()) {
@@ -251,7 +251,7 @@ int fnTrayIconInit(HWND hwnd) if (j >= 0) {
PROTOACCOUNT *pa = accounts[j];
if (pa->IsVisible())
- Clist_TrayIconAdd(hwnd, pa->szModuleName, nullptr, CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0));
+ Clist_TrayIconAdd(hwnd, pa->szModuleName, nullptr, pa->iRealStatus);
}
}
}
@@ -446,8 +446,7 @@ static VOID CALLBACK TrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD) if (i) {
DestroyIcon(cli.trayIcon[0].hBaseIcon);
- cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(0, accounts[cli.cycleStep]->szModuleName,
- CallProtoServiceInt(0, accounts[cli.cycleStep]->szModuleName, PS_GETSTATUS, 0, 0));
+ cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(0, accounts[cli.cycleStep]->szModuleName, accounts[cli.cycleStep]->iRealStatus);
if (cli.trayIcon[0].isBase)
TrayIconUpdate(cli.trayIcon[0].hBaseIcon, nullptr, nullptr, 1);
}
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index a44c800dc2..af5047e9ba 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -479,7 +479,6 @@ static INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) pimi->mi.flags &= ~CMIF_CHECKED;
}
else if ((!smep || smep->szProto) && pimi->mi.name.a) {
- int curProtoStatus = 0;
BOOL IconNeedDestroy = FALSE;
char* prot;
if (smep)
@@ -489,14 +488,12 @@ static INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) prot = NEWSTR_ALLOCA(prn);
if (prn) mir_free(prn);
}
- if (Proto_GetAccount(prot) == nullptr)
+ PROTOACCOUNT *pa = Proto_GetAccount(prot);
+ if (pa == nullptr)
return TRUE;
- if ((curProtoStatus = CallProtoServiceInt(0, prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND)
- curProtoStatus = 0;
-
- if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE)
- pimi->mi.hIcolibItem = Skin_LoadProtoIcon(prot, curProtoStatus);
+ if (pa->iRealStatus >= ID_STATUS_OFFLINE && pa->iRealStatus < ID_STATUS_IDLE)
+ pimi->mi.hIcolibItem = Skin_LoadProtoIcon(prot, pa->iRealStatus);
else {
pimi->mi.hIcolibItem = (HICON)CallProtoServiceInt(0, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (pimi->mi.hIcolibItem == (HICON)CALLSERVICE_NOTFOUND)
@@ -792,7 +789,6 @@ void RebuildMenuOrder(void) pMenu->hIcon = nullptr;
pMenu->pMenu = rootmenu;
pMenu->szProto = mir_strdup(pa->szModuleName);
- pMenu->iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
g_menuProtos.insert(pMenu);
char buf[256];
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 1143ab5590..8343314e05 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -55,6 +55,8 @@ static int EnumDbModules(const char *szModuleName, void*) pa->bIsVisible = true;
pa->bIsEnabled = false;
pa->iOrder = accounts.getCount();
+ pa->iIconBase = -1;
+ pa->iRealStatus = ID_STATUS_OFFLINE;
accounts.insert(pa);
}
}
@@ -77,6 +79,8 @@ void LoadDbAccounts(void) if (pa == nullptr) {
pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
pa->szModuleName = szModuleName;
+ pa->iIconBase = -1;
+ pa->iRealStatus = ID_STATUS_OFFLINE;
accounts.insert(pa);
}
else {
@@ -312,8 +316,8 @@ MIR_APP_DLL(int) Proto_GetAverageStatus(int *pAccountNumber) netProtoCount++;
if (averageMode == 0)
- averageMode = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0);
- else if (averageMode > 0 && averageMode != CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0)) {
+ averageMode = pa->iRealStatus;
+ else if (averageMode > 0 && averageMode != pa->iRealStatus) {
averageMode = -1;
if (pAccountNumber == nullptr)
break;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 1ded064a65..87032ad73f 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -61,6 +61,8 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const ch pa->bIsEnabled = pa->bIsVisible = true;
pa->iOrder = accounts.getCount();
pa->szProtoName = mir_strdup(pszBaseProto);
+ pa->iRealStatus = ID_STATUS_OFFLINE;
+ pa->iIconBase = -1;
// if the internal name is empty, generate new one
if (mir_strlen(pszInternal) == 0) {
@@ -456,8 +458,7 @@ public: }
}
else {
- DWORD dwStatus = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0);
- if (dwStatus >= ID_STATUS_ONLINE) {
+ if (pa->iRealStatus >= ID_STATUS_ONLINE) {
wchar_t buf[200];
mir_snwprintf(buf, TranslateT("Account %s is being disabled"), pa->tszAccountName);
if (IDNO == ::MessageBox(m_hwnd, TranslateT("Account is online. Disable account?"), buf, MB_ICONWARNING | MB_DEFBUTTON2 | MB_YESNO))
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 7d9c992a94..0179f80bde 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -130,6 +130,7 @@ MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd) pa->bIsVisible = pa->bIsEnabled = true;
pa->iOrder = accounts.getCount();
pa->iIconBase = -1;
+ pa->iRealStatus = ID_STATUS_OFFLINE;
accounts.insert(pa);
}
pa->bOldProto = true;
|