summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TabSRMM/src/chat/chat.h2
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp58
-rw-r--r--src/modules/chat/tools.cpp130
4 files changed, 124 insertions, 68 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 211a11e60c..5515358a5f 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -168,6 +168,8 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SES
void DestroyGCMenu(HMENU *hMenu, int iIndex);
void Chat_SetFilters(SESSION_INFO *si);
void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p);
+BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce);
+int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
// message.c
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 1e4ab502c9..5989cbf31b 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -275,6 +275,8 @@ int Chat_Load()
pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
pci->IsHighlighted = IsHighlighted;
pci->LogToFile = LogToFile;
+ pci->DoPopup = DoPopup;
+ pci->ShowPopup = ShowPopup;
pci->Log_CreateRtfHeader = Log_CreateRtfHeader;
pci->ReloadSettings();
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index e0d2cc7488..c31372cc54 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -104,12 +104,62 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
return TRUE;
}
-static BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce, TWindowData *dat)
+int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
+{
+ POPUPDATAT pd = { 0 };
+ va_list marker;
+ static TCHAR szBuf[4 * 1024];
+
+ if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
+ return 0;
+
+ va_start(marker, fmt);
+ mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
+ va_end(marker);
+
+ pd.lchContact = hContact;
+
+ if (hIcon)
+ pd.lchIcon = hIcon;
+ else
+ pd.lchIcon = LoadIconEx(IDI_CHANMGR, "window", 0, 0);
+
+ PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
+ mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
+ (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
+ pcli->pfnGetContactDisplayName(hContact, 0));
+
+ lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
+ pd.iSeconds = g_Settings.iPopupTimeout;
+
+ if (g_Settings.iPopupStyle == 2) {
+ pd.colorBack = 0;
+ pd.colorText = 0;
+ }
+ else if (g_Settings.iPopupStyle == 3) {
+ pd.colorBack = g_Settings.crPUBkgColour;
+ pd.colorText = g_Settings.crPUTextColour;
+ }
+ else {
+ pd.colorBack = M.GetDword(FONTMODULE, SRMSGSET_BKGCOLOUR_MUC, SRMSGDEFSET_BKGCOLOUR);
+ pd.colorText = crBkg;
+ }
+
+ pd.PluginWindowProc = PopupDlgProc;
+ pd.PluginData = si;
+ return PUAddPopupT(&pd);
+}
+
+BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce)
{
int iEvent = gce->pDest->iType;
if (si == NULL || !(iEvent & si->iLogPopupFlags))
return true;
+ TWindowData *dat = si->dat;
+ if (dat == NULL)
+ return true;
+
TContainerData *pContainer = dat ? dat->pContainer : NULL;
TCHAR *bbStart, *bbEnd;
@@ -169,7 +219,7 @@ passed:
}
if (iNewEvent == GC_EVENT_MESSAGE) {
- pci->ShowPopup(si->hContact, si, pci->hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : pci->aFonts[9].color,
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : pci->aFonts[9].color,
TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, pci->RemoveFormatting(gce->ptszText));
}
else pci->DoPopup(si, gce);
@@ -304,7 +354,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
}
#endif
if (dat || !nen_options.iMUCDisable)
- DoPopup(si, gce, dat);
+ DoPopup(si, gce);
if (params->bInactive && si && si->hWnd)
SendMessage(si->hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
if (g_Settings.bFlashWindowHightlight && params->bInactive)
@@ -323,7 +373,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
if (bManyFix == 0) {
// do popups
if (dat || !nen_options.iMUCDisable)
- DoPopup(si, gce, dat);
+ DoPopup(si, gce);
// do sounds and flashing
switch (params->iEvent) {
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index 384992b8f7..5b91b0e2e1 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -116,52 +116,6 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
return DefWindowProc(hWnd, message, wParam, lParam);
}
-int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
-{
- static TCHAR szBuf[4 * 1024];
-
- if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
- return 0;
-
- va_list marker;
- va_start(marker, fmt);
- mir_vsntprintf(szBuf, 4096, fmt, marker);
- va_end(marker);
-
- POPUPDATAT pd = { 0 };
- pd.lchContact = hContact;
-
- if (hIcon)
- pd.lchIcon = hIcon;
- else
- pd.lchIcon = LoadIconEx("window", FALSE);
-
- PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
- (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
- cli.pfnGetContactDisplayName(hContact, 0));
-
- lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
- pd.iSeconds = g_Settings->iPopupTimeout;
-
- if (g_Settings->iPopupStyle == 2) {
- pd.colorBack = 0;
- pd.colorText = 0;
- }
- else if (g_Settings->iPopupStyle == 3) {
- pd.colorBack = g_Settings->crPUBkgColour;
- pd.colorText = g_Settings->crPUTextColour;
- }
- else {
- pd.colorBack = g_Settings->crLogBackground;
- pd.colorText = crBkg;
- }
-
- pd.PluginWindowProc = PopupDlgProc;
- pd.PluginData = si;
- return PUAddPopupT(&pd);
-}
-
BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
switch (gce->pDest->iType) {
@@ -210,62 +164,110 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
return TRUE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
+{
+ static TCHAR szBuf[4 * 1024];
+
+ if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
+ return 0;
+
+ va_list marker;
+ va_start(marker, fmt);
+ mir_vsntprintf(szBuf, 4096, fmt, marker);
+ va_end(marker);
+
+ POPUPDATAT pd = { 0 };
+ pd.lchContact = hContact;
+
+ if (hIcon)
+ pd.lchIcon = hIcon;
+ else
+ pd.lchIcon = LoadIconEx("window", FALSE);
+
+ PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
+ mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
+ (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
+ cli.pfnGetContactDisplayName(hContact, 0));
+
+ lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
+ pd.iSeconds = g_Settings->iPopupTimeout;
+
+ if (g_Settings->iPopupStyle == 2) {
+ pd.colorBack = 0;
+ pd.colorText = 0;
+ }
+ else if (g_Settings->iPopupStyle == 3) {
+ pd.colorBack = g_Settings->crPUBkgColour;
+ pd.colorText = g_Settings->crPUTextColour;
+ }
+ else {
+ pd.colorBack = g_Settings->crLogBackground;
+ pd.colorText = crBkg;
+ }
+
+ pd.PluginWindowProc = PopupDlgProc;
+ pd.PluginData = si;
+ return PUAddPopupT(&pd);
+}
+
BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
{
switch (gce->pDest->iType) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, ci.aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, ci.aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, ci.aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, ci.aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_MESSAGE:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, ci.aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, ci.aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_ACTION], si->pszModule, si->ptszName, ci.aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_ACTION], si->pszModule, si->ptszName, ci.aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_JOIN:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_JOIN], si->pszModule, si->ptszName, ci.aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_JOIN], si->pszModule, si->ptszName, ci.aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
break;
case GC_EVENT_PART:
if (!gce->ptszText)
- ShowPopup(si->hContact, si, ci.hIcons[ICON_PART], si->pszModule, si->ptszName, ci.aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_PART], si->pszModule, si->ptszName, ci.aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
else
- ShowPopup(si->hContact, si, ci.hIcons[ICON_PART], si->pszModule, si->ptszName, ci.aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_PART], si->pszModule, si->ptszName, ci.aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_QUIT:
if (!gce->ptszText)
- ShowPopup(si->hContact, si, ci.hIcons[ICON_QUIT], si->pszModule, si->ptszName, ci.aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_QUIT], si->pszModule, si->ptszName, ci.aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
else
- ShowPopup(si->hContact, si, ci.hIcons[ICON_QUIT], si->pszModule, si->ptszName, ci.aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_QUIT], si->pszModule, si->ptszName, ci.aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NICK:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_NICK], si->pszModule, si->ptszName, ci.aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_NICK], si->pszModule, si->ptszName, ci.aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
if (!gce->ptszText)
- ShowPopup(si->hContact, si, ci.hIcons[ICON_KICK], si->pszModule, si->ptszName, ci.aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_KICK], si->pszModule, si->ptszName, ci.aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
else
- ShowPopup(si->hContact, si, ci.hIcons[ICON_KICK], si->pszModule, si->ptszName, ci.aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_KICK], si->pszModule, si->ptszName, ci.aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_NOTICE], si->pszModule, si->ptszName, ci.aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_NOTICE], si->pszModule, si->ptszName, ci.aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_TOPIC:
if (!gce->ptszNick)
- ShowPopup(si->hContact, si, ci.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, ci.aFonts[11].color, TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, ci.aFonts[11].color, TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
else
- ShowPopup(si->hContact, si, ci.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, ci.aFonts[11].color, TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, ci.aFonts[11].color, TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
break;
case GC_EVENT_INFORMATION:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_INFO], si->pszModule, si->ptszName, ci.aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_INFO], si->pszModule, si->ptszName, ci.aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ADDSTATUS:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, ci.aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, ci.aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
- ShowPopup(si->hContact, si, ci.hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, ci.aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ ci.ShowPopup(si->hContact, si, ci.hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, ci.aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
}