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 --- plugins/SimpleStatusMsg/src/main.cpp | 289 +++++++++++++++++--------------- plugins/SimpleStatusMsg/src/msgbox.cpp | 54 +++--- plugins/SimpleStatusMsg/src/options.cpp | 79 +++++---- 3 files changed, 227 insertions(+), 195 deletions(-) (limited to 'plugins/SimpleStatusMsg/src') 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); -- cgit v1.2.3