diff options
author | George Hazan <george.hazan@gmail.com> | 2014-06-23 20:29:08 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-06-23 20:29:08 +0000 |
commit | 37a3130638a43029a072fcef77dd3afb88e0e029 (patch) | |
tree | d96296e6130a044fb3fd9f6df81b91b043cc29f7 /src | |
parent | fbf061103982319c8023e48b150295fed547c9de (diff) |
more correct way of catching incoming messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@9560 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/metacontacts/meta_main.cpp | 4 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_services.cpp | 39 | ||||
-rw-r--r-- | src/modules/metacontacts/metacontacts.h | 2 |
3 files changed, 29 insertions, 16 deletions
diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp index dec65ef7d0..257f557814 100644 --- a/src/modules/metacontacts/meta_main.cpp +++ b/src/modules/metacontacts/meta_main.cpp @@ -70,6 +70,10 @@ int LoadMetacontacts(void) Meta_ReadOptions(&options);
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = META_FILTER;
+ pd.type = PROTOTYPE_FILTER;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
pd.szName = META_PROTO;
pd.type = PROTOTYPE_VIRTUAL;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index dbd04d6658..01fc809867 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -118,6 +118,26 @@ INT_PTR Meta_LoadIcon(WPARAM wParam,LPARAM lParam) GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR MetaFilter_RecvMessage(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *ccs = (CCSDATA*)lParam;
+ PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam;
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(ccs->hContact);
+ if (cc == NULL)
+ return 0;
+ if (cc->IsSub()) {
+ MetaSrmmData tmp = { cc->parentID };
+ if (MetaSrmmData *p = arMetaWindows.find(&tmp))
+ p->m_hSub = cc->contactID;
+ }
+ CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CALLBACK SetStatusThread(HWND hWnd, UINT msg, UINT_PTR id, DWORD dw)
{
previousMode = mcStatus;
@@ -556,18 +576,6 @@ static int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) return 0;
}
-static int Meta_EventAdded(WPARAM hMeta, LPARAM hDbEvent)
-{
- MetaSrmmData tmp = { hMeta };
- if (MetaSrmmData *p = arMetaWindows.find(&tmp)) {
- DBEVENTINFO dbei = { sizeof(dbei) };
- db_event_get(HANDLE(hDbEvent), &dbei);
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
- p->m_hSub = db_event_getContact(HANDLE(hDbEvent));
- }
- return 0;
-}
-
// returns manually chosen sub in the meta window
static INT_PTR Meta_SrmmCurrentSub(WPARAM hMeta, LPARAM lParam)
{
@@ -880,13 +888,13 @@ void Meta_InitServices() // file recv is done by subcontacts
CreateProtoServiceFunction(META_PROTO, PSS_FILE, Meta_FileSend);
-
CreateProtoServiceFunction(META_PROTO, PSS_GETAWAYMSG, Meta_GetAwayMsg);
-
CreateProtoServiceFunction(META_PROTO, PS_GETAVATARINFOT, Meta_GetAvatarInfo);
-
CreateProtoServiceFunction(META_PROTO, PSS_GETINFO, Meta_GetInfo);
+ // receive filter
+ CreateProtoServiceFunction(META_FILTER, PSR_MESSAGE, MetaFilter_RecvMessage);
+
// API services and events
CreateApiServices();
@@ -903,7 +911,6 @@ void Meta_InitServices() HookEvent(ME_PROTO_CONTACTISTYPING, Meta_ContactIsTyping);
HookEvent(ME_DB_CONTACT_DELETED, Meta_ContactDeleted);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, Meta_SettingChanged);
- HookEvent(ME_DB_EVENT_ADDED, Meta_EventAdded);
HookEvent(ME_OPT_INITIALISE, Meta_OptInit);
HookEvent(ME_SYSTEM_MODULESLOADED, Meta_ModulesLoaded);
HookEvent(ME_SYSTEM_PRESHUTDOWN, Meta_PreShutdown);
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 19b970a308..637ae30bec 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAX_CONTACTS 20
+#define META_FILTER "MetaContactsFilter"
+
INT_PTR TranslateMenuFunc(MCONTACT hContact, int i);
// contact menu items
|