From d7c69a80488184b9a36a0d4dbe6d44730ad343a4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 15 May 2018 14:34:09 +0300 Subject: fixes #1348 (unused protocols aren't listed in VI info) --- plugins/CrashDumper/src/dumper.cpp | 68 +++++++++++++++++--------------------- plugins/CrashDumper/src/version.h | 2 +- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index 1eb4113e24..4e2123733a 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -262,62 +262,56 @@ static void GetPluginsString(CMStringW &buffer, unsigned &flags) } } -struct ProtoCount +///////////////////////////////////////////////////////////////////////////////////////// + +struct ProtoCount : public MZeroedObject { - int countse; - int countsd; - bool nloaded; + ProtoCount(char *p) : + szProto(p) + {} + + char *szProto; + int countse; + int countsd; + bool nloaded; + + static int Compare(const ProtoCount *p1, const ProtoCount *p2) + { return mir_strcmp(p1->szProto, p2->szProto); + } }; static void GetProtocolStrings(CMStringW &buffer) { - int accCount; - PROTOACCOUNT **accList; - Proto_EnumAccounts(&accCount, &accList); - int protoCount; PROTOCOLDESCRIPTOR **protoList; Proto_EnumProtocols(&protoCount, &protoList); - int protoCountMy = 0; - char **protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*)); + OBJLIST arProtos(10, &ProtoCount::Compare); + // add first all declared protocols, both old & new for (int i = 0; i < protoCount; i++) switch (protoList[i]->type) { case PROTOTYPE_PROTOCOL: case PROTOTYPE_PROTOWITHACCS: - protoListMy[protoCountMy++] = protoList[i]->szName; + arProtos.insert(new ProtoCount(protoList[i]->szName)); } - for (int j = 0; j < accCount; j++) { - int i; - for (i = 0; i < protoCountMy; i++) - if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) - break; + // try to gather all missing protocols from accounts + for (auto &pa : Accounts()) { + ProtoCount *p = arProtos.find((ProtoCount*)&pa->szProtoName); + if (p == nullptr) + continue; - if (i == protoCountMy) - protoListMy[protoCountMy++] = accList[j]->szProtoName; + p->nloaded = pa->bDynDisabled; + if (pa->IsEnabled()) + ++p->countse; + else + ++p->countsd; } - ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy); - memset(protos, 0, sizeof(ProtoCount) * protoCountMy); - - for (int j = 0; j < accCount; j++) - for (int i = 0; i < protoCountMy; i++) - if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) { - protos[i].nloaded = accList[j]->bDynDisabled != 0; - if (accList[j]->IsEnabled()) - ++protos[i].countse; - else - ++protos[i].countsd; - break; - } - - for (int i = 0; i < protoCountMy; i++) { - auto &p = protos[i]; - buffer.AppendFormat(L"%-24s %d - Enabled %d - Disabled %sLoaded\r\n", - (wchar_t*)_A2T(protoListMy[i]), p.countse, p.countsd, p.nloaded ? L"Not " : L""); - } + for (auto &p : arProtos) + if (p->countsd != 0 || p->countse != 0) + buffer.AppendFormat(L"%-24S %d - Enabled %d - Disabled %sLoaded\r\n", p->szProto, p->countse, p->countsd, p->nloaded ? L"Not " : L""); } static void GetWeatherStrings(CMStringW &buffer, unsigned flags) diff --git a/plugins/CrashDumper/src/version.h b/plugins/CrashDumper/src/version.h index af1c0543f6..390610fc81 100644 --- a/plugins/CrashDumper/src/version.h +++ b/plugins/CrashDumper/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3