summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/msgs.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-01-28 11:20:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-01-28 11:20:28 +0000
commit3ffb500915c8b5a9e02d2b0136c20e9519d4f983 (patch)
tree1773fa5354865dcbaf8a45efd418d4420cfbfff5 /plugins/Scriver/src/msgs.cpp
parent02d5017ff8c7e8d66adbb210433a93cff45d94d8 (diff)
port of tabsrmm's solution for events to StdMsg & Scriver
git-svn-id: http://svn.miranda-ng.org/main/trunk@16177 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver/src/msgs.cpp')
-rw-r--r--plugins/Scriver/src/msgs.cpp82
1 files changed, 52 insertions, 30 deletions
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index ecc63cbc13..a7e3db3628 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -131,7 +131,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
cle.pszService = "SRMsg/ReadMessage";
mir_sntprintf(toolTip, TranslateT("Message from %s"), contactName);
cle.ptszTooltip = toolTip;
- CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
+ pcli->pfnAddEvent(&cle);
}
return 0;
}
@@ -220,15 +220,17 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam)
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn);
}
else {
- CLISTEVENT cle = { sizeof(cle) };
+ pcli->pfnRemoveEvent(hContact, 1);
+
+ CLISTEVENT cle = {};
+ cle.cbSize = sizeof(cle);
cle.hContact = hContact;
cle.hDbEvent = 1;
cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
cle.hIcon = GetCachedIcon("scriver_TYPING");
cle.pszService = "SRMsg/TypingMessage";
cle.ptszTooltip = szTip;
- CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1);
- CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle);
+ pcli->pfnAddEvent(&cle);
}
}
return 0;
@@ -251,43 +253,63 @@ static int ContactDeleted(WPARAM wParam, LPARAM)
return 0;
}
-static void RestoreUnreadMessageAlerts(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct MSavedEvent
{
- TCHAR toolTip[256];
+ MSavedEvent(MCONTACT _hContact, MEVENT _hEvent) :
+ hContact(_hContact),
+ hEvent(_hEvent)
+ {
+ }
- DBEVENTINFO dbei = { sizeof(dbei) };
+ MEVENT hEvent;
+ MCONTACT hContact;
+};
- CLISTEVENT cle = { sizeof(cle) };
- cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
- cle.pszService = "SRMsg/ReadMessage";
- cle.flags = CLEF_TCHAR;
- cle.ptszTooltip = toolTip;
+static void RestoreUnreadMessageAlerts(void)
+{
+ OBJLIST<MSavedEvent> arEvents(10, NumericKeySortT);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = 0;
db_event_get(hDbEvent, &dbei);
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && DbEventIsMessageOrCustom(&dbei)) {
- int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
- if (windowAlreadyExists)
- continue;
-
- if (IsAutoPopup(hContact) && !windowAlreadyExists) {
- NewMessageWindowLParam newData = { 0 };
- newData.hContact = hContact;
- newData.flags = NMWLP_INCOMING;
- HWND hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData);
- }
- else {
- cle.hContact = hContact;
- cle.hDbEvent = hDbEvent;
- mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
- CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
- }
+ if ((dbei.flags & (DBEF_SENT | DBEF_READ)) || !DbEventIsMessageOrCustom(&dbei))
+ continue;
+
+ int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
+ if (windowAlreadyExists)
+ continue;
+
+ if (IsAutoPopup(hContact) && !windowAlreadyExists) {
+ NewMessageWindowLParam newData = { 0 };
+ newData.hContact = hContact;
+ newData.flags = NMWLP_INCOMING;
+ HWND hParent = GetParentWindow(newData.hContact, FALSE);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData);
}
+ else arEvents.insert(new MSavedEvent(hContact, hDbEvent));
}
}
+
+ TCHAR toolTip[256];
+
+ CLISTEVENT cle = {};
+ cle.cbSize = sizeof(cle);
+ cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
+ cle.pszService = "SRMsg/ReadMessage";
+ cle.flags = CLEF_TCHAR;
+ cle.ptszTooltip = toolTip;
+
+ for (int i = 0; i < arEvents.getCount(); i++) {
+ MSavedEvent &e = arEvents[i];
+ mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0));
+ cle.hContact = e.hContact;
+ cle.hDbEvent = e.hEvent;
+ pcli->pfnAddEvent(&cle);
+ }
}
static INT_PTR GetWindowAPI(WPARAM, LPARAM)