From f725c70b482df377119e2c09b36c9317f86ef494 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Apr 2013 15:52:48 +0000 Subject: 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 --- plugins/Scriver/src/globals.cpp | 95 ++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 45 deletions(-) (limited to 'plugins/Scriver/src/globals.cpp') 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; } -- cgit v1.2.3