From 91a382b14d293137fa3fd90d3f5d315491df9716 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 8 Sep 2016 12:08:57 +0000 Subject: Srmm_* wrappers for services converted into regular functions git-svn-id: http://svn.miranda-ng.org/main/trunk@17274 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_app.lib | Bin 74136 -> 75000 bytes bin10/lib/mir_app64.lib | Bin 71438 -> 72224 bytes bin12/lib/mir_app.lib | Bin 74136 -> 75000 bytes bin12/lib/mir_app64.lib | Bin 71438 -> 72224 bytes bin14/lib/mir_app.lib | Bin 74136 -> 75000 bytes bin14/lib/mir_app64.lib | Bin 71438 -> 72224 bytes include/delphi/m_helpers.inc | 29 ----------- include/delphi/m_message.inc | 30 ------------ include/m_message.h | 48 +++++++------------ plugins/CountryFlags/src/extraimg.cpp | 3 +- protocols/JabberG/src/jabber_proto.cpp | 4 +- src/mir_app/src/mir_app.def | 4 ++ src/mir_app/src/mir_app64.def | 4 ++ src/mir_app/src/srmm_statusicon.cpp | 85 ++++++++++++++++----------------- 14 files changed, 68 insertions(+), 139 deletions(-) diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib index 4bab0ad512..9d9cae772b 100644 Binary files a/bin10/lib/mir_app.lib and b/bin10/lib/mir_app.lib differ diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib index e4501109e0..2b94aead96 100644 Binary files a/bin10/lib/mir_app64.lib and b/bin10/lib/mir_app64.lib differ diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib index 4bab0ad512..9d9cae772b 100644 Binary files a/bin12/lib/mir_app.lib and b/bin12/lib/mir_app.lib differ diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib index e4501109e0..2b94aead96 100644 Binary files a/bin12/lib/mir_app64.lib and b/bin12/lib/mir_app64.lib differ diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib index 4bab0ad512..9d9cae772b 100644 Binary files a/bin14/lib/mir_app.lib and b/bin14/lib/mir_app.lib differ diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib index e4501109e0..2b94aead96 100644 Binary files a/bin14/lib/mir_app64.lib and b/bin14/lib/mir_app64.lib differ diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 0e51727d89..62bdd92c10 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -40,11 +40,6 @@ function Langpack_Register:int_ptr; function CreateProtoServiceFunction(const szModule, szService: PAnsiChar; serviceProc: TMIRANDASERVICE): int_ptr; -function Srmm_AddIcon (sid: PStatusIconData):int_ptr; -procedure Srmm_RemoveIcon(sid: PStatusIconData); -procedure Srmm_ModifyIcon(hContact:TMCONTACT; sid:PStatusIconData); -function Srmm_GetNthIcon(hContact:TMCONTACT; index:int):pStatusIconData; - function SkinAddNewSound(const name, description, defaultFile: PAnsiChar): int_ptr; function SkinPlaySound (const name: PAnsiChar): int_ptr; @@ -336,30 +331,6 @@ begin Result := CreateServiceFunction(szStr, @serviceProc); end; -// Hidden variable hLangpack - do not use Inline style -function Srmm_AddIcon(sid: PStatusIconData):int_ptr; -begin - result:=CallService(MS_MSG_ADDICON, hLangpack, LPARAM(sid)); -end; - -procedure Srmm_RemoveIcon(sid: PStatusIconData); - {$IFDEF AllowInline}inline;{$ENDIF} -begin - CallService(MS_MSG_REMOVEICON, 0, LPARAM(sid)); -end; - -procedure Srmm_ModifyIcon(hContact:TMCONTACT; sid:PStatusIconData); - {$IFDEF AllowInline}inline;{$ENDIF} -begin - CallService(MS_MSG_GETNTHICON, hContact, LPARAM(sid)); -end; - -function Srmm_GetNthIcon(hContact:TMCONTACT; index:int):PStatusIconData; - {$IFDEF AllowInline}inline;{$ENDIF} -begin - result:=PStatusIconData(CallService(MS_MSG_GETNTHICON, hContact, index)); -end; - function SkinAddNewSound(const name, description, defaultFile: PAnsiChar): int_ptr; var ssd: TSKINSOUNDDESCEX; diff --git a/include/delphi/m_message.inc b/include/delphi/m_message.inc index a6cddc4cdc..1a50da7c6f 100644 --- a/include/delphi/m_message.inc +++ b/include/delphi/m_message.inc @@ -210,36 +210,6 @@ type end; const -{ - wParam = hLangpack - lParam = (StatusIconData *)&StatusIconData -} - MS_MSG_ADDICON:PAnsiChar = 'MessageAPI/AddIcon'; - -{ - wParam = 0 - lParam = (StatusIconData *)&StatusIconData - only szModule and szId are used -} - MS_MSG_REMOVEICON:PAnsiChar = 'MessageAPI/RemoveIcon'; - -{ - wParam = (HANDLE)hContact - lParam = (int)zero-based index of a visible icon - returns (StatusIconData*)icon description filled for the required contact - don't free this memory. -} - MS_MSG_GETNTHICON:PAnsiChar = 'MessageAPI/GetNthIcon'; - -{ - wParam = (HANDLE)hContact - lParam = (StatusIconData *)&StatusIconData - if hContact is null, icon is modified for all contacts - otherwise, only the flags field is valid - if either hIcon, hIconDisabled or szTooltip is null, they will not be modified -} - MS_MSG_MODIFYICON:PAnsiChar = 'MessageAPI/ModifyIcon'; - { wParam = (HANDLE)hContact; lParam = (StatusIconClickData *)&StatusIconClickData; diff --git a/include/m_message.h b/include/m_message.h index 8d4678daca..fe80b9c8e8 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -175,50 +175,38 @@ typedef struct { #define MBCF_RIGHTBUTTON 0x01 // if this flag is specified, the click was a right button - otherwize it was a left click -typedef struct { - int cbSize; - POINT clickLocation; // click location, in screen coordinates - char *szModule; - DWORD dwId; - int flags; // bitwize OR of MBCF_* flags above -} StatusIconClickData; +// adds an icon -// wParam = (int)hLangpack -// lParam = (StatusIconData *)&StatusIconData -// #define MS_MSG_ADDICON "MessageAPI/AddIcon" +EXTERN_C MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, int _hLang = hLangpack); -__forceinline INT_PTR Srmm_AddIcon(StatusIconData *sid) -{ return CallService("MessageAPI/AddIcon", hLangpack, (LPARAM)sid); -} +// removes an icon -// wParam = 0 (unused) -// lParam = (StatusIconData *)&StatusIconData -// only szModule and szId are used -#define MS_MSG_REMOVEICON "MessageAPI/RemoveIcon" +EXTERN_C MIR_APP_DLL(void) Srmm_RemoveIcon(const char *szProto, DWORD iconId); -__forceinline void Srmm_RemoveIcon(StatusIconData *sid) -{ CallService(MS_MSG_REMOVEICON, 0, (LPARAM)sid); -} - -// wParam = (HANDLE)hContact -// lParam = (StatusIconData *)&StatusIconData // if hContact is null, icon is modified for all contacts // otherwise, only the flags field is valid // if either hIcon, hIconDisabled or szTooltip is null, they will not be modified -#define MS_MSG_MODIFYICON "MessageAPI/ModifyIcon" -__forceinline void Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid) -{ CallService(MS_MSG_MODIFYICON, hContact, (LPARAM)sid); -} +EXTERN_C MIR_APP_DLL(int) Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid); // wParam = (HANDLE)hContact // lParam = (int)zero-based index of a visible icon // returns (StatusIconData*)icon description filled for the required contact // don't free this memory. -__forceinline StatusIconData* Srmm_GetNthIcon(MCONTACT hContact, int index) -{ return (StatusIconData*)CallService("MessageAPI/GetNthIcon", hContact, index); -} +EXTERN_C MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index); + +///////////////////////////////////////////////////////////////////////////////////////// +// status icons click notification + +struct StatusIconClickData +{ + int cbSize; + POINT clickLocation; // click location, in screen coordinates + char *szModule; + DWORD dwId; + int flags; // bitwize OR of MBCF_* flags above +}; // wParam = (HANDLE)hContact; // lParam = (StatusIconClickData *)&StatusIconClickData; diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp index 9990563094..1ab9cbd72d 100644 --- a/plugins/CountryFlags/src/extraimg.cpp +++ b/plugins/CountryFlags/src/extraimg.cpp @@ -169,8 +169,7 @@ static int ExtraImgSettingChanged(WPARAM hContact, LPARAM lParam) /* Extra Image */ SetExtraImage(hContact); /* Status Icon */ - if (ServiceExists(MS_MSG_REMOVEICON)) - CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY); + CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY); } } return 0; diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 4e66179a64..b7422a4896 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -286,9 +286,7 @@ int __cdecl CJabberProto::OnPreShutdown(WPARAM, LPARAM) m_iqManager.Shutdown(); ConsoleUninit(); - StatusIconData sid = { sizeof(sid) }; - sid.szModule = m_szModuleName; - Srmm_RemoveIcon(&sid); + Srmm_RemoveIcon(m_szModuleName, 0); return 0; } diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 00556c908f..0a7e79dcec 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -275,3 +275,7 @@ Clist_GetImageList @274 Clist_GetInterface @275 Clist_TrayNotifyA @276 Clist_TrayNotifyW @277 +Srmm_AddIcon @278 +Srmm_GetNthIcon @279 +Srmm_ModifyIcon @280 +Srmm_RemoveIcon @281 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 7a39c78b76..76df5da91f 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -275,3 +275,7 @@ Clist_GetImageList @274 Clist_GetInterface @275 Clist_TrayNotifyA @276 Clist_TrayNotifyW @277 +Srmm_AddIcon @278 +Srmm_GetNthIcon @279 +Srmm_ModifyIcon @280 +Srmm_RemoveIcon @281 diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp index dbc6daff65..1ca52bb065 100644 --- a/src/mir_app/src/srmm_statusicon.cpp +++ b/src/mir_app/src/srmm_statusicon.cpp @@ -76,9 +76,35 @@ static OBJLIST arIcons(3, CompareIcons); static HANDLE hHookIconsChanged; -INT_PTR ModifyStatusIcon(WPARAM hContact, LPARAM lParam) +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, int hLangpack) +{ + if (sid == NULL || sid->cbSize != sizeof(StatusIconData)) + return 1; + + StatusIconMain *p = arIcons.find((StatusIconMain*)sid); + if (p != NULL) + return Srmm_ModifyIcon(0, sid); + + p = new StatusIconMain; + memcpy(&p->sid, sid, sizeof(p->sid)); + p->hLangpack = hLangpack; + p->sid.szModule = mir_strdup(sid->szModule); + if (sid->flags & MBF_UNICODE) + p->sid.tszTooltip = mir_wstrdup(sid->wszTooltip); + else + p->sid.tszTooltip = mir_a2u(sid->szTooltip); + arIcons.insert(p); + + NotifyEventHooks(hHookIconsChanged, NULL, (LPARAM)p); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(int) Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid) { - StatusIconData *sid = (StatusIconData *)lParam; if (sid == NULL || sid->cbSize != sizeof(StatusIconData)) return 1; @@ -116,52 +142,26 @@ INT_PTR ModifyStatusIcon(WPARAM hContact, LPARAM lParam) return 0; } -static INT_PTR AddStatusIcon(WPARAM wParam, LPARAM lParam) -{ - StatusIconData *sid = (StatusIconData *)lParam; - if (sid == NULL || sid->cbSize != sizeof(StatusIconData)) - return 1; +///////////////////////////////////////////////////////////////////////////////////////// - StatusIconMain *p = arIcons.find((StatusIconMain*)sid); +MIR_APP_DLL(void) Srmm_RemoveIcon(const char *szProto, DWORD iconId) +{ + StatusIconData tmp = { sizeof(tmp), (char*)szProto, iconId }; + StatusIconMain *p = arIcons.find((StatusIconMain*)&tmp); if (p != NULL) - return ModifyStatusIcon(0, lParam); - - p = new StatusIconMain; - memcpy(&p->sid, sid, sizeof(p->sid)); - p->hLangpack = (int)wParam; - p->sid.szModule = mir_strdup(sid->szModule); - if (sid->flags & MBF_UNICODE) - p->sid.tszTooltip = mir_wstrdup(sid->wszTooltip); - else - p->sid.tszTooltip = mir_a2u(sid->szTooltip); - arIcons.insert(p); - - NotifyEventHooks(hHookIconsChanged, NULL, (LPARAM)p); - return 0; + arIcons.remove(p); } -static INT_PTR RemoveStatusIcon(WPARAM, LPARAM lParam) -{ - StatusIconData *sid = (StatusIconData *)lParam; - if (sid == NULL || sid->cbSize != sizeof(StatusIconData)) - return 1; - - StatusIconMain *p = arIcons.find((StatusIconMain*)sid); - if (p == NULL) - return 1; - - arIcons.remove(p); - return 0; -} +///////////////////////////////////////////////////////////////////////////////////////// -static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index) { static StatusIconData res; for (int i=arIcons.getCount()-1, nVis = 0; i >= 0; i--) { StatusIconMain &p = arIcons[i]; - StatusIconChild *pc = p.arChildren.find((StatusIconChild*)&wParam); + StatusIconChild *pc = p.arChildren.find((StatusIconChild*)&hContact); if (pc) { if (pc->flags & MBF_HIDDEN) continue; @@ -169,7 +169,7 @@ static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam) else if (p.sid.flags & MBF_HIDDEN) continue; - if (nVis == (int)lParam) { + if (nVis == index) { memcpy(&res, &p, sizeof(res)); if (pc) { if (pc->hIcon) res.hIcon = pc->hIcon; @@ -181,12 +181,12 @@ static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam) res.flags = pc->flags; } res.tszTooltip = TranslateW_LP(res.tszTooltip, p.hLangpack); - return (INT_PTR)&res; + return &res; } nVis++; } - return 0; + return NULL; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -202,11 +202,6 @@ void KillModuleSrmmIcons(int _hLang) int LoadSrmmModule() { - CreateServiceFunction("MessageAPI/AddIcon", AddStatusIcon); - CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon); - CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon); - CreateServiceFunction("MessageAPI/GetNthIcon", GetNthIcon); - hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED); return 0; } -- cgit v1.2.3