summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-01 17:20:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-01 17:20:04 +0000
commitb660fac5560005706aeab0a0d5ad2b32bdcaf929 (patch)
treed8db661d0b0e025156c3706e93f1aafa22708358 /src
parent098b75ec924b6a52328e3803f5bf9e5f45835f5d (diff)
- 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
Diffstat (limited to 'src')
-rw-r--r--src/core/miranda.h2
-rw-r--r--src/core/stdautoaway/src/autoaway.cpp7
-rw-r--r--src/core/stdchat/src/window.cpp2
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/protos.cpp13
-rw-r--r--src/modules/ignore/ignore.cpp9
-rw-r--r--src/modules/metacontacts/meta_services.cpp6
-rw-r--r--src/modules/protocols/protocols.cpp136
-rw-r--r--src/modules/protocols/protoopts.cpp2
10 files changed, 82 insertions, 97 deletions
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<PROTOACCOUNT> 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<TServiceListItem> 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;