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 /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 'src')
-rw-r--r-- | src/core/stdmsg/src/cmdlist.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/cmdlist.h | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/globals.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 43 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 47 |
5 files changed, 52 insertions, 50 deletions
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 77dc44f3ee..12ccf08593 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -89,7 +89,7 @@ static VOID CALLBACK MsgTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi MessageFailureProcess(tmlst[i], LPGEN("The message send timed out."));
}
-void msgQueue_add(HANDLE hContact, HANDLE id, const TCHAR* szMsg, HANDLE hDbEvent)
+void msgQueue_add(HANDLE hContact, int id, const TCHAR* szMsg, HANDLE hDbEvent)
{
TMsgQueue *item = (TMsgQueue*)mir_alloc(sizeof(TMsgQueue));
item->hContact = hContact;
@@ -106,7 +106,7 @@ void msgQueue_add(HANDLE hContact, HANDLE id, const TCHAR* szMsg, HANDLE hDbEven }
-void msgQueue_processack(HANDLE hContact, HANDLE id, BOOL success, const char* szErr)
+void msgQueue_processack(HANDLE hContact, int id, BOOL success, const char* szErr)
{
int i;
TMsgQueue* item = NULL;;
diff --git a/src/core/stdmsg/src/cmdlist.h b/src/core/stdmsg/src/cmdlist.h index 5311ebd13c..c57499c0bc 100644 --- a/src/core/stdmsg/src/cmdlist.h +++ b/src/core/stdmsg/src/cmdlist.h @@ -37,7 +37,7 @@ __inline TCHAR* tcmdlist_getitem(SortedList *list, int ind) typedef struct _TMsgQueue
{
- HANDLE id;
+ int id;
HANDLE hContact;
TCHAR* szMsg;
HANDLE hDbEvent;
@@ -45,8 +45,8 @@ typedef struct _TMsgQueue }
TMsgQueue;
-void msgQueue_add(HANDLE hContact, HANDLE id, const TCHAR* szMsg, HANDLE hDbEvent);
-void msgQueue_processack(HANDLE hContact, HANDLE id, BOOL success, const char* szErr);
+void msgQueue_add(HANDLE hContact, int id, const TCHAR* szMsg, HANDLE hDbEvent);
+void msgQueue_processack(HANDLE hContact, int id, BOOL success, const char* szErr);
void msgQueue_init(void);
void msgQueue_destroy(void);
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index 086510461a..56c2b83c87 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -135,7 +135,7 @@ static int ackevent(WPARAM wParam, LPARAM lParam) {
ACKDATA *pAck = (ACKDATA *)lParam;
if (pAck && pAck->type == ACKTYPE_MESSAGE) {
- msgQueue_processack(pAck->hContact, pAck->hProcess, pAck->result == ACKRESULT_SUCCESS, (char*)pAck->lParam);
+ msgQueue_processack(pAck->hContact, (int)pAck->hProcess, pAck->result == ACKRESULT_SUCCESS, (char*)pAck->lParam);
if (pAck->result == ACKRESULT_SUCCESS)
SkinPlaySound("SendMsg");
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 31616882c9..009e96b0e9 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define VALID_AVATAR(x) (x == PA_FORMAT_PNG || x == PA_FORMAT_JPEG || x == PA_FORMAT_ICON || x == PA_FORMAT_BMP || x == PA_FORMAT_GIF)
extern HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand;
-extern HANDLE hHookWinEvt, hHookWinPopup;
+extern HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
extern CREOleCallback reOleCallback;
static void UpdateReadChars(HWND hwndDlg, HWND hwndStatus);
@@ -82,6 +82,9 @@ static int RTL_Detect(const TCHAR *ptszText) HANDLE SendMessageDirect(const TCHAR *szMsg, HANDLE hContact, char *szProto)
{
+ if (hContact == NULL)
+ return NULL;
+
int flags = 0;
int bufSize = 0;
char *sendBuffer = NULL;
@@ -113,29 +116,27 @@ HANDLE SendMessageDirect(const TCHAR *szMsg, HANDLE hContact, char *szProto) bufSize += (int)bufSizeT;
}
- if (hContact == NULL) {
- mir_free(sendBuffer);
+ if (sendBuffer == NULL)
return NULL;
- }
- if (sendBuffer) {
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | (flags & PREF_UTF ? DBEF_UTF : 0) | (flags & PREF_RTL ? DBEF_RTL : 0);
- dbei.szModule = szProto;
- dbei.timestamp = (DWORD)time(NULL);
- dbei.cbBlob = (DWORD)bufSize;
- dbei.pBlob = (PBYTE)sendBuffer;
- HANDLE hNewEvent = db_event_add(hContact, &dbei);
-
- HANDLE hSendId = (HANDLE) CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM) sendBuffer);
- msgQueue_add(hContact, hSendId, szMsg, hNewEvent);
- mir_free(sendBuffer);
- return hNewEvent;
- }
- return NULL;
-}
+ int sendId = CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)sendBuffer);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | (flags & PREF_UTF ? DBEF_UTF : 0) | (flags & PREF_RTL ? DBEF_RTL : 0);
+ dbei.szModule = szProto;
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.cbBlob = (DWORD)bufSize;
+ dbei.pBlob = (PBYTE)sendBuffer;
+ HANDLE hNewEvent = db_event_add(hContact, &dbei);
+ MessageWindowEvent evt = { sizeof(evt), sendId, hContact, hNewEvent };
+ NotifyEventHooks(hHookWinWrite, 0, (LPARAM)&evt);
+
+ msgQueue_add(hContact, sendId, szMsg, hNewEvent);
+ mir_free(sendBuffer);
+ return hNewEvent;
+}
static void AddToFileList(TCHAR ***pppFiles,int *totalCount,const TCHAR* szFilename)
{
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 26047b065c..969e049017 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -29,7 +29,7 @@ const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0 #endif
HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand;
-HANDLE hHookWinEvt, hHookWinPopup;
+HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
HGENMENU hMsgMenuItem;
static int SRMMStatusToPf2(int status)
@@ -155,7 +155,6 @@ static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam) static INT_PTR ReadMessageCommand(WPARAM wParam, LPARAM lParam)
{
CLISTEVENT *cle = (CLISTEVENT *) lParam;
-
if (cle)
SendMessageCmd(cle->hContact, NULL, 0);
@@ -178,8 +177,7 @@ static int TypingMessage(WPARAM wParam, LPARAM lParam) mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR));
if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags&SMF_SHOWTYPINGCLIST)) {
- MIRANDASYSTRAYNOTIFY tn = {0};
- tn.cbSize = sizeof(tn);
+ MIRANDASYSTRAYNOTIFY tn = { sizeof(tn) };
tn.tszInfoTitle = TranslateT("Typing Notification");
tn.tszInfo = szTip;
tn.dwInfoFlags = NIIF_INFO;
@@ -188,11 +186,9 @@ static int TypingMessage(WPARAM wParam, LPARAM lParam) CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & tn);
}
else {
- CLISTEVENT cle = {0};
-
- cle.cbSize = sizeof(cle);
- cle.hContact = (HANDLE) wParam;
- cle.hDbEvent = (HANDLE) 1;
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.hContact = (HANDLE)wParam;
+ cle.hDbEvent = (HANDLE)1;
cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
cle.hIcon = LoadSkinnedIcon( SKINICON_OTHER_TYPING );
cle.pszService = "SRMsg/ReadMessage";
@@ -318,20 +314,6 @@ int PreshutdownSendRecv(WPARAM wParam, LPARAM lParam) return 0;
}
-int SplitmsgShutdown(void)
-{
- DestroyCursor(hCurSplitNS);
- DestroyCursor(hCurHyperlinkHand);
- DestroyCursor(hCurSplitWE);
-
- FreeMsgLogIcons();
- FreeLibrary(GetModuleHandleA("riched20"));
- OleUninitialize();
- RichUtil_Unload();
- msgQueue_destroy();
- return 0;
-}
-
static int IconsChanged(WPARAM wParam, LPARAM lParam)
{
FreeMsgLogIcons();
@@ -427,6 +409,7 @@ int LoadSendRecvMessageModule(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)"));
@@ -444,6 +427,24 @@ int LoadSendRecvMessageModule(void) return 0;
}
+int SplitmsgShutdown(void)
+{
+ DestroyCursor(hCurSplitNS);
+ DestroyCursor(hCurHyperlinkHand);
+ DestroyCursor(hCurSplitWE);
+
+ DestroyHookableEvent(hHookWinEvt);
+ DestroyHookableEvent(hHookWinPopup);
+ DestroyHookableEvent(hHookWinWrite);
+
+ FreeMsgLogIcons();
+ FreeLibrary(GetModuleHandleA("riched20"));
+ OleUninitialize();
+ RichUtil_Unload();
+ msgQueue_destroy();
+ return 0;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////////
CREOleCallback reOleCallback;
|