From b660fac5560005706aeab0a0d5ad2b32bdcaf929 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Jun 2015 17:20:04 +0000 Subject: - ProtoCallService() function considered too dangerous and therefore isn't exported anymore, it's closed in the core, CallProtoService() is used instead everywhere; - fixes for some quirks with PS_* calls. git-svn-id: http://svn.miranda-ng.org/main/trunk@13959 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_core.lib | Bin 385874 -> 385644 bytes bin10/lib/mir_core64.lib | Bin 388946 -> 388740 bytes bin12/lib/mir_core.lib | Bin 385874 -> 385644 bytes bin12/lib/mir_core64.lib | Bin 388946 -> 388740 bytes include/delphi/m_core.inc | 3 - include/m_core.h | 1 - include/m_protosvc.h | 2 +- plugins/AutoShutdown/src/watcher.cpp | 2 +- plugins/BossKeyPlus/src/BossKey.cpp | 2 +- plugins/CSList/src/cslist.cpp | 2 +- plugins/Clist_modern/src/modern_clistmod.cpp | 4 +- plugins/Clist_modern/src/modern_clisttray.cpp | 12 +-- plugins/Clist_modern/src/modern_statusbar.cpp | 4 +- plugins/Clist_nicer/skineditor/src/main.cpp | 3 +- plugins/Clist_nicer/src/clc.cpp | 2 +- plugins/Clist_nicer/src/clcitems.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 4 +- plugins/CmdLine/src/mimcmd_handlers.cpp | 4 +- plugins/ModernOpt/src/mopt_selector.cpp | 6 +- plugins/New_GPG/src/main.cpp | 4 +- plugins/New_GPG/src/messages.cpp | 4 +- plugins/New_GPG/src/utilities.cpp | 2 +- plugins/Ping/src/pingthread.cpp | 4 +- plugins/SMS/src/send.cpp | 2 +- plugins/Scriver/src/chat/window.cpp | 2 +- plugins/ShellExt/src/shlcom.cpp | 2 +- plugins/StopSpamPlus/src/events.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 4 +- plugins/TipperYM/src/popwin.cpp | 4 +- protocols/Xfire/src/all_statusmsg.cpp | 10 +- src/core/miranda.h | 2 + src/core/stdautoaway/src/autoaway.cpp | 7 +- src/core/stdchat/src/window.cpp | 2 +- src/mir_core/src/mir_core.def | 1 - src/mir_core/src/mir_core64.def | 1 - src/mir_core/src/protos.cpp | 13 --- src/modules/ignore/ignore.cpp | 9 +- src/modules/metacontacts/meta_services.cpp | 6 +- src/modules/protocols/protocols.cpp | 136 +++++++++++++------------- src/modules/protocols/protoopts.cpp | 2 +- 40 files changed, 126 insertions(+), 146 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index cfca520b05..f3202d04eb 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index 3ff897278e..cdd92f5529 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib index 8904f185f4..f73ab631f1 100644 Binary files a/bin12/lib/mir_core.lib and b/bin12/lib/mir_core.lib differ diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib index 1b69a48ad2..4a7b8d10ea 100644 Binary files a/bin12/lib/mir_core64.lib and b/bin12/lib/mir_core64.lib differ diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 6e89a196e2..6c5494e6d9 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -434,9 +434,6 @@ function ProtoBroadcastAck(const szModule:PAnsiChar; hContact:TMCONTACT; type_:i function ProtoServiceExists(const szModule, szName:PAnsiChar):int; stdcall; external CoreDLL name 'ProtoServiceExists'; -function ProtoCallService(const szModule, szName:PAnsiChar; wParam:WPARAM; lParam:LPARAM):int_ptr; stdcall; - external CoreDLL name 'ProtoServiceExists'; - procedure ProtoWindowAdd(pThis:pointer; wnd:HWND); stdcall; external CoreDLL name 'ProtoWindowAdd'; diff --git a/include/m_core.h b/include/m_core.h index c70a79a7ab..c35fb86aa0 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -371,7 +371,6 @@ MIR_CORE_DLL(int) mir_vsnwprintf(wchar_t *buffer, size_t count, const wchar_t struct PROTO_INTERFACE; -MIR_CORE_DLL(INT_PTR) ProtoCallService(LPCSTR szModule, const char *szService, WPARAM wParam, LPARAM lParam); MIR_CORE_DLL(int) ProtoServiceExists(LPCSTR szModule, const char *szService); MIR_CORE_DLL(INT_PTR) ProtoBroadcastAck(LPCSTR szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam); diff --git a/include/m_protosvc.h b/include/m_protosvc.h index 0ac0c7c8a1..338e6de153 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -257,7 +257,7 @@ static __inline unsigned long Proto_Status2Flag(int status) /////////////////////////////////////////////////////////////////////////////// // Sets the status-mode specific message for yourself // wParam = status mode -// lParam = (LPARAM)(const char*)szMessage +// lParam = (LPARAM)(const TCHAR*)szMessage // Returns 0 on success, nonzero on failure // Note that this service will not be available unless PF1_MODEMSGSEND is set // and PF1_INDIVMODEMSG is *not* set. diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index 8efdf3a5c4..029d0af01d 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -179,7 +179,7 @@ static BOOL CheckAllContactsOffline(void) fSmartCheck=db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *pszProto = GetContactProto(hContact); - if (pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0) != ID_STATUS_OFFLINE) { + if (pszProto != NULL && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) { if (db_get_b(hContact,pszProto,"ChatRoom",0)) continue; if (db_get_w(hContact,pszProto,"Status",0) != ID_STATUS_OFFLINE) { if (fSmartCheck) { diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 4838940312..a2000694d4 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -221,7 +221,7 @@ static int ChangeAllProtoStatuses(unsigned statusMode, TCHAR *msg) if (g_wMask & OPT_SETONLINEBACK){ // need to save old statuses & status messages oldStatus[i] = status; if (ProtoServiceExists(proto[i]->szModuleName, PS_GETMYAWAYMSG)) - oldStatusMsg[i] = (TCHAR*)ProtoCallService(proto[i]->szModuleName, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); + oldStatusMsg[i] = (TCHAR*)CallProtoService(proto[i]->szModuleName, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); else oldStatusMsg[i] = GetDefStatusMsg(status, proto[i]->szModuleName); } diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp index 0b49d38101..9cd70916c5 100644 --- a/plugins/CSList/src/cslist.cpp +++ b/plugins/CSList/src/cslist.cpp @@ -204,7 +204,7 @@ void SetStatus(WORD code, StatusItem* item, char *szAccName) else return; ics.status = &statusToSet; - ProtoCallService(szAccName, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics); + CallProtoService(szAccName, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics); } INT_PTR showList(WPARAM, LPARAM, LPARAM param) diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index d033a41625..7015a99388 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -61,7 +61,7 @@ HICON cliGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int statu // check status is online if (status > ID_STATUS_OFFLINE) { // get xicon - HICON hXIcon = (HICON)ProtoCallService(szProto, PS_GETCUSTOMSTATUSICON, 0, 0); + HICON hXIcon = (HICON)CallProtoService(szProto, PS_GETCUSTOMSTATUSICON, 0, 0); if (hXIcon) { // check overlay mode if (trayOption & 2) { @@ -102,7 +102,7 @@ int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact) int result = -1; if (ProtoServiceExists(szActProto, PS_GETADVANCEDSTATUSICON)) - result = ProtoCallService(szActProto, PS_GETADVANCEDSTATUSICON, (WPARAM)hActContact, 0); + result = CallProtoService(szActProto, PS_GETADVANCEDSTATUSICON, (WPARAM)hActContact, 0); if (result == -1 || !(LOWORD(result))) { //Get normal Icon diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index e89b6f8aab..cd3f19d1c6 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -603,21 +603,21 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int) if (szProto == NULL) break; - iStatus = ProtoCallService(szProto, PS_GETSTATUS, 0, 0); + iStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (g_StatusBarData.bConnectingIcon && IsStatusConnecting(iStatus)) hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szProto, 0); else - hIcon = pcli->pfnGetIconFromStatusMode(NULL, szProto, ProtoCallService(szProto, PS_GETSTATUS, 0, 0)); + hIcon = pcli->pfnGetIconFromStatusMode(NULL, szProto, CallProtoService(szProto, PS_GETSTATUS, 0, 0)); pcli->pfnTrayIconMakeTooltip(NULL, szProto); break; case TRAY_ICON_MODE_CYCLE: - iStatus = ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0); + iStatus = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0); if (g_StatusBarData.bConnectingIcon && IsStatusConnecting(iStatus)) hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0); else if (!bConn) - hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0)); + hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0)); pcli->pfnTrayIconMakeTooltip(NULL, NULL); break; @@ -627,11 +627,11 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int) if (!mir_strcmp(pcli->trayIcon[i].szProto, szChangedProto)) break; - iStatus = ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0); + iStatus = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0); if (g_StatusBarData.bConnectingIcon && IsStatusConnecting(iStatus)) hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0); else - hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0)); + hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0)); pcli->pfnTrayIconMakeTooltip(NULL, pcli->trayIcon[i].szProto); break; } diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 4e6ea38bc4..e5ba279caf 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -244,7 +244,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) if (p->iProtoStatus > ID_STATUS_OFFLINE) if (p->bShowProtoEmails == 1 && ProtoServiceExists(szProto, PS_GETUNREADEMAILCOUNT)) { - int nEmails = (int)ProtoCallService(szProto, PS_GETUNREADEMAILCOUNT, 0, 0); + int nEmails = (int)CallProtoService(szProto, PS_GETUNREADEMAILCOUNT, 0, 0); if (nEmails > 0) { TCHAR buf[40]; mir_sntprintf(buf, SIZEOF(buf), _T("[%d]"), nEmails); @@ -360,7 +360,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) if ((p.xStatusMode & 3)) { if (p.iProtoStatus > ID_STATUS_OFFLINE) { if (ProtoServiceExists(p.szAccountName, PS_GETCUSTOMSTATUSICON)) - p.extraIcon = (HICON)ProtoCallService(p.szAccountName, PS_GETCUSTOMSTATUSICON, 0, 0); + p.extraIcon = (HICON)CallProtoService(p.szAccountName, PS_GETCUSTOMSTATUSICON, 0, 0); if (p.extraIcon && (p.xStatusMode & 3) == 3) w += iconWidth + 1; } diff --git a/plugins/Clist_nicer/skineditor/src/main.cpp b/plugins/Clist_nicer/skineditor/src/main.cpp index c3a652a135..3171cf3d86 100644 --- a/plugins/Clist_nicer/skineditor/src/main.cpp +++ b/plugins/Clist_nicer/skineditor/src/main.cpp @@ -730,8 +730,7 @@ static INT_PTR CALLBACK SkinEdit_ExtBkDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa } else if (item) { char *szName = item->szName[0] == '{' ? &item->szName[3] : item->szName; - - TextOutA(dis->hDC, dis->rcItem.left, dis->rcItem.top, szName, mir_strlen(szName)); + TextOutA(dis->hDC, dis->rcItem.left, dis->rcItem.top, szName, (int)mir_strlen(szName)); } return TRUE; } diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 0316c8170c..91b1dfface 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -584,7 +584,7 @@ LBL_Def: if (contact) { if (ProtoServiceExists(szProto, PS_GETADVANCEDSTATUSICON)) { - int iconId = ProtoCallService(szProto, PS_GETADVANCEDSTATUSICON, hContact, 0); + int iconId = CallProtoService(szProto, PS_GETADVANCEDSTATUSICON, hContact, 0); if (iconId != -1) contact->xStatusIcon = iconId >> 16; } diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 1d610cd65d..19e2d7ceec 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -275,7 +275,7 @@ BYTE GetCachedStatusMsg(TExtraCache *p, char *szProto) CUSTOM_STATUS cst = { sizeof(cst) }; cst.flags = CSSF_MASK_STATUS; cst.status = &xStatus; - if (ProtoServiceExists(szProto, PS_GETCUSTOMSTATUSEX) && !ProtoCallService(szProto, PS_GETCUSTOMSTATUSEX, hContact, (LPARAM)&cst) && xStatus > 0) { + if (ProtoServiceExists(szProto, PS_GETCUSTOMSTATUSEX) && !CallProtoService(szProto, PS_GETCUSTOMSTATUSEX, hContact, (LPARAM)&cst) && xStatus > 0) { cst.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_TCHAR; cst.wParam = &xStatus2; cst.ptszName = xStatusName; diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 2b2fe4328b..812c732e9c 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -1362,7 +1362,7 @@ skipbg: if (contactOK) { char *szProto = GetContactProto(hContact); if (ProtoServiceExists(szProto, item->szService)) - ProtoCallService(szProto, item->szService, wwParam, llParam); + CallProtoService(szProto, item->szService, wwParam, llParam); else serviceFailure = TRUE; } @@ -1691,7 +1691,7 @@ buttons_done: CUSTOM_STATUS cst = { sizeof(cst) }; cst.flags = CSSF_MASK_STATUS; cst.status = &xStatus; - if (ProtoServiceExists(pd->RealName, PS_GETCUSTOMSTATUSEX) && !ProtoCallService(pd->RealName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cst) && xStatus > 0) + if (ProtoServiceExists(pd->RealName, PS_GETCUSTOMSTATUSEX) && !CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cst) && xStatus > 0) hIcon = (HICON)CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSICON, 0, LR_SHARED); // get OWN xStatus icon (if set) else hIcon = LoadSkinnedProtoIcon(szProto, status); diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index e26b134d7e..3b450485a1 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -370,7 +370,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re { status = CallProtoService(protocol, PS_GETSTATUS, 0, 0); ptrW wszAwayMsg(mir_a2u(awayMsg)); - res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM)wszAwayMsg); + res = CallProtoService(protocol, PS_SETAWAYMSG, status, wszAwayMsg); PrettyStatusMode(status, pn, sizeof(pn)); if (res) szReply.AppendFormat(Translate("Failed to set '%S' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName , awayMsg, pn); @@ -396,7 +396,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re if ((res & PF1_MODEMSGSEND) != 0) //if the protocol supports away messages { INT_PTR status = CallProtoService(protocol, PS_GETSTATUS, 0, 0); - res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM) awayMsg); + res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM)awayMsg); PrettyStatusMode(status, pn, sizeof(pn)); } diff --git a/plugins/ModernOpt/src/mopt_selector.cpp b/plugins/ModernOpt/src/mopt_selector.cpp index 47658055f6..df9fdc565b 100644 --- a/plugins/ModernOpt/src/mopt_selector.cpp +++ b/plugins/ModernOpt/src/mopt_selector.cpp @@ -28,13 +28,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void sttApplySkin(MODERNOPTOBJECT *obj, TCHAR *fn) { - ProtoCallService(obj->lpzThemeModuleName, TS_SKIN_APPLY, NULL, (LPARAM)fn); + CallProtoService(obj->lpzThemeModuleName, TS_SKIN_APPLY, NULL, (LPARAM)fn); } static TCHAR *sttGetActiveSkin(MODERNOPTOBJECT *obj) { return ProtoServiceExists(obj->lpzThemeModuleName, TS_SKIN_ACTIVE) ? - (TCHAR*)ProtoCallService(obj->lpzThemeModuleName, TS_SKIN_ACTIVE, 0, 0) : 0; + (TCHAR*)CallProtoService(obj->lpzThemeModuleName, TS_SKIN_ACTIVE, 0, 0) : 0; } static void sttPreviewSkin(MODERNOPTOBJECT *obj, TCHAR *fn, LPDRAWITEMSTRUCT lps) @@ -42,7 +42,7 @@ static void sttPreviewSkin(MODERNOPTOBJECT *obj, TCHAR *fn, LPDRAWITEMSTRUCT lps if (!fn) return; if ( ProtoServiceExists(obj->lpzThemeModuleName, TS_SKIN_PREVIEW)) { - ProtoCallService(obj->lpzThemeModuleName, TS_SKIN_PREVIEW, (WPARAM)lps, (LPARAM)fn); + CallProtoService(obj->lpzThemeModuleName, TS_SKIN_PREVIEW, (WPARAM)lps, (LPARAM)fn); return; } diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 872fa7b141..b07872ca9c 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -2251,7 +2251,7 @@ void InitCheck() for(int i = 0; i < count; i++) if( ProtoServiceExists(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY)) - ProtoCallService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); + CallProtoService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); } if(bFileTransfers) { @@ -2266,7 +2266,7 @@ void InitCheck() for(int i = 0; i < count; i++) if( ProtoServiceExists(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY)) - ProtoCallService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); + CallProtoService(accounts[i]->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); } } diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 3c6f993507..42f3db1978 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -539,7 +539,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if( ProtoServiceExists(proto, PS_ICQ_CHECKCAPABILITY)) { ICQ_CUSTOMCAP cap = {0}; strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps)); - if(ProtoCallService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) { + if(CallProtoService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) { CallContactService(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----"); return 0; } @@ -836,7 +836,7 @@ int HookSendMsg(WPARAM w, LPARAM l) debuglog<hContact, (LPARAM)&cap)) + if (CallProtoService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) cap_found = true; } } diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index 49b689b56c..16dde60f03 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -63,13 +63,13 @@ void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_stat } else { if (ProtoServiceExists(pszProto, PS_GETSTATUS)) { - if (ProtoCallService(pszProto, PS_GETSTATUS, 0, 0) == if_status) { + if (CallProtoService(pszProto, PS_GETSTATUS, 0, 0) == if_status) { if (options.logging) { TCHAR buf[1024]; mir_sntprintf(buf, SIZEOF(buf), TranslateT("%s - setting status of protocol '%S' (%d)"), pszLabel, pszProto, new_status); CallService(PLUG "/Log", (WPARAM)buf, 0); } - ProtoCallService(pszProto, PS_SETSTATUS, new_status, 0); + CallProtoService(pszProto, PS_SETSTATUS, new_status, 0); } } } diff --git a/plugins/SMS/src/send.cpp b/plugins/SMS/src/send.cpp index 52f18ed826..f1a7afc41b 100644 --- a/plugins/SMS/src/send.cpp +++ b/plugins/SMS/src/send.cpp @@ -70,7 +70,7 @@ void StartSmsSend(HWND hWndDlg,size_t dwModuleIndex,LPWSTR lpwszPhone,size_t dwP char *szProto = ssSMSSettings.ppaSMSAccounts[dwModuleIndex]->szModuleName; if ( ProtoServiceExists(szProto, MS_ICQ_SENDSMS)) { WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpszMessageUTF, dwMessageUTFBuffSize, NULL, NULL); - hProcess = (HANDLE)ProtoCallService(szProto, MS_ICQ_SENDSMS, (WPARAM)szPhone, (LPARAM)lpszMessageUTF); + hProcess = (HANDLE)CallProtoService(szProto, MS_ICQ_SENDSMS, (WPARAM)szPhone, (LPARAM)lpszMessageUTF); SendSMSWindowHProcessSet(hWndDlg, hProcess); } else MEMFREE(pdbei); diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 47080766e5..bad5e0c81c 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -791,7 +791,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO * p USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered); if (ui) { if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { - TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui->pszUID); + TCHAR *p = (TCHAR*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui->pszUID); if (p != NULL) { _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 498fc55d61..8a502c9c2d 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -260,7 +260,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) char *szProto = GetContactProto(hContact); if (szProto != NULL) { // does it support file sends? - DWORD dwCaps = ProtoCallService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); + DWORD dwCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ((dwCaps & PF1_FILESEND) == 0) continue; diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index ce63fdc878..e4b7d41e9c 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -33,7 +33,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) // ...send message char *AuthRepl = mir_u2a(variables_parse(plSets->AuthRepl.Get(), hcntct).c_str()); - ProtoCallService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)AuthRepl); + CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)AuthRepl); mir_free(AuthRepl); db_set_b(hcntct, "CList", "NotOnList", 1); diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 1610fa672a..ae45ebdf77 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1315,7 +1315,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered); if (ui1) { if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { - TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); + TCHAR *p = (TCHAR*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); if (p != NULL) { _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); @@ -1664,7 +1664,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (ui1) { TCHAR tszBuf[1024]; tszBuf[0] = 0; if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { - TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); + TCHAR *p = (TCHAR*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); if (p) { _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 1396836639..a0755b2a2f 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -115,7 +115,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa // number of unread emails TCHAR swzEmailCount[64]; if (ProtoServiceExists(pwd->clcit.szProto, PS_GETUNREADEMAILCOUNT)) { - int iCount = (int)ProtoCallService(pwd->clcit.szProto, PS_GETUNREADEMAILCOUNT, 0, 0); + int iCount = (int)CallProtoService(pwd->clcit.szProto, PS_GETUNREADEMAILCOUNT, 0, 0); if (iCount > 0) { _itot(iCount, swzEmailCount, 10); AddRow(pwd, TranslateT("Unread emails:"), swzEmailCount, NULL, false, false, false); @@ -1516,7 +1516,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa } if (dwItems & TRAYTIP_UNREAD_EMAILS && ProtoServiceExists(pa->szModuleName, PS_GETUNREADEMAILCOUNT)) { - int iCount = (int)ProtoCallService(pa->szModuleName, PS_GETUNREADEMAILCOUNT, 0, 0); + int iCount = (int)CallProtoService(pa->szModuleName, PS_GETUNREADEMAILCOUNT, 0, 0); if (iCount > 0) { _itot(iCount, buff, 10); AddRow(pwd, TranslateT("Unread emails:"), buff, NULL, false, false, false); diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp index 6387f5a798..f5910b2df5 100644 --- a/protocols/Xfire/src/all_statusmsg.cpp +++ b/protocols/Xfire/src/all_statusmsg.cpp @@ -63,11 +63,11 @@ BOOL BackupStatusMsg() { statusid = CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0); XFireLog("Get Status of %s ...", temp[i]->szModuleName); - char ttemp[128]; - mir_snprintf(ttemp, SIZEOF(ttemp), "%s%s", temp[i]->szModuleName, PS_SETAWAYMSG); - //xfire wird geskipped, offline prots und invs prots auch, und locked status prots auch - if (!temp[i]->bIsEnabled || statusid == ID_STATUS_INVISIBLE || statusid == ID_STATUS_OFFLINE || !mir_strcmpi(temp[i]->szModuleName, protocolname) || !ServiceExists(ttemp) || db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1) + if (!temp[i]->bIsEnabled || statusid == ID_STATUS_INVISIBLE || statusid == ID_STATUS_OFFLINE || + !mir_strcmpi(temp[i]->szModuleName, protocolname) || + !ProtoServiceExists(temp[i]->szModuleName, PS_SETAWAYMSG) || + db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1) { XFireLog("-> Skip %s.", temp[i]->szModuleName); @@ -87,7 +87,7 @@ BOOL BackupStatusMsg() { int caps = CallProtoService(temp[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0); bool dndFirst = db_get_b(NULL, protocolname, "dndfirst", 0) > 0; - if (dndFirst ? caps&PF2_HEAVYDND : caps&PF2_LIGHTDND) + if (dndFirst ? caps & PF2_HEAVYDND : caps & PF2_LIGHTDND) { dummystatusid = dndFirst ? ID_STATUS_DND : ID_STATUS_OCCUPIED; XFireLog("%s supports %s.", temp[i]->szModuleName, dndFirst ? "DND" : "OCCUPIED"); diff --git a/src/core/miranda.h b/src/core/miranda.h index c5008e358a..5d31e64aed 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -142,6 +142,8 @@ void KillModuleMenus(int hLangpack); extern LIST accounts; +INT_PTR ProtoCallService(LPCSTR szModule, const char *szService, WPARAM wParam, LPARAM lParam); + PROTOACCOUNT* Proto_CreateAccount(const char *szModuleName, const char *szBaseProto, const TCHAR *tszAccountName); PROTOACCOUNT* __fastcall Proto_GetAccount(const char *accName); diff --git a/src/core/stdautoaway/src/autoaway.cpp b/src/core/stdautoaway/src/autoaway.cpp index f501ec2bda..e3aa0603de 100644 --- a/src/core/stdautoaway/src/autoaway.cpp +++ b/src/core/stdautoaway/src/autoaway.cpp @@ -45,12 +45,11 @@ static bool Proto_IsAccountLocked(PROTOACCOUNT *pa) return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0; } -static void Proto_SetStatus(const char* szProto, unsigned status) +static void Proto_SetStatus(const char *szProto, unsigned status) { if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) { - TCHAR *awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, status, (LPARAM)szProto); - CallProtoService(szProto, PS_SETAWAYMSG, status, (LPARAM)awayMsg); - mir_free(awayMsg); + ptrT awayMsg((TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, status, (LPARAM)szProto)); + CallProtoService(szProto, PS_SETAWAYMSG, status, awayMsg); } CallProtoService(szProto, PS_SETSTATUS, status, 0); diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 806fa9a128..e8e9071dd4 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -989,7 +989,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *si USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, currentHovered); if (ui) { if (ProtoServiceExists(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { - TCHAR *p = (TCHAR*)ProtoCallService(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)si->ptszID, (LPARAM)ui->pszUID); + TCHAR *p = (TCHAR*)CallProtoService(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)si->ptszID, (LPARAM)ui->pszUID); if (p != NULL) { _tcsncpy_s(tszBuf, p, _TRUNCATE); mir_free(p); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 1157f2edb5..82bbf9bb2a 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -163,7 +163,6 @@ mir_base64_encode @160 mir_base64_decode @161 ProtoServiceExists @162 ProtoBroadcastAck @163 -ProtoCallService @164 db_set_resident @165 db_set @166 ProtoConstructor @167 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 9018911b8b..fb910e5329 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -163,7 +163,6 @@ mir_base64_encode @160 mir_base64_decode @161 ProtoServiceExists @162 ProtoBroadcastAck @163 -ProtoCallService @164 db_set_resident @165 db_set @166 ProtoConstructor @167 diff --git a/src/mir_core/src/protos.cpp b/src/mir_core/src/protos.cpp index 852fed884a..2e4f009cdc 100644 --- a/src/mir_core/src/protos.cpp +++ b/src/mir_core/src/protos.cpp @@ -111,19 +111,6 @@ MIR_CORE_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, ///////////////////////////////////////////////////////////////////////////////////////// -MIR_CORE_DLL(INT_PTR) ProtoCallService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam) -{ - if (szModule == NULL || szService == NULL) - return false; - - char str[MAXMODULELABELLENGTH * 2]; - strncpy_s(str, szModule, _TRUNCATE); - strncat_s(str, szService, _TRUNCATE); - return CallService(str, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - MIR_CORE_DLL(int) ProtoServiceExists(const char *szModule, const char *szService) { if (szModule == NULL || szService == NULL) diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index b863848109..9d984a5a5c 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -425,10 +425,11 @@ int LoadIgnoreModule(void) pd.type = PROTOTYPE_IGNORE; CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); - CreateServiceFunction("Ignore"PSR_MESSAGE, IgnoreRecvMessage); - CreateServiceFunction("Ignore"PSR_URL, IgnoreRecvUrl); - CreateServiceFunction("Ignore"PSR_FILE, IgnoreRecvFile); - CreateServiceFunction("Ignore"PSR_AUTH, IgnoreRecvAuth); + CreateProtoServiceFunction("Ignore", PSR_MESSAGE, IgnoreRecvMessage); + CreateProtoServiceFunction("Ignore", PSR_URL, IgnoreRecvUrl); + CreateProtoServiceFunction("Ignore", PSR_FILE, IgnoreRecvFile); + CreateProtoServiceFunction("Ignore", PSR_AUTH, IgnoreRecvAuth); + CreateServiceFunction(MS_IGNORE_ISIGNORED, IsIgnored); CreateServiceFunction(MS_IGNORE_IGNORE, Ignore); CreateServiceFunction(MS_IGNORE_UNIGNORE, Unignore); diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index f550d4edbd..b947a6f551 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -209,7 +209,7 @@ INT_PTR Meta_SendNudge(WPARAM wParam, LPARAM lParam) return 1; MCONTACT hSubContact = Meta_GetMostOnline(cc); - return ProtoCallService(GetContactProto(hSubContact), PS_SEND_NUDGE, hSubContact, lParam); + return CallProtoService(GetContactProto(hSubContact), PS_SEND_NUDGE, hSubContact, lParam); } /** Send a message to the protocol specific network. @@ -516,7 +516,7 @@ static INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam) char *proto = GetContactProto(hMostOnline); if (proto) if (ProtoServiceExists(proto, PSS_USERISTYPING)) - ProtoCallService(proto, PSS_USERISTYPING, hMostOnline, lParam); + CallProtoService(proto, PSS_USERISTYPING, hMostOnline, lParam); return 0; } @@ -765,7 +765,7 @@ INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR; AI->hContact = hSub; - INT_PTR result = ProtoCallService(proto, PS_GETAVATARINFOT, wParam, lParam); + INT_PTR result = CallProtoService(proto, PS_GETAVATARINFOT, wParam, lParam); AI->hContact = cc->contactID; if (result != CALLSERVICE_NOTFOUND) return result; diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 314071a55a..c1eff7848e 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -31,19 +31,53 @@ HANDLE hAccListChanged; static HANDLE hTypeEvent; static BOOL bModuleInitialized = FALSE; -typedef struct +struct TServiceListItem { - const char* name; + const char *name; int id; -} -TServiceListItem; +}; -static int CompareServiceItems(const TServiceListItem* p1, const TServiceListItem* p2) -{ - return mir_strcmp(p1->name, p2->name); +static int __cdecl CompareServiceItems(const void *p1, const void *p2) +{ return strcmp(((TServiceListItem*)p1)->name, ((TServiceListItem*)p2)->name); } -static LIST serviceItems(10, CompareServiceItems); +static TServiceListItem serviceItems[] = +{ + { PS_ADDTOLIST, 1 }, + { PS_ADDTOLISTBYEVENT, 2 }, + { PS_AUTHALLOW, 3 }, + { PS_AUTHDENY, 4 }, + { PSR_AUTH, 5 }, + { PSS_AUTHREQUEST, 6 }, + { PSS_FILEALLOW, 8 }, + { PSS_FILECANCEL, 9 }, + { PSS_FILEDENY, 10 }, + { PS_FILERESUME, 11 }, + { PS_GETCAPS, 12 }, + { PS_LOADICON, 13 }, + { PSS_GETINFO, 14 }, + { PS_BASICSEARCH, 15 }, + { PS_SEARCHBYEMAIL, 16 }, + { PS_SEARCHBYNAME, 17 }, + { PS_SEARCHBYADVANCED, 18 }, + { PS_CREATEADVSEARCHUI, 19 }, + { PSR_CONTACTS, 20 }, + { PSR_FILE, 21 }, + { PSR_MESSAGE, 22 }, + { PSR_URL, 23 }, + { PSS_CONTACTS, 24 }, + { PSS_FILE, 25 }, + { PSS_MESSAGE, 26 }, + { PSS_URL, 27 }, + { PSS_SETAPPARENTMODE, 28 }, + { PS_SETSTATUS, 29 }, + { PSS_GETAWAYMSG, 30 }, + { PSR_AWAYMSG, 31 }, + { PS_SETAWAYMSG, 33 }, + { PSS_USERISTYPING, 34 }, + { PS_GETNAME, 35 }, + { PS_GETSTATUS, 36 } +}; //------------------------------------------------------------------------------------ @@ -209,9 +243,8 @@ static INT_PTR Proto_ContactIsTyping(WPARAM wParam, LPARAM lParam) void Proto_SetStatus(const char *szProto, unsigned status) { if (CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) { - TCHAR *awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, status, (LPARAM)szProto); - CallProtoServiceInt(NULL, szProto, PS_SETAWAYMSG, status, (LPARAM)awayMsg); - mir_free(awayMsg); + ptrT tszAwayMsg((TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, status, (LPARAM)szProto)); + CallProtoServiceInt(NULL, szProto, PS_SETAWAYMSG, status, tszAwayMsg); } CallProtoServiceInt(NULL, szProto, PS_SETSTATUS, status, 0); } @@ -246,21 +279,20 @@ static wchar_t** __fastcall Proto_FilesMatrixU(char **files) HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex) { - if (LOWORD(iconIndex) == PLI_PROTOCOL) { - if (iconIndex & PLIF_ICOLIBHANDLE) - return (HICON)ppro->m_hProtoIcon; + if (LOWORD(iconIndex) != PLI_PROTOCOL) + return NULL; - bool big = (iconIndex & PLIF_SMALL) == 0; - HICON hIcon = Skin_GetIconByHandle(ppro->m_hProtoIcon, big); + if (iconIndex & PLIF_ICOLIBHANDLE) + return (HICON)ppro->m_hProtoIcon; - if (iconIndex & PLIF_ICOLIB) - return hIcon; + bool big = (iconIndex & PLIF_SMALL) == 0; + HICON hIcon = Skin_GetIconByHandle(ppro->m_hProtoIcon, big); + if (iconIndex & PLIF_ICOLIB) + return hIcon; - HICON hIcon2 = CopyIcon(hIcon); - Skin_ReleaseIcon(hIcon); - return hIcon2; - } - return NULL; + HICON hIcon2 = CopyIcon(hIcon); + Skin_ReleaseIcon(hIcon); + return hIcon2; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -345,7 +377,7 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char if (pa && !pa->bOldProto) { PROTO_INTERFACE *ppi = pa->ppro; if (ppi != NULL && ppi->m_iVersion > 1) { - TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService); + TServiceListItem *item = (TServiceListItem*)bsearch(&szService, serviceItems, _countof(serviceItems), sizeof(serviceItems[0]), CompareServiceItems); if (item) { switch (item->id) { case 1: return (INT_PTR)ppi->AddToList(wParam, (PROTOSEARCHRESULT*)lParam); @@ -398,16 +430,19 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char return ProtoCallService(szModule, szService, wParam, lParam); } -///////////////////////////////////////////////////////////////////////////////////////// - -static void InsertServiceListItem(int id, const char* szName) +INT_PTR ProtoCallService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam) { - TServiceListItem* p = (TServiceListItem*)mir_alloc(sizeof(TServiceListItem)); - p->id = id; - p->name = szName; - serviceItems.insert(p); + if (szModule == NULL || szService == NULL) + return false; + + char str[MAXMODULELABELLENGTH * 2]; + strncpy_s(str, szModule, _TRUNCATE); + strncat_s(str, szService, _TRUNCATE); + return CallService(str, wParam, lParam); } +///////////////////////////////////////////////////////////////////////////////////////// + int LoadProtocolsModule(void) { bModuleInitialized = TRUE; @@ -415,40 +450,7 @@ int LoadProtocolsModule(void) if (LoadProtoChains()) return 1; - InsertServiceListItem(1, PS_ADDTOLIST); - InsertServiceListItem(2, PS_ADDTOLISTBYEVENT); - InsertServiceListItem(3, PS_AUTHALLOW); - InsertServiceListItem(4, PS_AUTHDENY); - InsertServiceListItem(5, PSR_AUTH); - InsertServiceListItem(6, PSS_AUTHREQUEST); - InsertServiceListItem(8, PSS_FILEALLOW); - InsertServiceListItem(9, PSS_FILECANCEL); - InsertServiceListItem(10, PSS_FILEDENY); - InsertServiceListItem(11, PS_FILERESUME); - InsertServiceListItem(12, PS_GETCAPS); - InsertServiceListItem(13, PS_LOADICON); - InsertServiceListItem(14, PSS_GETINFO); - InsertServiceListItem(15, PS_BASICSEARCH); - InsertServiceListItem(16, PS_SEARCHBYEMAIL); - InsertServiceListItem(17, PS_SEARCHBYNAME); - InsertServiceListItem(18, PS_SEARCHBYADVANCED); - InsertServiceListItem(19, PS_CREATEADVSEARCHUI); - InsertServiceListItem(20, PSR_CONTACTS); - InsertServiceListItem(21, PSR_FILE); - InsertServiceListItem(22, PSR_MESSAGE); - InsertServiceListItem(23, PSR_URL); - InsertServiceListItem(24, PSS_CONTACTS); - InsertServiceListItem(25, PSS_FILE); - InsertServiceListItem(26, PSS_MESSAGE); - InsertServiceListItem(27, PSS_URL); - InsertServiceListItem(28, PSS_SETAPPARENTMODE); - InsertServiceListItem(29, PS_SETSTATUS); - InsertServiceListItem(30, PSS_GETAWAYMSG); - InsertServiceListItem(31, PSR_AWAYMSG); - InsertServiceListItem(33, PS_SETAWAYMSG); - InsertServiceListItem(34, PSS_USERISTYPING); - InsertServiceListItem(35, PS_GETNAME); - InsertServiceListItem(36, PS_GETSTATUS); + qsort(serviceItems, _countof(serviceItems), sizeof(serviceItems[0]), CompareServiceItems); hTypeEvent = CreateHookableEvent(ME_PROTO_CONTACTISTYPING); hAccListChanged = CreateHookableEvent(ME_PROTO_ACCLISTCHANGED); @@ -481,10 +483,6 @@ void UnloadProtocolsModule() DestroyHookableEvent(hAccListChanged); hAccListChanged = NULL; } - - for (int i = 0; i < serviceItems.getCount(); i++) - mir_free(serviceItems[i]); - serviceItems.destroy(); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index 48cb033202..0b54d8e30c 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -440,7 +440,7 @@ static void sttUpdateAccountInfo(HWND hwndDlg, struct TAccMgrData *dat) SetDlgItemText(hwndDlg, IDC_TXT_INFO, TranslateT("Account is disabled. Please activate it to access options.")); } else { - HWND hwnd = (HWND)ProtoCallService(pa->szModuleName, PS_CREATEACCMGRUI, 0, (LPARAM)hwndDlg); + HWND hwnd = (HWND)CallProtoService(pa->szModuleName, PS_CREATEACCMGRUI, 0, (LPARAM)hwndDlg); if (hwnd && (hwnd != (HWND)CALLSERVICE_NOTFOUND)) { RECT rc; -- cgit v1.2.3