diff options
Diffstat (limited to 'plugins')
74 files changed, 743 insertions, 1151 deletions
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 2f3577df98..e98e60b23a 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -324,10 +324,6 @@ static int ModulesLoaded(WPARAM, LPARAM) g_AvatarHistoryAvail = ServiceExists(MS_AVATARHISTORY_ENABLED);
- int accCount;
- PROTOACCOUNT **accs = nullptr;
- Proto_EnumAccounts(&accCount, &accs);
-
LoadDefaultInfo();
int protoCount;
@@ -335,8 +331,9 @@ static int ModulesLoaded(WPARAM, LPARAM) Proto_EnumProtocols(&protoCount, &proto);
for (int i = 0; i < protoCount; i++)
LoadProtoInfo(proto[i]);
- for (int i = 0; i < accCount; i++)
- LoadAccountInfo(accs[i]);
+
+ for (auto &it : Accounts())
+ LoadAccountInfo(it);
// Load global avatar
protoPicCacheEntry *pce = new protoPicCacheEntry(PCE_TYPE_GLOBAL);
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index da93793d14..d540b4ef83 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -1008,21 +1008,18 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP item.iItem = 1000; // List protocols - PROTOACCOUNT **accs; - int count, num = 0; - - Proto_EnumAccounts(&count, &accs); - for (int i = 0; i < count; i++) { - if (!ProtoServiceExists(accs[i]->szModuleName, PS_GETMYAVATAR)) + int num = 0; + for (auto &it : Accounts()) { + if (!ProtoServiceExists(it->szModuleName, PS_GETMYAVATAR)) continue; - if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName)) + if (!Proto_IsAvatarsEnabled(it->szModuleName)) continue; - ImageList_AddIcon(hIml, Skin_LoadProtoIcon(accs[i]->szModuleName, ID_STATUS_ONLINE)); - item.pszText = accs[i]->tszAccountName; + ImageList_AddIcon(hIml, Skin_LoadProtoIcon(it->szModuleName, ID_STATUS_ONLINE)); + item.pszText = it->tszAccountName; item.iImage = num; - item.lParam = (LPARAM)accs[i]->szModuleName; + item.lParam = (LPARAM)it->szModuleName; ListView_InsertItem(hwndList, &item); num++; diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index aac9a39080..de0710e82a 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -213,19 +213,15 @@ static int InternalRemoveMyAvatar(char *protocol) }
}
else {
- PROTOACCOUNT **accs;
- int i, count;
-
- Proto_EnumAccounts(&count, &accs);
- for (i = 0; i < count; i++) {
- if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR))
+ for (auto &it : Accounts()) {
+ if (!ProtoServiceExists(it->szModuleName, PS_SETMYAVATAR))
continue;
- if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName))
+ if (!Proto_IsAvatarsEnabled(it->szModuleName))
continue;
// Found a protocol
- int retTmp = SaveAvatar(accs[i]->szModuleName, nullptr);
+ int retTmp = SaveAvatar(it->szModuleName, nullptr);
if (retTmp != 0)
ret = retTmp;
}
@@ -510,17 +506,14 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar }
}
else {
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
- for (int i = 0; i < count; i++) {
- if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR))
+ for (auto &it : Accounts()) {
+ if (!ProtoServiceExists(it->szModuleName, PS_SETMYAVATAR))
continue;
- if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName))
+ if (!Proto_IsAvatarsEnabled(it->szModuleName))
continue;
- int retTmp = SetProtoMyAvatar(accs[i]->szModuleName, hBmp, szFinalName, format, data.square, data.grow);
+ int retTmp = SetProtoMyAvatar(it->szModuleName, hBmp, szFinalName, format, data.square, data.grow);
if (retTmp != 0)
ret = retTmp;
}
@@ -610,18 +603,15 @@ INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam) allAcceptXML = TRUE;
allAcceptSWF = TRUE;
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
- for (int i = 0; i < count; i++) {
- if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR))
+ for (auto &it : Accounts()) {
+ if (!ProtoServiceExists(it->szModuleName, PS_SETMYAVATAR))
continue;
- if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName))
+ if (!Proto_IsAvatarsEnabled(it->szModuleName))
continue;
- allAcceptXML = allAcceptXML && Proto_IsAvatarFormatSupported(accs[i]->szModuleName, PA_FORMAT_XML);
- allAcceptSWF = allAcceptSWF && Proto_IsAvatarFormatSupported(accs[i]->szModuleName, PA_FORMAT_SWF);
+ allAcceptXML = allAcceptXML && Proto_IsAvatarFormatSupported(it->szModuleName, PA_FORMAT_XML);
+ allAcceptSWF = allAcceptSWF && Proto_IsAvatarFormatSupported(it->szModuleName, PA_FORMAT_SWF);
}
data.square = db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0);
diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp index 479dfd3fed..a48157af37 100644 --- a/plugins/AddContactPlus/src/addcontact.cpp +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -79,15 +79,13 @@ void AddContactDlgOpts(HWND hdlg, const char* szProto, BOOL bAuthOptsOnly = FALS bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs)
{
- PROTOACCOUNT** pAccounts;
- int iRealAccCount, iAccCount = 0;
+ int iAccCount = 0;
- Proto_EnumAccounts(&iRealAccCount, &pAccounts);
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled())
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME)
iAccCount++;
}
@@ -112,23 +110,26 @@ bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs) cbei.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM;
HDC hdc = GetDC(hdlg);
SelectObject(hdc, (HFONT)SendDlgItemMessage(hdlg, IDC_PROTO, WM_GETFONT, 0, 0));
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled()) continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
+ continue;
+
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (!(dwCaps & PF1_BASICSEARCH) && !(dwCaps & PF1_EXTSEARCH) && !(dwCaps & PF1_SEARCHBYEMAIL) && !(dwCaps & PF1_SEARCHBYNAME))
continue;
- cbei.pszText = pAccounts[i]->tszAccountName;
+ cbei.pszText = pa->tszAccountName;
GetTextExtentPoint32(hdc, cbei.pszText, (int)mir_wstrlen(cbei.pszText), &textSize);
if (textSize.cx > cbWidth)
cbWidth = textSize.cx;
- HICON hIcon = (HICON)CallProtoService(pAccounts[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ HICON hIcon = (HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon(hIml, hIcon);
DestroyIcon(hIcon);
- cbei.lParam = (LPARAM)pAccounts[i]->szModuleName;
+ cbei.lParam = (LPARAM)pa->szModuleName;
SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
- if (cbei.lParam && !mir_strcmp(acs->proto, pAccounts[i]->szModuleName))
+ if (cbei.lParam && !mir_strcmp(acs->proto, pa->szModuleName))
iIndex = cbei.iItem;
cbei.iItem++;
}
diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp index 9c80075431..30611ab8aa 100644 --- a/plugins/AddContactPlus/src/main.cpp +++ b/plugins/AddContactPlus/src/main.cpp @@ -74,15 +74,12 @@ static INT_PTR AddContactPlusDialog(WPARAM, LPARAM) static int OnAccListChanged(WPARAM, LPARAM)
{
- PROTOACCOUNT** pAccounts;
- int iRealAccCount, iAccCount = 0;
-
- Proto_EnumAccounts(&iRealAccCount, &pAccounts);
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled())
+ int iAccCount = 0;
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME)
iAccCount++;
}
diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 662196b3ca..f16108840d 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -51,13 +51,10 @@ static BOOL CALLBACK DisplayCpuUsageProc(BYTE nCpuUsage, LPARAM lParam) static bool AnyProtoHasCaps(DWORD caps1)
{
- int nProtoCount;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&nProtoCount, &protos);
-
- for (int i = 0; i < nProtoCount; ++i)
- if (CallProtoService(protos[i]->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&caps1)
+ for (auto &pa : Accounts())
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0) & caps1)
return true; /* CALLSERVICE_NOTFOUND also handled gracefully */
+
return false;
}
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp index a63999c415..cf4a830c2a 100644 --- a/plugins/CSList/src/cslist.cpp +++ b/plugins/CSList/src/cslist.cpp @@ -93,13 +93,9 @@ static int OnInitOptions(WPARAM wparam, LPARAM) static int OnCreateMenuItems(WPARAM, LPARAM) { - int protoCount; - PROTOACCOUNT** pdesc; - Proto_EnumAccounts(&protoCount, &pdesc); - - for (int i = 0; i < protoCount; i++) - if (ProtoServiceExists(pdesc[i]->szModuleName, PS_SETCUSTOMSTATUSEX)) - addProtoStatusMenuItem(pdesc[i]->szModuleName); + for (auto &pa : Accounts()) + if (ProtoServiceExists(pa->szModuleName, PS_SETCUSTOMSTATUSEX)) + addProtoStatusMenuItem(pa->szModuleName); return 0; } diff --git a/plugins/Clist_blind/src/clistopts.cpp b/plugins/Clist_blind/src/clistopts.cpp index 05423af61c..7192649702 100644 --- a/plugins/Clist_blind/src/clistopts.cpp +++ b/plugins/Clist_blind/src/clistopts.cpp @@ -90,16 +90,13 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global"));
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)0);
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
- for (int i = 0; i < count; i++) {
- if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled() || CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)accs[i]);
- if (!mir_strcmp(szPrimaryStatus, accs[i]->szModuleName))
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)pa);
+ if (!mir_strcmp(szPrimaryStatus, pa->szModuleName))
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0);
}
}
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 56b9b2ace6..11f08454c7 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -470,12 +470,9 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar static int _GetNetVisibleProtoCount()
{
- int count, netProtoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
-
- for (int i = 0, netProtoCount = 0; i < count; i++)
- if (accs[i]->IsVisible())
+ int netProtoCount = 0;
+ for (auto &pa : Accounts())
+ if (pa->IsVisible())
netProtoCount++;
return netProtoCount;
@@ -606,22 +603,19 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L // == Tray icon mode ==
// preparing account list.
{
- int AccNum, i, siS, siV, item;
- PROTOACCOUNT **acc;
- Proto_EnumAccounts(&AccNum, &acc);
-
- for (siS = siV = -1, i = 0; i < AccNum; i++) {
- if (!acc[i]->bIsVirtual && acc[i]->bIsVisible && !acc[i]->bDynDisabled && acc[i]->bIsEnabled) {
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)acc[i]);
+ int siS = -1, siV = -1;
+ for (auto &pa : Accounts()) {
+ if (!pa->bIsVirtual && pa->bIsVisible && !pa->bDynDisabled && pa->bIsEnabled) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)pa);
- if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(0, "CList", "tiAccS")))
+ if (!mir_strcmp(pa->szModuleName, db_get_sa(0, "CList", "tiAccS")))
siS = item;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)acc[i]);
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)pa);
- if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(0, "CList", "tiAccV")))
+ if (!mir_strcmp(pa->szModuleName, db_get_sa(0, "CList", "tiAccV")))
siV = item;
}
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 49d924a24b..20ae2065a3 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -274,17 +274,12 @@ void SettingsMigrate(void) static int GetGoodAccNum(bool *bDiffers, bool *bConn = nullptr)
{
- PROTOACCOUNT **acc;
- int AccNum;
- Proto_EnumAccounts(&AccNum, &acc);
-
*bDiffers = false;
if (bConn)
*bConn = false;
int iPrevStatus = 0, res = 0;
- while (AccNum--) {
- PROTOACCOUNT *pa = acc[AccNum];
+ for (auto &pa : Accounts()) {
if (!pa->IsVisible())
continue;
@@ -373,15 +368,9 @@ int cliTrayIconInit(HWND hwnd) break;
case TRAY_ICON_MODE_ALL:
- PROTOACCOUNT **acc;
- int AccNum;
- Proto_EnumAccounts(&AccNum, &acc);
-
- for (int i = AccNum; i--;) {
- PROTOACCOUNT *pa = acc[i];
+ for (auto &pa : Accounts().rev_iter())
if (pa->IsVisible() && pa->ppro != nullptr)
pcli->pfnTrayIconAdd(hwnd, pa->szModuleName, nullptr, pa->ppro->m_iStatus);
- }
break;
}
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 7763e5c34a..64b47b95d8 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -1053,13 +1053,9 @@ int CLUI_ReloadCLUIOptions() void CLUI_DisconnectAll()
{
- PROTOACCOUNT **accs;
- int nProtoCount;
- Proto_EnumAccounts(&nProtoCount, &accs);
-
- for (int nProto = 0; nProto < nProtoCount; nProto++)
- if (accs[nProto]->IsEnabled())
- CallProtoService(accs[nProto]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
+ for (auto &pa : Accounts())
+ if (pa->IsEnabled())
+ CallProtoService(pa->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
}
static int CLUI_DrawMenuBackGround(HWND hwnd, HDC hdc, int item, int state)
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 3e15378cf1..c56b9622f9 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -76,15 +76,10 @@ DWORD CompareContacts2_getLMTime(MCONTACT hContact) int GetProtoIndex(char * szName)
{
- if (szName) {
- PROTOACCOUNT **accs = nullptr;
- int accCount = 0;
- Proto_EnumAccounts(&accCount, &accs);
-
- for (int i = 0; i < accCount; i++)
- if (!mir_strcmpi(szName, accs[i]->szModuleName))
- return accs[i]->iOrder;
- }
+ if (szName)
+ for (auto &pa : Accounts())
+ if (!mir_strcmpi(szName, pa->szModuleName))
+ return pa->iOrder;
return -1;
}
diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index ccb7808d7b..1b396c6652 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -167,14 +167,12 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) ProtosData.destroy();
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
- if (protoCount == 0)
+ auto &accs = Accounts();
+ if (accs.getCount() == 0)
return 0;
int iProtoInStatusMenu = 0;
- for (int j = 0; j < protoCount; j++) {
+ for (int j = 0; j < accs.getCount(); j++) {
int i = pcli->pfnGetAccountIndexByPos(j);
if (i == -1)
continue;
@@ -266,7 +264,6 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) return 0;
// START MULTILINE HERE
- int orig_protoCount = protoCount;
int orig_visProtoCount = ProtosData.getCount();
int protosperline = 0;
@@ -274,9 +271,9 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) protosperline = g_StatusBarData.nProtosPerLine;
else if (orig_visProtoCount)
protosperline = orig_visProtoCount;
- else if (protoCount) {
- protosperline = protoCount;
- orig_visProtoCount = protoCount;
+ else if (accs.getCount()) {
+ protosperline = accs.getCount();
+ orig_visProtoCount = accs.getCount();
}
else {
protosperline = 1;
@@ -287,7 +284,6 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) int linecount = protosperline ? (orig_visProtoCount + (protosperline - 1)) / protosperline : 1; // divide with rounding to up
for (int line = 0; line < linecount; line++) {
int rowheight = 2 + max(textSize.cy, iconHeight);
- protoCount = min(protosperline, (orig_protoCount - line*protosperline));
int visProtoCount = min(protosperline, (orig_visProtoCount - line*protosperline));
GetClientRect(hWnd, &rc);
diff --git a/plugins/Clist_modern/src/modern_statusbar_options.cpp b/plugins/Clist_modern/src/modern_statusbar_options.cpp index 69bd3e30d2..6a56cd1270 100644 --- a/plugins/Clist_modern/src/modern_statusbar_options.cpp +++ b/plugins/Clist_modern/src/modern_statusbar_options.cpp @@ -158,22 +158,18 @@ INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // populate per-proto list box.
SendMessage(hwndComboBox, CB_RESETCONTENT, 0, 0);
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
-
SendMessage(hwndComboBox, CB_ADDSTRING, 0, (LPARAM)TranslateT("<<Global>>"));
SendMessage(hwndComboBox, CB_SETITEMDATA, 0, 0);
- for (int i = 0; i < count; i++) {
- if (accs[i]->bIsVirtual)
+ for (auto &pa : Accounts()) {
+ if (pa->bIsVirtual)
continue;
- char *szName = accs[i]->szModuleName;
+ char *szName = pa->szModuleName;
dat = (StatusBarProtocolOptions *)mir_calloc(sizeof(StatusBarProtocolOptions));
dat->szName = szName;
- DWORD dwNewId = SendMessage(hwndComboBox, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
+ DWORD dwNewId = SendMessage(hwndComboBox, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
SendMessage(hwndComboBox, CB_SETITEMDATA, dwNewId, (LPARAM)dat);
char buf[256];
@@ -205,8 +201,7 @@ INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->PaddingRight = db_get_dw(0, "CLUI", buf, SETTING_PADDINGRIGHT_DEFAULT);
}
- if (count)
- SendMessage(hwndComboBox, CB_SETCURSEL, 0, 0);
+ SendMessage(hwndComboBox, CB_SETCURSEL, 0, 0);
}
_GlobalOptions.AccountIsCustomized = TRUE;
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 565d2edaeb..f51c72b5ed 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -208,17 +208,12 @@ static int FillDialog(HWND hwnd) ListView_InsertColumn(GetDlgItem(hwnd, IDC_PROTOCOLS), 0, &lvc);
// fill protocols...
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
- {
- LVITEMA item = { 0 };
- item.mask = LVIF_TEXT;
- item.iItem = 1000;
- for (int i = 0; i < protoCount; i++) {
- item.pszText = accs[i]->szModuleName;
- SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
- }
+ LVITEMA item = { 0 };
+ item.mask = LVIF_TEXT;
+ item.iItem = 1000;
+ for (auto &pa : Accounts()) {
+ item.pszText = pa->szModuleName;
+ SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
}
ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
diff --git a/plugins/Clist_nicer/src/clistopts.cpp b/plugins/Clist_nicer/src/clistopts.cpp index d713c58080..44fab1e82e 100644 --- a/plugins/Clist_nicer/src/clistopts.cpp +++ b/plugins/Clist_nicer/src/clistopts.cpp @@ -89,16 +89,13 @@ INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global"));
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)0);
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
- for (int i = 0; i < count; i++) {
- if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled() || CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)accs[i]);
- if (!mir_strcmp(szPrimaryStatus, accs[i]->szModuleName))
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)pa);
+ if (!mir_strcmp(szPrimaryStatus, pa->szModuleName))
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0);
}
}
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index bf76dfffae..78de87fb99 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -259,17 +259,14 @@ static void InitIcoLib() Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Overlay icons"), &icon, 1); } - PROTOACCOUNT **accs = nullptr; - int p_count = 0; - Proto_EnumAccounts(&p_count, &accs); - for (int k = 0; k < p_count; k++) { - if (!accs[k]->IsEnabled() || CallProtoService(accs[k]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) + for (auto &pa : Accounts()) { + if (!pa->IsEnabled() || CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; wchar_t szDescr[128]; - mir_snwprintf(szDescr, TranslateT("%s connecting"), accs[k]->tszAccountName); + mir_snwprintf(szDescr, TranslateT("%s connecting"), pa->tszAccountName); IconItemT icon = { szDescr, "conn", IDI_PROTOCONNECTING }; - Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Connecting icons"), &icon, 1, accs[k]->szModuleName); + Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Connecting icons"), &icon, 1, pa->szModuleName); } } diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp index 2e84ed6039..7f88c7b9fe 100644 --- a/plugins/Clist_nicer/src/cluiservices.cpp +++ b/plugins/Clist_nicer/src/cluiservices.cpp @@ -57,10 +57,8 @@ void CluiProtocolStatusChanged(int, const char*) if (pcli->hwndStatus == nullptr || cfg::shutDown)
return;
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
- if (protoCount == 0)
+ auto &accs = Accounts();
+ if (accs.getCount() == 0)
return;
FreeProtocolData();
@@ -70,7 +68,7 @@ void CluiProtocolStatusChanged(int, const char*) int borders[3];
SendMessage(pcli->hwndStatus, SB_GETBORDERS, 0, (LPARAM)&borders);
- int *partWidths = (int*)_alloca((protoCount + 1)*sizeof(int));
+ int *partWidths = (int*)_alloca((accs.getCount() + 1)*sizeof(int));
int partCount;
if (cfg::dat.bEqualSections) {
@@ -78,13 +76,14 @@ void CluiProtocolStatusChanged(int, const char*) GetClientRect(pcli->hwndStatus, &rc);
rc.right -= borders[0] * 2;
int toshow = 0;
- for (int i = 0; i < protoCount; i++)
- if (accs[i]->IsVisible())
+ for (auto &pa : accs)
+ if (pa->IsVisible())
toshow++;
if (toshow > 0) {
- for (int part = 0, i = 0; i < protoCount; i++) {
- if (!accs[i]->IsVisible())
+ int part = 0;
+ for (auto &pa : accs) {
+ if (!pa->IsVisible())
continue;
partWidths[part] = ((rc.right - rc.left - rdelta) / toshow)*(part + 1) + cfg::dat.bCLeft;
@@ -106,7 +105,7 @@ void CluiProtocolStatusChanged(int, const char*) // count down since built in ones tend to go at the end
partCount = 0;
- for (int i = 0; i < protoCount; i++) {
+ for (int i = 0; i < accs.getCount(); i++) {
int idx = pcli->pfnGetAccountIndexByPos(i);
if (idx == -1)
continue;
@@ -151,7 +150,7 @@ void CluiProtocolStatusChanged(int, const char*) // count down since built in ones tend to go at the end
char *szMaxProto = nullptr;
partCount = 0;
- for (int i = 0; i < protoCount; i++) {
+ for (int i = 0; i < accs.getCount(); i++) {
int idx = pcli->pfnGetAccountIndexByPos(i);
if (idx == -1)
continue;
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 7b8ff8a8ff..fb674e4b5e 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -277,20 +277,17 @@ void LoadExtBkSettingsFromDB() arStatusItems.insert(p);
}
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
-
- for (int i = 0; i < protoCount; i++) {
+ auto &accs = Accounts();
+ for (auto &pa : accs) {
StatusItems_t *p = (StatusItems_t*)mir_alloc(sizeof(StatusItems_t));
*p = _StatusItems[0];
ID_EXTBK_LAST++;
- mir_snprintf(p->szDBname, "EXBK_%s", accs[i]->szModuleName);
- if (i == 0)
- mir_snprintf(p->szName, "{-}%s", accs[i]->szModuleName);
+ mir_snprintf(p->szDBname, "EXBK_%s", pa->szModuleName);
+ if (accs.indexOf(&pa) == 0)
+ mir_snprintf(p->szName, "{-}%s", pa->szModuleName);
else
- strncpy_s(p->szName, accs[i]->szModuleName, _TRUNCATE);
+ strncpy_s(p->szName, pa->szModuleName, _TRUNCATE);
p->statusID = ID_EXTBK_LAST;
arStatusItems.insert(p);
}
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index c6851bf790..1939f5ec24 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -160,8 +160,6 @@ static int FillDialog(HWND hwnd) LVCOLUMN lvc = { 0 };
HWND hwndList = GetDlgItem(hwnd, IDC_PROTOCOLS);
LVITEM item = { 0 };
- int protoCount = 0, i;
- PROTOACCOUNT **accs = nullptr;
CLVM_EnumModes(FillModes);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES);
@@ -170,13 +168,11 @@ static int FillDialog(HWND hwnd) ListView_InsertColumn(hwndList, 0, &lvc);
// fill protocols...
-
- Proto_EnumAccounts(&protoCount, &accs);
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = 1000;
- for (i = 0; i < protoCount; i++) {
- item.lParam = (LPARAM)accs[i]->szModuleName;
- item.pszText = accs[i]->tszAccountName;
+ for (auto &pa : Accounts()) {
+ item.lParam = (LPARAM)pa->szModuleName;
+ item.pszText = pa->tszAccountName;
ListView_InsertItem(hwndList, &item);
}
@@ -195,7 +191,7 @@ static int FillDialog(HWND hwnd) SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
wchar_t *grpName;
- for (i = 1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++) {
+ for (int i = 1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++) {
item.pszText = grpName;
SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
}
@@ -209,7 +205,7 @@ static int FillDialog(HWND hwnd) lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
ListView_InsertColumn(hwndList, 0, &lvc);
- for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
item.pszText = TranslateW(pcli->pfnGetStatusModeDescription(i, 0));
item.iItem = i - ID_STATUS_OFFLINE;
ListView_InsertItem(hwndList, &item);
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index acad40a2ed..2055973420 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -66,20 +66,15 @@ int Get2StateValue(wchar_t *state) int AccountName2Protocol(const wchar_t *accountName, OUT char *uniqueProtocolName, size_t length)
{
- int count;
- PROTOACCOUNT **accounts = nullptr;
- Proto_EnumAccounts(&count, &accounts);
-
strncpy_s(uniqueProtocolName, length, _T2A(accountName), _TRUNCATE);
- for (int i = 0; i < count; i++) {
- if (accounts[i]->bIsEnabled) {
- if (_wcsicmp(accountName, accounts[i]->tszAccountName) == 0) {
- strncpy_s(uniqueProtocolName, length, accounts[i]->szModuleName, _TRUNCATE);
+ for (auto &pa : Accounts())
+ if (pa->bIsEnabled) {
+ if (_wcsicmp(accountName, pa->tszAccountName) == 0) {
+ strncpy_s(uniqueProtocolName, length, pa->szModuleName, _TRUNCATE);
return 0;
}
}
- }
return 1;
}
@@ -203,20 +198,15 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep PrettyStatusMode(status, pretty, _countof(pretty));
CMStringW perAccountStatus;
-
- int count;
- PROTOACCOUNT **accounts = nullptr;
- Proto_EnumAccounts(&count, &accounts);
-
wchar_t pn[128];
- for (int i = 0; i < count; i++) {
- if (accounts[i]->bIsEnabled) {
- status = CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0);
+ for (auto &pa : Accounts()) {
+ if (pa->bIsEnabled) {
+ status = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
PrettyStatusMode(status, pn, _countof(pn));
perAccountStatus.AppendChar('\n');
- perAccountStatus.Append(accounts[i]->tszAccountName);
+ perAccountStatus.Append(pa->tszAccountName);
perAccountStatus.Append(L": ");
perAccountStatus.Append(pn);
}
@@ -233,9 +223,8 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep if (status) {
INT_PTR old = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
wchar_t po[128];
- if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) {
+ if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE))
announce_status_change(nullptr, status, nullptr);
- }
PrettyStatusMode(old, po, _countof(po));
Clist_SetStatusMode(status);
@@ -300,19 +289,16 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re case 3:
{
wchar_t *awayMsg = argv[2];
- int count = 0;
- PROTOACCOUNT **accounts = nullptr;
- Proto_EnumAccounts(&count, &accounts);
CMStringW szReply;
- for (int i = 0; i < count; i++) {
- if (!accounts[i]->bIsEnabled)
+ for (auto &pa : Accounts()) {
+ if (!pa->bIsEnabled)
continue;
- if (i != 0)
+ if (!szReply.IsEmpty())
szReply.AppendChar('\n');
- char *protocol = accounts[i]->szModuleName;
+ char *protocol = pa->szModuleName;
if ((CallProtoService(protocol, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) != 0) { //if the protocol supports away messages
INT_PTR status = CallProtoService(protocol, PS_GETSTATUS, 0, 0);
INT_PTR res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM)awayMsg);
@@ -320,11 +306,11 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re wchar_t pn[128];
PrettyStatusMode(status, pn, _countof(pn));
if (res)
- szReply.AppendFormat(TranslateT("Failed to set '%s' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName, awayMsg, pn);
+ szReply.AppendFormat(TranslateT("Failed to set '%s' status message to '%s' (status is '%s')."), pa->tszAccountName, awayMsg, pn);
else
- szReply.AppendFormat(TranslateT("Successfully set '%s' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName, awayMsg, pn);
+ szReply.AppendFormat(TranslateT("Successfully set '%s' status message to '%s' (status is '%s')."), pa->tszAccountName, awayMsg, pn);
}
- else szReply.AppendFormat(TranslateT("Account '%s' does not support away messages, skipping."), accounts[i]->tszAccountName);
+ else szReply.AppendFormat(TranslateT("Account '%s' does not support away messages, skipping."), pa->tszAccountName);
}
wcsncpy_s(reply->message, szReply, _TRUNCATE);
reply->code = MIMRES_SUCCESS;
@@ -1107,11 +1093,6 @@ void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply repl char protocol[128];
AccountName2Protocol(account, protocol, _countof(protocol));
- int count = 0;
- PROTOACCOUNT **accounts = nullptr;
- Proto_EnumAccounts(&count, &accounts);
-
- int i;
int global = (mir_strcmp(protocol, "GLOBAL") == 0);
reply->message[0] = 0;
@@ -1124,15 +1105,14 @@ void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply repl char *match;
- for (i = 0; i < count; i++) {
- if (accounts[i]->bIsEnabled) {
- match = accounts[i]->szModuleName;
+ for (auto &pa : Accounts())
+ if (pa->bIsEnabled) {
+ match = pa->szModuleName;
if ((global) || (mir_strcmp(protocol, match) == 0)) {
HandleProtocolProxyCommand(command, argv, argc, reply, match, match);
found = 1;
}
}
- }
if (!found) {
reply->code = MIMRES_FAILURE;
diff --git a/plugins/DbEditorPP/src/icons.cpp b/plugins/DbEditorPP/src/icons.cpp index 6a98c9a86d..a80958d752 100644 --- a/plugins/DbEditorPP/src/icons.cpp +++ b/plugins/DbEditorPP/src/icons.cpp @@ -72,14 +72,10 @@ HIMAGELIST LoadIcons() for (auto &it : dbeIcons)
ImageList_AddIcon(hil, LoadSkinnedDBEIcon(it));
- int protoCount = 0;
- PROTOACCOUNT **protocols = nullptr;
- Proto_EnumAccounts(&protoCount, &protocols);
-
- for (int i = 0; i < protoCount; i++) {
- if (!Proto_GetAccount(protocols[i]->szModuleName))
+ for (auto &pa : Accounts()) {
+ if (!Proto_GetAccount(pa->szModuleName))
ImageList_AddIcon(hil, LoadSkinnedDBEIcon(ICO_OFFLINE));
- else if (hIcon = Skin_LoadProtoIcon(protocols[i]->szModuleName, ID_STATUS_ONLINE))
+ else if (hIcon = Skin_LoadProtoIcon(pa->szModuleName, ID_STATUS_ONLINE))
ImageList_AddIcon(hil, hIcon);
else
ImageList_AddIcon(hil, LoadSkinnedDBEIcon(ICO_ONLINE));
@@ -91,13 +87,10 @@ HIMAGELIST LoadIcons() int GetProtoIconIndex(const char *szProto)
{
if (szProto && szProto[0]) {
- int protoCount = 0;
- PROTOACCOUNT **protocols = nullptr;
- Proto_EnumAccounts(&protoCount, &protocols);
-
- for (int i = 0; i < protoCount; i++)
- if (!mir_strcmp(protocols[i]->szModuleName, szProto))
- return i + _countof(dbeIcons);
+ auto &accs = Accounts();
+ for (auto &pa : accs)
+ if (!mir_strcmp(pa->szModuleName, szProto))
+ return accs.indexOf(&pa) + _countof(dbeIcons);
if (Proto_GetAccount(szProto))
return _countof(dbeIcons) - 2; // ICO_ONLINE;
diff --git a/plugins/HistoryStats/src/dlgoption_subglobal.cpp b/plugins/HistoryStats/src/dlgoption_subglobal.cpp index 2ceed39e26..5f340c857e 100644 --- a/plugins/HistoryStats/src/dlgoption_subglobal.cpp +++ b/plugins/HistoryStats/src/dlgoption_subglobal.cpp @@ -239,17 +239,8 @@ void DlgOption::SubGlobal::onWMInitDialog() // insert known protocols
m_hHideContactMenuProtos.clear();
- PROTOACCOUNT **protoList;
- int protoCount;
- Proto_EnumAccounts(&protoCount, &protoList);
- upto_each_(i, protoCount)
- {
- m_hHideContactMenuProtos.push_back(m_Options.insertCheck(
- m_hProtocols,
- protoList[i]->tszAccountName,
- 0,
- reinterpret_cast<INT_PTR>(protoList[i]->szModuleName)));
- }
+ for (auto &pa : Accounts())
+ m_hHideContactMenuProtos.push_back(m_Options.insertCheck(m_hProtocols, pa->tszAccountName, 0, INT_PTR(pa->szModuleName)));
m_Options.ensureVisible(nullptr);
diff --git a/plugins/HistoryStats/src/dlgoption_subinput.cpp b/plugins/HistoryStats/src/dlgoption_subinput.cpp index f87cf76cde..31f836c87f 100644 --- a/plugins/HistoryStats/src/dlgoption_subinput.cpp +++ b/plugins/HistoryStats/src/dlgoption_subinput.cpp @@ -99,17 +99,8 @@ void DlgOption::SubInput::onWMInitDialog() // insert known protocols
m_hProtosIgnore.clear();
- PROTOACCOUNT **protoList;
- int protoCount;
- Proto_EnumAccounts(&protoCount, &protoList);
- upto_each_(i, protoCount)
- {
- m_hProtosIgnore.push_back(m_Options.insertCheck(
- m_hProtocols,
- protoList[i]->tszAccountName,
- 0,
- reinterpret_cast<INT_PTR>(protoList[i]->szModuleName)));
- }
+ for (auto &pa : Accounts())
+ m_hProtosIgnore.push_back(m_Options.insertCheck(m_hProtocols, pa->tszAccountName, 0, INT_PTR(pa->szModuleName)));
// diable filtering raw RTF if 'rtfconv.dll' isn't available
if (!RTFFilter::available())
diff --git a/plugins/HistoryStats/src/mirandahistory.cpp b/plugins/HistoryStats/src/mirandahistory.cpp index 792b6fcf46..6caea4fb75 100644 --- a/plugins/HistoryStats/src/mirandahistory.cpp +++ b/plugins/HistoryStats/src/mirandahistory.cpp @@ -11,13 +11,9 @@ void MirandaHistory::populateProtocols() {
m_Protocols.clear();
- PROTOACCOUNT **protoList;
- int protoCount;
- Proto_EnumAccounts(&protoCount, &protoList);
- upto_each_(i, protoCount)
- {
- ext::a::string protoName = protoList[i]->szModuleName;
- m_Protocols[protoName] = protoList[i]->tszAccountName;
+ for (auto &pa : Accounts()) {
+ ext::a::string protoName = pa->szModuleName;
+ m_Protocols[protoName] = pa->tszAccountName;
}
m_DefaultProtocol = TranslateT("(Unknown)");
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index c1ad7c19d5..127a21ff5e 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -261,14 +261,12 @@ static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("<New account>"));
SendMessage(hwndCombo, CB_SETITEMDATA, 0, lvitem.lParam);
- int protoCount, iSel = 0;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
- for (int i = 0; i < protoCount; i++) {
- int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
- SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)accs[i]);
+ int iSel = 0;
+ for (auto &it : Accounts()) {
+ int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)it->tszAccountName);
+ SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)it);
- if (!mir_wstrcmpi(accs[i]->tszAccountName, tszText))
+ if (!mir_wstrcmpi(it->tszAccountName, tszText))
iSel = idx;
}
@@ -379,13 +377,8 @@ static bool FindDestAccount(const char *szProto) static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const wchar_t *ptszName, bool bStrict)
{
- int destProtoCount;
- PROTOACCOUNT **destAccs;
- Proto_EnumAccounts(&destProtoCount, &destAccs);
-
PROTOACCOUNT *pProto = nullptr;
- for (int i = 0; i < destProtoCount; i++) {
- PROTOACCOUNT *pa = destAccs[i];
+ for (auto &pa : Accounts()) {
// already used? skip
if (FindDestAccount(pa->szModuleName))
continue;
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 86706d178a..3e6a15fdfb 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -94,10 +94,7 @@ static int ModulesLoaded(WPARAM, LPARAM) if (!db_get_b(NULL, IMPORT_MODULE, IMP_KEY_FR, 0)) {
// Only autorun import wizard if at least one protocol is installed
- int nProtocols = 0;
- PROTOACCOUNT **ppProtos = nullptr;
- Proto_EnumAccounts(&nProtocols, &ppProtos);
- if (nProtocols > 0) {
+ if (Accounts().getCount() > 0) {
CallService(IMPORT_SERVICE, 0, 0);
db_set_b(NULL, IMPORT_MODULE, IMP_KEY_FR, 1);
}
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 6233fae662..79ba940b61 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -220,13 +220,9 @@ int ModulesLoaded(WPARAM, LPARAM) proto_items[0].old_xstatus_message[0] = '\0';
// Add each proto
- PROTOACCOUNT **protos;
- int count;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- if (protos[i]->bIsEnabled)
- RegisterProtocol(protos[i]->szModuleName, protos[i]->tszAccountName);
+ for (auto &pa : Accounts())
+ if (pa->bIsEnabled)
+ RegisterProtocol(pa->szModuleName, pa->tszAccountName);
HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged);
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 877ad01dbc..f4845deb7e 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -485,16 +485,12 @@ void MirandaUtils::translateOldDBNames() { db_free(&opt2Dbv);
}
- //account's settings "ACCOUNTSTATE_"
- int accountsTmpCount = 0;
- PROTOACCOUNT **accountsTmp;
- Proto_EnumAccounts(&accountsTmpCount, &accountsTmp);
-
- for(int i=0; i<accountsTmpCount; i++) {
- logger->log_p(L"TranslateOldDBNames: found ACCOUNT: [%s] protocol: [%S]", accountsTmp[i]->tszAccountName, accountsTmp[i]->szProtoName);
+ // account's settings "ACCOUNTSTATE_"
+ for (auto &pa : Accounts()) {
+ logger->log_p(L"TranslateOldDBNames: found ACCOUNT: [%s] protocol: [%S]", pa->tszAccountName, pa->szProtoName);
std::string mirandaAccountDBKey("ACCOUNTSTATE_");
- mirandaAccountDBKey += accountsTmp[i]->szModuleName;
+ mirandaAccountDBKey += pa->szModuleName;
int keyValue = db_get_b(0, OLD_PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0);
if (keyValue != 0){
db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), keyValue);
diff --git a/plugins/MirFox/src/MirfoxData.cpp b/plugins/MirFox/src/MirfoxData.cpp index aad3018e48..9a29cf99d7 100644 --- a/plugins/MirFox/src/MirfoxData.cpp +++ b/plugins/MirFox/src/MirfoxData.cpp @@ -582,39 +582,27 @@ MirfoxData::initializeMirandaAccounts() clearMirandaAccounts();
//get accounts from Miranda by CallService MS_PROTO_ENUMACCOUNTS
- int accountsCount = 0;
- PROTOACCOUNT **accounts;
- Proto_EnumAccounts(&accountsCount, &accounts);
-
- for(int i=0; i<accountsCount; i++) {
-
- //checking account
- if(accounts[i]->bIsEnabled == 0){
+ for (auto &pa : Accounts()) {
+ // checking account
+ if (pa->bIsEnabled == 0)
continue;
- }
- if(accounts[i]->bDynDisabled != 0){
+
+ if (pa->bDynDisabled != 0)
continue;
- }
//add to list
- MirandaAccount* mirandaAccountItemPtr = new MirandaAccount(
- mirfoxAccountIdPool,
- accounts[i]->szModuleName,
- accounts[i]->tszAccountName,
- accounts[i]->szProtoName,
- accounts[i]->iOrder
- );
+ MirandaAccount* mirandaAccountItemPtr = new MirandaAccount(mirfoxAccountIdPool, pa->szModuleName, pa->tszAccountName, pa->szProtoName, pa->iOrder);
MFLogger* logger = MFLogger::getInstance();
- logger->log_p(L"initializeMirandaAccounts: tszAccountName: [%s] protocol: [%S]", accounts[i]->tszAccountName, accounts[i]->szProtoName );
+ logger->log_p(L"initializeMirandaAccounts: tszAccountName: [%s] protocol: [%S]", pa->tszAccountName, pa->szProtoName);
mirfoxAccountIdPool++;
- if (accounts[i]->iOrder > maxAccountIOrder) maxAccountIOrder = accounts[i]->iOrder;
+ if (pa->iOrder > maxAccountIOrder)
+ maxAccountIOrder = pa->iOrder;
mirandaAccountItemPtr->accountState = createOrGetAccountStateFromDB(mirandaAccountItemPtr);
addMirandaAccount(mirandaAccountItemPtr);
-
}
//TODO - sort by mirandaAccount.displayOrder
diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index c458cce276..3092cdd8e9 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -365,24 +365,21 @@ static INT_PTR CALLBACK DlgProcMirOTROptsProto(HWND hwndDlg, UINT msg, WPARAM wP { LV_ITEM item = { 0 }; - int num_protocols; - PROTOACCOUNT **pppDesc; - Proto_EnumAccounts(&num_protocols, &pppDesc); - for (int i = 0; i < num_protocols; i++) { - if (!mir_strcmp(pppDesc[i]->szModuleName, META_PROTO)) + for (auto &pa : Accounts()) { + if (!mir_strcmp(pa->szModuleName, META_PROTO)) continue; - if ((CallProtoService(pppDesc[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM) == 0) + if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM) == 0) continue; item.mask = LVIF_TEXT | LVIF_PARAM; - item.pszText = pppDesc[i]->tszAccountName; - item.lParam = (LPARAM)pppDesc[i]->szModuleName; + item.pszText = pa->tszAccountName; + item.lParam = (LPARAM)pa->szModuleName; int ilvItem = ListView_InsertItem(lv, &item); - ListView_SetItemText(lv, ilvItem, 1, (wchar_t*)policy_to_string(db_get_dw(0, MODULENAME"_ProtoPol", pppDesc[i]->szModuleName, CONTACT_DEFAULT_POLICY))); + ListView_SetItemText(lv, ilvItem, 1, (wchar_t*)policy_to_string(db_get_dw(0, MODULENAME"_ProtoPol", pa->szModuleName, CONTACT_DEFAULT_POLICY))); char fprint[45]; - if (otrl_privkey_fingerprint(otr_user_state, fprint, pppDesc[i]->szModuleName, pppDesc[i]->szModuleName)) { + if (otrl_privkey_fingerprint(otr_user_state, fprint, pa->szModuleName, pa->szModuleName)) { wchar_t *temp = mir_a2u(fprint); ListView_SetItemText(lv, ilvItem, 2, temp); mir_free(temp); diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 3abdd9c0cb..2f3375b481 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -81,23 +81,18 @@ bool CAppletManager::Initialize(tstring strAppletName) m_hMIHookChatEvent = HookEvent(ME_GC_HOOK_EVENT, CAppletManager::HookChatInbound); // enumerate protocols - int iCount; int iProtoCount = 0; - PROTOACCOUNT **ppAccounts; CProtocolData *pProtoData = nullptr; CIRCConnection *pIRCConnection = nullptr; - Proto_EnumAccounts(&iCount, &ppAccounts); - for (int i = 0; i < iCount; i++) { - /**if(ppProtocolDescriptor[i]->type != PROTOTYPE_PROTOCOL) - continue;**/ - if (ppAccounts[i]->bIsEnabled == 0) + for (auto &pa : Accounts()) { + if (pa->bIsEnabled == 0) continue; iProtoCount++; pProtoData = new CProtocolData(); pProtoData->iStatus = ID_STATUS_OFFLINE; - pProtoData->strProtocol = toTstring(ppAccounts[i]->szModuleName); + pProtoData->strProtocol = toTstring(pa->szModuleName); pProtoData->lTimeStamp = 0; // try to create an irc connection for that protocol (will fail if it is no irc protocol) diff --git a/plugins/MirandaG15/src/CConfig.cpp b/plugins/MirandaG15/src/CConfig.cpp index 351755a572..0d56bdf3a6 100644 --- a/plugins/MirandaG15/src/CConfig.cpp +++ b/plugins/MirandaG15/src/CConfig.cpp @@ -110,22 +110,17 @@ void CConfig::LoadSettings() LoadFontSettings(i);
// Load protocol specific settings
- int iCount;
int iProtoCount = 0;
- PROTOACCOUNT **ppAccounts;
CProtoFilter *pProtoFilter;
tstring strSetting;
- Proto_EnumAccounts(&iCount, &ppAccounts);
- for (int i = 0; i < iCount; i++) {
- /*if(ppProtocolDescriptor[i]->type != PROTOTYPE_PROTOCOL)
- continue;*/
- if (ppAccounts[i]->bIsEnabled == 0)
+ for (auto &pa : Accounts()) {
+ if (pa->bIsEnabled == 0)
continue;
iProtoCount++;
pProtoFilter = new CProtoFilter();
- pProtoFilter->strName = toTstring(ppAccounts[i]->szModuleName);
+ pProtoFilter->strName = toTstring(pa->szModuleName);
strSetting = L"ProtoFilter_" + pProtoFilter->strName;
pProtoFilter->bNotificationFilter = db_get_dw(NULL, "MirandaG15", toNarrowString(strSetting).c_str(), 1) != 0;
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 7dff1cf799..70da9b568c 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -1134,17 +1134,13 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wPa ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_TICK));
ListView_SetImageList(hMapUser, hIml, LVSIL_SMALL);
- PROTOACCOUNT **proto;
- int nCount;
- Proto_EnumAccounts(&nCount, &proto);
-
LVITEMA sItem = { 0 };
sItem.mask = LVIF_TEXT | LVIF_IMAGE;
char szTemp[500];
- for (int i = 0; i < nCount; i++) {
- mir_snprintf(szTemp, "DisableProt_%s", proto[i]->szModuleName);
- sItem.pszText = proto[i]->szModuleName;
+ for (auto &pa : Accounts()) {
+ mir_snprintf(szTemp, "DisableProt_%s", pa->szModuleName);
+ sItem.pszText = pa->szModuleName;
sItem.iImage = db_get_b(NULL, MODULE, szTemp, 1);
::SendMessage(hMapUser, LVM_INSERTITEMA, 0, (LPARAM)&sItem);
sItem.iItem++;
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index fe0dafb388..5f28e074e0 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -25,19 +25,14 @@ ProtocolArray *protocols = nullptr; void InitProtocolData()
{
- PROTOACCOUNT **protos;
- int count;
- Proto_EnumAccounts(&count, &protos);
+ protocols = new ProtocolArray(10);
- protocols = new ProtocolArray(count);
-
- for (int i = 0; i < count; i++) {
- PROTOACCOUNT *acc = protos[i];
- if (acc->szModuleName == nullptr || acc->szModuleName[0] == '\0' || acc->bIsVirtual)
+ for (auto &pa : Accounts()) {
+ if (pa->szModuleName == nullptr || pa->szModuleName[0] == '\0' || pa->bIsVirtual)
continue;
// Found a protocol
- Protocol *p = new Protocol(acc->szModuleName, acc->tszAccountName);
+ Protocol *p = new Protocol(pa->szModuleName, pa->tszAccountName);
if (p->IsValid())
protocols->Add(p);
else
@@ -144,21 +139,13 @@ int Protocol::GetStatus() void Protocol::SetStatus(int aStatus)
{
if (ServiceExists(MS_CS_SETSTATUSEX)) {
- // BEGIN From commomstatus.cpp (KeepStatus)
- int i, count, pCount;
- PROTOACCOUNT **accs;
-
- pCount = 0;
- Proto_EnumAccounts(&count, &accs);
- for (i = 0; i < count; i++) {
- if (CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
- continue;
- pCount++;
- }
- // END From commomstatus.cpp (KeepStatus)
-
+ int pCount = 0;
+ for (auto &pa : Accounts())
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0)
+ pCount++;
+
PROTOCOLSETTINGEX **pse = (PROTOCOLSETTINGEX **)mir_calloc(pCount * sizeof(PROTOCOLSETTINGEX *));
- for (i = 0; i < pCount; i++) {
+ for (int i = 0; i < pCount; i++) {
pse[i] = (PROTOCOLSETTINGEX *)mir_calloc(sizeof(PROTOCOLSETTINGEX));
pse[i]->m_szName = "";
}
@@ -172,7 +159,7 @@ void Protocol::SetStatus(int aStatus) CallService(MS_CS_SETSTATUSEX, (WPARAM)&pse, 0);
- for (i = 0; i < pCount; i++)
+ for (int i = 0; i < pCount; i++)
mir_free(pse[i]);
mir_free(pse);
}
diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index c0d049f1fb..f691316049 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -229,12 +229,9 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) Flag3 = CallProtoService((char*)lParam, PS_GETCAPS, PFLAGNUM_3, 0);
}
else {
- PROTOACCOUNT **accs;
- int numAccs = 0;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0; i < numAccs; i++) {
- Flag1 |= CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
- Flag3 |= CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
+ for (auto &pa : Accounts()) {
+ Flag1 |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ Flag3 |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
}
@@ -585,14 +582,13 @@ int MirandaLoaded(WPARAM, LPARAM) InitUpdateMsgs();
g_IconList.ReloadIcons();
- int numAccs = 0;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0, CurProtoIndex = 0; i < numAccs && CurProtoIndex < MAXICQACCOUNTS; i++) {
- HANDLE hHook = HookEvent(CString(accs[i]->szModuleName) + ME_ICQ_STATUSMSGREQ, StatusMsgReqHooks[CurProtoIndex]);
+ int CurProtoIndex = 0;
+ for (auto &pa : Accounts()) {
+ HANDLE hHook = HookEvent(CString(pa->szModuleName) + ME_ICQ_STATUSMSGREQ, StatusMsgReqHooks[CurProtoIndex]);
if (hHook) {
- ICQProtoList[CurProtoIndex] = accs[i]->szModuleName;
- CurProtoIndex++;
+ ICQProtoList[CurProtoIndex++] = pa->szModuleName;
+ if (CurProtoIndex >= MAXICQACCOUNTS)
+ break;
}
}
diff --git a/plugins/NewAwaySysMod/src/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index a062efb8ac..ec121bf903 100644 --- a/plugins/NewAwaySysMod/src/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -32,14 +32,9 @@ void __cdecl UpdateMsgsThreadProc(void *) {
Thread_SetName("NewAwaySysMod: UpdateMsgsThreadProc");
- int numAccs;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
-
while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_IsTerminated()) {
DWORD MinUpdateTimeDifference = (DWORD)g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGSPERIOD) * 1000; // in milliseconds
- for (int i = 0; i < numAccs; i++) {
- PROTOACCOUNT *p = accs[i];
+ for (auto &p : Accounts()) {
if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND && !IsAnICQProto(p->szModuleName)) {
int Status = CallProtoService(p->szModuleName, PS_GETSTATUS, 0, 0);
if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH) {
@@ -92,17 +87,13 @@ void ChangeProtoMessages(char* szProto, int iMode, const TCString &Msg) g_ProtoStates[szProto].CurStatusMsg = CurMsg;
}
else { // change message of all protocols
- int numAccs;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0; i < numAccs; i++) {
- PROTOACCOUNT *p = accs[i];
- if (!db_get_b(NULL, p->szModuleName, "LockMainStatus", 0)) {
+ for (auto &pa : Accounts()) {
+ if (!db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) {
if (Msg == nullptr)
- CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName);
+ CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, pa->szModuleName);
- CallAllowedPS_SETAWAYMSG(p->szModuleName, iMode, CurMsg);
- g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg;
+ CallAllowedPS_SETAWAYMSG(pa->szModuleName, iMode, CurMsg);
+ g_ProtoStates[pa->szModuleName].CurStatusMsg = CurMsg;
}
}
}
diff --git a/plugins/NewAwaySysMod/src/Properties.h b/plugins/NewAwaySysMod/src/Properties.h index 64180a6405..5c7f42d718 100644 --- a/plugins/NewAwaySysMod/src/Properties.h +++ b/plugins/NewAwaySysMod/src/Properties.h @@ -257,13 +257,10 @@ public: return ProtoStates[i];
// we need to be sure that we have _all_ protocols in the list, before dealing with global status, so we're adding them here.
- if (!szProto) {
- int numAccs;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0; i < numAccs; i++)
- (*this)[accs[i]->szModuleName]; // add a protocol if it isn't in the list yet
- }
+ if (!szProto)
+ for (auto &pa : Accounts())
+ (*this)[pa->szModuleName]; // add a protocol if it isn't in the list yet
+
return ProtoStates[ProtoStates.AddElem(CProtoState(szProto, this))];
}
diff --git a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index d591f306d4..27d11321be 100644 --- a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -864,11 +864,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA HTREEITEM hSelItem;
HTREEITEM hItem = hSelItem = CList->AddInfo(TranslateT("** All contacts **"), CLC_ROOT, CLC_ROOT, NULL, Skin_LoadProtoIcon(nullptr, g_ProtoStates[(char*)nullptr].m_status));
- int numAccs;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0; i < numAccs; i++) {
- PROTOACCOUNT *p = accs[i];
+ for (auto &p : Accounts())
// don't forget to change Recent Message Save loop in the UM_SAM_APPLYANDCLOSE if you're changing something here
if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
PROTOACCOUNT * acc = Proto_GetAccount(p->szModuleName);
@@ -876,7 +872,6 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (dat->szProtocol && !mir_strcmp(p->szModuleName, dat->szProtocol))
hSelItem = hItem;
}
- }
CList->SetRedraw(false);
for (auto &hContact : Contacts()) {
@@ -918,18 +913,14 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA MsgTree->Save();
{
// save Recent Messages
- int numAccs;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&numAccs, &accs);
- for (int i = 0; i < numAccs; i++) {
- PROTOACCOUNT *p = accs[i];
+ for (auto &p : Accounts())
if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
TCString Message(CProtoSettings(p->szModuleName).GetMsgFormat(GMF_PERSONAL)); // yes, we don't specify GMF_TEMPORARY here, because we don't need to save it
if (Message != nullptr)
CProtoSettings(p->szModuleName).SetMsgFormat(SMF_LAST, Message); // if the user set a message for this protocol, save it to the recent messages
ChangeProtoMessages(p->szModuleName, g_ProtoStates[p->szModuleName].m_status, TCString(nullptr)); // and actual setting of a status message for the protocol
}
- }
+
TCString Message(CProtoSettings().GetMsgFormat(GMF_PERSONAL));
if (Message != nullptr)
CProtoSettings().SetMsgFormat(SMF_LAST, Message); // save the global message to the recent messages
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 46660e1545..39faa19528 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -1136,12 +1136,9 @@ int ModulesLoaded(WPARAM, LPARAM) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
nullptr, hInst, nullptr);
- int count = 0;
- PROTOACCOUNT **accounts = nullptr;
- Proto_EnumAccounts(&count, &accounts);
- for (int i = 0; i < count; i++)
- if (accounts[i]->IsEnabled())
- db_set_b(NULL, MODULE, accounts[i]->szModuleName, 0);
+ for (auto &pa : Accounts())
+ if (pa->IsEnabled())
+ db_set_b(NULL, MODULE, pa->szModuleName, 0);
return 0;
}
diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp index 2b3231a74b..4c88c3d10a 100644 --- a/plugins/NewXstatusNotify/src/options.cpp +++ b/plugins/NewXstatusNotify/src/options.cpp @@ -196,8 +196,7 @@ void SaveOptions() INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -224,9 +223,7 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return TRUE;
case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_CONFIGUREAUTODISABLE:
CreateDialog(hInst, MAKEINTRESOURCE(IDD_AUTODISABLE), hwndDlg, DlgProcAutoDisableOpts);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -244,36 +241,35 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ShowLog(opt.LogFilePath);
break;
case IDC_BT_CHOOSELOGFILE:
- {
- wchar_t buff[MAX_PATH];
- OPENFILENAME ofn = { 0 };
-
- GetDlgItemText(hwndDlg, IDC_LOGFILE, buff, _countof(buff));
-
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.lpstrFile = buff;
- ofn.nMaxFile = MAX_PATH;
- ofn.hwndOwner = hwndDlg;
- wchar_t filter[MAX_PATH];
- mir_snwprintf(filter, L"%s (*.*)%c*.*%c%s (*.log)%c*.log%c%s (*.txt)%c*.txt%c", TranslateT("All Files"), 0, 0, TranslateT("Log"), 0, 0, TranslateT("Text"), 0, 0);
- ofn.lpstrFilter = filter;
- ofn.nFilterIndex = 2;
- ofn.lpstrInitialDir = buff;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
- ofn.lpstrDefExt = L"log";
- if (GetSaveFileName(&ofn)) {
- SetDlgItemText(hwndDlg, IDC_LOGFILE, buff);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ {
+ wchar_t buff[MAX_PATH];
+ OPENFILENAME ofn = { 0 };
+
+ GetDlgItemText(hwndDlg, IDC_LOGFILE, buff, _countof(buff));
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.lpstrFile = buff;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.hwndOwner = hwndDlg;
+ wchar_t filter[MAX_PATH];
+ mir_snwprintf(filter, L"%s (*.*)%c*.*%c%s (*.log)%c*.log%c%s (*.txt)%c*.txt%c", TranslateT("All Files"), 0, 0, TranslateT("Log"), 0, 0, TranslateT("Text"), 0, 0);
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 2;
+ ofn.lpstrInitialDir = buff;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.lpstrDefExt = L"log";
+ if (GetSaveFileName(&ofn)) {
+ SetDlgItemText(hwndDlg, IDC_LOGFILE, buff);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
}
- break;
- }
default:
if (HIWORD(wParam) == BN_CLICKED || (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
-
break;
- }
+
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
opt.AutoDisable = IsDlgButtonChecked(hwndDlg, IDC_AUTODISABLE);
@@ -303,10 +299,8 @@ INT_PTR CALLBACK DlgProcGeneralOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_USEOWNCOLORS, (opt.Colors == POPUP_COLOR_OWN) ? BST_CHECKED : BST_UNCHECKED);
@@ -344,83 +338,78 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_STATUS_RC, CB_SETCURSEL, opt.RightClickAction, 0);
SendMessage(hwndDlg, WM_USER + 1, (WPARAM)opt.ShowStatus, 0);
-
return TRUE;
- }
+
case WM_COMMAND:
- {
- WORD idCtrl = LOWORD(wParam);
- if (HIWORD(wParam) == CPN_COLOURCHANGED) {
- if (idCtrl >= IDC_CHK_OFFLINE) {
- COLORREF colour = SendDlgItemMessage(hwndDlg, idCtrl, CPM_GETCOLOUR, 0, 0);
- if ((idCtrl >= IDC_OFFLINE_TX) && (idCtrl <= IDC_ONTHEPHONE_TX)) //Text colour
- StatusList[Index(idCtrl - 1000)].colorText = colour;
- else //Background colour
- StatusList[Index(idCtrl - 2000)].colorBack = colour;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
+ {
+ WORD idCtrl = LOWORD(wParam);
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) {
+ if (idCtrl >= IDC_CHK_OFFLINE) {
+ COLORREF colour = SendDlgItemMessage(hwndDlg, idCtrl, CPM_GETCOLOUR, 0, 0);
+ if ((idCtrl >= IDC_OFFLINE_TX) && (idCtrl <= IDC_ONTHEPHONE_TX)) //Text colour
+ StatusList[Index(idCtrl - 1000)].colorText = colour;
+ else //Background colour
+ StatusList[Index(idCtrl - 2000)].colorBack = colour;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
}
- }
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (idCtrl)
- {
- case IDC_USEOWNCOLORS:
- case IDC_USEWINCOLORS:
- case IDC_USEPOPUPCOLORS:
- for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX2; i++) {
- EnableWindow(GetDlgItem(hwndDlg, (i + 2000)), idCtrl == IDC_USEOWNCOLORS); //Background
- EnableWindow(GetDlgItem(hwndDlg, (i + 1000)), idCtrl == IDC_USEOWNCOLORS); //Text
- }
- break;
- case IDC_SHOWSTATUS:
- SendMessage(hwndDlg, WM_USER + 1, (WPARAM)IsDlgButtonChecked(hwndDlg, IDC_SHOWSTATUS), 0);
- break;
- case IDC_PREVIEW:
- {
- wchar_t str[MAX_SECONDLINE] = { 0 };
- for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) {
- wcsncpy(str, L"", _countof(str));
-
- if (opt.ShowStatus) {
- if (opt.UseAlternativeText == 1)
- wcsncpy(str, StatusList[Index(i)].lpzUStatusText, _countof(str));
- else
- wcsncpy(str, StatusList[Index(i)].lpzStandardText, _countof(str));
-
- if (opt.ShowPreviousStatus) {
- wchar_t buff[MAX_STATUSTEXT];
- mir_snwprintf(buff, TranslateW(STRING_SHOWPREVIOUSSTATUS), StatusList[Index(i)].lpzStandardText);
- mir_wstrcat(str, L" ");
- mir_wstrcat(str, buff);
- }
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (idCtrl) {
+ case IDC_USEOWNCOLORS:
+ case IDC_USEWINCOLORS:
+ case IDC_USEPOPUPCOLORS:
+ for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX2; i++) {
+ EnableWindow(GetDlgItem(hwndDlg, (i + 2000)), idCtrl == IDC_USEOWNCOLORS); //Background
+ EnableWindow(GetDlgItem(hwndDlg, (i + 1000)), idCtrl == IDC_USEOWNCOLORS); //Text
}
+ break;
+
+ case IDC_SHOWSTATUS:
+ SendMessage(hwndDlg, WM_USER + 1, (WPARAM)IsDlgButtonChecked(hwndDlg, IDC_SHOWSTATUS), 0);
+ break;
+
+ case IDC_PREVIEW:
+ wchar_t str[MAX_SECONDLINE];
+ for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) {
+ str[0] = 0;
+
+ if (opt.ShowStatus) {
+ if (opt.UseAlternativeText == 1)
+ wcsncpy(str, StatusList[Index(i)].lpzUStatusText, _countof(str));
+ else
+ wcsncpy(str, StatusList[Index(i)].lpzStandardText, _countof(str));
+
+ if (opt.ShowPreviousStatus) {
+ wchar_t buff[MAX_STATUSTEXT];
+ mir_snwprintf(buff, TranslateW(STRING_SHOWPREVIOUSSTATUS), StatusList[Index(i)].lpzStandardText);
+ mir_wstrcat(str, L" ");
+ mir_wstrcat(str, buff);
+ }
+ }
- if (opt.ReadAwayMsg) {
- if (str[0])
- mir_wstrcat(str, L"\n");
- mir_wstrcat(str, TranslateT("This is status message"));
+ if (opt.ReadAwayMsg) {
+ if (str[0])
+ mir_wstrcat(str, L"\n");
+ mir_wstrcat(str, TranslateT("This is status message"));
+ }
+
+ ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, i), i, str);
}
- ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, i), i, str);
+ ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_EXTRASTATUS, TranslateT("This is extra status"));
+ ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_STATUSMSG, TranslateT("This is status message"));
+ return FALSE;
}
- wcsncpy(str, TranslateT("This is extra status"), _countof(str));
- ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_EXTRASTATUS, str);
- wcsncpy(str, TranslateT("This is status message"), _countof(str));
- ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_STATUSMSG, str);
-
- return FALSE;
- }
}
- }
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
+ break;
+ }
case WM_NOTIFY:
- {
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
char str[8];
DWORD ctlColour = 0;
@@ -458,7 +447,7 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
break;
- }
+
case WM_USER + 1:
EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWALTDESCS), wParam);
EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWPREVIOUSSTATUS), wParam);
@@ -528,7 +517,6 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM {
switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_ED_MSGLEN, EM_LIMITTEXT, 3, 0);
@@ -561,11 +549,9 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BUTTONADDTOOLTIP, (WPARAM)LPGENW("Reset all templates to default"), BATF_UNICODE);
SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib));
-
return TRUE;
- }
+
case WM_COMMAND:
- {
switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD(wParam)) {
@@ -609,9 +595,8 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
return TRUE;
- }
+
case WM_NOTIFY:
- {
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
opt.PXOnConnect = IsDlgButtonChecked(hwndDlg, IDC_XONCONNECT);
opt.PXDisableForMusic = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEMUSIC);
@@ -636,7 +621,7 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
return TRUE;
- }
+
case WM_USER + 1:
SetDlgItemText(hwndDlg, IDC_ED_TCHANGE, DEFAULT_POPUP_CHANGED);
SetDlgItemText(hwndDlg, IDC_ED_TREMOVE, DEFAULT_POPUP_REMOVED);
@@ -668,7 +653,6 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_ED_SMSGLEN, EM_LIMITTEXT, 3, 0);
@@ -693,69 +677,65 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib));
// proto list
- HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST);
- SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- LVCOLUMN lvCol = { 0 };
- lvCol.mask = LVCF_WIDTH | LVCF_TEXT;
- lvCol.pszText = TranslateT("Account");
- lvCol.cx = 118;
- ListView_InsertColumn(hList, 0, &lvCol);
- // fill the list
- LVITEM lvItem = { 0 };
- lvItem.mask = LVIF_TEXT | LVIF_PARAM;
- lvItem.iItem = 0;
- lvItem.iSubItem = 0;
-
- int count;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++) {
- if (IsSuitableProto(protos[i])) {
- UpdateListFlag = TRUE;
- lvItem.pszText = protos[i]->tszAccountName;
- lvItem.lParam = (LPARAM)protos[i]->szModuleName;
- PROTOTEMPLATE *prototemplate = (PROTOTEMPLATE *)mir_alloc(sizeof(PROTOTEMPLATE));
- prototemplate->ProtoName = protos[i]->szModuleName;
-
- DBVARIANT dbVar = { 0 };
- char protoname[MAX_PATH] = { 0 };
- mir_snprintf(protoname, "%s_TPopupSMsgChanged", protos[i]->szModuleName);
- if (db_get_ws(NULL, MODULE, protoname, &dbVar))
- wcsncpy(prototemplate->ProtoTemplateMsg, DEFAULT_POPUP_SMSGCHANGED, _countof(prototemplate->ProtoTemplateMsg));
- else {
- wcsncpy(prototemplate->ProtoTemplateMsg, dbVar.ptszVal, _countof(prototemplate->ProtoTemplateMsg));
- db_free(&dbVar);
- }
+ {
+ HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST);
+ SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+ LVCOLUMN lvCol = { 0 };
+ lvCol.mask = LVCF_WIDTH | LVCF_TEXT;
+ lvCol.pszText = TranslateT("Account");
+ lvCol.cx = 118;
+ ListView_InsertColumn(hList, 0, &lvCol);
+ // fill the list
+ LVITEM lvItem = { 0 };
+ lvItem.mask = LVIF_TEXT | LVIF_PARAM;
+ lvItem.iItem = 0;
+ lvItem.iSubItem = 0;
+
+ for (auto &pa : Accounts()) {
+ if (IsSuitableProto(pa)) {
+ UpdateListFlag = TRUE;
+ lvItem.pszText = pa->tszAccountName;
+ lvItem.lParam = (LPARAM)pa->szModuleName;
+ PROTOTEMPLATE *prototemplate = (PROTOTEMPLATE *)mir_alloc(sizeof(PROTOTEMPLATE));
+ prototemplate->ProtoName = pa->szModuleName;
+
+ DBVARIANT dbVar = { 0 };
+ char protoname[MAX_PATH] = { 0 };
+ mir_snprintf(protoname, "%s_TPopupSMsgChanged", pa->szModuleName);
+ if (db_get_ws(NULL, MODULE, protoname, &dbVar))
+ wcsncpy(prototemplate->ProtoTemplateMsg, DEFAULT_POPUP_SMSGCHANGED, _countof(prototemplate->ProtoTemplateMsg));
+ else {
+ wcsncpy(prototemplate->ProtoTemplateMsg, dbVar.ptszVal, _countof(prototemplate->ProtoTemplateMsg));
+ db_free(&dbVar);
+ }
- mir_snprintf(protoname, "%s_TPopupSMsgRemoved", protos[i]->szModuleName);
- if (db_get_ws(NULL, MODULE, protoname, &dbVar))
- wcsncpy(prototemplate->ProtoTemplateRemoved, DEFAULT_POPUP_SMSGREMOVED, _countof(prototemplate->ProtoTemplateRemoved));
- else {
- wcsncpy(prototemplate->ProtoTemplateRemoved, dbVar.ptszVal, _countof(prototemplate->ProtoTemplateRemoved));
- db_free(&dbVar);
- }
+ mir_snprintf(protoname, "%s_TPopupSMsgRemoved", pa->szModuleName);
+ if (db_get_ws(NULL, MODULE, protoname, &dbVar))
+ wcsncpy(prototemplate->ProtoTemplateRemoved, DEFAULT_POPUP_SMSGREMOVED, _countof(prototemplate->ProtoTemplateRemoved));
+ else {
+ wcsncpy(prototemplate->ProtoTemplateRemoved, dbVar.ptszVal, _countof(prototemplate->ProtoTemplateRemoved));
+ db_free(&dbVar);
+ }
- ListView_InsertItem(hList, &lvItem);
- ProtoTemplates.insert(prototemplate, ProtoTemplates.getCount());
+ ListView_InsertItem(hList, &lvItem);
+ ProtoTemplates.insert(prototemplate, ProtoTemplates.getCount());
- char dbSetting[128];
- mir_snprintf(dbSetting, "%s_enabled", protos[i]->szModuleName);
- ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, MODULE, dbSetting, TRUE));
- lvItem.iItem++;
+ char dbSetting[128];
+ mir_snprintf(dbSetting, "%s_enabled", pa->szModuleName);
+ ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, MODULE, dbSetting, TRUE));
+ lvItem.iItem++;
+ }
}
- }
- if (lvItem.iItem)
- {
- ListView_SetItemState(hList, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- PROTOTEMPLATE *prototemplate = ProtoTemplates[0];
- SetDlgItemText(hwndDlg, IDC_ED_TNEWSMSG, prototemplate->ProtoTemplateMsg);
- SetDlgItemText(hwndDlg, IDC_ED_TSMSGREMOVE, prototemplate->ProtoTemplateRemoved);
+ if (lvItem.iItem) {
+ ListView_SetItemState(hList, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ PROTOTEMPLATE *prototemplate = ProtoTemplates[0];
+ SetDlgItemText(hwndDlg, IDC_ED_TNEWSMSG, prototemplate->ProtoTemplateMsg);
+ SetDlgItemText(hwndDlg, IDC_ED_TSMSGREMOVE, prototemplate->ProtoTemplateRemoved);
+ }
+ UpdateListFlag = FALSE;
}
- UpdateListFlag = FALSE;
- }
- return TRUE;
+ return TRUE;
case WM_COMMAND:
switch (HIWORD(wParam)) {
@@ -799,10 +779,8 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (((NMHDR *)lParam)->idFrom == IDC_PROTOCOLLIST) {
switch (((NMHDR *)lParam)->code) {
case LVN_ITEMCHANGED:
- {
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
- if (nmlv->uNewState == 3 && !UpdateListFlag)
- {
+ if (nmlv->uNewState == 3 && !UpdateListFlag) {
HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST);
PROTOTEMPLATE *prototemplate;
if (ListView_GetHotItem(hList) != ListView_GetSelectionMark(hList)) {
@@ -821,8 +799,6 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK && !UpdateListFlag)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- break;
- }
}
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
@@ -883,7 +859,6 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l {
switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_XLOGTOFILE, opt.XLogToFile ? BST_CHECKED : BST_UNCHECKED);
@@ -913,11 +888,9 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l SendDlgItemMessage(hwndDlg, IDC_BT_RESET, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib));
SendMessage(hwndDlg, WM_USER + 2, (WPARAM)opt.XLogToFile || opt.XLogToDB, 0);
-
return TRUE;
- }
+
case WM_COMMAND:
- {
switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD(wParam)) {
@@ -968,9 +941,8 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break;
}
return TRUE;
- }
+
case WM_NOTIFY:
- {
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
opt.XLogToFile = IsDlgButtonChecked(hwndDlg, IDC_XLOGTOFILE);
opt.XLogToDB = IsDlgButtonChecked(hwndDlg, IDC_XLOGTODB);
@@ -996,7 +968,7 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l SaveTemplates();
}
return TRUE;
- }
+
case WM_USER + 1:
CheckDlgButton(hwndDlg, IDC_CHK_XSTATUSCHANGED, BST_CHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_XSTATUSREMOVED, BST_CHECKED);
@@ -1015,8 +987,8 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TMSGCHANGED), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TMSGREMOVED), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TXSTATUSOPENING), TRUE);
-
return TRUE;
+
case WM_USER + 2:
EnableWindow(GetDlgItem(hwndDlg, IDC_XLOGTODB_WINOPEN), IsDlgButtonChecked(hwndDlg, IDC_XLOGTODB));
EnableWindow(GetDlgItem(hwndDlg, IDC_XLOGTODB_REMOVE), IsDlgButtonChecked(hwndDlg, IDC_XLOGTODB) && IsDlgButtonChecked(hwndDlg, IDC_XLOGTODB_WINOPEN));
@@ -1035,7 +1007,6 @@ INT_PTR CALLBACK DlgProcXLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_BT_VARIABLES), wParam);
EnableWindow(GetDlgItem(hwndDlg, IDC_BT_RESET), wParam);
-
return TRUE;
}
@@ -1046,7 +1017,6 @@ INT_PTR CALLBACK DlgProcLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP {
switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_LOGTOFILE, opt.LogToFile ? BST_CHECKED : BST_UNCHECKED);
@@ -1077,11 +1047,9 @@ INT_PTR CALLBACK DlgProcLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndDlg, WM_USER + 2, (WPARAM)opt.LogToFile || opt.LogToDB, 0);
SendMessage(hwndDlg, WM_USER + 3, (WPARAM)opt.SMsgLogToFile || opt.SMsgLogToDB, 0);
-
return TRUE;
- }
+
case WM_COMMAND:
- {
switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD(wParam)) {
@@ -1133,9 +1101,8 @@ INT_PTR CALLBACK DlgProcLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
}
return TRUE;
- }
+
case WM_NOTIFY:
- {
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
opt.LogToFile = IsDlgButtonChecked(hwndDlg, IDC_LOGTOFILE);
opt.LogToDB = IsDlgButtonChecked(hwndDlg, IDC_LOGTODB);
@@ -1161,7 +1128,7 @@ INT_PTR CALLBACK DlgProcLogOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SaveTemplates();
}
return TRUE;
- }
+
case WM_USER + 1:
CheckDlgButton(hwndDlg, IDC_LOG_SMSGCHANGED, BST_CHECKED);
CheckDlgButton(hwndDlg, IDC_LOG_SMSGREMOVED, BST_CHECKED);
diff --git a/plugins/NewXstatusNotify/src/popup.cpp b/plugins/NewXstatusNotify/src/popup.cpp index 8b4593ce47..c0765dddb9 100644 --- a/plugins/NewXstatusNotify/src/popup.cpp +++ b/plugins/NewXstatusNotify/src/popup.cpp @@ -35,8 +35,7 @@ void ShowChangePopup(MCONTACT hContact, HICON hIcon, WORD newStatus, const wchar buf.AppendFormat(L" (%s)", tszGroup);
}
wcsncpy_s(ppd.lptzContactName, buf, _TRUNCATE);
-
- wcsncpy(ppd.lptzText, stzText, _countof(ppd.lptzText));
+ wcsncpy_s(ppd.lptzText, stzText, _TRUNCATE);
switch (opt.Colors) {
case POPUP_COLOR_OWN:
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 4f44a8f172..7b93bb6ea7 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -97,19 +97,17 @@ void InitCheck() mir_free(home_dir); tmp_dir += L"\\tmp"; _wmkdir(tmp_dir.c_str()); - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); + string question; char *keyid = nullptr; - for (int i = 0; i < count; i++) { - if (StriStr(accounts[i]->szModuleName, "metacontacts")) + for (auto &pa : Accounts()) { + if (StriStr(pa->szModuleName, "metacontacts")) continue; - if (StriStr(accounts[i]->szModuleName, "weather")) + if (StriStr(pa->szModuleName, "weather")) continue; - std::string acc = toUTF8(accounts[i]->tszAccountName); + std::string acc = toUTF8(pa->tszAccountName); acc += "("; - acc += accounts[i]->szModuleName; + acc += pa->szModuleName; acc += ")"; acc += "_KeyID"; keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc.c_str(), ""); @@ -120,7 +118,7 @@ void InitCheck() if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" for account "); - question += toUTF8(accounts[i]->tszAccountName); + question += toUTF8(pa->tszAccountName); question += Translate(" deleted from GPG secret keyring.\nDo you want to set another key?"); if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) { @@ -161,7 +159,7 @@ void InitCheck() if (expired) { question += keyid; question += Translate(" for account "); - question += toUTF8(accounts[i]->tszAccountName); + question += toUTF8(pa->tszAccountName); question += Translate(" expired and will not work.\nDo you want to set another key?"); if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) { @@ -252,32 +250,26 @@ void InitCheck() mir_free(path); } if (globals.bAutoExchange) { - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); ICQ_CUSTOMCAP cap; cap.cbSize = sizeof(ICQ_CUSTOMCAP); cap.hIcon = nullptr; strncpy(cap.name, "GPG Key AutoExchange", MAX_CAPNAME); strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps)); - for (int i = 0; i < count; i++) - if (ProtoServiceExists(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY)) - CallProtoService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); + for (auto &pa : Accounts()) + if (ProtoServiceExists(pa->szProtoName, PS_ICQ_ADDCAPABILITY)) + CallProtoService(pa->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); } if (globals.bFileTransfers) { - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); ICQ_CUSTOMCAP cap; cap.cbSize = sizeof(ICQ_CUSTOMCAP); cap.hIcon = nullptr; strncpy(cap.name, "GPG Encrypted FileTransfers", MAX_CAPNAME); strncpy(cap.caps, "GPGFileTransfer", sizeof(cap.caps)); - for (int i = 0; i < count; i++) - if (ProtoServiceExists(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY)) - CallProtoService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); + for (auto &pa : Accounts()) + if (ProtoServiceExists(pa->szProtoName, PS_ICQ_ADDCAPABILITY)) + CallProtoService(pa->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); } } diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index 1a5ec6a5d0..d9677fd529 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -200,31 +200,28 @@ void CDlgFirstRun::OnInitDialog() refresh_key_list(); - { - combo_ACCOUNT.AddString(TranslateT("Default")); - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); - for (int n = 0; n < count; n++) { - if (StriStr(accounts[n]->szModuleName, "metacontacts")) - continue; - if (StriStr(accounts[n]->szModuleName, "weather")) - continue; - std::string acc = toUTF8(accounts[n]->tszAccountName); - acc += "("; - acc += accounts[n]->szModuleName; - acc += ")"; - //acc += "_KeyID"; - combo_ACCOUNT.AddStringA(acc.c_str()); - } - combo_ACCOUNT.SelectString(TranslateT("Default")); - string keyinfo = Translate("key ID"); - keyinfo += ": "; - char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); - keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); - mir_free(keyid); - lbl_KEY_ID.SetTextA(keyinfo.c_str()); + combo_ACCOUNT.AddString(TranslateT("Default")); + + for (auto &pa : Accounts()) { + if (StriStr(pa->szModuleName, "metacontacts")) + continue; + if (StriStr(pa->szModuleName, "weather")) + continue; + std::string acc = toUTF8(pa->tszAccountName); + acc += "("; + acc += pa->szModuleName; + acc += ")"; + //acc += "_KeyID"; + combo_ACCOUNT.AddStringA(acc.c_str()); } + combo_ACCOUNT.SelectString(TranslateT("Default")); + string keyinfo = Translate("key ID"); + keyinfo += ": "; + char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + keyinfo += (mir_strlen(keyid) > 0) ? keyid : Translate("not set"); + mir_free(keyid); + lbl_KEY_ID.SetTextA(keyinfo.c_str()); + combo_ACCOUNT.OnChange = Callback(this, &CDlgFirstRun::onChange_ACCOUNT); list_KEY_LIST.OnClick = Callback(this, &CDlgFirstRun::onChange_KEY_LIST); } @@ -706,21 +703,18 @@ void CDlgFirstRun::refresh_key_list() list_KEY_LIST.SetItemText(row, 1, (wchar_t*)tmp.c_str()); // get accounts - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); std::wstring accs; - for (int n = 0; n < count; n++) { - std::string setting = toUTF8(accounts[n]->tszAccountName); + for (auto &pa : Accounts()) { + std::string setting = toUTF8(pa->tszAccountName); setting += "("; - setting += accounts[n]->szModuleName; + setting += pa->szModuleName; setting += ")"; setting += "_KeyID"; wchar_t *str = UniGetContactSettingUtf(NULL, szGPGModuleName, setting.c_str(), L""); if (key_id == str) { if (!accs.empty()) accs += L","; - accs += accounts[n]->tszAccountName; + accs += pa->tszAccountName; } mir_free(str); } diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index a38429091d..3781161311 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -595,26 +595,23 @@ int ComboBoxAddStringUtf(HWND hCombo, const wchar_t *szString, DWORD data) int GetJabberInterface(WPARAM, LPARAM) //get interface for all jabber accounts, options later { void AddHandlers(); - int count = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&count, &accounts); + list <JabberAccount*>::iterator p; globals.Accounts.clear(); globals.Accounts.push_back(new JabberAccount); p = globals.Accounts.begin(); (*p)->setAccountNumber(0); - for (int i = 0; i < count; i++) //get only jabber accounts from all accounts - { - IJabberInterface *JIftmp = getJabberApi(accounts[i]->szModuleName); + for (auto &pa : Accounts()) { + IJabberInterface *JIftmp = getJabberApi(pa->szModuleName); int a = 0; if (JIftmp) { (*p)->setJabberInterface(JIftmp); - if (accounts[i]->tszAccountName) { - wchar_t* tmp = mir_wstrdup(accounts[i]->tszAccountName); + if (pa->tszAccountName) { + wchar_t* tmp = mir_wstrdup(pa->tszAccountName); (*p)->setAccountName(tmp); } else { - wchar_t *tmp = mir_a2u(accounts[i]->szModuleName); + wchar_t *tmp = mir_a2u(pa->szModuleName); (*p)->setAccountName(tmp); } (*p)->setAccountNumber(a); @@ -1434,9 +1431,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) if (!file.is_open()) return 1; //TODO: handle error - PROTOACCOUNT **accs; - int acc_count = 0, processed_keys = 0, processed_private_keys = 0; - Proto_EnumAccounts(&acc_count, &accs); + int processed_keys = 0, processed_private_keys = 0; char line[256]; file.getline(line, 255); @@ -1464,52 +1459,48 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) p2++; key.erase(p1, p2 - p1); std::string acc; - for (int i = 0; i < acc_count; i++) { + + for (auto &pa : Accounts()) { if (acc.length()) break; - const char *uid = Proto_GetUniqueId(accs[i]->szModuleName); + const char *uid = Proto_GetUniqueId(pa->szModuleName); DBVARIANT dbv = { 0 }; - db_get(0, accs[i]->szModuleName, uid, &dbv); + db_get(0, pa->szModuleName, uid, &dbv); std::string id; switch (dbv.type) { case DBVT_DELETED: continue; break; + case DBVT_BYTE: - { - char _id[64]; - mir_snprintf(_id, "%d", dbv.bVal); - id += _id; - if (id == login) - acc = accs[i]->szModuleName; - } + char _id[64]; + mir_snprintf(_id, "%d", dbv.bVal); + id += _id; + if (id == login) + acc = pa->szModuleName; break; + case DBVT_WORD: - { - char _id[64]; - mir_snprintf(_id, "%d", dbv.wVal); - id += _id; - if (id == login) - acc = accs[i]->szModuleName; - } + mir_snprintf(_id, "%d", dbv.wVal); + id += _id; + if (id == login) + acc = pa->szModuleName; break; + case DBVT_DWORD: - { - char _id[64]; - mir_snprintf(_id, "%d", dbv.dVal); - id += _id; - if (id == login) - acc = accs[i]->szModuleName; - } + mir_snprintf(_id, "%d", dbv.dVal); + id += _id; + if (id == login) + acc = pa->szModuleName; break; + case DBVT_ASCIIZ: - { - id += dbv.pszVal; - db_free(&dbv); - if (id == login) - acc = accs[i]->szModuleName; - } + id += dbv.pszVal; + db_free(&dbv); + if (id == login) + acc = pa->szModuleName; break; + case DBVT_UTF8: { char *tmp = mir_utf8decodeA(dbv.pszVal); @@ -1518,19 +1509,22 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_free(tmp); db_free(&dbv); if (id == login) - acc = accs[i]->szModuleName; + acc = pa->szModuleName; } break; + case DBVT_BLOB: //TODO db_free(&dbv); break; + case DBVT_WCHAR: //TODO db_free(&dbv); break; } } + if (acc.length()) { const char *uid = Proto_GetUniqueId(acc.c_str()); for (auto &hContact : Contacts(acc.c_str())) { diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index fc2b9b6fd1..2246e107cf 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -207,11 +207,8 @@ void LoadProtocols(void) GlobalNudge.Load();
- int numberOfProtocols = 0;
- PROTOACCOUNT **ppProtocolDescriptors;
- Proto_EnumAccounts(&numberOfProtocols, &ppProtocolDescriptors);
- for (int i = 0; i < numberOfProtocols; i++)
- Nudge_AddAccount(ppProtocolDescriptors[i]);
+ for (auto &pa : Accounts())
+ Nudge_AddAccount(pa);
shake.Load();
}
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp index f8ee4ec831..f818782ec7 100644 --- a/plugins/Ping/src/options.cpp +++ b/plugins/Ping/src/options.cpp @@ -191,15 +191,8 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)TranslateT("<none>"));
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)TranslateT("<all>"));
- {
- int num_protocols = 0;
- PROTOACCOUNT **pppDesc;
-
- Proto_EnumAccounts(&num_protocols, &pppDesc);
- for (int i = 0; i < num_protocols; i++)
- SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->tszAccountName);
-
- }
+ for (auto &pa : Accounts())
+ SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pa->tszAccountName);
if (add_edit_addr.pszProto[0] == '\0') {
SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_SETCURSEL, 0, 0);
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index 1cc8632675..0b21f6aac7 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -58,12 +58,8 @@ void set_list_changed(bool f) void SetProtoStatus(wchar_t *pszLabel, char *pszProto, int if_status, int new_status)
{
if (mir_strcmp(pszProto, Translate("<all>")) == 0) {
- int num_protocols;
- PROTOACCOUNT **pppDesc;
-
- Proto_EnumAccounts(&num_protocols, &pppDesc);
- for (int i = 0; i < num_protocols; i++)
- SetProtoStatus(pszLabel, pppDesc[i]->szModuleName, if_status, new_status);
+ for (auto &pa : Accounts())
+ SetProtoStatus(pszLabel, pa->szModuleName, if_status, new_status);
}
else {
if (ProtoServiceExists(pszProto, PS_GETSTATUS)) {
diff --git a/plugins/Popup/src/opt_gen.cpp b/plugins/Popup/src/opt_gen.cpp index 677e1bc459..3747ff1ada 100644 --- a/plugins/Popup/src/opt_gen.cpp +++ b/plugins/Popup/src/opt_gen.cpp @@ -202,14 +202,12 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM // new status options
{
- int protocolCount = 0;
statusOptionsCount = 0;
- PROTOACCOUNT **protocols;
- Proto_EnumAccounts(&protocolCount, &protocols);
DWORD globalFlags = 0;
- for (int i = 0; i < protocolCount; ++i) {
- if (!protocols[i]->bIsVirtual) {
- DWORD protoFlags = CallProtoService(protocols[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
+ auto &accs = Accounts();
+ for (auto &pa : accs) {
+ if (!pa->bIsVirtual) {
+ DWORD protoFlags = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
globalFlags |= protoFlags;
statusOptionsCount += CountStatusModes(protoFlags);
}
@@ -219,14 +217,14 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM statusOptions = new OPTTREE_OPTION[statusOptionsCount];
int pos = AddStatusModes(statusOptions, 0, LPGENW("Global Status"), globalFlags);
- for (int i = 0; i < protocolCount; ++i) {
- if (!protocols[i]->bIsVirtual) {
- DWORD protoFlags = CallProtoService(protocols[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
+ for (auto &pa : accs) {
+ if (!pa->bIsVirtual) {
+ DWORD protoFlags = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
if (!CountStatusModes(protoFlags))
continue;
wchar_t prefix[128];
- mir_snwprintf(prefix, LPGENW("Protocol Status")L"/%s", protocols[i]->tszAccountName);
+ mir_snwprintf(prefix, LPGENW("Protocol Status")L"/%s", pa->tszAccountName);
pos = AddStatusModes(statusOptions, pos, prefix, protoFlags);
}
}
@@ -234,17 +232,17 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM int index;
OptTree_ProcessMessage(hwnd, msg, wParam, lParam, &index, IDC_STATUSES, statusOptions, statusOptionsCount);
- for (int i = 0; i < protocolCount; ++i) {
- if (!protocols[i]->bIsVirtual) {
- DWORD protoFlags = CallProtoService(protocols[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
+ for (auto &pa : accs) {
+ if (!pa->bIsVirtual) {
+ DWORD protoFlags = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
if (!CountStatusModes(protoFlags))
continue;
char prefix[128];
- mir_snprintf(prefix, "Protocol Status/%s", protocols[i]->szModuleName);
+ mir_snprintf(prefix, "Protocol Status/%s", pa->szModuleName);
wchar_t pszSettingName[256];
- mir_snwprintf(pszSettingName, LPGENW("Protocol Status")L"/%s", protocols[i]->tszAccountName);
+ mir_snwprintf(pszSettingName, LPGENW("Protocol Status")L"/%s", pa->tszAccountName);
OptTree_SetOptions(hwnd, IDC_STATUSES, statusOptions, statusOptionsCount, db_get_dw(NULL, MODULNAME, prefix, 0), pszSettingName);
}
}
@@ -308,50 +306,48 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break;
case IDC_CUSTOMPOS:
- {
- RECT rcButton, rcBox;
- HWND hwndBox = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POSITION), nullptr, PositionBoxDlgProc);
- GetWindowRect((HWND)lParam, &rcButton);
- GetWindowRect(hwndBox, &rcBox);
- MoveWindow(hwndBox,
- rcButton.right - (rcBox.right - rcBox.left) + 15,
- rcButton.bottom + 3,
- rcBox.right - rcBox.left,
- rcBox.bottom - rcBox.top,
- FALSE);
-
- SetWindowLongPtr(hwndBox, GWL_EXSTYLE, GetWindowLongPtr(hwndBox, GWL_EXSTYLE) | WS_EX_LAYERED);
- SetLayeredWindowAttributes(hwndBox, NULL, 0, LWA_ALPHA);
- ShowWindow(hwndBox, SW_SHOW);
- for (int i = 0; i <= 255; i += 15) {
- SetLayeredWindowAttributes(hwndBox, NULL, i, LWA_ALPHA);
- UpdateWindow(hwndBox);
- Sleep(1);
- }
- SetWindowLongPtr(hwndBox, GWL_EXSTYLE, GetWindowLongPtr(hwndBox, GWL_EXSTYLE) & ~WS_EX_LAYERED);
+ {
+ RECT rcButton, rcBox;
+ HWND hwndBox = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POSITION), nullptr, PositionBoxDlgProc);
+ GetWindowRect((HWND)lParam, &rcButton);
+ GetWindowRect(hwndBox, &rcBox);
+ MoveWindow(hwndBox,
+ rcButton.right - (rcBox.right - rcBox.left) + 15,
+ rcButton.bottom + 3,
+ rcBox.right - rcBox.left,
+ rcBox.bottom - rcBox.top,
+ FALSE);
+
+ SetWindowLongPtr(hwndBox, GWL_EXSTYLE, GetWindowLongPtr(hwndBox, GWL_EXSTYLE) | WS_EX_LAYERED);
+ SetLayeredWindowAttributes(hwndBox, NULL, 0, LWA_ALPHA);
+ ShowWindow(hwndBox, SW_SHOW);
+ for (int i = 0; i <= 255; i += 15) {
+ SetLayeredWindowAttributes(hwndBox, NULL, i, LWA_ALPHA);
+ UpdateWindow(hwndBox);
+ Sleep(1);
+ }
+ SetWindowLongPtr(hwndBox, GWL_EXSTYLE, GetWindowLongPtr(hwndBox, GWL_EXSTYLE) & ~WS_EX_LAYERED);
- ShowWindow(hwndBox, SW_SHOW);
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
+ ShowWindow(hwndBox, SW_SHOW);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
case IDC_REORDERPOPUPS:
- {
PopupOptions.ReorderPopups = !PopupOptions.ReorderPopups;
PopupOptions.ReorderPopupsWarning = PopupOptions.ReorderPopups ? db_get_b(NULL, MODULNAME, "ReorderPopupsWarning", TRUE) : TRUE;
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
+ break;
case IDC_POPUPENABLED:
- {
- int chk = IsDlgButtonChecked(hwnd, IDC_POPUPENABLED);
- if (PopupOptions.ModuleIsEnabled&&chk || !PopupOptions.ModuleIsEnabled && !chk)
- svcEnableDisableMenuCommand(0, 0);
- EnableWindow(GetDlgItem(hwnd, IDC_STATUSES), PopupOptions.ModuleIsEnabled);
- EnableWindow(GetDlgItem(hwnd, IDC_DISABLEINFS), PopupOptions.ModuleIsEnabled);
- }
- break;
+ {
+ int chk = IsDlgButtonChecked(hwnd, IDC_POPUPENABLED);
+ if (PopupOptions.ModuleIsEnabled&&chk || !PopupOptions.ModuleIsEnabled && !chk)
+ svcEnableDisableMenuCommand(0, 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_STATUSES), PopupOptions.ModuleIsEnabled);
+ EnableWindow(GetDlgItem(hwnd, IDC_DISABLEINFS), PopupOptions.ModuleIsEnabled);
+ }
+ break;
case IDC_DISABLEINFS:
PopupOptions.DisableWhenFullscreen = !PopupOptions.DisableWhenFullscreen;
@@ -365,8 +361,7 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break;
case CBN_SELCHANGE: // ComboBox controls
- switch (LOWORD(wParam)) {
- // lParam = Handle to the control
+ switch (LOWORD(wParam)) { // lParam = Handle to the control
case IDC_WHERE:
PopupOptions.Position = ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
@@ -380,99 +375,101 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case EN_CHANGE: // Edit controls change
if (!bDlgInit) break;
- switch (LOWORD(wParam)) {
- // lParam = Handle to the control
+ switch (LOWORD(wParam)) { // lParam = Handle to the control
case IDC_SECONDS:
- {
- int seconds = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
- if (seconds >= SETTING_LIFETIME_MIN &&
- seconds <= SETTING_LIFETIME_MAX &&
- seconds != PopupOptions.Seconds) {
- PopupOptions.Seconds = seconds;
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ {
+ int seconds = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
+ if (seconds >= SETTING_LIFETIME_MIN &&
+ seconds <= SETTING_LIFETIME_MAX &&
+ seconds != PopupOptions.Seconds) {
+ PopupOptions.Seconds = seconds;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
}
- }
- break;
+ break;
+
case IDC_MINIMUMWIDTH:
- {
- int temp = GetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, nullptr, FALSE);
- if (temp >= SETTING_MINIMUMWIDTH_MIN &&
- temp <= SETTING_MAXIMUMWIDTH_MAX &&
- temp != PopupOptions.MinimumWidth) {
- PopupOptions.MinimumWidth = temp;
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ {
+ int temp = GetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, nullptr, FALSE);
+ if (temp >= SETTING_MINIMUMWIDTH_MIN &&
+ temp <= SETTING_MAXIMUMWIDTH_MAX &&
+ temp != PopupOptions.MinimumWidth) {
+ PopupOptions.MinimumWidth = temp;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
}
- }
- break;
+ break;
+
case IDC_MAXIMUMWIDTH:
- {
- int temp = GetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, nullptr, FALSE);
- if (temp >= SETTING_MINIMUMWIDTH_MIN &&
- temp <= SETTING_MAXIMUMWIDTH_MAX &&
- temp != PopupOptions.MaximumWidth) {
- PopupOptions.MaximumWidth = temp;
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ {
+ int temp = GetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, nullptr, FALSE);
+ if (temp >= SETTING_MINIMUMWIDTH_MIN &&
+ temp <= SETTING_MAXIMUMWIDTH_MAX &&
+ temp != PopupOptions.MaximumWidth) {
+ PopupOptions.MaximumWidth = temp;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
}
- }
- break;
+ break;
}// end switch(idCtrl)
break;
case EN_KILLFOCUS: // Edit controls lost fokus
- switch (LOWORD(wParam)) {
- // lParam = Handle to the control
+ switch (LOWORD(wParam)) { // lParam = Handle to the control
case IDC_SECONDS:
- {
- int seconds = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
- if (seconds > SETTING_LIFETIME_MAX)
- PopupOptions.Seconds = SETTING_LIFETIME_MAX;
- else if (seconds < SETTING_LIFETIME_MIN)
- PopupOptions.Seconds = SETTING_LIFETIME_MIN;
- if (seconds != PopupOptions.Seconds) {
- SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.Seconds, FALSE);
- ErrorMSG(SETTING_LIFETIME_MIN, SETTING_LIFETIME_MAX);
- SetFocus((HWND)lParam);
+ {
+ int seconds = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
+ if (seconds > SETTING_LIFETIME_MAX)
+ PopupOptions.Seconds = SETTING_LIFETIME_MAX;
+ else if (seconds < SETTING_LIFETIME_MIN)
+ PopupOptions.Seconds = SETTING_LIFETIME_MIN;
+ if (seconds != PopupOptions.Seconds) {
+ SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.Seconds, FALSE);
+ ErrorMSG(SETTING_LIFETIME_MIN, SETTING_LIFETIME_MAX);
+ SetFocus((HWND)lParam);
+ }
}
- }
- break;
+ break;
+
case IDC_MINIMUMWIDTH:
- {
- int temp = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
- if (temp < SETTING_MINIMUMWIDTH_MIN)
- PopupOptions.MinimumWidth = SETTING_MINIMUMWIDTH_MIN;
- else if (temp > SETTING_MAXIMUMWIDTH_MAX)
- PopupOptions.MinimumWidth = SETTING_MAXIMUMWIDTH_MAX;
- if (temp != PopupOptions.MinimumWidth) {
- SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.MinimumWidth, FALSE);
- ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX);
- SetFocus((HWND)lParam);
- break;
- }
- if (temp > PopupOptions.MaximumWidth) {
- PopupOptions.MaximumWidth = min(temp, SETTING_MAXIMUMWIDTH_MAX);
- SetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, PopupOptions.MaximumWidth, FALSE);
+ {
+ int temp = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
+ if (temp < SETTING_MINIMUMWIDTH_MIN)
+ PopupOptions.MinimumWidth = SETTING_MINIMUMWIDTH_MIN;
+ else if (temp > SETTING_MAXIMUMWIDTH_MAX)
+ PopupOptions.MinimumWidth = SETTING_MAXIMUMWIDTH_MAX;
+ if (temp != PopupOptions.MinimumWidth) {
+ SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.MinimumWidth, FALSE);
+ ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX);
+ SetFocus((HWND)lParam);
+ break;
+ }
+ if (temp > PopupOptions.MaximumWidth) {
+ PopupOptions.MaximumWidth = min(temp, SETTING_MAXIMUMWIDTH_MAX);
+ SetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, PopupOptions.MaximumWidth, FALSE);
+ }
}
- }
- break;
+ break;
+
case IDC_MAXIMUMWIDTH:
- {
- int temp = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
- if (temp >= SETTING_MAXIMUMWIDTH_MAX)
- PopupOptions.MaximumWidth = SETTING_MAXIMUMWIDTH_MAX;
- else if (temp < SETTING_MINIMUMWIDTH_MIN)
- PopupOptions.MaximumWidth = SETTING_MINIMUMWIDTH_MIN;
- if (temp != PopupOptions.MaximumWidth) {
- SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.MaximumWidth, FALSE);
- ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX);
- SetFocus((HWND)lParam);
- break;
- }
- if (temp < PopupOptions.MinimumWidth) {
- PopupOptions.MinimumWidth = max(temp, SETTING_MINIMUMWIDTH_MIN);
- SetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, PopupOptions.MinimumWidth, FALSE);
+ {
+ int temp = GetDlgItemInt(hwnd, LOWORD(wParam), nullptr, FALSE);
+ if (temp >= SETTING_MAXIMUMWIDTH_MAX)
+ PopupOptions.MaximumWidth = SETTING_MAXIMUMWIDTH_MAX;
+ else if (temp < SETTING_MINIMUMWIDTH_MIN)
+ PopupOptions.MaximumWidth = SETTING_MINIMUMWIDTH_MIN;
+ if (temp != PopupOptions.MaximumWidth) {
+ SetDlgItemInt(hwnd, LOWORD(wParam), PopupOptions.MaximumWidth, FALSE);
+ ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX);
+ SetFocus((HWND)lParam);
+ break;
+ }
+ if (temp < PopupOptions.MinimumWidth) {
+ PopupOptions.MinimumWidth = max(temp, SETTING_MINIMUMWIDTH_MIN);
+ SetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, PopupOptions.MinimumWidth, FALSE);
+ }
}
- }
- break;
+ break;
}
break;
}
@@ -519,48 +516,42 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM db_set_b(NULL, MODULNAME, "DisableWhenFullscreen", PopupOptions.DisableWhenFullscreen);
// new status options
- {
- int protocolCount;
- PROTOACCOUNT **protocols;
- Proto_EnumAccounts(&protocolCount, &protocols);
-
- for (int i = 0; i < protocolCount; ++i) {
- if (!protocols[i]->bIsVirtual) {
- char prefix[128];
- mir_snprintf(prefix, "Protocol Status/%s", protocols[i]->szModuleName);
-
- wchar_t pszSettingName[256];
- mir_snwprintf(pszSettingName, L"Protocol Status/%s", protocols[i]->tszAccountName);
- db_set_dw(NULL, MODULNAME, prefix, OptTree_GetOptions(hwnd, IDC_STATUSES, statusOptions, statusOptionsCount, pszSettingName));
- }
+ for (auto &pa : Accounts())
+ if (!pa->bIsVirtual) {
+ char prefix[128];
+ mir_snprintf(prefix, "Protocol Status/%s", pa->szModuleName);
+
+ wchar_t pszSettingName[256];
+ mir_snwprintf(pszSettingName, L"Protocol Status/%s", pa->tszAccountName);
+ db_set_dw(NULL, MODULNAME, prefix, OptTree_GetOptions(hwnd, IDC_STATUSES, statusOptions, statusOptionsCount, pszSettingName));
}
- db_set_dw(NULL, MODULNAME, "Global Status", OptTree_GetOptions(hwnd, IDC_STATUSES, statusOptions, statusOptionsCount, L"Global Status"));
- }
+
+ db_set_dw(NULL, MODULNAME, "Global Status", OptTree_GetOptions(hwnd, IDC_STATUSES, statusOptions, statusOptionsCount, L"Global Status"));
return TRUE;
}
break;
case IDC_MINIMUMWIDTH_SPIN:
- {
- LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
- int temp = lpnmud->iPos + lpnmud->iDelta;
- if (temp > PopupOptions.MaximumWidth) {
- PopupOptions.MaximumWidth = min(temp, SETTING_MAXIMUMWIDTH_MAX);
- SetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, PopupOptions.MaximumWidth, FALSE);
+ {
+ LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
+ int temp = lpnmud->iPos + lpnmud->iDelta;
+ if (temp > PopupOptions.MaximumWidth) {
+ PopupOptions.MaximumWidth = min(temp, SETTING_MAXIMUMWIDTH_MAX);
+ SetDlgItemInt(hwnd, IDC_MAXIMUMWIDTH, PopupOptions.MaximumWidth, FALSE);
+ }
}
- }
- break;
+ break;
case IDC_MAXIMUMWIDTH_SPIN:
- {
- LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
- int temp = lpnmud->iPos + lpnmud->iDelta;
- if (temp < PopupOptions.MinimumWidth) {
- PopupOptions.MinimumWidth = max(temp, SETTING_MINIMUMWIDTH_MIN);
- SetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, PopupOptions.MinimumWidth, FALSE);
+ {
+ LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
+ int temp = lpnmud->iPos + lpnmud->iDelta;
+ if (temp < PopupOptions.MinimumWidth) {
+ PopupOptions.MinimumWidth = max(temp, SETTING_MINIMUMWIDTH_MIN);
+ SetDlgItemInt(hwnd, IDC_MINIMUMWIDTH, PopupOptions.MinimumWidth, FALSE);
+ }
}
}
- }
break;
case WM_DESTROY:
@@ -586,7 +577,8 @@ void ErrorMSG(int minValue, int maxValue) MSGERROR(str);
}
-void Check_ReorderPopups(HWND hwnd) {
+void Check_ReorderPopups(HWND hwnd)
+{
if (!PopupOptions.ReorderPopups && PopupOptions.ReorderPopupsWarning) {
int res = MessageBox(hwnd,
TranslateT("'Reorder popups' option is currently disabled.\r\nThis may cause misaligned popups when used with\r\navatars and text replacement (mainly NewXstatusNotify).\r\n\r\nDo you want to enable popup reordering now?\r\n"),
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp index 72489fc90d..629faddd9a 100644 --- a/plugins/QuickContacts/src/quickcontacts.cpp +++ b/plugins/QuickContacts/src/quickcontacts.cpp @@ -107,15 +107,9 @@ int ModulesLoaded(WPARAM, LPARAM) InitOptions();
// Get number of protocols
- int pcount = 0;
- PROTOACCOUNT** pdesc;
-
- Proto_EnumAccounts(&pcount, &pdesc);
-
- opts.num_protos = pcount;
+ Proto_EnumAccounts(&opts.num_protos, nullptr);
// Add hotkey to multiple services
-
hasNewHotkeyModule = TRUE;
HOTKEYDESC hkd = {};
diff --git a/plugins/RemovePersonalSettings/src/rps.cpp b/plugins/RemovePersonalSettings/src/rps.cpp index f48e3d4855..b1ec8ef5b2 100644 --- a/plugins/RemovePersonalSettings/src/rps.cpp +++ b/plugins/RemovePersonalSettings/src/rps.cpp @@ -164,20 +164,14 @@ INT_PTR RemoveAllService(WPARAM, LPARAM) void SetProtocolsOffline()
{
if ( GetSettingBool("GlobalSettings", "SetProtocolsOffline", TRUE) ) {
- PROTOACCOUNT **accounts;
- int count;
- Proto_EnumAccounts(&count, &accounts);
-
- for (int i = 0; i < count; i++) {
- /*if (protos[i]->type != PROTOTYPE_PROTOCOL)
- continue;*/
- if (!accounts[i]->bIsEnabled)
+ for (auto &pa : Accounts()) {
+ if (!pa->bIsEnabled)
continue;
- if (accounts[i]->szModuleName == nullptr || accounts[i]->szModuleName[0] == '\0')
+ if (pa->szModuleName == nullptr || pa->szModuleName[0] == '\0')
continue;
- CallProtoService(accounts[i]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
+ CallProtoService(pa->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
}
// Give some time to make it really offline
@@ -288,24 +282,18 @@ void RemoveSettings() // Delete protocol settings
if ( GetSettingBool("GlobalSettings", "RemoveProtocolSettings", TRUE) ) {
- PROTOACCOUNT **accounts;
- int i,count;
- Proto_EnumAccounts(&count, &accounts);
-
- for (i = 0; i < count; i++) {
- /*if (protos[i]->type != PROTOTYPE_PROTOCOL)
- continue;*/
- if (!accounts[i]->bIsEnabled)
+ for (auto &pa : Accounts()) {
+ if (!pa->bIsEnabled)
continue;
- if (accounts[i]->szModuleName == nullptr || accounts[i]->szModuleName[0] == '\0')
+ if (pa->szModuleName == nullptr || pa->szModuleName[0] == '\0')
continue;
- RemoveProtocolSettings(accounts[i]->szModuleName);
+ RemoveProtocolSettings(pa->szModuleName);
}
// Get disabled protocols
- if ( GetSettings("DisabledProtocols", buffer, sizeof(buffer)) ) {
+ if (GetSettings("DisabledProtocols", buffer, sizeof(buffer))) {
char *name;
char *value;
@@ -397,20 +385,14 @@ void RemoveDirectories() // Remove protocol folders
if (GetSettingBool("GlobalSettings", "RemoveProtocolFolders", TRUE)) {
- PROTOACCOUNT **accounts;
- int count;
- Proto_EnumAccounts(&count, &accounts);
-
- for (int i = 0; i < count; i++) {
- /*if (protos[i]->type != PROTOTYPE_PROTOCOL)
- continue;*/
- if (!accounts[i]->bIsEnabled)
+ for (auto &pa : Accounts()) {
+ if (!pa->bIsEnabled)
continue;
- if (accounts[i]->szModuleName == nullptr || accounts[i]->szModuleName[0] == '\0')
+ if (pa->szModuleName == nullptr || pa->szModuleName[0] == '\0')
continue;
- mir_snprintf(dir, "%s%s", gMirandaDir, accounts[i]->szModuleName);
+ mir_snprintf(dir, "%s%s", gMirandaDir, pa->szModuleName);
DeleteFileOrFolder(dir);
}
}
diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp index cbebb2bcf2..a5cee92a75 100644 --- a/plugins/SMS/src/functions.cpp +++ b/plugins/SMS/src/functions.cpp @@ -492,7 +492,6 @@ int RefreshAccountList(WPARAM, LPARAM) {
int dwAccCount = 0, dwSMSAccountsCount = 0;
PROTOACCOUNT **ppaAccounts;
-
Proto_EnumAccounts((int*)&dwAccCount, &ppaAccounts);
FreeAccountList();
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 5844557134..e927f7a853 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -19,16 +19,12 @@ void loadSupportedProtocols() db_set_s(0, MODULENAME, "protos", szNames);
}
- int numberOfProtocols;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&numberOfProtocols, &protos);
-
- for (int i = 0; i < numberOfProtocols; i++) {
- if (!protos[i]->szModuleName || !CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0))
+ for (auto &pa : Accounts()) {
+ if (!pa->szModuleName || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0))
continue;
SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro));
- p->name = mir_strdup(protos[i]->szModuleName);
+ p->name = mir_strdup(pa->szModuleName);
if (szNames && p->name) {
char tmp[128]; strncpy(tmp, p->name, sizeof(tmp) - 1); mir_strncat(tmp, ":", _countof(tmp) - mir_strlen(tmp));
LPSTR szName = strstr(szNames, tmp);
diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp index 00f5eaf808..4b4882d5d6 100644 --- a/plugins/SeenPlugin/src/options.cpp +++ b/plugins/SeenPlugin/src/options.cpp @@ -287,17 +287,13 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM tvis.item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- PROTOACCOUNT **protos;
- int numberOfProtocols;
- Proto_EnumAccounts(&numberOfProtocols, &protos);
-
- for (int i = 0; i < numberOfProtocols; i++) {
- if (CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ for (auto &pa : Accounts()) {
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
- tvis.item.pszText = protos[i]->tszAccountName;
- tvis.item.lParam = (LPARAM)mir_strdup(protos[i]->szModuleName);
- tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(protos[i]->szModuleName) + 1);
+ tvis.item.pszText = pa->tszAccountName;
+ tvis.item.lParam = (LPARAM)mir_strdup(pa->szModuleName);
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(pa->szModuleName) + 1);
TreeView_InsertItem(GetDlgItem(hdlg, IDC_PROTOCOLLIST), &tvis);
}
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 5782e39cb2..38a0c8e997 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1367,24 +1367,19 @@ void RegisterHotkey(void) static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
{
-#ifdef _DEBUG
- log2file("ChangeStatusMsgPrebuild()");
-#endif
- PROTOACCOUNT **pa;
- int iStatusMenuItemCount = 0, count;
+ int iStatusMenuItemCount = 0;
DWORD iStatusMsgFlags = 0;
- Proto_EnumAccounts(&count, &pa);
- hProtoStatusMenuItem = (HANDLE *)mir_realloc(hProtoStatusMenuItem, sizeof(HANDLE) * count);
- for (int i = 0; i < count; ++i)
- {
- if (!pa[i]->IsEnabled())
+ auto &accs = Accounts();
+ hProtoStatusMenuItem = (HANDLE *)mir_realloc(hProtoStatusMenuItem, sizeof(HANDLE) * accs.getCount());
+ for (auto &pa : accs) {
+ if (!pa->IsEnabled())
continue;
- if (CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)
- iStatusMsgFlags |= CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3,0);
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)
+ iStatusMsgFlags |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
- if (!pa[i]->bIsVisible)
+ if (!pa->bIsVisible)
continue;
iStatusMenuItemCount++;
@@ -1406,35 +1401,34 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) // mi.popupPosition = 500084000; !!!!!!!!!!!!!!!!!!!!!!!
mi.position = 2000040000;
- for (int i = 0; i < count; ++i)
- {
- if (!pa[i]->IsEnabled())
+ int i = 0;
+ for (auto &pa : accs) {
+ if (!pa->IsEnabled())
continue;
- if (!CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0))
+ if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0))
continue;
- if (!(CallProtoService(pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
+ if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
- if (!pa[i]->bIsVisible)
+ if (!pa->bIsVisible)
continue;
char szSetting[80];
- mir_snprintf(szSetting, "Proto%sFlags", pa[i]->szModuleName);
+ mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG)
continue;
- if (pa[i]->IsLocked())
- {
+ if (pa->IsLocked()) {
wchar_t szBuffer[256];
- mir_snwprintf(szBuffer, TranslateT("%s (locked)"), pa[i]->tszAccountName);
+ mir_snwprintf(szBuffer, TranslateT("%s (locked)"), pa->tszAccountName);
mi.root = Menu_CreateRoot(MO_STATUS, szBuffer, mi.position);
}
- else mi.root = Menu_CreateRoot(MO_STATUS, pa[i]->tszAccountName, mi.position);
+ else mi.root = Menu_CreateRoot(MO_STATUS, pa->tszAccountName, mi.position);
- hProtoStatusMenuItem[i] = Menu_AddStatusMenuItem(&mi);
+ hProtoStatusMenuItem[i++] = Menu_AddStatusMenuItem(&mi);
}
return 0;
diff --git a/plugins/SkypeStatusChange/src/options.cpp b/plugins/SkypeStatusChange/src/options.cpp index d2917833df..b80d7abfb2 100644 --- a/plugins/SkypeStatusChange/src/options.cpp +++ b/plugins/SkypeStatusChange/src/options.cpp @@ -41,15 +41,9 @@ HTREEITEM tree_insert_item(HWND hwndTree, wchar_t *pName, HTREEITEM htiParent, E void InitProtocolTree(HWND hwndTreeCtrl)
{
- int cAccounts = 0;
- PROTOACCOUNT** ppAccount;
-
enum{OFFLINE_STATUS_INDEX = 5};
- Proto_EnumAccounts(&cAccounts, &ppAccount);
- for(int i = 0; i < cAccounts;++i)
- {
- PROTOACCOUNT* pAccount = ppAccount[i];
+ for (auto &pAccount : Accounts()) {
CTreeItemData* pItemData = new CTreeItemData;
pItemData->m_nType = CTreeItemData::Protocol;
pItemData->m_pszModule = pAccount->szModuleName;
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 6c061d5fab..d4c4fdf5d0 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -836,10 +836,8 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) AddProtoAsCategory(pd->szName, defaultFile);
}
- PROTOACCOUNT **accList;
- Proto_EnumAccounts(&protoCount, &accList);
- for (int i = 0; i < protoCount; i++)
- AddAccountAsCategory(accList[i], defaultFile);
+ for (auto &pa : Accounts())
+ AddAccountAsCategory(pa, defaultFile);
for (auto &hContact : Contacts())
AddContactTransportAsCategory(hContact, defaultFile);
diff --git a/plugins/Spamotron/src/options.cpp b/plugins/Spamotron/src/options.cpp index f4d4733a49..43035e9f59 100644 --- a/plugins/Spamotron/src/options.cpp +++ b/plugins/Spamotron/src/options.cpp @@ -91,8 +91,7 @@ extern HINSTANCE hInst; INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static int bInitializing = 0, i, j, numProtocols;
- PROTOACCOUNT **pd;
+ static int bInitializing = 0, i, j;
wchar_t pName[256] = {0};
char protoOption[256] = {0};
HWND hProtocolsList = GetDlgItem(optDlg, IDC_OPT_PROTOCOLS);
@@ -125,18 +124,17 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM lvc.cx = 120;
ListView_InsertColumn(hProtocolsList, 0, &lvc);
lvi.mask = LVIF_TEXT | LVIF_STATE;
- Proto_EnumAccounts(&numProtocols, &pd);
- for (i = 0, j = 0; i < numProtocols; i++)
- {
+
+ for (auto &pa : Accounts()) {
lvi.iItem = i;
- _getMOptS(pName, 200*sizeof(wchar_t), pd[i]->szModuleName, "AM_BaseProto", L"");
+ _getMOptS(pName, 200*sizeof(wchar_t), pa->szModuleName, "AM_BaseProto", L"");
if (mir_wstrcmp(pName, L"ICQ") != 0)
continue;
- lvi.pszText = mir_a2u(pd[i]->szModuleName);
+ lvi.pszText = mir_a2u(pa->szModuleName);
ListView_InsertItem(hProtocolsList, &lvi);
memset(protoOption, 0, sizeof(protoOption));
mir_strcat(protoOption, "proto_");
- mir_strcat(protoOption, pd[i]->szModuleName);
+ mir_strcat(protoOption, pa->szModuleName);
ListView_SetCheckState(hProtocolsList, j++, _getOptB(protoOption, 0));
}
@@ -196,7 +194,8 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM _saveDlgItemText(optDlg, IDC_OPT_DONT_REPLY_MSG_WORDLIST, "DontReplyMsgWordlist");
_saveDlgItemInt(optDlg, IDC_OPT_MAX_MSG_CONTACT, "MaxMsgContactCountPerDay");
_saveDlgItemInt(optDlg, IDC_OPT_MAX_SAME_MSG, "MaxSameMsgCountPerDay");
- numProtocols = ListView_GetItemCount(hProtocolsList);
+
+ int numProtocols = ListView_GetItemCount(hProtocolsList);
for (i = 0; i < numProtocols; i++) {
ListView_GetItemText(hProtocolsList, i, 0, buf, _countof(buf));
//wcstombs(protoName, buf, _countof(buf));
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index 0d70c4d010..bb58b27323 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -726,27 +726,25 @@ static void CheckContinuouslyFunction(void *) if (((!ping) && (!InternetGetConnectedState(nullptr, 0))) || ((ping) && (!bLastPingResult) && (pingFailures >= db_get_w(0, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT)))) { pingFailures = 0; - int count; - PROTOACCOUNT** protos; - Proto_EnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) { - if (!IsSuitableProto(protos[i])) + for (auto &pa : Accounts()) { + if (!IsSuitableProto(pa)) continue; - if (IsStatusConnecting(CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0))) { - log_debugA("CheckContinuouslyFunction: %s is connecting", protos[i]->szModuleName); + if (IsStatusConnecting(CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0))) { + log_debugA("CheckContinuouslyFunction: %s is connecting", pa->szModuleName); continue; // connecting, leave alone } - if (IsProtocolEnabledService(0, (LPARAM)protos[i]->szModuleName)) { - log_debugA("CheckContinuouslyFunction: forcing %s offline", protos[i]->szModuleName); - CallProtoService(protos[i]->szModuleName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); + if (IsProtocolEnabledService(0, (LPARAM)pa->szModuleName)) { + log_debugA("CheckContinuouslyFunction: forcing %s offline", pa->szModuleName); + CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); } } + if (StartTimer(IDT_CHECKCONN | IDT_PROCESSACK, -1, FALSE)) {// are our 'set offlines' noticed? log_debugA("CheckContinuouslyFunction: currently checking"); return; } + log_infoA("KeepStatus: connection lost! (continuesly check)"); NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOST, 0); ProcessPopup(KS_CONN_STATE_LOST, 0); diff --git a/plugins/StatusManager/src/KeepStatus/ks_options.cpp b/plugins/StatusManager/src/KeepStatus/ks_options.cpp index 812d26ad6c..72b5bb2bd3 100644 --- a/plugins/StatusManager/src/KeepStatus/ks_options.cpp +++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp @@ -58,20 +58,16 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam lvItem.iItem = 0; lvItem.iSubItem = 0; - int count; - PROTOACCOUNT** protos; - Proto_EnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) { - if (!IsSuitableProto(protos[i])) + for (auto &pa : Accounts()) { + if (!IsSuitableProto(pa)) continue; - lvItem.pszText = protos[i]->tszAccountName; - lvItem.lParam = (LPARAM)protos[i]->szModuleName; + lvItem.pszText = pa->tszAccountName; + lvItem.lParam = (LPARAM)pa->szModuleName; ListView_InsertItem(hList, &lvItem); char dbSetting[128]; - mir_snprintf(dbSetting, "%s_enabled", protos[i]->szModuleName); + mir_snprintf(dbSetting, "%s_enabled", pa->szModuleName); ListView_SetCheckState(hList, lvItem.iItem, db_get_b(0, KSMODULENAME, dbSetting, TRUE)); lvItem.iItem++; } diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index 2a72f80300..793276ff6a 100644 --- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -221,12 +221,7 @@ static void CALLBACK SetStatusTimed(HWND, UINT, UINT_PTR, DWORD) static int OnOkToExit(WPARAM, LPARAM) { // save last protocolstatus - int count; - PROTOACCOUNT** protos; - Proto_EnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) { - PROTOACCOUNT *pa = protos[i]; + for (auto &pa : Accounts()) { if (!IsSuitableProto(pa)) continue; diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp index a35b8496da..9bcfff4d89 100644 --- a/plugins/StatusManager/src/commonstatus.cpp +++ b/plugins/StatusManager/src/commonstatus.cpp @@ -151,25 +151,21 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) if (it->m_szMsg != nullptr && GetActualStatus(it) != ID_STATUS_OFFLINE) return 0; - int count; - PROTOACCOUNT **protos; - Proto_EnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) { - if (!IsSuitableProto(protos[i])) + for (auto &pa : Accounts()) { + if (!IsSuitableProto(pa)) continue; pstatus = 0; for (j = 0; j < protoList.getCount(); j++) - if (!mir_strcmp(protos[i]->szModuleName, ps[j]->m_szName)) + if (!mir_strcmp(pa->szModuleName, ps[j]->m_szName)) pstatus = GetActualStatus(ps[j]); if (pstatus == 0) - pstatus = CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0); + pstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - if (db_get_b(0, protos[i]->szModuleName, "LockMainStatus", 0)) { + if (db_get_b(0, pa->szModuleName, "LockMainStatus", 0)) { // if proto is locked, pstatus must be the current status - if (pstatus != CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0)) + if (pstatus != CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)) return 0; } else { @@ -295,12 +291,10 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM) static INT_PTR GetProtocolCountService(WPARAM, LPARAM) { - int pCount = 0, count; - PROTOACCOUNT **accs; - Proto_EnumAccounts(&count, &accs); + int pCount = 0; - for (int i = 0; i < count; i++) - if (IsSuitableProto(accs[i])) + for (auto &pa : Accounts()) + if (IsSuitableProto(pa)) pCount++; return pCount; diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp index 5d5db295e3..5996a200c6 100644 --- a/plugins/StatusManager/src/main.cpp +++ b/plugins/StatusManager/src/main.cpp @@ -83,13 +83,9 @@ int OnModulesLoaded(WPARAM, LPARAM) //////////////////////////////////////////////////////////////////////////////////////// - int count; - PROTOACCOUNT** protos; - Proto_EnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) - if (IsSuitableProto(protos[i])) - protoList.insert(new SMProto(protos[i])); + for (auto &pa : Accounts()) + if (IsSuitableProto(pa)) + protoList.insert(new SMProto(pa)); return 0; } diff --git a/plugins/StopSpamMod/src/options.cpp b/plugins/StopSpamMod/src/options.cpp index 86ef404329..7d7e6f5770 100755 --- a/plugins/StopSpamMod/src/options.cpp +++ b/plugins/StopSpamMod/src/options.cpp @@ -123,18 +123,16 @@ public: btn_ADDALL.OnClick = Callback(this, &COptProtoDlg::onClick_ADDALL);
btn_REMOVEALL.OnClick = Callback(this, &COptProtoDlg::onClick_REMOVEALL);
}
+
virtual void OnInitDialog() override
{
- int nAccs;
- PROTOACCOUNT **pppd;
- Proto_EnumAccounts(&nAccs, &pppd);
- for (int i = 0; i < nAccs; ++i)
- {
- wchar_t *str = mir_utf8decodeW(pppd[i]->szModuleName);
- ProtoInList(pppd[i]->szModuleName) ? list_USEDPROTO.AddString(str) : list_ALLPROTO.AddString(str);
+ for (auto &pa : Accounts()) {
+ wchar_t *str = mir_utf8decodeW(pa->szModuleName);
+ ProtoInList(pa->szModuleName) ? list_USEDPROTO.AddString(str) : list_ALLPROTO.AddString(str);
mir_free(str);
}
}
+
virtual void OnApply() override
{
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index be3667ed3a..b001fa98db 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -305,12 +305,9 @@ void __cdecl CleanProtocolExclThread(void *param) void __cdecl CleanThread(void*)
{
std::list<std::string> protocols;
- int count = 0;
- PROTOACCOUNT **accounts;
- Proto_EnumAccounts(&count, &accounts);
- for (int i = 0; i < count; i++)
- if (!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols
- protocols.push_back(accounts[i]->szModuleName);
+ for (auto &pa : Accounts())
+ if (!strstr(pa->szModuleName, "MetaContacts") && !strstr(pa->szModuleName, "Weather")) //not real protocols
+ protocols.push_back(pa->szModuleName);
std::list<std::string>::iterator end = protocols.end();
for (std::list<std::string>::iterator i = protocols.begin(); i != end; ++i) {
diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp index 158f0f5acd..db5d0f6588 100644 --- a/plugins/StopSpamPlus/src/options.cpp +++ b/plugins/StopSpamPlus/src/options.cpp @@ -115,19 +115,14 @@ public: item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = 1000;
- int n;
- PROTOACCOUNT **pa;
- Proto_EnumAccounts(&n, &pa);
-
- for (int i = 0; i < n; i++) {
- PROTOACCOUNT *p = pa[i];
- if (!p->IsEnabled() || p->bIsVirtual)
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled() || pa->bIsVirtual)
continue;
- item.lParam = (LPARAM)p->szModuleName;
- item.pszText = p->tszAccountName;
+ item.lParam = (LPARAM)pa->szModuleName;
+ item.pszText = pa->tszAccountName;
int idx = m_accounts.InsertItem(&item);
- m_accounts.SetCheckState(idx, g_sets.ProtoDisabled(p->szModuleName));
+ m_accounts.SetCheckState(idx, g_sets.ProtoDisabled(pa->szModuleName));
}
}
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp index 02786dbd07..13cf5ad354 100644 --- a/plugins/TipperYM/src/options.cpp +++ b/plugins/TipperYM/src/options.cpp @@ -1916,17 +1916,13 @@ INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
- int count = 0;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
-
- for (int i = 0; i < count; i++) {
- if (CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0) {
- tvi.item.pszText = accs[i]->tszAccountName;
+ for (auto &pa : Accounts()) {
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0) {
+ tvi.item.pszText = pa->tszAccountName;
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
- tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, false) ? 2 : 1);
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(pa->tszAccountName, false) ? 2 : 1);
TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), &tvi);
- tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, true) ? 2 : 1);
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(pa->tszAccountName, true) ? 2 : 1);
TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), &tvi);
}
}
diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index c5e0a5795d..8095077b7d 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -633,31 +633,25 @@ BOOL CTooltipNotify::ProtosDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM) ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_PROTOS), LVS_EX_CHECKBOXES);
// enum protocols currently running
- int iProtoCount = 0;
- PROTOACCOUNT **ppProtos = nullptr;
- Proto_EnumAccounts(&iProtoCount, &ppProtos);
-
- // and fill in the list
- for (int i = 0; i < iProtoCount; i++) {
+ auto &accs = Accounts();
+ for (auto &pa : accs) {
LV_ITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0;
- lvi.iItem = i;
- lvi.lParam = i;
+ lvi.iItem = lvi.lParam = accs.indexOf(&pa);
WCHAR wszProto[128];
- long lLen = MultiByteToWideChar(CP_ACP, 0, ppProtos[i]->szModuleName,
- (int)mir_strlen(ppProtos[i]->szModuleName), wszProto, _countof(wszProto));
+ long lLen = MultiByteToWideChar(CP_ACP, 0, pa->szModuleName, (int)mir_strlen(pa->szModuleName), wszProto, _countof(wszProto));
wszProto[lLen] = L'\0';
lvi.pszText = wszProto;
ListView_InsertItem(GetDlgItem(hDlg, IDC_PROTOS), &lvi);
- BYTE bProtoState = db_get_b(NULL, MODULENAME, ppProtos[i]->szModuleName, ProtoUserBit | ProtoIntBit);
- BOOL bProtoEnabled = (bProtoState & ProtoUserBit) != 0;
- ListView_SetCheckState(GetDlgItem(hDlg, IDC_PROTOS), i, bProtoEnabled);
+ BYTE bProtoState = db_get_b(NULL, MODULENAME, pa->szModuleName, ProtoUserBit | ProtoIntBit);
+ BOOL bProtoEnabled = (bProtoState & ProtoUserBit) != 0;
+ ListView_SetCheckState(GetDlgItem(hDlg, IDC_PROTOS), lvi.iItem, bProtoEnabled);
}
}
return TRUE;
diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index 1bd103b6f3..36f8abde3c 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -275,16 +275,13 @@ HICON CPsTreeItem::ProtoIcon() if (!_pszName)
return nullptr;
- PROTOACCOUNT **pa;
- int ProtoCount;
- Proto_EnumAccounts(&ProtoCount, &pa);
- for (int i = 0; i < ProtoCount; i++) {
- if (!mir_wstrncmpi(pa[i]->tszAccountName, _A2T(_pszName), mir_wstrlen(pa[i]->tszAccountName))) {
+ for (auto &pa : Accounts()) {
+ if (!mir_wstrncmpi(pa->tszAccountName, _A2T(_pszName), mir_wstrlen(pa->tszAccountName))) {
CHAR szIconID[MAX_PATH];
- mir_snprintf(szIconID, "core_status_%s1", pa[i]->szModuleName);
+ mir_snprintf(szIconID, "core_status_%s1", pa->szModuleName);
HICON hIco = IcoLib_GetIcon(szIconID);
if (!hIco)
- hIco = (HICON)CallProtoService(pa[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL, NULL);
+ hIco = (HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL, NULL);
return hIco;
}
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index b5142bdcd4..3e4807a5ee 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -562,15 +562,12 @@ void DlgContactInfoInitTreeIcons() psh._dwFlags |= PSF_PROTOPAGESONLY_INIT;
// enumerate all protocols
- PROTOACCOUNT **pd;
- int ProtoCount = 0;
- Proto_EnumAccounts(&ProtoCount, &pd);
- for (int i = 0; i < ProtoCount; i++) {
+ for (auto &pa : Accounts()) {
// enumerate all contacts
for (psh._hContact = db_find_first(); psh._hContact != NULL; psh._hContact = db_find_next(psh._hContact)) {
// compare contact's protocol to the current one, to add
LPCSTR pszContactProto = Proto_GetBaseAccountName(psh._hContact);
- if ((INT_PTR)pszContactProto != CALLSERVICE_NOTFOUND && !mir_strcmp(pd[i]->szModuleName, pszContactProto)) {
+ if ((INT_PTR)pszContactProto != CALLSERVICE_NOTFOUND && !mir_strcmp(pa->szModuleName, pszContactProto)) {
// call a notification for the contact to retrieve all protocol specific tree items
NotifyEventHooks(g_hDetailsInitEvent, (WPARAM)&psh, (LPARAM)psh._hContact);
if (psh._pPages) {
@@ -630,12 +627,10 @@ void DlgContactInfoLoadModule() // check whether changing my details via UserInfoEx is basically possible
myGlobals.CanChangeDetails = FALSE;
- PROTOACCOUNT **pAcc;
- int nAccCount;
- Proto_EnumAccounts(&nAccCount, &pAcc);
- for (int i = 0; (i < nAccCount) && !myGlobals.CanChangeDetails; i++)
- if (IsProtoAccountEnabled(pAcc[i])) // update my contact information on icq server
- myGlobals.CanChangeDetails = MIREXISTS(CallProtoService(pAcc[i]->szModuleName, PS_CHANGEINFOEX, NULL, NULL));
+ for (auto &pa : Accounts())
+ if (IsProtoAccountEnabled(pa)) // update my contact information on icq server
+ if (myGlobals.CanChangeDetails = MIREXISTS(CallProtoService(pa->szModuleName, PS_CHANGEINFOEX, NULL, NULL)))
+ break;
}
static void ResetUpdateInfo(LPPS pPs)
diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index b409fb78b6..59b991cfb9 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -725,7 +725,6 @@ public: RemoveAll();
ContinueWithNext();
}
-
};
static CContactUpdater *ContactUpdater = nullptr;
@@ -744,15 +743,11 @@ static CContactUpdater *ContactUpdater = nullptr; **/
static BOOL IsMirandaOnline()
{
- BOOL bIsOnline = FALSE;
- PROTOACCOUNT **pAcc;
- int nAccCount;
- Proto_EnumAccounts(&nAccCount, &pAcc);
-
- for (int i = 0; (i < nAccCount) && !bIsOnline; i++)
- bIsOnline |= (IsProtoAccountEnabled(pAcc[i]) && IsProtoOnline(pAcc[i]->szModuleName));
+ for (auto &pa : Accounts())
+ if (IsProtoAccountEnabled(pa) && IsProtoOnline(pa->szModuleName))
+ return true;
- return bIsOnline;
+ return false;
}
/***********************************************************************************************************
diff --git a/plugins/XSoundNotify/src/options.cpp b/plugins/XSoundNotify/src/options.cpp index cc8f91796b..cc2d8a51ca 100644 --- a/plugins/XSoundNotify/src/options.cpp +++ b/plugins/XSoundNotify/src/options.cpp @@ -28,12 +28,10 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- int count;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&count, &protos);
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_SETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_ADDSTRING, 0, (LPARAM)protos[i]->tszAccountName), (LPARAM)protos[i]);
+
+ for (auto &pa : Accounts())
+ if (IsSuitableProto(pa))
+ SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_SETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName), (LPARAM)pa);
return TRUE;
case WM_COMMAND:
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index f5b87586cd..81a2482774 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -66,17 +66,13 @@ static selfSounds[] = void InitSelfSounds()
{
// initializing self sounds for protocols
- int protoCount = 0;
- PROTOACCOUNT** protos = nullptr;
-
- Proto_EnumAccounts(&protoCount, &protos);
- for (int i = 0; i < protoCount; i++) {
+ for (auto &pa : Accounts()) {
for (int j = 0; j < _countof(selfSounds); j++) {
char namebuf[128];
- mir_snprintf(namebuf, "%s%s", protos[i]->szModuleName, selfSounds[j].szName);
+ mir_snprintf(namebuf, "%s%s", pa->szModuleName, selfSounds[j].szName);
wchar_t infobuf[256];
- mir_snwprintf(infobuf, L"%s [%s]", TranslateT("Self status"), protos[i]->tszAccountName);
+ mir_snwprintf(infobuf, L"%s [%s]", TranslateT("Self status"), pa->tszAccountName);
Skin_AddSound(namebuf, infobuf, pcli->pfnGetStatusModeDescription(selfSounds[j].iStatus, 0));
}
}
diff --git a/plugins/ZeroNotification/src/main.cpp b/plugins/ZeroNotification/src/main.cpp index 172b961d8e..66ca7a1903 100644 --- a/plugins/ZeroNotification/src/main.cpp +++ b/plugins/ZeroNotification/src/main.cpp @@ -113,17 +113,12 @@ static int SetNotify(const long status) //Called whenever a change in status is detected
static int ProtoAck(WPARAM, LPARAM lParam)
{
+ // quit if not status event
ACKDATA *ack = (ACKDATA*)lParam;
- PROTOACCOUNT **protos;
-
- //quit if not status event
if (ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) {
long status = 0;
- int count;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- status = status | Proto_Status2Flag(CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0));
+ for (auto &pa : Accounts())
+ status = status | Proto_Status2Flag(CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0));
SetNotify(status);
}
|