diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-29 17:02:01 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-29 17:02:01 +0300 |
commit | 9aa85e74dcb8ef8bda5cd94a5cda60267816a082 (patch) | |
tree | 29d3179b24a8ee10b2c54fedbbf6b2795f98f591 /src/mir_app | |
parent | 2bfaad4e1e3a2aea665bc5b3d70b3a249c01b257 (diff) |
code cleaning
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/miranda.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/proto_chains.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/proto_opts.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/proto_utils.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/protocols.cpp | 14 |
5 files changed, 22 insertions, 26 deletions
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 36b14b2022..d124ecb5cd 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -140,7 +140,7 @@ struct MBaseProto : public PROTOCOLDESCRIPTOR char *szUniqueId; // name of the unique setting that identifies a contact
};
-extern LIST<MBaseProto> protos, filters;
+extern LIST<MBaseProto> g_arProtos, g_arFilters;
INT_PTR ProtoCallService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index d405cccae9..8ca44c145a 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -60,8 +60,8 @@ MIR_APP_DLL(INT_PTR) Proto_ChainSend(int iOrder, CCSDATA *ccs) if (iOrder == -1)
return 1;
- for (int i = iOrder; i < filters.getCount(); i++) {
- if ((ret = CallProtoServiceInt(0, filters[i]->szName, ccs->szProtoService, i + 1, LPARAM(ccs))) != CALLSERVICE_NOTFOUND) {
+ for (int i = iOrder; i < g_arFilters.getCount(); i++) {
+ if ((ret = CallProtoServiceInt(0, g_arFilters[i]->szName, ccs->szProtoService, i + 1, LPARAM(ccs))) != CALLSERVICE_NOTFOUND) {
//chain was started, exit
return ret;
}
@@ -106,12 +106,12 @@ MIR_APP_DLL(INT_PTR) Proto_ChainRecv(int iOrder, CCSDATA *ccs) if (GetCurrentThreadId() != hMainThreadId) // restart this function in the main thread
return CallServiceSync(MS_PROTO_HIDDENSTUB, iOrder, LPARAM(ccs));
- iOrder = filters.getCount();
+ iOrder = g_arFilters.getCount();
}
else iOrder--;
for (int i = iOrder - 1; i >= 0; i--)
- if ((ret = CallProtoServiceInt(0, filters[i]->szName, ccs->szProtoService, i + 1, (LPARAM)ccs)) != CALLSERVICE_NOTFOUND)
+ if ((ret = CallProtoServiceInt(0, g_arFilters[i]->szName, ccs->szProtoService, i + 1, (LPARAM)ccs)) != CALLSERVICE_NOTFOUND)
//chain was started, exit
return ret;
@@ -168,9 +168,9 @@ MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char *szProto) if (!_stricmp(szProto, szContactProto))
return -1;
- for (auto &it : filters)
+ for (auto &it : g_arFilters)
if (!mir_strcmp(szProto, it->szName))
- return filters.indexOf(&it) + 1;
+ return g_arFilters.indexOf(&it) + 1;
return 0;
}
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index f761bc4859..4f39719228 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -129,16 +129,12 @@ public: virtual void OnInitDialog() override
{
- PROTOCOLDESCRIPTOR **proto;
- int protoCount, i, cnt = 0;
- Proto_EnumProtocols(&protoCount, &proto);
- for (i = 0; i < protoCount; i++) {
- PROTOCOLDESCRIPTOR *pd = proto[i];
- if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd)) {
- m_prototype.AddStringA(proto[i]->szName);
+ int cnt = 0;
+ for (auto &it : g_arProtos)
+ if (it->type == PROTOTYPE_PROTOCOL && it->cbSize == sizeof(PROTOCOLDESCRIPTOR)) {
+ m_prototype.AddStringA(it->szName);
++cnt;
}
- }
m_prototype.SetCurSel(0);
m_btnOk.Enable(cnt != 0);
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 16c094e51b..2211332254 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -28,7 +28,7 @@ static int CompareProtos(const MBaseProto *p1, const MBaseProto *p2) return strcmp(p1->szName, p2->szName);
}
-LIST<MBaseProto> protos(10, CompareProtos);
+LIST<MBaseProto> g_arProtos(10, CompareProtos);
extern HANDLE hAckEvent;
@@ -41,15 +41,15 @@ MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_IsProtocolLoaded(const char *szProtoName) MBaseProto tmp;
tmp.szName = (char*)szProtoName;
- return protos.find(&tmp);
+ return g_arProtos.find(&tmp);
}
/////////////////////////////////////////////////////////////////////////////////////////
MIR_APP_DLL(void) Proto_EnumProtocols(int *nProtos, PROTOCOLDESCRIPTOR ***pProtos)
{
- if (nProtos) *nProtos = protos.getCount();
- if (pProtos) *pProtos = (PROTOCOLDESCRIPTOR **)protos.getArray();
+ if (nProtos) *nProtos = g_arProtos.getCount();
+ if (pProtos) *pProtos = (PROTOCOLDESCRIPTOR **)g_arProtos.getArray();
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index f18b256ea1..931e83a179 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -89,7 +89,7 @@ static int CompareProtos(const MBaseProto *p1, const MBaseProto *p2) return mir_strcmp(p1->szName, p2->szName);
}
-LIST<MBaseProto> filters(10, CompareProtos);
+LIST<MBaseProto> g_arFilters(10, CompareProtos);
//------------------------------------------------------------------------------------
@@ -116,7 +116,7 @@ MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd) p->fnInit = pd->fnInit;
p->fnUninit = pd->fnUninit;
}
- protos.insert(p);
+ g_arProtos.insert(p);
if (p->fnInit == nullptr && (p->type == PROTOTYPE_PROTOCOL || p->type == PROTOTYPE_VIRTUAL)) {
// let's create a new container
@@ -143,7 +143,7 @@ MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd) }
if (p->type != PROTOTYPE_PROTOCOL && p->type != PROTOTYPE_VIRTUAL)
- filters.insert(p);
+ g_arFilters.insert(p);
return 0;
}
@@ -159,7 +159,7 @@ MIR_APP_DLL(void) Proto_SetUniqueId(const char *szModuleName, const char *pszUni MBaseProto tmp;
tmp.szName = (char*)szModuleName;
- MBaseProto *pd = protos.find(&tmp);
+ MBaseProto *pd = g_arProtos.find(&tmp);
if (pd != nullptr)
pd->szUniqueId = mir_strdup(pszUniqueId);
}
@@ -176,7 +176,7 @@ MIR_APP_DLL(const char*) Proto_GetUniqueId(const char *szModuleName) }
else tmp.szName = (char*)szModuleName;
- MBaseProto *pd = protos.find(&tmp);
+ MBaseProto *pd = g_arProtos.find(&tmp);
return (pd != nullptr) ? pd->szUniqueId : nullptr;
}
@@ -459,12 +459,12 @@ void UnloadProtocolsModule() {
if (!bModuleInitialized) return;
- for (auto &p : protos) {
+ for (auto &p : g_arProtos) {
mir_free(p->szUniqueId);
mir_free(p->szName);
mir_free(p);
}
- protos.destroy();
+ g_arProtos.destroy();
if (hAckEvent) {
DestroyHookableEvent(hAckEvent);
|