summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat_int.h6
-rw-r--r--plugins/Scriver/src/chat/chat.h1
-rw-r--r--plugins/Scriver/src/chat/main.cpp22
-rw-r--r--plugins/Scriver/src/chat/window.cpp14
-rw-r--r--plugins/TabSRMM/src/chat/chat.h11
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp6
-rw-r--r--plugins/TabSRMM/src/chat/options.cpp6
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp185
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp20
-rw-r--r--plugins/TabSRMM/src/utils.h2
-rw-r--r--src/core/stdchat/src/chat.h11
-rw-r--r--src/core/stdchat/src/main.cpp22
-rw-r--r--src/core/stdchat/src/manager.cpp47
-rw-r--r--src/core/stdchat/src/tools.cpp20
-rw-r--r--src/core/stdchat/src/window.cpp16
-rw-r--r--src/modules/chat/chat.h2
-rw-r--r--src/modules/chat/chat_opts.cpp19
-rw-r--r--src/modules/chat/chat_svc.cpp2
-rw-r--r--src/modules/chat/manager.cpp53
-rw-r--r--src/modules/chat/tools.cpp440
20 files changed, 411 insertions, 494 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 7ebeb02068..899c9f41b5 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -221,7 +221,7 @@ struct GCSessionInfoBase
HWND hwndTooltip;
int iOldItemID;
- interface IAccPropServices* pAccPropServicesForNickList;
+ TCHAR pszLogFileName[MAX_PATH];
SESSION_INFO *next;
};
@@ -314,8 +314,6 @@ struct CHAT_MANAGER
BOOL (*SM_SetStatusEx)(const TCHAR *pszID, const char *pszModule, const TCHAR* pszText, int flags);
BOOL (*SM_SendUserMessage)(const TCHAR *pszID, const char *pszModule, const TCHAR* pszText);
STATUSINFO* (*SM_AddStatus)(const TCHAR *pszID, const char *pszModule, const TCHAR *pszStatus);
- SESSION_INFO* (*SM_GetNextWindow)(SESSION_INFO *si);
- SESSION_INFO* (*SM_GetPrevWindow)(SESSION_INFO *si);
BOOL (*SM_AddEventToAllMatchingUID)(GCEVENT *gce);
BOOL (*SM_AddEvent)(const TCHAR *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted);
LRESULT (*SM_SendMessage)(const TCHAR *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -378,9 +376,11 @@ struct CHAT_MANAGER
BOOL (*DoEventHookAsync)(HWND hwnd, const TCHAR *pszID, const char *pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, INT_PTR dwItem);
BOOL (*DoSoundsFlashPopupTrayStuff)(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+ BOOL (*DoTrayIcon)(SESSION_INFO *si, GCEVENT *gce);
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);
+ TCHAR* (*GetChatLogsFilename)(SESSION_INFO *si, time_t tTime);
BOOL (*IsHighlighted)(SESSION_INFO *si, GCEVENT *pszText);
TCHAR* (*RemoveFormatting)(const TCHAR *pszText);
diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h
index 00598c44e1..44623a8f68 100644
--- a/plugins/Scriver/src/chat/chat.h
+++ b/plugins/Scriver/src/chat/chat.h
@@ -112,7 +112,6 @@ int GetColorIndex(const char* pszModule, COLORREF cr);
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ;
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
// message.c
TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si);
diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp
index b8d2dbc0b4..6e991c12d9 100644
--- a/plugins/Scriver/src/chat/main.cpp
+++ b/plugins/Scriver/src/chat/main.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../commonheaders.h"
// globals
-CHAT_MANAGER *pci;
+CHAT_MANAGER *pci, saveCI;
HMENU g_hMenu = NULL;
GlobalLogSettings g_Settings;
@@ -116,6 +116,20 @@ static void OnCreateModule(MODULEINFO *mi)
mi->hOfflineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_OFFLINE);
}
+static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (gce->pDest->iType & g_Settings.dwTrayIconFlags)
+ return saveCI.DoTrayIcon(si, gce);
+ return TRUE;
+}
+
+static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (gce->pDest->iType & g_Settings.dwPopupFlags)
+ return saveCI.DoPopup(si, gce);
+ return TRUE;
+}
+
static void RegisterFonts()
{
ColourIDT colourid = { sizeof(colourid) };
@@ -148,6 +162,8 @@ int Chat_Load()
{
CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Messaging")_T("/")LPGENT("Group chats") };
mir_getCI(&data);
+ saveCI = *pci;
+
pci->OnCreateModule = OnCreateModule;
pci->OnNewUser = OnNewUser;
@@ -164,6 +180,9 @@ int Chat_Load()
pci->OnSetStatusBar = OnSetStatusBar;
pci->OnFlashWindow = OnFlashWindow;
pci->ShowRoom = ShowRoom;
+
+ pci->DoPopup = DoPopup;
+ pci->DoTrayIcon = DoTrayIcon;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
@@ -176,6 +195,7 @@ int Chat_Unload(void)
db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
DestroyMenu(g_hMenu);
+ *pci = saveCI;
return 0;
}
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 12047a4ab6..cbcd8c270a 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -741,7 +741,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
default:
PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0);
- DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
break;
}
DestroyGCMenu(&hMenu, 5);
@@ -916,11 +916,11 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case ID_MESS:
- DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
break;
default:
- DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
break;
}
DestroyGCMenu(&hMenu, 1);
@@ -948,7 +948,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
int index = SendMessage(hwnd, LB_GETCURSEL, 0, 0);
if (index != LB_ERR) {
USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
- DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
break;
}
@@ -1724,7 +1724,7 @@ LABEL_SHOWWINDOW:
SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM)pszName);
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
}
- else DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ else pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
return TRUE;
@@ -1756,7 +1756,7 @@ LABEL_SHOWWINDOW:
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
mir_free(pszRtf);
mir_free(ptszText);
SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
@@ -1815,7 +1815,7 @@ LABEL_SHOWWINDOW:
case IDC_CHAT_CHANMGR:
if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHAT_CHANMGR)))
break;
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
break;
case IDC_CHAT_FILTER:
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 605e9fefc0..e5d82d1272 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -61,17 +61,14 @@ struct MODULEINFO : public GCModuleInfoBase
DWORD idleTimeStamp;
DWORD lastIdleCheck;
TCHAR tszIdleMsg[60];
- MODULEINFO * next;
};
struct SESSION_INFO : public GCSessionInfoBase
{
TWindowData *dat;
TContainerData *pContainer;
- int iLogTrayFlags, iLogPopupFlags, iSearchItem;
-
+ int iLogTrayFlags, iLogPopupFlags, iDiskLogFlags, iSearchItem;
TCHAR szSearch[255];
- TCHAR pszLogFileName[MAX_PATH + 50];
};
struct LOGSTREAMDATA : public GCLogStreamDataBase
@@ -113,6 +110,7 @@ struct FLASH_PARAMS
};
extern TMUCSettings g_Settings;
+extern CHAT_MANAGER saveCI;
struct COLORCHOOSER
{
@@ -133,7 +131,6 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L
// log.c
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
char* Log_CreateRtfHeader(MODULEINFO *mi);
-TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
void Log_SetStyles();
// window.c
@@ -142,7 +139,6 @@ int GetTextPixelSize(TCHAR* pszText, HFONT hFont, bool bWidth);
// options.c
enum { FONTSECTION_AUTO, FONTSECTION_IM, FONTSECTION_IP };
-int OptionsInit(void);
void LoadMsgDlgFont(int section, int i, LOGFONT * lf, COLORREF * colour, char* szMod);
void AddIcons(void);
HICON LoadIconEx(int iIndex, char * pszIcoLibName, int iX, int iY);
@@ -171,9 +167,10 @@ int GetRichTextLength(HWND hwnd);
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
void Chat_SetFilters(SESSION_INFO *si);
void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+
// message.c
char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si);
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index c367f9cef0..1e4ab502c9 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -49,6 +49,7 @@ static void OnAddLog(SESSION_INFO *si, int isOk)
static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi)
{
+ Chat_SetFilters(si);
if (mi) {
mi->idleTimeStamp = time(0);
pci->SM_BroadcastMessage(mi->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
@@ -207,7 +208,7 @@ void Chat_ModulesLoaded()
/////////////////////////////////////////////////////////////////////////////////////////
// load the group chat module
-static CHAT_MANAGER saveCI;
+CHAT_MANAGER saveCI;
static int CopyChatSetting(const char *szSetting, LPARAM param)
{
@@ -273,12 +274,13 @@ int Chat_Load()
// this operation is unsafe, that's why we restore the old pci state on exit
pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
pci->IsHighlighted = IsHighlighted;
+ pci->LogToFile = LogToFile;
pci->Log_CreateRtfHeader = Log_CreateRtfHeader;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
- OptionsInit();
+ g_Settings.Highlight = new CMUCHighlight();
return 0;
}
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp
index 0aa3a65092..5b9a0dda05 100644
--- a/plugins/TabSRMM/src/chat/options.cpp
+++ b/plugins/TabSRMM/src/chat/options.cpp
@@ -1109,9 +1109,3 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
}
return FALSE;
}
-
-int OptionsInit(void)
-{
- g_Settings.Highlight = new CMUCHighlight();
- return 0;
-}
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 334447193a..e0d2cc7488 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -96,67 +96,11 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
return DefWindowProc(hWnd, message, wParam, lParam);
}
-static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
+BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
int iEvent = gce->pDest->iType;
-
- if (si && (iEvent & si->iLogTrayFlags)) {
- switch (iEvent) {
- case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT :
- case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT :
- pci->AddEvent(si->hContact, PluginConfig.g_IconMsgEvent, szChatIconString, 0,
- TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_MESSAGE :
- pci->AddEvent(si->hContact, pci->hIcons[ICON_MESSAGE], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_ACTION:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_ACTION], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_JOIN:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_JOIN], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_PART:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_PART], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_QUIT:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_QUIT], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s has disconnected"), gce->ptszNick);
- break;
- case GC_EVENT_NICK:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_NICK], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
- break;
- case GC_EVENT_KICK:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_KICK], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_NOTICE:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("Notice from %s"), gce->ptszNick);
- break;
- case GC_EVENT_TOPIC:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_TOPIC], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("Topic change in %s"), si->ptszName);
- break;
- case GC_EVENT_INFORMATION:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_INFO], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("Information in %s"), si->ptszName);
- break;
- case GC_EVENT_ADDSTATUS:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_ADDSTATUS], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_REMOVESTATUS:
- pci->AddEvent(si->hContact, pci->hIcons[ICON_REMSTATUS], szChatIconString, CLEF_ONLYAFEW,
- TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- }
- }
+ if (si && (iEvent & si->iLogTrayFlags))
+ return saveCI.DoTrayIcon(si, gce);
return TRUE;
}
@@ -515,6 +459,25 @@ TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2)
return NULL;
}
+/*
+* log the event to the log file
+* allows selective logging of wanted events
+*/
+
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (!si || !gce)
+ return FALSE;
+
+ /*
+ * check whether we have to log this event
+ */
+ if (!(gce->pDest->iType & si->iDiskLogFlags))
+ return FALSE;
+
+ return saveCI.LogToFile(si, gce); // call kernel method
+}
+
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
HMENU hSubMenu = 0;
@@ -615,25 +578,6 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex)
}
}
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem)
-{
- SESSION_INFO *si = pci->SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
- GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
- gcd->pszModule = mir_strdup(pszModule);
- gcd->ptszID = mir_tstrdup(pszID);
- gch->ptszUID = mir_tstrdup(pszUID);
- gch->ptszText = mir_tstrdup(pszText);
- gcd->iType = iType;
- gch->dwData = dwItem;
- gch->pDest = gcd;
- PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch);
- return TRUE;
-}
-
/*
* set all filters and notification config for a session
* uses per channel mask + filterbits, default config as backup
@@ -666,6 +610,8 @@ void Chat_SetFilters(SESSION_INFO *si)
dwFlags_local = db_get_dw(si->hContact, "Chat", "TrayIconFlags", 0x03E0);
dwMask = db_get_dw(si->hContact, "Chat", "TrayIconMask", 0);
+ si->iDiskLogFlags = M.GetDword("Chat", "DiskLogFlags", 0xFFFF);
+
si->iLogTrayFlags = dwFlags_default;
for (int i=0; i < 32; i++)
if (dwMask & (1 << i))
@@ -675,89 +621,6 @@ void Chat_SetFilters(SESSION_INFO *si)
si->bFilterEnabled = 0;
}
-static TCHAR tszOldTimeStamp[30];
-
-TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
-{
- if (!tTime)
- time(&tTime);
-
- /*
- * check whether relevant parts of the timestamp have changed and
- * we have to reparse the filename
- */
-
- TCHAR *tszNow = pci->MakeTimeStamp(_T("%a%d%m%Y"), tTime);
-
- bool fReparse = false;
- if (_tcscmp(tszOldTimeStamp, tszNow)) {
- _tcsncpy(tszOldTimeStamp, tszNow, 30);
- tszOldTimeStamp[29] = 0;
- fReparse = true;
- }
-
- if (fReparse || 0 == si->pszLogFileName[0]) {
- REPLACEVARSARRAY rva[11];
- rva[0].lptzKey = _T("d");
- rva[0].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%#d"), tTime));
- // day 01-31
- rva[1].lptzKey = _T("dd");
- rva[1].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%d"), tTime));
- // month 1-12
- rva[2].lptzKey = _T("m");
- rva[2].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%#m"), tTime));
- // month 01-12
- rva[3].lptzKey = _T("mm");
- rva[3].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%m"), tTime));
- // month text short
- rva[4].lptzKey = _T("mon");
- rva[4].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%b"), tTime));
- // month text
- rva[5].lptzKey = _T("month");
- rva[5].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%B"), tTime));
- // year 01-99
- rva[6].lptzKey = _T("yy");
- rva[6].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%y"), tTime));
- // year 1901-9999
- rva[7].lptzKey = _T("yyyy");
- rva[7].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%Y"), tTime));
- // weekday short
- rva[8].lptzKey = _T("wday");
- rva[8].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%a"), tTime));
- // weekday
- rva[9].lptzKey = _T("weekday");
- rva[9].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%A"), tTime));
- // end of array
- rva[10].lptzKey = NULL;
- rva[10].lptzValue = NULL;
-
- if (g_Settings.pszLogDir[lstrlen(g_Settings.pszLogDir)-1] == '\\')
- _tcscat(g_Settings.pszLogDir, _T("%userid%.log"));
-
- REPLACEVARSDATA dat = { sizeof(dat) };
- dat.dwFlags = RVF_TCHAR;
- dat.hContact = si->hContact;
- dat.variables = rva;
- TCHAR *tszParsedName = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)g_Settings.pszLogDir, (LPARAM)&dat);
-
- if (!M.pathIsAbsolute(tszParsedName))
- mir_sntprintf(si->pszLogFileName, MAX_PATH, _T("%s%s"), M.getChatLogPath(), tszParsedName);
- else
- mir_sntprintf(si->pszLogFileName, MAX_PATH, _T("%s"), tszParsedName);
-
- mir_free(tszParsedName);
-
- for (int i=0; i < SIZEOF(rva);i++)
- mir_free(rva[i].lptzValue);
-
- for (TCHAR *p = si->pszLogFileName + 2; *p; ++p)
- if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|' )
- *p = _T('_');
- }
-
- return si->pszLogFileName;
-}
-
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
if (!g_Settings.HighlightEnabled || !g_Settings.pszHighlightWords || !gce)
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index ea559adc64..4ef037a93c 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -1665,7 +1665,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case ID_MESS:
- DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
break;
default:
@@ -1679,7 +1679,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
for (int i=0; i < iSelectedItems; i++) {
USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, pItems[i]);
if (ui1)
- DoEventHookAsync(hwndParent, parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui1->pszUID, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(hwndParent, parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui1->pszUID, NULL, (LPARAM)uID);
}
}
mir_free(pItems);
@@ -2605,7 +2605,7 @@ LABEL_SHOWWINDOW:
return(_dlgReturn(hwndDlg, 1));
case TABSRMM_HK_MUC_SHOWSERVER:
if (si->iType != GCW_SERVER)
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, L"/servershow", 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, L"/servershow", 0);
return(_dlgReturn(hwndDlg, 1));
}
}
@@ -2705,7 +2705,7 @@ LABEL_SHOWWINDOW:
default:
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
break;
}
@@ -2812,11 +2812,11 @@ LABEL_SHOWWINDOW:
break;
case ID_MESS:
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
break;
default:
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
break;
}
DestroyGCMenu(&hMenu, 1);
@@ -2939,7 +2939,7 @@ LABEL_SHOWWINDOW:
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
}
- else DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ else pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
return TRUE;
}
@@ -2979,7 +2979,7 @@ LABEL_SHOWWINDOW:
bool fSound = true;
if (ptszText[0] == '/' || si->iType == GCW_SERVER)
fSound = false;
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
mi->idleTimeStamp = time(0);
mi->lastIdleCheck = 0;
pci->SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
@@ -3050,7 +3050,7 @@ LABEL_SHOWWINDOW:
CallService("MSP/HTMLlog/ViewLog", (WPARAM)si->pszModule, (LPARAM)szName);
}
else if (pInfo)
- ShellExecute(hwndDlg, NULL, GetChatLogsFilename(si, 0), NULL, NULL, SW_SHOW);
+ ShellExecute(hwndDlg, NULL, pci->GetChatLogsFilename(si, 0), NULL, NULL, SW_SHOW);
}
break;
@@ -3061,7 +3061,7 @@ LABEL_SHOWWINDOW:
case IDC_CHANMGR:
if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHANMGR)))
break;
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
break;
case IDC_FILTER:
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h
index 88c82acd3d..107aca9e16 100644
--- a/plugins/TabSRMM/src/utils.h
+++ b/plugins/TabSRMM/src/utils.h
@@ -34,7 +34,7 @@
#define RTF_DEFAULT_HEADER _T("{\\rtf1\\ansi\\deff0\\pard\\li%u\\fi-%u\\ri%u\\tx%u")
-#define CNT_KEYNAME "CNTW_Def"
+#define CNT_KEYNAME "CNTW_Def"
#define CNT_BASEKEYNAME "CNTW_"
struct TRTFColorTable
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h
index 4b1ce18173..3c3fb68d4e 100644
--- a/src/core/stdchat/src/chat.h
+++ b/src/core/stdchat/src/chat.h
@@ -86,7 +86,11 @@ struct MODULEINFO : public GCModuleInfoBase
int OfflineIconIndex;
};
-struct SESSION_INFO : public GCSessionInfoBase {};
+struct SESSION_INFO : public GCSessionInfoBase
+{
+ IAccPropServices* pAccPropServicesForNickList;
+};
+
struct LOGSTREAMDATA : public GCLogStreamDataBase {};
struct GlobalLogSettings : public GlobalLogSettingsBase
@@ -99,6 +103,7 @@ struct GlobalLogSettings : public GlobalLogSettingsBase
extern GlobalLogSettings g_Settings;
extern SESSION_INFO g_TabSession;
+extern CHAT_MANAGER saveCI;
extern TABLIST *g_TabList;
extern HMENU g_hMenu;
extern HIMAGELIST hIconsList;
@@ -157,6 +162,9 @@ char* Log_CreateRtfHeader(MODULEINFO * mi);
INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth);
+SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si);
+SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);
+
// options.c
int OptionsInitialize(WPARAM wParam, LPARAM lParam);
void AddIcons(void);
@@ -171,7 +179,6 @@ void CheckColorsInModule(const char* pszModule);
int GetRichTextLength(HWND hwnd);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
// message.c
char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp
index 3fbbc0c281..6c87170a48 100644
--- a/src/core/stdchat/src/main.cpp
+++ b/src/core/stdchat/src/main.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// globals
CLIST_INTERFACE *pcli;
-CHAT_MANAGER *pci;
+CHAT_MANAGER *pci, saveCI;
SESSION_INFO g_TabSession;
HMENU g_hMenu = NULL;
@@ -237,6 +237,20 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive)
SendMessage(g_TabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
}
+static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (gce->pDest->iType & g_Settings.dwTrayIconFlags)
+ return saveCI.DoTrayIcon(si, gce);
+ return TRUE;
+}
+
+static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (gce->pDest->iType & g_Settings.dwPopupFlags)
+ return saveCI.DoPopup(si, gce);
+ return TRUE;
+}
+
static void OnLoadSettings()
{
g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
@@ -299,6 +313,8 @@ extern "C" __declspec(dllexport) int Load(void)
CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Chat module") };
mir_getCI(&data);
+ saveCI = *pci;
+
pci->OnAddUser = OnAddUser;
pci->OnNewUser = OnNewUser;
pci->OnRemoveUser = OnRemoveUser;
@@ -321,6 +337,9 @@ extern "C" __declspec(dllexport) int Load(void)
pci->OnSetStatusBar = OnSetStatusBar;
pci->OnFlashWindow = OnFlashWindow;
pci->ShowRoom = ShowRoom;
+
+ pci->DoPopup = DoPopup;
+ pci->DoTrayIcon = DoTrayIcon;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
@@ -341,6 +360,7 @@ extern "C" __declspec(dllexport) int Unload(void)
db_set_dw(NULL, "Chat", "roomheight", g_Settings.iHeight);
DestroyMenu(g_hMenu);
+ *pci = saveCI;
return 0;
}
diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp
index 925efde9f8..995011dc42 100644
--- a/src/core/stdchat/src/manager.cpp
+++ b/src/core/stdchat/src/manager.cpp
@@ -24,6 +24,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TABLIST *g_TabList = 0;
+SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
+{
+ if (!si)
+ return NULL;
+
+ BOOL bFound = FALSE;
+ SESSION_INFO *pTemp = pci->wndList;
+ while (pTemp != NULL) {
+ if (si == pTemp) {
+ if (bFound)
+ return NULL;
+ else
+ bFound = TRUE;
+ }
+ else if (bFound == TRUE && pTemp->hWnd)
+ return pTemp;
+ pTemp = pTemp->next;
+ if (pTemp == NULL && bFound)
+ pTemp = pci->wndList;
+ }
+ return NULL;
+}
+
+SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
+{
+ if (!si)
+ return NULL;
+
+ SESSION_INFO *pTemp = pci->wndList, *pLast = NULL;
+ while (pTemp != NULL) {
+ if (si == pTemp) {
+ if (pLast) {
+ if (pLast != pTemp)
+ return pLast;
+ else
+ return NULL;
+ }
+ }
+ if (pTemp->hWnd)
+ pLast = pTemp;
+ pTemp = pTemp->next;
+ if (pTemp == NULL)
+ pTemp = pci->wndList;
+ }
+ return NULL;
+}
+
//---------------------------------------------------
// Tab list manager functions
//
diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp
index 072bf6f359..3b29352143 100644
--- a/src/core/stdchat/src/tools.cpp
+++ b/src/core/stdchat/src/tools.cpp
@@ -162,26 +162,6 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex)
}
}
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem)
-{
- SESSION_INFO *si = pci->SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
- gcd->pszModule = mir_strdup(pszModule);
- gcd->ptszID = mir_tstrdup(pszID);
- gcd->iType = iType;
-
- GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
- gch->ptszUID = mir_tstrdup(pszUID);
- gch->ptszText = mir_tstrdup(pszText);
- gch->dwData = dwItem;
- gch->pDest = gcd;
- PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch);
- return TRUE;
-}
-
void ValidateFilename(TCHAR *filename)
{
TCHAR *p1 = filename;
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp
index 4c622eee41..3e54bcf393 100644
--- a/src/core/stdchat/src/window.cpp
+++ b/src/core/stdchat/src/window.cpp
@@ -341,7 +341,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (g_Settings.TabsEnable)
SendMessage(GetParent(hwnd), GC_SWITCHNEXTTAB, 0, 0);
else
- pci->ShowRoom(pci->SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
return TRUE;
}
@@ -349,7 +349,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (g_Settings.TabsEnable)
SendMessage(GetParent(hwnd), GC_SWITCHPREVTAB, 0, 0);
else
- pci->ShowRoom(pci->SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
return TRUE;
}
@@ -1046,11 +1046,11 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case ID_MESS:
- DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
break;
default:
- DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
break;
}
DestroyGCMenu(&hMenu, 1);
@@ -2209,7 +2209,7 @@ LABEL_SHOWWINDOW:
default:
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
break;
}
DestroyGCMenu(&hMenu, 5);
@@ -2322,7 +2322,7 @@ LABEL_SHOWWINDOW:
SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM)pszName);
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
}
- else DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ else pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
return TRUE;
@@ -2353,7 +2353,7 @@ LABEL_SHOWWINDOW:
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
mir_free(pszRtf);
mir_free(ptszText);
SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
@@ -2430,7 +2430,7 @@ LABEL_SHOWWINDOW:
case IDC_CHANMGR:
if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHANMGR)))
break;
- DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
break;
case IDC_FILTER:
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h
index 458926df89..6121d302f2 100644
--- a/src/modules/chat/chat.h
+++ b/src/modules/chat/chat.h
@@ -45,6 +45,7 @@ void LoadMsgLogBitmaps(void);
void FreeMsgLogBitmaps(void);
void ValidateFilename (TCHAR *filename);
TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time);
+TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
char* Log_CreateRtfHeader(MODULEINFO *mi);
char* Log_CreateRTF(LOGSTREAMDATA *streamData);
@@ -91,6 +92,7 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char *pszModule, in
BOOL DoEventHook(const TCHAR *pszID, const char *pszModule, int iType, const TCHAR *pszUID, const TCHAR* pszText, INT_PTR dwItem);
BOOL IsEventSupported(int eventType);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
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, ...);
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp
index 45f179e99b..1565f7efa6 100644
--- a/src/modules/chat/chat_opts.cpp
+++ b/src/modules/chat/chat_opts.cpp
@@ -255,21 +255,7 @@ void LoadGlobalSettings(void)
InitSetting(&g_Settings->pszOutgoingNick, "HeaderOutgoing", _T("%n:"));
InitSetting(&g_Settings->pszHighlightWords, "HighlightWords", _T("%m"));
- TCHAR pszTemp[MAX_PATH];
- DBVARIANT dbv;
- g_Settings->pszLogDir = (TCHAR *)mir_realloc(g_Settings->pszLogDir, MAX_PATH*sizeof(TCHAR));
- if (!db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
- lstrcpyn(pszTemp, dbv.ptszVal, MAX_PATH);
- db_free(&dbv);
- }
- else {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat"));
- lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp) - 1);
- mir_free(tmpPath);
- }
-
- PathToAbsoluteT(pszTemp, g_Settings->pszLogDir);
-
+ InitSetting(&g_Settings->pszLogDir, "LogDirectory", _T("%miranda_logpath%\\Chat"));
g_Settings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
LOGFONT lf;
@@ -288,9 +274,6 @@ void LoadGlobalSettings(void)
LoadMsgDlgFont(19, &lf, NULL);
g_Settings->UserListHeadingsFont = CreateFontIndirect(&lf);
- if (g_Settings->LoggingEnabled)
- CreateDirectoryTreeT(g_Settings->pszLogDir);
-
SetIndentSize();
}
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index 7aefea1e20..c8735ca7c8 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -516,7 +516,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
ci.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->LoggingEnabled)
- LogToFile(si, gce);
+ ci.LogToFile(si, gce);
}
if (!bRemoveFlag)
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index d418b56a24..9edf986e23 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -251,7 +251,7 @@ static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce)
bManyFix++;
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->LoggingEnabled)
- LogToFile(pTemp, gce);
+ ci.LogToFile(pTemp, gce);
}
}
}
@@ -565,53 +565,6 @@ static BOOL SM_SendUserMessage(const TCHAR *pszID, const char *pszModule, const
return TRUE;
}
-static SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
-{
- if (!si)
- return NULL;
-
- BOOL bFound = FALSE;
- SESSION_INFO *pTemp = ci.wndList;
- while (pTemp != NULL) {
- if (si == pTemp) {
- if (bFound)
- return NULL;
- else
- bFound = TRUE;
- }
- else if (bFound == TRUE && pTemp->hWnd)
- return pTemp;
- pTemp = pTemp->next;
- if (pTemp == NULL && bFound)
- pTemp = ci.wndList;
- }
- return NULL;
-}
-
-SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
-{
- if (!si)
- return NULL;
-
- SESSION_INFO *pTemp = ci.wndList, *pLast = NULL;
- while (pTemp != NULL) {
- if (si == pTemp) {
- if (pLast) {
- if (pLast != pTemp)
- return pLast;
- else
- return NULL;
- }
- }
- if (pTemp->hWnd)
- pLast = pTemp;
- pTemp = pTemp->next;
- if (pTemp == NULL)
- pTemp = ci.wndList;
- }
- return NULL;
-}
-
static BOOL SM_ChangeUID(const TCHAR *pszID, const char *pszModule, const TCHAR *pszUID, const TCHAR* pszNewUID)
{
if (!pszModule)
@@ -1397,8 +1350,6 @@ CHAT_MANAGER ci =
SM_SetStatusEx,
SM_SendUserMessage,
SM_AddStatus,
- SM_GetNextWindow,
- SM_GetPrevWindow,
SM_AddEventToAllMatchingUID,
SM_AddEvent,
SM_SendMessage,
@@ -1461,9 +1412,11 @@ CHAT_MANAGER ci =
DoEventHookAsync,
DoSoundsFlashPopupTrayStuff,
+ DoTrayIcon,
DoPopup,
ShowPopup,
LogToFile,
+ GetChatLogsFilename,
IsHighlighted,
RemoveFormatting,
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index ba036031ca..c54341e8f3 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -162,53 +162,49 @@ int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName
return PUAddPopupT(&pd);
}
-static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
+BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
- int iEvent = gce->pDest->iType;
-
- if (iEvent&g_Settings->dwTrayIconFlags) {
- switch (iEvent) {
- case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- ci.AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_MESSAGE:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_ACTION:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_JOIN:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_PART:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_QUIT:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
- break;
- case GC_EVENT_NICK:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
- break;
- case GC_EVENT_KICK:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_NOTICE:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
- break;
- case GC_EVENT_TOPIC:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
- break;
- case GC_EVENT_INFORMATION:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
- break;
- case GC_EVENT_ADDSTATUS:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_REMOVESTATUS:
- ci.AddEvent(si->hContact, ci.hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- }
+ switch (gce->pDest->iType) {
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
+ ci.AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_MESSAGE:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_ACTION:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_JOIN:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_PART:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_QUIT:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
+ break;
+ case GC_EVENT_NICK:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ break;
+ case GC_EVENT_KICK:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_NOTICE:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
+ break;
+ case GC_EVENT_TOPIC:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
+ break;
+ case GC_EVENT_INFORMATION:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
+ break;
+ case GC_EVENT_ADDSTATUS:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ break;
+ case GC_EVENT_REMOVESTATUS:
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ break;
}
return TRUE;
@@ -216,65 +212,61 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
{
- int iEvent = gce->pDest->iType;
-
- if (iEvent & g_Settings->dwPopupFlags) {
- switch (iEvent) {
- 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));
- 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));
- 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));
- 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));
- 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);
- 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);
- 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));
- 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);
- 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));
- 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);
- 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);
- 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));
- 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));
- 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));
- 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);
- 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));
- 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);
- 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);
- break;
- }
+ 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));
+ 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));
+ 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));
+ 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));
+ 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);
+ 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);
+ 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));
+ 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);
+ 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));
+ 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);
+ 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);
+ 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));
+ 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));
+ 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));
+ 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);
+ 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));
+ 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);
+ 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);
+ break;
}
return TRUE;
@@ -296,9 +288,9 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0)
db_unset(si->hContact, "CList", "Hidden");
if (bInactive)
- DoTrayIcon(si, gce);
+ ci.DoTrayIcon(si, gce);
if (bInactive || !g_Settings->PopupInactiveOnly)
- DoPopup(si, gce);
+ ci.DoPopup(si, gce);
if (ci.OnFlashWindow)
ci.OnFlashWindow(si, bInactive);
return TRUE;
@@ -306,13 +298,13 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
// do blinking icons in tray
if (bInactive || !g_Settings->TrayIconInactiveOnly)
- DoTrayIcon(si, gce);
+ ci.DoTrayIcon(si, gce);
// stupid thing to not create multiple popups for a QUIT event for instance
if (bManyFix == 0) {
// do popups
if (bInactive || !g_Settings->PopupInactiveOnly)
- DoPopup(si, gce);
+ ci.DoPopup(si, gce);
// do sounds and flashing
switch (iEvent) {
@@ -507,42 +499,31 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
{
TCHAR szBuffer[4096];
TCHAR szLine[4096];
- TCHAR szTime[100];
- TCHAR szFile[MAX_PATH];
- TCHAR szName[MAX_PATH];
- TCHAR szFolder[MAX_PATH];
- char p = '\0';
+ TCHAR p = '\0';
szBuffer[0] = '\0';
- if (!si || !gce)
- return FALSE;
+ GetChatLogsFilename(si, gce->time);
+ BOOL bFileJustCreated = !PathFileExists(si->pszLogFileName);
- MODULEINFO *mi = ci.MM_FindModule(si->pszModule);
- if (!mi)
- return FALSE;
+ TCHAR tszFolder[MAX_PATH];
+ _tcscpy(tszFolder, si->pszLogFileName);
+ PathRemoveFileSpec(tszFolder);
+ if (!PathIsDirectory(tszFolder))
+ CreateDirectoryTreeT(tszFolder);
- TCHAR *szModName = mir_a2t(si->pszModule);
- mir_sntprintf(szName, MAX_PATH, _T("%s"), mi->ptszModDispName ? mi->ptszModDispName : (szModName = mir_a2t(si->pszModule)));
- mir_free(szModName);
- ValidateFilename(szName);
- mir_sntprintf(szFolder, MAX_PATH, _T("%s\\%s"), g_Settings->pszLogDir, szName );
-
- CreateDirectoryTreeT(szFolder);
-
- mir_sntprintf( szName, MAX_PATH, _T("%s.log"), si->ptszID );
- ValidateFilename(szName);
-
- mir_sntprintf(szFile, MAX_PATH, _T("%s\\%s"), szFolder, szName );
- lstrcpyn(szTime, MakeTimeStamp(g_Settings->pszTimeStampLog, gce->time), 99);
+ TCHAR szTime[100];
+ lstrcpyn(szTime, ci.MakeTimeStamp(g_Settings->pszTimeStampLog, gce->time), 99);
- FILE *hFile = _tfopen(szFile, _T("at+"));
+ FILE *hFile = _tfopen(si->pszLogFileName, _T("ab+"));
if (hFile) {
TCHAR szTemp[512], szTemp2[512];
TCHAR* pszNick = NULL;
- if ( gce->ptszNick ) {
- if ( g_Settings->LogLimitNames && lstrlen(gce->ptszNick) > 20 ) {
+ if (bFileJustCreated)
+ fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE
+ if (gce->ptszNick) {
+ if (g_Settings->LogLimitNames && lstrlen(gce->ptszNick) > 20) {
lstrcpyn(szTemp2, gce->ptszNick, 20);
- lstrcpyn(szTemp2+20, _T("..."), 4);
+ lstrcpyn(szTemp2 + 20, _T("..."), 4);
}
else lstrcpyn(szTemp2, gce->ptszNick, 511);
@@ -552,35 +533,36 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2);
pszNick = szTemp;
}
+
switch (gce->pDest->iType) {
case GC_EVENT_MESSAGE:
- case GC_EVENT_MESSAGE|GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
p = '*';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s * %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: %s"), gce->ptszNick, ci.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
- case GC_EVENT_ACTION|GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
p = '*';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, ci.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_JOIN:
p = '>';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), pszNick);
break;
case GC_EVENT_PART:
p = '<';
if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), pszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText));
- break;
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), pszNick, ci.RemoveFormatting(gce->ptszText));
+ break;
case GC_EVENT_QUIT:
p = '<';
if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), pszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick,RemoveFormatting(gce->ptszText));
- break;
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), pszNick, ci.RemoveFormatting(gce->ptszText));
+ break;
case GC_EVENT_NICK:
p = '^';
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
@@ -588,90 +570,87 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
case GC_EVENT_KICK:
p = '~';
if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, ci.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
- p = '¤';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ p = 'o';
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, ci.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_TOPIC:
p = '#';
if (!gce->ptszNick)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\'"), ci.RemoveFormatting(gce->ptszText));
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), ci.RemoveFormatting(gce->ptszText), gce->ptszNick);
break;
case GC_EVENT_INFORMATION:
p = '!';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), ci.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ADDSTATUS:
p = '+';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
p = '-';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
break;
}
+
+ /*
+ * formatting strings don't need to be translatable - changing them via language pack would
+ * only screw up the log format.
+ */
if (p)
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %c %s\n"), szTime, p, szBuffer);
+ mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %c %s\r\n"), szTime, p, szBuffer);
else
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %s\n"), szTime, szBuffer);
+ mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %s\r\n"), szTime, szBuffer);
if (szLine[0]) {
- char *p = mir_t2a(szLine);
- fputs(p, hFile);
- mir_free(p);
+ _fputts(szLine, hFile);
if (g_Settings->LoggingLimit > 0) {
- DWORD dwSize;
- DWORD trimlimit;
-
fseek(hFile, 0, SEEK_END);
- dwSize = ftell(hFile);
+ long dwSize = ftell(hFile);
rewind(hFile);
- trimlimit = g_Settings->LoggingLimit * 1024 + 1024 * 10;
+
+ long trimlimit = g_Settings->LoggingLimit * 1024;
if (dwSize > trimlimit) {
- BYTE * pBuffer = 0;
- BYTE * pBufferTemp = 0;
- int read = 0;
-
- pBuffer = (BYTE *)mir_alloc(g_Settings->LoggingLimit * 1024 + 1);
- pBuffer[g_Settings->LoggingLimit * 1024] = '\0';
- fseek(hFile, -g_Settings->LoggingLimit * 1024, SEEK_END);
- read = (int)fread(pBuffer, 1, g_Settings->LoggingLimit * 1024, hFile);
+ time_t now = time(0);
+
+ TCHAR tszTimestamp[20];
+ _tcsftime(tszTimestamp, 20, _T("%Y%m%d-%H%M%S"), _localtime32((__time32_t *)&now));
+ tszTimestamp[19] = 0;
+ /*
+ * max size reached, rotate the log
+ * move old logs to /archived sub folder just inside the log root folder.
+ * add a time stamp to the file name.
+ */
+ TCHAR tszDrive[_MAX_DRIVE], tszDir[_MAX_DIR], tszName[_MAX_FNAME], tszExt[_MAX_EXT];
+ _tsplitpath(si->pszLogFileName, tszDrive, tszDir, tszName, tszExt);
+
+ TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
+ mir_sntprintf(tszNewPath, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%sarchived\\"), tszDrive, tszDir);
+ CreateDirectoryTreeT(tszNewPath);
+
+ TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
+ mir_sntprintf(tszNewName, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
fclose(hFile);
- hFile = NULL;
-
- // trim to whole lines, should help with broken log files I hope.
- pBufferTemp = (BYTE *)strchr((char *)pBuffer, '\n');
- if (pBufferTemp) {
- pBufferTemp++;
- read -= pBufferTemp - pBuffer;
- }
- else pBufferTemp = pBuffer;
-
- if (read > 0) {
- hFile = _tfopen(szFile, _T("wt"));
- if (hFile) {
- fwrite(pBufferTemp, 1, read, hFile);
- fclose(hFile); hFile = NULL;
- }
- }
-
- mir_free(pBuffer);
+ hFile = 0;
+ if (!PathFileExists(tszNewName))
+ CopyFile(si->pszLogFileName, tszNewName, TRUE);
+ DeleteFile(si->pszLogFileName);
}
}
}
if (hFile)
- fclose(hFile); hFile = NULL;
+ fclose(hFile);
+ hFile = NULL;
return TRUE;
}
-
return FALSE;
}
@@ -755,3 +734,74 @@ void ValidateFilename(TCHAR *filename)
p1 += 1;
}
}
+
+static TCHAR tszOldTimeStamp[30];
+
+TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
+{
+ if (!tTime)
+ time(&tTime);
+
+ /*
+ * check whether relevant parts of the timestamp have changed and
+ * we have to reparse the filename
+ */
+ TCHAR *tszNow = ci.MakeTimeStamp(_T("%a%d%m%Y"), tTime); // once a day
+ if (_tcscmp(tszOldTimeStamp, tszNow)) {
+ _tcsncpy_s(tszOldTimeStamp, 30, tszNow, _TRUNCATE);
+ *si->pszLogFileName = 0;
+ }
+
+ if (si->pszLogFileName[0] == 0) {
+ REPLACEVARSARRAY rva[11];
+ rva[0].lptzKey = _T("d");
+ rva[0].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%#d"), tTime));
+ // day 01-31
+ rva[1].lptzKey = _T("dd");
+ rva[1].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%d"), tTime));
+ // month 1-12
+ rva[2].lptzKey = _T("m");
+ rva[2].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%#m"), tTime));
+ // month 01-12
+ rva[3].lptzKey = _T("mm");
+ rva[3].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%m"), tTime));
+ // month text short
+ rva[4].lptzKey = _T("mon");
+ rva[4].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%b"), tTime));
+ // month text
+ rva[5].lptzKey = _T("month");
+ rva[5].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%B"), tTime));
+ // year 01-99
+ rva[6].lptzKey = _T("yy");
+ rva[6].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%y"), tTime));
+ // year 1901-9999
+ rva[7].lptzKey = _T("yyyy");
+ rva[7].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%Y"), tTime));
+ // weekday short
+ rva[8].lptzKey = _T("wday");
+ rva[8].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%a"), tTime));
+ // weekday
+ rva[9].lptzKey = _T("weekday");
+ rva[9].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%A"), tTime));
+ // end of array
+ rva[10].lptzKey = NULL;
+ rva[10].lptzValue = NULL;
+
+ REPLACEVARSDATA dat = { sizeof(dat) };
+ dat.dwFlags = RVF_TCHAR;
+ dat.hContact = si->hContact;
+ dat.variables = rva;
+ TCHAR *tszParsedName = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)g_Settings->pszLogDir, (LPARAM)&dat);
+ PathToAbsoluteT(tszParsedName, si->pszLogFileName);
+ mir_free(tszParsedName);
+
+ for (int i = 0; i < SIZEOF(rva); i++)
+ mir_free(rva[i].lptzValue);
+
+ for (TCHAR *p = si->pszLogFileName + 2; *p; ++p)
+ if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|')
+ *p = _T('_');
+ }
+
+ return si->pszLogFileName;
+}