From 26a653ecae7edbeefb7966e08714e152c73b78eb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 7 Apr 2018 19:46:44 +0300 Subject: Proto_GetStatus() - fast method that returns a cached protocol status --- include/m_protocols.h | 5 +++++ libs/win32/mir_app.lib | Bin 155986 -> 156206 bytes libs/win64/mir_app.lib | Bin 151038 -> 151238 bytes src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/protocols.cpp | 17 +++++++++++------ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/m_protocols.h b/include/m_protocols.h index 884ca2c5c3..ee81f41ef8 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -313,6 +313,11 @@ EXTERN_C MIR_APP_DLL(int) Proto_GetAverageStatus(int *pAccountNumber = nullptr); EXTERN_C MIR_APP_DLL(PROTOACCOUNT*) Proto_GetAccount(const char *pszModuleName); +///////////////////////////////////////////////////////////////////////////////////////// +// returns last status reported by a protocol + +EXTERN_C MIR_APP_DLL(int) Proto_GetStatus(const char *pszModuleName); + ///////////////////////////////////////////////////////////////////////////////////////// // this event is fired when the accounts list gets changed // wParam = event type (1 - added, 2 - changed, 3 - deleted, 4 - upgraded, 5 - enabled/disabled) diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 363e98de44..3b58fe9d1e 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 9d004e115f..f004b34805 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ 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(); -- cgit v1.2.3