summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-20 15:52:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-20 15:52:48 +0000
commitf725c70b482df377119e2c09b36c9317f86ef494 (patch)
tree584e839d2b786835acb9dd460aab0758dd736cf9
parent66e9197603643cc587909fb1bce7402383dbad69 (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
-rw-r--r--include/delphi/m_message.inc31
-rw-r--r--include/m_message.h16
-rw-r--r--plugins/Scriver/src/commonheaders.h2
-rw-r--r--plugins/Scriver/src/globals.cpp95
-rw-r--r--plugins/Scriver/src/msgs.cpp8
-rw-r--r--plugins/TabSRMM/src/globals.cpp85
-rw-r--r--plugins/TabSRMM/src/globals.h2
-rw-r--r--plugins/TabSRMM/src/msgs.cpp1
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp26
-rw-r--r--plugins/TabSRMM/src/srmm.cpp1
-rw-r--r--src/core/stdmsg/src/cmdlist.cpp4
-rw-r--r--src/core/stdmsg/src/cmdlist.h6
-rw-r--r--src/core/stdmsg/src/globals.cpp2
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp43
-rw-r--r--src/core/stdmsg/src/msgs.cpp47
15 files changed, 206 insertions, 163 deletions
diff --git a/include/delphi/m_message.inc b/include/delphi/m_message.inc
index a89204f1b0..662171f9ae 100644
--- a/include/delphi/m_message.inc
+++ b/include/delphi/m_message.inc
@@ -1,20 +1,20 @@
-{
- Miranda IM: the free IM client for Microsoft Windows
-
- Copyright 2000-2003 Miranda ICQ/IM project,
- all portions of this codebase are copyrighted to the people
+{
+ Miranda IM: the free IM client for Microsoft Windows
+
+ Copyright 2000-2003 Miranda ICQ/IM project,
+ all portions of this codebase are copyrighted to the people
listed in contributors.txt.
-
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -120,6 +120,12 @@ const
}
MS_MSG_GETWINDOWDATA:PAnsiChar = 'MessageAPI/GetWindowData';
+{ wparam=0(unused)
+ lparam=(pMessageWindowEvent) event written
+ fired when SRMM writes an entered message into the database
+}
+ ME_MSG_WRITEEVENT:PAnsiChar = 'MessageAPI/OnWriteEvent';
+
{ wParam = 0
lParam = (MessageWindowPopupData *)&MessageWindowPopupData;
Fired to allow plugins to add itens to the msg window popup menu
@@ -146,6 +152,15 @@ type
selection:int; // The menu control id or 0 if no one was selected
end;
+type
+ pMessageWindowEvent = ^MessageWindowEvent;
+ MessageWindowEvent = record
+ cbSize :int;
+ seq :int; // number returned by PSS_MESSAGE
+ hContact :THANDLE;
+ hDbEvent :THANDLE; // database event written on the basis of message sent
+ end;
+
// status icons
const
MBF_DISABLED = 1;
diff --git a/include/m_message.h b/include/m_message.h
index 9c9bca2549..6d842ebc20 100644
--- a/include/m_message.h
+++ b/include/m_message.h
@@ -107,6 +107,21 @@ typedef struct {
//returns 0 on success and returns non-zero (1) on error or if no window data exists for that hcontact
#define MS_MSG_GETWINDOWDATA "MessageAPI/GetWindowData"
+//wparam = 0 (unused)
+//lparam = (MessageWindowEvent*)
+//fired when SRMM writes an entered message into the database
+#define ME_MSG_WRITEEVENT "MessageAPI/OnWriteEvent"
+
+typedef struct {
+ int cbSize;
+ int seq; // number returned by PSS_MESSAGE
+ HANDLE hContact;
+ HANDLE hDbEvent; // database event written on the basis of message sent
+} MessageWindowEvent;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// SRMM popup menu
+
// wParam = 0
// lParam = (MessageWindowPopupData *)&MessageWindowPopupData;
// Fired to allow plugins to add items to the msg window popup menu
@@ -131,6 +146,7 @@ typedef struct {
int selection; // The menu control id or 0 if no one was selected
} MessageWindowPopupData;
+/////////////////////////////////////////////////////////////////////////////////////////
// status icons
#define MBF_DISABLED 0x01
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)"));
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 76f44eefe7..eb1d7216c1 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -178,9 +178,9 @@ void CGlobals::reloadSystemModulesChanged()
}
else M->WriteByte(SRMSGMOD_T, "ieview_installed", 0);
- g_iButtonsBarGap = M->GetByte("ButtonsBarGap", 1);
- m_hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
- m_MathModAvail = (ServiceExists(MATH_RTF_REPLACE_FORMULAE) ? 1 : 0);
+ g_iButtonsBarGap = M->GetByte("ButtonsBarGap", 1);
+ m_hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
+ m_MathModAvail = (ServiceExists(MATH_RTF_REPLACE_FORMULAE) ? 1 : 0);
if (m_MathModAvail) {
char *szDelim = (char *)CallService(MATH_GET_STARTDELIMITER, 0, 0);
if (szDelim) {
@@ -223,69 +223,69 @@ void CGlobals::reloadSettings(bool fReloadSkins)
m_ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m_ncm, 0);
- DWORD dwFlags = M->GetDword("mwflags", MWF_LOG_DEFAULT);
-
- m_SendOnShiftEnter = (int)M->GetByte("sendonshiftenter", 0);
- m_SendOnEnter = (int)M->GetByte(SRMSGSET_SENDONENTER, SRMSGDEFSET_SENDONENTER);
- m_SendOnDblEnter = (int)M->GetByte("SendOnDblEnter", 0);
- m_AutoLocaleSupport = (int)M->GetByte("al", 0);
- m_AutoSwitchTabs = (int)M->GetByte("autoswitchtabs", 1);
- m_CutContactNameTo = (int)db_get_w(NULL, SRMSGMOD_T, "cut_at", 15);
- m_CutContactNameOnTabs = (int)M->GetByte("cuttitle", 0);
- m_StatusOnTabs = (int)M->GetByte("tabstatus", 1);
- m_LogStatusChanges = (int)M->GetByte("logstatuschanges", 0);
- m_UseDividers = (int)M->GetByte("usedividers", 0);
- m_DividersUsePopupConfig = (int)M->GetByte("div_popupconfig", 0);
- m_MsgTimeout = (int)M->GetDword(SRMSGMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT);
+ DWORD dwFlags = M->GetDword("mwflags", MWF_LOG_DEFAULT);
+
+ m_SendOnShiftEnter = M->GetByte("sendonshiftenter", 0);
+ m_SendOnEnter = M->GetByte(SRMSGSET_SENDONENTER, SRMSGDEFSET_SENDONENTER);
+ m_SendOnDblEnter = M->GetByte("SendOnDblEnter", 0);
+ m_AutoLocaleSupport = M->GetByte("al", 0);
+ m_AutoSwitchTabs = M->GetByte("autoswitchtabs", 1);
+ m_CutContactNameTo = db_get_w(NULL, SRMSGMOD_T, "cut_at", 15);
+ m_CutContactNameOnTabs = M->GetByte("cuttitle", 0);
+ m_StatusOnTabs = M->GetByte("tabstatus", 1);
+ m_LogStatusChanges = M->GetByte("logstatuschanges", 0);
+ m_UseDividers = M->GetByte("usedividers", 0);
+ m_DividersUsePopupConfig = M->GetByte("div_popupconfig", 0);
+ m_MsgTimeout = M->GetDword(SRMSGMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT);
if (m_MsgTimeout < SRMSGSET_MSGTIMEOUT_MIN)
m_MsgTimeout = SRMSGSET_MSGTIMEOUT_MIN;
- m_EscapeCloses = (int)M->GetByte("escmode", 0);
+ m_EscapeCloses = M->GetByte("escmode", 0);
- m_HideOnClose = (int) M->GetByte("hideonclose", 0);
- m_AllowTab = (int) M->GetByte("tabmode", 0);
+ m_HideOnClose = M->GetByte("hideonclose", 0);
+ m_AllowTab = M->GetByte("tabmode", 0);
- m_FlashOnClist = (int)M->GetByte("flashcl", 0);
- m_AlwaysFullToolbarWidth = (int)M->GetByte("alwaysfulltoolbar", 1);
- m_LimitStaticAvatarHeight = (int)M->GetDword("avatarheight", 96);
- m_SendFormat = (int)M->GetByte("sendformat", 0);
+ m_FlashOnClist = M->GetByte("flashcl", 0);
+ m_AlwaysFullToolbarWidth = M->GetByte("alwaysfulltoolbar", 1);
+ m_LimitStaticAvatarHeight = M->GetDword("avatarheight", 96);
+ m_SendFormat = M->GetByte("sendformat", 0);
m_FormatWholeWordsOnly = 1;
- m_RTLDefault = (int)M->GetByte("rtldefault", 0);
- m_TabAppearance = (int)M->GetDword("tabconfig", TCF_FLASHICON | TCF_SINGLEROWTABCONTROL);
- m_panelHeight = (DWORD)M->GetDword("panelheight", CInfoPanel::DEGRADE_THRESHOLD);
- m_MUCpanelHeight = M->GetDword("Chat", "panelheight", CInfoPanel::DEGRADE_THRESHOLD);
- m_IdleDetect = (int)M->GetByte("dimIconsForIdleContacts", 1);
+ m_RTLDefault = M->GetByte("rtldefault", 0);
+ m_TabAppearance = M->GetDword("tabconfig", TCF_FLASHICON | TCF_SINGLEROWTABCONTROL);
+ m_panelHeight = (DWORD)M->GetDword("panelheight", CInfoPanel::DEGRADE_THRESHOLD);
+ m_MUCpanelHeight = M->GetDword("Chat", "panelheight", CInfoPanel::DEGRADE_THRESHOLD);
+ m_IdleDetect = M->GetByte("dimIconsForIdleContacts", 1);
m_smcxicon = 16;
m_smcyicon = 16;
- m_PasteAndSend = (int)M->GetByte("pasteandsend", 1);
- m_szNoStatus = TranslateT("No status message");
- m_LangPackCP = ServiceExists(MS_LANGPACK_GETCODEPAGE) ? CallService(MS_LANGPACK_GETCODEPAGE, 0, 0) : CP_ACP;
- m_visualMessageSizeIndicator = M->GetByte("msgsizebar", 0);
- m_autoSplit = M->GetByte("autosplit", 0);
- m_FlashOnMTN = M->GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINFLASH, SRMSGDEFSET_SHOWTYPINGWINFLASH);
+ m_PasteAndSend = M->GetByte("pasteandsend", 1);
+ m_szNoStatus = TranslateT("No status message");
+ m_LangPackCP = ServiceExists(MS_LANGPACK_GETCODEPAGE) ? CallService(MS_LANGPACK_GETCODEPAGE, 0, 0) : CP_ACP;
+ m_visualMessageSizeIndicator = M->GetByte("msgsizebar", 0);
+ m_autoSplit = M->GetByte("autosplit", 0);
+ m_FlashOnMTN = M->GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINFLASH, SRMSGDEFSET_SHOWTYPINGWINFLASH);
if (m_MenuBar == 0) {
m_MenuBar = ::LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENUBAR));
TranslateMenu(m_MenuBar);
}
- m_ipBackgroundGradient = M->GetDword(FONTMODULE, "ipfieldsbg", 0x62caff);
+ m_ipBackgroundGradient = M->GetDword(FONTMODULE, "ipfieldsbg", 0x62caff);
if (0 == m_ipBackgroundGradient)
m_ipBackgroundGradient = 0x62caff;
- m_ipBackgroundGradientHigh = M->GetDword(FONTMODULE, "ipfieldsbgHigh", 0xf0f0f0);
+ m_ipBackgroundGradientHigh = M->GetDword(FONTMODULE, "ipfieldsbgHigh", 0xf0f0f0);
if (0 == m_ipBackgroundGradientHigh)
m_ipBackgroundGradientHigh = 0xf0f0f0;
- m_tbBackgroundHigh = M->GetDword(FONTMODULE, "tbBgHigh", 0);
- m_tbBackgroundLow = M->GetDword(FONTMODULE, "tbBgLow", 0);
- m_fillColor = M->GetDword(FONTMODULE, "fillColor", 0);
+ m_tbBackgroundHigh = M->GetDword(FONTMODULE, "tbBgHigh", 0);
+ m_tbBackgroundLow = M->GetDword(FONTMODULE, "tbBgLow", 0);
+ m_fillColor = M->GetDword(FONTMODULE, "fillColor", 0);
if (CSkin::m_BrushFill) {
::DeleteObject(CSkin::m_BrushFill);
CSkin::m_BrushFill = 0;
}
- m_genericTxtColor = M->GetDword(FONTMODULE, "genericTxtClr", GetSysColor(COLOR_BTNTEXT));
- m_cRichBorders = M->GetDword(FONTMODULE, "cRichBorders", 0);
+ m_genericTxtColor = M->GetDword(FONTMODULE, "genericTxtClr", GetSysColor(COLOR_BTNTEXT));
+ m_cRichBorders = M->GetDword(FONTMODULE, "cRichBorders", 0);
::CopyMemory(&globalContainerSettings, &_cnt_default, sizeof(TContainerSettings));
Utils::ReadContainerSettingsFromDB(0, &globalContainerSettings);
@@ -594,6 +594,7 @@ int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam)
DestroyHookableEvent(PluginConfig.m_event_MsgWin);
DestroyHookableEvent(PluginConfig.m_event_MsgPopup);
+ DestroyHookableEvent(PluginConfig.m_event_WriteEvent);
::NEN_WriteOptions(&nen_options);
::DestroyWindow(PluginConfig.g_hwndHotkeyHandler);
diff --git a/plugins/TabSRMM/src/globals.h b/plugins/TabSRMM/src/globals.h
index 6fb727ac6e..6bc4987886 100644
--- a/plugins/TabSRMM/src/globals.h
+++ b/plugins/TabSRMM/src/globals.h
@@ -190,7 +190,7 @@ public:
COLORREF m_tbBackgroundHigh, m_tbBackgroundLow, m_fillColor, m_cRichBorders, m_genericTxtColor;
BYTE m_dontUseDefaultKbd;
HANDLE hSvc[SERVICE_LAST];
- HANDLE m_event_MsgWin, m_event_MsgPopup;
+ HANDLE m_event_MsgWin, m_event_MsgPopup, m_event_WriteEvent;
HGENMENU m_hMenuItem;
BYTE m_useAeroPeek;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 63daf44ece..fd7300789d 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -540,6 +540,7 @@ static void TSAPI InitAPI()
PluginConfig.m_event_MsgWin = CreateHookableEvent(ME_MSG_WINDOWEVENT);
PluginConfig.m_event_MsgPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
+ PluginConfig.m_event_WriteEvent = CreateHookableEvent(ME_MSG_WRITEEVENT);
}
int LoadSendRecvMessageModule(void)
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index 2713cd1470..62b31a6a57 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -604,14 +604,13 @@ void SendQueue::recallFailed(const TWindowData *dat, int iEntry) const
void SendQueue::UpdateSaveAndSendButton(TWindowData *dat)
{
if (dat) {
- int len;
HWND hwndDlg = dat->hwnd;
- GETTEXTLENGTHEX gtxl = {0};
+ GETTEXTLENGTHEX gtxl = {0};
gtxl.codepage = CP_UTF8;
gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMBYTES;
- len = SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)& gtxl, 0);
+ int len = SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)& gtxl, 0);
if (len && GetSendButtonState(hwndDlg) == PBS_DISABLED)
EnableSendButton(dat, TRUE);
else if (len == 0 && GetSendButtonState(hwndDlg) != PBS_DISABLED)
@@ -665,21 +664,19 @@ void SendQueue::NotifyDeliveryFailure(const TWindowData *dat)
int SendQueue::RTL_Detect(const WCHAR *pszwText)
{
- WORD *infoTypeC2;
- int i, n = 0;
- int iLen = lstrlenW(pszwText);
-
- infoTypeC2 = (WORD *)mir_alloc(sizeof(WORD) * (iLen + 2));
+ int i, n = 0;
+ int iLen = lstrlenW(pszwText);
+ WORD *infoTypeC2 = (WORD *)mir_alloc(sizeof(WORD) * (iLen + 2));
if (infoTypeC2) {
ZeroMemory(infoTypeC2, sizeof(WORD) * (iLen + 2));
GetStringTypeW(CT_CTYPE2, pszwText, iLen, infoTypeC2);
- for (i=0; i < iLen; i++) {
+ for (i=0; i < iLen; i++)
if (infoTypeC2[i] == C2_RIGHTTOLEFT)
n++;
- }
+
mir_free(infoTypeC2);
return(n >= 2 ? 1 : 0);
}
@@ -766,17 +763,18 @@ inform_and_discard:
dbei.pBlob = (PBYTE) m_jobs[iFound].sendBuffer;
hNewEvent = db_event_add(m_jobs[iFound].hOwner, &dbei);
- if (m_pContainer) {
+ MessageWindowEvent evt = { sizeof(evt), (int)m_jobs[iFound].hSendId, m_jobs[iFound].hOwner, hNewEvent };
+ NotifyEventHooks(PluginConfig.m_event_WriteEvent, 0, (LPARAM)&evt);
+
+ if (m_pContainer)
if (!nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND))
SkinPlaySound("SendMsg");
- }
- if (dat && (m_jobs[iFound].hOwner == dat->hContact)) {
+ if (dat && (m_jobs[iFound].hOwner == dat->hContact))
if (dat->hDbEventFirst == NULL) {
dat->hDbEventFirst = hNewEvent;
SendMessage(dat->hwnd, DM_REMAKELOG, 0, 0);
}
- }
m_jobs[iFound].hSendId = NULL;
m_jobs[iFound].iAcksNeeded--;
diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp
index 87135cc49e..3012fe6334 100644
--- a/plugins/TabSRMM/src/srmm.cpp
+++ b/plugins/TabSRMM/src/srmm.cpp
@@ -76,7 +76,6 @@ extern "C" int __declspec(dllexport) Load(void)
return 1;
}
-
mir_getTMI(&tmi);
mir_getLP(&pluginInfo);
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;