From 1383e88abf16de34fb680dfb5001ba79d44d933c Mon Sep 17 00:00:00 2001 From: aunsane Date: Sat, 21 Apr 2018 22:34:54 +0300 Subject: core: add Contact_GetStatus function --- include/m_contacts.h | 4 +++- libs/win32/mir_app.lib | Bin 157574 -> 157804 bytes plugins/CloudFile/src/stdafx.h | 1 + plugins/CloudFile/src/utils.cpp | 6 +++--- src/mir_app/src/contacts.cpp | 13 +++++++++++++ src/mir_app/src/mir_app.def | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/m_contacts.h b/include/m_contacts.h index 779582878f..a8463ee43c 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -79,6 +79,8 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Contact_GetInfo( MCONTACT hContact, // contact id or NULL for the global data const char *szProto = nullptr); // protocol for global data. if skipped, grabbed from hContact +EXTERN_C MIR_APP_DLL(int) Contact_GetStatus(MCONTACT hContact); + ///////////////////////////////////////////////////////////////////////////////////////// // Add contact's dialog @@ -86,6 +88,6 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Contact_GetInfo( EXTERN_C MIR_APP_DLL(void) Contact_Add(MCONTACT hContact, HWND hwndParent = nullptr); EXTERN_C MIR_APP_DLL(void) Contact_AddByEvent(MEVENT hEvent, HWND hwndParent = nullptr); -EXTERN_C MIR_APP_DLL(void) Contact_AddBySearch(const char *m_szProto, struct PROTOSEARCHRESULT *m_psr, HWND hwndParent = nullptr); +EXTERN_C MIR_APP_DLL(void) Contact_AddBySearch(const char *szProto, struct PROTOSEARCHRESULT *psr, HWND hwndParent = nullptr); #endif // M_CONTACTS_H__ diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 0315eeafe2..aba422d92b 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index 6edf174305..7a54a943b9 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -30,6 +30,7 @@ #include #include #include +#include #include diff --git a/plugins/CloudFile/src/utils.cpp b/plugins/CloudFile/src/utils.cpp index 65fd99e376..ec5bc04d10 100644 --- a/plugins/CloudFile/src/utils.cpp +++ b/plugins/CloudFile/src/utils.cpp @@ -49,11 +49,11 @@ bool CanSendToContact(MCONTACT hContact) if (!canSend) return false; - bool isProtoOffline = Proto_GetStatus(proto) <= ID_STATUS_OFFLINE; - if (isProtoOffline) + bool isProtoOnline = Proto_GetStatus(proto) > ID_STATUS_OFFLINE; + if (!isProtoOnline) return false; - bool isContactOnline = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE) > ID_STATUS_OFFLINE; + bool isContactOnline = Contact_GetStatus(hContact) > ID_STATUS_OFFLINE; if (isContactOnline) return true; diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index b53fb0bcd5..2f52b6ca91 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -285,6 +285,19 @@ MIR_APP_DLL(wchar_t*) Contact_GetInfo(int type, MCONTACT hContact, const char *s return nullptr; } +MIR_APP_DLL(int) Contact_GetStatus(MCONTACT hContact) +{ + if (hContact == 0) + return ID_STATUS_OFFLINE; + + const char *szProto = GetContactProto(hContact); + if (szProto == nullptr) + return ID_STATUS_OFFLINE; + + return db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); +} + + ///////////////////////////////////////////////////////////////////////////////////////// // Options dialog diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index ec0240613f..f8b2c787d4 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -583,3 +583,4 @@ Proto_GetStatus @601 ?IsReadyToExit@PROTO_INTERFACE@@UAE_NXZ @606 NONAME ?OnModulesLoaded@PROTO_INTERFACE@@UAEXXZ @607 NONAME ?OnShutdown@PROTO_INTERFACE@@UAEXXZ @608 NONAME +Contact_GetStatus @609 -- cgit v1.2.3