summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-07 19:46:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-07 19:47:27 +0300
commit26a653ecae7edbeefb7966e08714e152c73b78eb (patch)
treee4f73b393a061ae296a36f802796f0fcc86cf573 /src
parent5565e5b9839eea8a57e9c46f87e611dd546c8b46 (diff)
Proto_GetStatus() - fast method that returns a cached protocol status
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/protocols.cpp17
3 files changed, 13 insertions, 6 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index a6aab7290b..987cb33996 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -578,3 +578,4 @@ Clist_RemoveItemFromGroup @597
Clist_ClcOptionsChanged @598
Clist_GetRealStatus @599
Clist_GetGeneralizedStatus @600
+Proto_GetStatus @601
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 3c749c9007..6d6a10621a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -578,3 +578,4 @@ Clist_RemoveItemFromGroup @597
Clist_ClcOptionsChanged @598
Clist_GetRealStatus @599
Clist_GetGeneralizedStatus @600
+Proto_GetStatus @601
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp
index 0179f80bde..477dbd2083 100644
--- a/src/mir_app/src/protocols.cpp
+++ b/src/mir_app/src/protocols.cpp
@@ -310,15 +310,20 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_GetAccount(const char *accName)
if (accName == nullptr)
return nullptr;
- int idx;
- PROTOACCOUNT temp;
- temp.szModuleName = (char*)accName;
- if ((idx = accounts.getIndex(&temp)) == -1)
- return nullptr;
+ return accounts.find((PROTOACCOUNT*)&accName);
+}
- return accounts[idx];
+MIR_APP_DLL(int) Proto_GetStatus(const char *accName)
+{
+ if (accName == nullptr)
+ return ID_STATUS_OFFLINE;
+
+ PROTOACCOUNT *pa = accounts.find((PROTOACCOUNT*)&accName);
+ return (pa) ? pa->iRealStatus : ID_STATUS_OFFLINE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(void) Proto_EnumAccounts(int *nAccs, PROTOACCOUNT ***pAccs)
{
if (nAccs) *nAccs = accounts.getCount();