From 9613f96e6a6f96ad02a0fc926054132811ae2bb1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Apr 2018 16:30:25 +0300 Subject: Accounts() : iterator for accounts --- plugins/AVS/src/main.cpp | 9 +++------ plugins/AVS/src/options.cpp | 17 +++++++---------- plugins/AVS/src/services.cpp | 36 +++++++++++++----------------------- 3 files changed, 23 insertions(+), 39 deletions(-) (limited to 'plugins/AVS/src') 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); -- cgit v1.2.3