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/StopSpamMod/src/options.cpp | 12 +++++------- plugins/StopSpamMod/src/utilities.cpp | 9 +++------ 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'plugins/StopSpamMod') 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 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::iterator end = protocols.end(); for (std::list::iterator i = protocols.begin(); i != end; ++i) { -- cgit v1.2.3