summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-07-08 22:10:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-07-08 22:10:14 +0000
commitbb952e431866d131bae95c08e579ec8a00f00343 (patch)
tree60881668cf328b50906346c5f66ce47da2d9ad88 /src
parentc181af64bab27eb50e684c64c0a3caa49f8bbe39 (diff)
core protocol helpers for creating protocol evengs, services & threads
git-svn-id: http://svn.miranda-ng.org/main/trunk@5286 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/mir_core.def6
-rw-r--r--src/mir_core/protos.cpp45
-rw-r--r--src/modules/extraicons/options_ei.cpp10
3 files changed, 54 insertions, 7 deletions
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index 0e4103229a..a601d34b0b 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -168,3 +168,9 @@ db_set_resident @165
db_set @166
ProtoConstructor @167
ProtoDestructor @168
+ProtoCreateService @169
+ProtoCreateServiceParam @170
+ProtoHookEvent @171
+ProtoCreateHookableEvent @172
+ProtoForkThread @173
+ProtoForkThreadEx @174
diff --git a/src/mir_core/protos.cpp b/src/mir_core/protos.cpp
index 291b7a0fa4..098bf280d4 100644
--- a/src/mir_core/protos.cpp
+++ b/src/mir_core/protos.cpp
@@ -79,8 +79,8 @@ MIR_CORE_DLL(int) ProtoServiceExists(const char *szModule, const char *szService
return false;
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str,szModule,strlen(szModule));
- strncat_s(str,szService,strlen(szService));
+ strncpy_s(str, szModule, strlen(szModule));
+ strncat_s(str, szService, strlen(szService));
return ServiceExists(str);
}
@@ -100,3 +100,44 @@ MIR_CORE_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis)
mir_free(pThis->m_szModuleName);
mir_free(pThis->m_tszUserName);
}
+
+MIR_CORE_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szService, strlen(szService));
+ ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, pThis);
+}
+
+MIR_CORE_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam serviceProc, LPARAM lParam)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szService, strlen(szService));
+ ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, pThis, lParam);
+}
+
+MIR_CORE_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szEvent, ProtoEventFunc handler)
+{
+ ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, pThis);
+}
+
+MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szName)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szName, strlen(szName));
+ return CreateHookableEvent(str);
+}
+
+MIR_CORE_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param)
+{
+ UINT threadID;
+ CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, &threadID));
+}
+
+MIR_CORE_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param, UINT* threadID)
+{
+ UINT lthreadID;
+ return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, threadID ? threadID : &lthreadID);
+}
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp
index 48a763dc83..81d5a3f7bf 100644
--- a/src/modules/extraicons/options_ei.cpp
+++ b/src/modules/extraicons/options_ei.cpp
@@ -546,14 +546,14 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CallService(MS_DB_MODULE_DELETE, 0, (LPARAM) MODULE_NAME "Groups");
db_set_w(NULL, MODULE_NAME "Groups", "Count", (WORD)groups.size());
- for (i = 0; i < groups.size(); i++) {
- ExtraIconGroup *group = groups[i];
+ for (unsigned k = 0; k < groups.size(); k++) {
+ ExtraIconGroup *group = groups[k];
char setting[512];
mir_snprintf(setting, SIZEOF(setting), "%d_count", i);
db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->items.size());
- for (unsigned int j = 0; j < group->items.size(); j++) {
+ for (unsigned j = 0; j < group->items.size(); j++) {
BaseExtraIcon *extra = group->items[j];
mir_snprintf(setting, SIZEOF(setting), "%d_%d", i, j);
@@ -567,8 +567,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Apply icons to new slots
RebuildListsBasedOnGroups(groups);
- for (i = 0; i < extraIconsBySlot.size(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
+ for (unsigned n = 0; n < extraIconsBySlot.size(); n++) {
+ ExtraIcon *extra = extraIconsBySlot[n];
if (extra->getType() != EXTRAICON_TYPE_GROUP)
if (oldSlots[((BaseExtraIcon *) extra)->getID() - 1] == extra->getSlot())