diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-20 15:52:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-20 15:52:48 +0000 |
commit | f725c70b482df377119e2c09b36c9317f86ef494 (patch) | |
tree | 584e839d2b786835acb9dd460aab0758dd736cf9 /plugins/Scriver/src | |
parent | 66e9197603643cc587909fb1bce7402383dbad69 (diff) |
ME_MSG_WRITEEVENT - new hookable event to catch the db event creation moment in SRMM
git-svn-id: http://svn.miranda-ng.org/main/trunk@4484 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r-- | plugins/Scriver/src/commonheaders.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/globals.cpp | 95 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 8 |
3 files changed, 58 insertions, 47 deletions
diff --git a/plugins/Scriver/src/commonheaders.h b/plugins/Scriver/src/commonheaders.h index 9eeef8af3b..6c18ab90aa 100644 --- a/plugins/Scriver/src/commonheaders.h +++ b/plugins/Scriver/src/commonheaders.h @@ -120,7 +120,7 @@ extern HMENU g_hMenu; extern HANDLE hBuildMenuEvent;
extern HANDLE hSendEvent;
extern TABLIST *g_TabList;
-extern HANDLE hHookWinPopup;
+extern HANDLE hHookWinPopup, hHookWinWrite;
extern HCURSOR hCurSplitNS, hCurSplitWE;
extern CREOleCallback reOleCallback;
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index a174f4c91f..c69337ff02 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -416,54 +416,59 @@ static int ackevent(WPARAM wParam, LPARAM lParam) ACKDATA *ack = (ACKDATA*) lParam;
MessageSendQueueItem *item = FindSendQueueItem((HANDLE)pAck->hContact, (HANDLE)pAck->hProcess);
- if (item != NULL) {
- HWND hwndSender = item->hwndSender;
- if (ack->result == ACKRESULT_FAILED) {
- if (item->hwndErrorDlg != NULL) {
- item = FindOldestPendingSendQueueItem(hwndSender, (HANDLE)pAck->hContact);
- }
- if (item != NULL && item->hwndErrorDlg == NULL) {
- if (hwndSender != NULL) {
- ErrorWindowData *ewd = (ErrorWindowData *) mir_alloc(sizeof(ErrorWindowData));
- ewd->szName = GetNickname(item->hContact, item->proto);
- ewd->szDescription = a2t((char *) ack->lParam);
- ewd->szText = GetSendBufferMsg(item);
- ewd->hwndParent = hwndSender;
- ewd->queueItem = item;
- SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0);
- SendMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd);
- } else {
- RemoveSendQueueItem(item);
- }
- }
- return 0;
- }
+ if (item == NULL)
+ return 0;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | (( item->flags & PREF_RTL) ? DBEF_RTL : 0 );
- if ( item->flags & PREF_UTF )
- dbei.flags |= DBEF_UTF;
- dbei.szModule = GetContactProto(item->hContact);
- dbei.timestamp = time(NULL);
- dbei.cbBlob = lstrlenA(item->sendBuffer) + 1;
- if ( !( item->flags & PREF_UTF ))
- dbei.cbBlob *= sizeof(TCHAR) + 1;
- dbei.pBlob = (PBYTE) item->sendBuffer;
- db_event_add(item->hContact, &dbei);
-
- if (item->hwndErrorDlg != NULL)
- DestroyWindow(item->hwndErrorDlg);
-
- if (RemoveSendQueueItem(item) && db_get_b(NULL, SRMMMOD, SRMSGSET_AUTOCLOSE, SRMSGDEFSET_AUTOCLOSE)) {
- if (hwndSender != NULL)
- DestroyWindow(hwndSender);
+ HWND hwndSender = item->hwndSender;
+ if (ack->result == ACKRESULT_FAILED) {
+ if (item->hwndErrorDlg != NULL) {
+ item = FindOldestPendingSendQueueItem(hwndSender, (HANDLE)pAck->hContact);
}
- else if (hwndSender != NULL) {
- SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0);
- SkinPlaySound("SendMsg");
+ if (item != NULL && item->hwndErrorDlg == NULL) {
+ if (hwndSender != NULL) {
+ ErrorWindowData *ewd = (ErrorWindowData *) mir_alloc(sizeof(ErrorWindowData));
+ ewd->szName = GetNickname(item->hContact, item->proto);
+ ewd->szDescription = a2t((char *) ack->lParam);
+ ewd->szText = GetSendBufferMsg(item);
+ ewd->hwndParent = hwndSender;
+ ewd->queueItem = item;
+ SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0);
+ SendMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd);
+ } else {
+ RemoveSendQueueItem(item);
+ }
}
+ return 0;
+ }
+
+ DBEVENTINFO dbei = { 0 };
+ dbei.cbSize = sizeof(dbei);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | (( item->flags & PREF_RTL) ? DBEF_RTL : 0 );
+ if ( item->flags & PREF_UTF )
+ dbei.flags |= DBEF_UTF;
+ dbei.szModule = GetContactProto(item->hContact);
+ dbei.timestamp = time(NULL);
+ dbei.cbBlob = lstrlenA(item->sendBuffer) + 1;
+ if ( !( item->flags & PREF_UTF ))
+ dbei.cbBlob *= sizeof(TCHAR) + 1;
+ dbei.pBlob = (PBYTE) item->sendBuffer;
+ HANDLE hNewEvent = db_event_add(item->hContact, &dbei);
+
+ MessageWindowEvent evt = { sizeof(evt), (int)item->hSendId, item->hContact, hNewEvent };
+ NotifyEventHooks(hHookWinWrite, 0, (LPARAM)&evt);
+
+ if (item->hwndErrorDlg != NULL)
+ DestroyWindow(item->hwndErrorDlg);
+
+ if (RemoveSendQueueItem(item) && db_get_b(NULL, SRMMMOD, SRMSGSET_AUTOCLOSE, SRMSGDEFSET_AUTOCLOSE)) {
+ if (hwndSender != NULL)
+ DestroyWindow(hwndSender);
}
+ else if (hwndSender != NULL) {
+ SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0);
+ SkinPlaySound("SendMsg");
+ }
+
return 0;
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index b0e95bdc99..85b8df532d 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand, hDragCursor;
-HANDLE hHookWinEvt=NULL, hHookWinPopup=NULL;
+HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
HGENMENU hMsgMenuItem;
extern HWND GetParentWindow(HANDLE hContact, BOOL bChat);
@@ -476,12 +476,16 @@ int OnSystemPreshutdown(WPARAM wParam, LPARAM lParam) int OnUnloadModule(void)
{
Chat_Unload();
+
DestroyCursor(hCurSplitNS);
DestroyCursor(hCurHyperlinkHand);
DestroyCursor(hCurSplitWE);
DestroyCursor(hDragCursor);
+
DestroyHookableEvent(hHookWinEvt);
DestroyHookableEvent(hHookWinPopup);
+ DestroyHookableEvent(hHookWinWrite);
+
ReleaseIcons();
FreeMsgLogIcons();
FreeLibrary(GetModuleHandleA("riched20.dll"));
@@ -532,6 +536,8 @@ int OnLoadModule(void) hHookWinEvt = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
+ hHookWinWrite = CreateHookableEvent(ME_MSG_WRITEEVENT);
+
SkinAddNewSoundEx("RecvMsgActive", LPGEN("Instant messages"), LPGEN("Incoming (Focused Window)"));
SkinAddNewSoundEx("RecvMsgInactive", LPGEN("Instant messages"), LPGEN("Incoming (Unfocused Window)"));
SkinAddNewSoundEx("AlertMsg", LPGEN("Instant messages"), LPGEN("Incoming (New Session)"));
|