summaryrefslogtreecommitdiff
path: root/src/modules/chat
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/chat')
-rw-r--r--src/modules/chat/chat.h80
-rw-r--r--src/modules/chat/chat_opts.cpp49
-rw-r--r--src/modules/chat/chat_svc.cpp254
-rw-r--r--src/modules/chat/clist.cpp99
-rw-r--r--src/modules/chat/log.cpp26
-rw-r--r--src/modules/chat/manager.cpp136
-rw-r--r--src/modules/chat/tools.cpp46
7 files changed, 222 insertions, 468 deletions
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h
index 5fe53a1a25..5b3b799d94 100644
--- a/src/modules/chat/chat.h
+++ b/src/modules/chat/chat.h
@@ -36,26 +36,27 @@ extern HGENMENU hJoinMenuItem, hLeaveMenuItem;
extern HANDLE hChatSendEvent;
extern BOOL PopupInstalled;
-//log.c
+// log.c
void LoadMsgLogBitmaps(void);
void FreeMsgLogBitmaps(void);
-void ValidateFilename (TCHAR * filename);
-TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time);
-char* Log_CreateRtfHeader(MODULEINFO * mi);
-
-//clist.c
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType);
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide);
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule);
-int CList_RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam);
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... ) ;
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
-int WCCmp(TCHAR* wild, TCHAR*string);
+void ValidateFilename (TCHAR *filename);
+TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time);
+char* Log_CreateRtfHeader(MODULEINFO *mi);
+char* Log_CreateRTF(LOGSTREAMDATA *streamData);
+
+// clist.c
+BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ...);
+HANDLE AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType);
+HANDLE FindRoom(const char* pszModule, const TCHAR* pszRoom);
+BOOL SetAllOffline(BOOL bHide, const char *pszModule);
+BOOL SetOffline(HANDLE hContact, BOOL bHide);
+
+int RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR JoinChat(WPARAM wParam, LPARAM lParam);
+INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam);
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
+INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
// options.c
int OptionsInit(void);
@@ -66,28 +67,25 @@ HICON LoadIconEx(char* pszIcoLibName, BOOL big);
void LoadLogFonts(void);
// services.c
-void HookEvents(void);
-void UnhookEvents(void);
-void CreateServiceFunctions(void);
-void CreateHookableEvents(void);
-void DestroyHookableEvents(void);
-void TabsInit(void);
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
-
-//tools.c
-int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth);
-TCHAR* RemoveFormatting(const TCHAR* pszText);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int GetColorIndex(const char* pszModule, COLORREF cr);
-void CheckColorsInModule(const char* pszModule);
-const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ;
-int GetRichTextLength(HWND hwnd);
-BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* 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);
-BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
-BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+void InitChatModule(void);
+void LoadChatModule(void);
+void UnloadChatModule(void);
+
+// tools.c
+int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth);
+TCHAR *RemoveFormatting(const TCHAR* pszText);
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+int GetColorIndex(const char* pszModule, COLORREF cr);
+void CheckColorsInModule(const char* pszModule);
+int GetRichTextLength(HWND hwnd);
+BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* 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);
+BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
+BOOL IsEventSupported(int eventType);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+
+const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2);
#pragma comment(lib,"comctl32.lib")
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp
index a2658f3a8f..59ca171575 100644
--- a/src/modules/chat/chat_opts.cpp
+++ b/src/modules/chat/chat_opts.cpp
@@ -205,14 +205,8 @@ static void InitSetting(TCHAR** ppPointer, char* pszSetting, TCHAR* pszDefault)
void LoadGlobalSettings(void)
{
- LOGFONT lf;
-
ci.pSettings->LogLimitNames = db_get_b(NULL, "Chat", "LogLimitNames", 1);
ci.pSettings->ShowTime = db_get_b(NULL, "Chat", "ShowTimeStamp", 1);
- ci.pSettings->TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
- ci.pSettings->TabsAtBottom = db_get_b(NULL, "Chat", "TabBottom", 0);
- ci.pSettings->TabCloseOnDblClick = db_get_b(NULL, "Chat", "TabCloseOnDblClick", 0);
- ci.pSettings->TabRestore = db_get_b(NULL, "Chat", "TabRestore", 0);
ci.pSettings->SoundsFocus = db_get_b(NULL, "Chat", "SoundsFocus", 0);
ci.pSettings->ShowTimeIfChanged = (BOOL)db_get_b(NULL, "Chat", "ShowTimeStampIfChanged", 0);
ci.pSettings->TimeStampEventColour = (BOOL)db_get_b(NULL, "Chat", "TimeStampEventColour", 0);
@@ -246,25 +240,24 @@ void LoadGlobalSettings(void)
InitSetting(&ci.pSettings->pszOutgoingNick, "HeaderOutgoing", _T("%n:"));
InitSetting(&ci.pSettings->pszHighlightWords, "HighlightWords", _T("%m"));
- {
- TCHAR pszTemp[MAX_PATH];
- DBVARIANT dbv;
- ci.pSettings->pszLogDir = (TCHAR *)mir_realloc(ci.pSettings->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, ci.pSettings->pszLogDir);
+ TCHAR pszTemp[MAX_PATH];
+ DBVARIANT dbv;
+ ci.pSettings->pszLogDir = (TCHAR *)mir_realloc(ci.pSettings->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, ci.pSettings->pszLogDir);
ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
+ LOGFONT lf;
if (ci.pSettings->MessageBoxFont)
DeleteObject(ci.pSettings->MessageBoxFont);
LoadMsgDlgFont(17, &lf, NULL);
@@ -299,17 +292,14 @@ static void FreeGlobalSettings(void)
int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth)
{
- HDC hdc;
- HFONT hOldFont;
- RECT rc = { 0 };
- int i;
-
if (!pszText || !hFont)
return 0;
- hdc = GetDC(NULL);
- hOldFont = (HFONT)SelectObject(hdc, hFont);
- i = DrawText(hdc, pszText, -1, &rc, DT_CALCRECT);
+ HDC hdc = GetDC(NULL);
+ HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);
+
+ RECT rc = { 0 };
+ int i = DrawText(hdc, pszText, -1, &rc, DT_CALCRECT);
SelectObject(hdc, hOldFont);
ReleaseDC(NULL, hdc);
return bWidth ? rc.right - rc.left : rc.bottom - rc.top;
@@ -318,6 +308,7 @@ int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth)
int OptionsInit(void)
{
LoadLogFonts();
+
LOGFONT lf;
LoadMsgDlgFont(18, &lf, NULL);
lstrcpy(lf.lfFaceName, _T("MS Shell Dlg"));
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index 5b5492987e..4532c7030b 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -22,14 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
+INT_PTR SvcGetChatManager(WPARAM, LPARAM);
+
#include "chat.h"
BOOL SmileyAddInstalled, PopupInstalled, IEviewInstalled;
-
-HANDLE hChatSendEvent;
-HANDLE hBuildMenuEvent;
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
-SESSION_INFO g_TabSession;
+HANDLE hChatSendEvent, hBuildMenuEvent;
+HGENMENU hJoinMenuItem, hLeaveMenuItem;
CRITICAL_SECTION cs;
void RegisterFonts( void );
@@ -46,111 +45,25 @@ static HANDLE
hEventJoinChat = NULL,
hEventLeaveChat = NULL;
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
-{
- if (!si)
- return;
-
- if (ci.pSettings->TabsEnable) {
- // the session is not the current tab, so we copy the necessary
- // details into the SESSION_INFO for the tabbed window
- if (!si->hWnd) {
- g_TabSession.iEventCount = si->iEventCount;
- g_TabSession.iStatusCount = si->iStatusCount;
- g_TabSession.iType = si->iType;
- g_TabSession.nUsersInNicklist = si->nUsersInNicklist;
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- g_TabSession.pMe = si->pMe;
- g_TabSession.dwFlags = si->dwFlags;
- g_TabSession.pStatuses = si->pStatuses;
- g_TabSession.ptszID = si->ptszID;
- g_TabSession.pszModule = si->pszModule;
- g_TabSession.ptszName = si->ptszName;
- g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
- g_TabSession.ptszTopic = si->ptszTopic;
- g_TabSession.pUsers = si->pUsers;
- g_TabSession.hContact = si->hContact;
- g_TabSession.wStatus = si->wStatus;
- g_TabSession.lpCommands = si->lpCommands;
- g_TabSession.lpCurrentCommand = NULL;
- }
-
- //Do we need to create a tabbed window?
-// if (g_TabSession.hWnd == NULL) !!!!!!!!!!!!!!!!!!!!!!!
-// g_TabSession.hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANNEL), NULL, RoomWndProc, (LPARAM)&g_TabSession);
-
- SetWindowLongPtr(g_TabSession.hWnd, GWL_EXSTYLE, GetWindowLongPtr(g_TabSession.hWnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
-
- // if the session was not the current tab we need to tell the window to
- // redraw to show the contents of the current SESSION_INFO
- if (!si->hWnd) {
- ci.SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
- SendMessage(g_TabSession.hWnd, GC_ADDTAB, -1, (LPARAM)si);
- SendMessage(g_TabSession.hWnd, GC_TABCHANGE, 0, (LPARAM)&g_TabSession);
- }
-
- ci.SetActiveSession(si->ptszID, si->pszModule);
-
- if (!IsWindowVisible(g_TabSession.hWnd) || wp == WINDOW_HIDDEN)
- SendMessage(g_TabSession.hWnd, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
- else {
- if (IsIconic(g_TabSession.hWnd))
- ShowWindow(g_TabSession.hWnd, SW_NORMAL);
-
- PostMessage(g_TabSession.hWnd, WM_SIZE, 0, 0);
- if (si->iType != GCW_SERVER)
- SendMessage(g_TabSession.hWnd, GC_UPDATENICKLIST, 0, 0);
- else
- SendMessage(g_TabSession.hWnd, GC_UPDATETITLE, 0, 0);
- SendMessage(g_TabSession.hWnd, GC_REDRAWLOG, 0, 0);
- SendMessage(g_TabSession.hWnd, GC_UPDATESTATUSBAR, 0, 0);
- ShowWindow(g_TabSession.hWnd, SW_SHOW);
- if (bSetForeground)
- SetForegroundWindow(g_TabSession.hWnd);
- }
- SendMessage(g_TabSession.hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(g_TabSession.hWnd, IDC_MESSAGE));
- return;
- }
-
- //Do we need to create a window?
-// if (si->hWnd == NULL) !!!!!!!!!!!!!!!!!!!!!!!s
-// si->hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANNEL), NULL, RoomWndProc, (LPARAM)si);
-
- SetWindowLongPtr(si->hWnd, GWL_EXSTYLE, GetWindowLongPtr(si->hWnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
- if (!IsWindowVisible(si->hWnd) || wp == WINDOW_HIDDEN)
- SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
- else {
- if (IsIconic(si->hWnd))
- ShowWindow(si->hWnd, SW_NORMAL);
- ShowWindow(si->hWnd, SW_SHOW);
- SetForegroundWindow(si->hWnd);
- }
-
- SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(si->hWnd, IDC_MESSAGE));
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Post-load event hooks
static int FontsChanged(WPARAM wParam, LPARAM lParam)
{
LoadLogFonts();
- {
- LOGFONT lf;
- HFONT hFont;
- int iText;
-
- LoadMsgDlgFont(0, &lf, NULL);
- hFont = CreateFontIndirect(&lf);
- iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
- DeleteObject(hFont);
- ci.pSettings->LogTextIndent = iText;
- ci.pSettings->LogTextIndent = ci.pSettings->LogTextIndent * 12 / 10;
- ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
- }
+
+ LOGFONT lf;
+ HFONT hFont;
+ int iText;
+
+ LoadMsgDlgFont(0, &lf, NULL);
+ hFont = CreateFontIndirect(&lf);
+ iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
+ DeleteObject(hFont);
+ ci.pSettings->LogTextIndent = iText;
+ ci.pSettings->LogTextIndent = ci.pSettings->LogTextIndent * 12 / 10;
+ ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
+
ci.MM_FontsChanged();
ci.MM_FixColors();
ci.SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
@@ -173,7 +86,6 @@ static int PreShutdown(WPARAM wParam, LPARAM lParam)
ci.SM_RemoveAll();
ci.MM_RemoveAll();
- ci.TabM_RemoveAll();
return 0;
}
@@ -265,7 +177,7 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
mi->pszHeader = Log_CreateRtfHeader(mi);
CheckColorsInModule((char*)gcr->pszModule);
- CList_SetAllOffline(TRUE, gcr->pszModule);
+ ci.SetAllOffline(TRUE, gcr->pszModule);
return 0;
}
@@ -287,8 +199,6 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
// create a new session and set the defaults
if (si != NULL) {
- TCHAR szTemp[256];
-
si->dwItemData = gcw->dwItemData;
if (gcw->iType != GCW_SERVER)
si->wStatus = ID_STATUS_ONLINE;
@@ -310,11 +220,13 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
si->iBG = 2;
si->bBGSet = TRUE;
}
+
+ TCHAR szTemp[256];
if (si->iType == GCW_SERVER)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName);
else
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
- si->hContact = CList_AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
+ si->hContact = ci.AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_unset(si->hContact, "CList", "StatusMsg");
if (si->ptszStatusbarText)
@@ -325,21 +237,14 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
else {
SESSION_INFO* si2 = ci.SM_FindSession(gcw->ptszID, gcw->pszModule);
if (si2) {
- if (si2->hWnd)
- g_TabSession.nUsersInNicklist = 0;
-
ci.UM_RemoveAll(&si2->pUsers);
ci.TM_RemoveAll(&si2->pStatuses);
si2->iStatusCount = 0;
si2->nUsersInNicklist = 0;
- if (!ci.pSettings->TabsEnable) {
- if (si2->hWnd)
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- else if (g_TabSession.hWnd)
- RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+ if (ci.OnSessionReplace)
+ ci.OnSessionReplace(si2);
}
}
@@ -357,7 +262,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp)
si->bInitDone = TRUE;
ci.SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
- ShowRoom(si, wp, FALSE);
+ ci.ShowRoom(si, wp, FALSE);
}
return 0;
@@ -368,7 +273,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp)
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
si->bInitDone = TRUE;
if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0)
- ShowRoom(si, wp, TRUE);
+ ci.ShowRoom(si, wp, TRUE);
return 0;
}
break;
@@ -384,10 +289,8 @@ static int DoControl(GCEVENT *gce, WPARAM wp)
case WINDOW_CLEARLOG:
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
ci.LM_RemoveAll(&si->pLog, &si->pLogEnd);
- if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- }
+ if (ci.OnClearLog)
+ ci.OnClearLog(si);
si->iEventCount = 0;
si->LastTime = 0;
}
@@ -408,11 +311,8 @@ static int DoControl(GCEVENT *gce, WPARAM wp)
replaceStrT(si->ptszName, gce->ptszText);
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
-
- if (g_TabSession.hWnd && ci.pSettings->TabsEnable) {
- g_TabSession.ptszName = si->ptszName;
- SendMessage(g_TabSession.hWnd, GC_SESSIONNAMECHANGE, 0, (LPARAM)si);
- }
+ if (ci.OnSessionRename)
+ ci.OnSessionRename(si);
}
}
@@ -435,11 +335,9 @@ static int DoControl(GCEVENT *gce, WPARAM wp)
db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
else
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
- if (si->hWnd) {
- g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
- SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
- }
}
+ if (ci.OnSetStatusBar)
+ ci.OnSetStatusBar(si);
}
else if (gce->pDest->iType == GC_EVENT_ACK) {
ci.SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0);
@@ -472,10 +370,8 @@ static void AddUser(GCEVENT *gce)
ui->Status = status;
ui->Status |= si->pStatuses->Status;
- if (si->hWnd) {
- g_TabSession.pUsers = si->pUsers;
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
+ if (ci.OnNewUser)
+ ci.OnNewUser(si, ui);
}
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
@@ -530,9 +426,9 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
if (si) {
if (gce->ptszText) {
replaceStrT(si->ptszTopic, gce->ptszText);
- if (si->hWnd)
- g_TabSession.ptszTopic = si->ptszTopic;
db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
+ if (ci.OnSetTopic)
+ ci.OnSetTopic(si);
if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic));
}
@@ -607,16 +503,9 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
return 0;
if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (ci.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+ int isOk = ci.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
+ if (ci.OnAddLog)
+ ci.OnAddLog(si, isOk);
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && ci.pSettings->LoggingEnabled)
@@ -649,15 +538,13 @@ static int ModuleLoad(WPARAM wParam, LPARAM lParam)
return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// Service creation
-
static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
char* mods[3] = { "Chat", "ChatFonts" };
CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
RegisterFonts();
+ OptionsInit();
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = -2000090001;
@@ -684,29 +571,34 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
ModuleLoad(0, 0);
- CList_SetAllOffline(TRUE, NULL);
+ ci.SetAllOffline(TRUE, NULL);
return 0;
}
-void HookEvents(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Service creation
+
+static bool bInited = false;
+
+void InitChatModule(void)
+{
+ CreateServiceFunction("GChat/GetInterface", SvcGetChatManager);
+}
+
+void LoadChatModule(void)
{
+ if (bInited)
+ return;
+
InitializeCriticalSection(&cs);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad);
HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
-}
-void UnhookEvents(void)
-{
- DeleteCriticalSection(&cs);
-}
-
-void CreateServiceFunctions(void)
-{
CreateServiceFunction(MS_GC_REGISTER, Service_Register);
CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
@@ -714,36 +606,24 @@ void CreateServiceFunctions(void)
CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo);
CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount);
- CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclicked);
- CreateServiceFunction("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc);
- CreateServiceFunction("GChat/JoinChat", CList_JoinChat);
- CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat);
-}
+ CreateServiceFunction("GChat/DblClickEvent", EventDoubleclicked);
+ CreateServiceFunction("GChat/PrebuildMenuEvent", PrebuildContactMenuSvc);
+ CreateServiceFunction("GChat/JoinChat", JoinChat);
+ CreateServiceFunction("GChat/LeaveChat", LeaveChat);
-void CreateHookableEvents(void)
-{
hChatSendEvent = CreateHookableEvent(ME_GC_EVENT);
hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
+ bInited = true;
}
-void DestroyHookableEvents(void)
+void UnloadChatModule(void)
{
+ if (!bInited)
+ return;
+
+ OptionsUnInit();
+ DeleteCriticalSection(&cs);
+
DestroyHookableEvent(hChatSendEvent);
DestroyHookableEvent(hBuildMenuEvent);
}
-
-void TabsInit(void)
-{
- ZeroMemory(&g_TabSession, sizeof(SESSION_INFO));
-
- g_TabSession.iType = GCW_TABROOM;
- g_TabSession.iSplitterX = ci.pSettings->iSplitterX;
- g_TabSession.iSplitterY = ci.pSettings->iSplitterY;
- g_TabSession.iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
- g_TabSession.bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
- g_TabSession.bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
- g_TabSession.iFG = 4;
- g_TabSession.bFGSet = TRUE;
- g_TabSession.iBG = 2;
- g_TabSession.bBGSet = TRUE;
-}
diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp
index a06c640c75..79c3a23dc3 100644
--- a/src/modules/chat/clist.cpp
+++ b/src/modules/chat/clist.cpp
@@ -22,9 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "chat.h"
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
+HANDLE AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
{
- HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
+ HANDLE hContact = ci.FindRoom(pszModule, pszRoom);
DBVARIANT dbv;
TCHAR pszGroup[50];
@@ -67,7 +67,7 @@ HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* p
return hContact;
}
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide)
+BOOL SetOffline(HANDLE hContact, BOOL bHide)
{
if ( hContact ) {
char* szProto = GetContactProto(hContact);
@@ -80,7 +80,7 @@ BOOL CList_SetOffline(HANDLE hContact, BOOL bHide)
return FALSE;
}
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
+BOOL SetAllOffline(BOOL bHide, const char *pszModule)
{
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
@@ -98,7 +98,7 @@ BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
return TRUE;
}
-int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
+int RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
{
BOOL bRedrawFlag = FALSE;
@@ -121,15 +121,14 @@ int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
&& db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1
&& !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0)
&& IsWindowVisible(si->hWnd)
- && !IsIconic(si->hWnd)) {
- if (ci.pSettings->TabsEnable)
- SendMessage(si->hWnd, GC_REMOVETAB, 1, (LPARAM)si);
- else
- PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+ && !IsIconic(si->hWnd))
+ {
+ if (ci.OnSessionDblClick)
+ ci.OnSessionDblClick(si);
db_free(&dbv);
return 1;
}
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
db_free(&dbv);
return 1;
@@ -138,38 +137,39 @@ int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
return 0;
}
-INT_PTR CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam)
+INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam)
{
- return CList_RoomDoubleclicked((WPARAM) ((CLISTEVENT*)lParam)->hContact,(LPARAM) 0);
+ return RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0);
}
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam)
+INT_PTR JoinChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
+ if (hContact) {
char* szProto = GetContactProto(hContact);
- if ( szProto ) {
- if ( db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
- CallProtoService( szProto, PS_JOINCHAT, wParam, lParam );
+ if (szProto) {
+ if (db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE)
+ CallProtoService(szProto, PS_JOINCHAT, wParam, lParam);
else
- CList_RoomDoubleclicked( wParam, 0 );
- } }
+ RoomDoubleclicked(wParam, 0);
+ }
+ }
return 0;
}
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam)
+INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
+ if (hContact) {
char* szProto = GetContactProto(hContact);
- if ( szProto )
- CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam );
+ if (szProto)
+ CallProtoService(szProto, PS_LEAVECHAT, wParam, lParam);
}
return 0;
}
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
if (hContact == NULL)
@@ -199,24 +199,24 @@ int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
return 0;
}
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
+INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
{
- return CList_PrebuildContactMenu(wParam, lParam);
+ return PrebuildContactMenu(wParam, lParam);
}
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
+BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
{
- CLISTEVENT cle = {0};
- va_list marker;
TCHAR szBuf[4096];
if (!fmt || !fmt[0] || _tcslen(fmt) > 2000)
return FALSE;
+ va_list marker;
va_start(marker, fmt);
mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
va_end(marker);
+ CLISTEVENT cle = { 0 };
cle.cbSize = sizeof(cle);
cle.hContact = hContact;
cle.hDbEvent = hEvent;
@@ -236,7 +236,7 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR
return TRUE;
}
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom)
+HANDLE FindRoom (const char* pszModule, const TCHAR* pszRoom)
{
for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
@@ -254,40 +254,3 @@ HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom)
return 0;
}
-
-int WCCmp(TCHAR* wild, TCHAR* string)
-{
- TCHAR *cp, *mp;
- if ( wild == NULL || !wild[0] || string == NULL || !string[0])
- return 0;
-
- while ((*string) && (*wild != '*')) {
- if ((*wild != *string) && (*wild != '?'))
- return 0;
-
- wild++;
- string++;
- }
-
- while (*string) {
- if (*wild == '*') {
- if (!*++wild)
- return 1;
-
- mp = wild;
- cp = string+1;
- }
- else if ((*wild == *string) || (*wild == '?')) {
- wild++;
- string++;
- }
- else {
- wild = mp;
- string = cp++;
- } }
-
- while (*wild == '*')
- wild++;
-
- return !*wild;
-}
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index ea05294de5..f791809f54 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -28,9 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static PBYTE pLogIconBmpBits[14];
static int logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
-static int logPixelSY = 0;
-static int logPixelSX = 0;
-
static int EventToIndex(LOGINFO * lin)
{
switch (lin->iType) {
@@ -85,7 +82,7 @@ static char *Log_SetStyle(int style, int fontindex)
static char szStyle[128];
mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u",
- style, style + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ style, style + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
return szStyle;
}
@@ -323,7 +320,7 @@ TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time)
return szTime;
}
-static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
+char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
int bufferAlloced, bufferEnd, i, me = 0;
@@ -374,13 +371,13 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE)
{
iii = lin->bIsHighlighted?16:(lin->bIsMe ? 2 : 1);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
else
{
iii = lin->bIsHighlighted?16:EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
}
@@ -479,13 +476,10 @@ char* Log_CreateRtfHeader(MODULEINFO * mi)
//get the number of pixels per logical inch
- {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC(NULL, hdc);
- }
+ HDC hdc = GetDC(NULL);
+ ci.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ ci.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
// ### RTF HEADER
@@ -512,12 +506,12 @@ char* Log_CreateRtfHeader(MODULEINFO * mi)
if (ci.pSettings->dwIconFlags)
{
- iIndent += (14*1440)/logPixelSX;
+ iIndent += (14 * 1440) / ci.logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
if (ci.pSettings->ShowTime)
{
- int iSize = (ci.pSettings->LogTextIndent*1440)/logPixelSX;
+ int iSize = (ci.pSettings->LogTextIndent * 1440) / ci.logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
if (ci.pSettings->LogIndentEnabled)
iIndent += iSize;
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index b50bc34598..4f6279a10b 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define STATUSICONCOUNT 6
SESSION_INFO *m_WndList = 0;
-TABLIST *g_TabList = 0;
MODULEINFO *m_ModList = 0;
static void SetActiveSessionEx(SESSION_INFO *si)
@@ -87,27 +86,17 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule)
static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL removeContact)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
- if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) // match
- {
- COMMANDINFO *pCurComm;
+ // match
+ if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
DWORD dw = pTemp->dwItemData;
- if (!ci.pSettings->TabsEnable) {
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- }
- else if (ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)pTemp);
-
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist = 0;
-
+ if (ci.OnSessionRemove)
+ ci.OnSessionRemove(pTemp);
DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
if (pLast == NULL)
@@ -124,7 +113,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo
// contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (pTemp->hContact && db_get_b(pTemp->hContact, pTemp->pszModule, "ChatRoom", 0) != 0) {
- CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE);
+ ci.SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE);
db_set_s(pTemp->hContact, pTemp->pszModule, "Topic", "");
db_set_s(pTemp->hContact, pTemp->pszModule, "StatusBar", "");
db_unset(pTemp->hContact, "CList", "StatusMsg");
@@ -142,7 +131,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo
mir_free(pTemp->pszName);
// delete commands
- pCurComm = pTemp->lpCommands;
+ COMMANDINFO *pCurComm = pTemp->lpCommands;
while (pCurComm != NULL) {
COMMANDINFO *pNext = pCurComm->next;
mir_free(pCurComm->lpCommand);
@@ -168,11 +157,10 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo
static SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return NULL;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
return pTemp;
@@ -185,22 +173,18 @@ static SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule)
static BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
ci.UM_RemoveAll(&pTemp->pUsers);
pTemp->nUsersInNicklist = 0;
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist = 0;
if (pTemp->iType != GCW_SERVER)
pTemp->bInitDone = FALSE;
- if (ci.pSettings->TabsEnable && pTemp->hWnd)
- ci.tabSession.pUsers = 0;
-
+ if (ci.OnSessionOffline)
+ ci.OnSessionOffline(pTemp);
if (pszID)
return TRUE;
}
@@ -267,18 +251,12 @@ static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce)
if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) {
if (ci.UM_FindUser(pTemp->pUsers, gce->ptszUID)) {
if (pTemp->bInitDone) {
- if (ci.SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE) && pTemp->hWnd && pTemp->bInitDone) {
- ci.tabSession.pLog = pTemp->pLog;
- ci.tabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (pTemp->hWnd && pTemp->bInitDone) {
- ci.tabSession.pLog = pTemp->pLog;
- ci.tabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+ if (ci.OnEventBroadcast)
+ ci.OnEventBroadcast(pTemp, gce);
+
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
DoSoundsFlashPopupTrayStuff(pTemp, gce, FALSE, bManyFix);
+
bManyFix++;
if ((gce->dwFlags & GCEF_ADDTOLOG) && ci.pSettings->LoggingEnabled)
LogToFile(pTemp, gce);
@@ -339,8 +317,8 @@ static USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCH
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO *p = ci.UM_AddUser(pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus);
pTemp->nUsersInNicklist++;
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist++;
+ if (ci.OnAddUser)
+ ci.OnAddUser(pTemp, p);
return p;
}
pLast = pTemp;
@@ -381,10 +359,8 @@ static BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR
USERINFO *ui = ci.UM_FindUser(pTemp->pUsers, pszUID);
if (ui) {
pTemp->nUsersInNicklist--;
- if (pTemp->hWnd) {
- ci.tabSession.pUsers = pTemp->pUsers;
- ci.tabSession.nUsersInNicklist--;
- }
+ if (ci.OnRemoveUser)
+ ci.OnRemoveUser(pTemp, ui);
dw = ci.UM_RemoveUser(&pTemp->pUsers, pszUID);
@@ -420,7 +396,7 @@ static USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule,
}
-STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
+STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
{
SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
@@ -432,8 +408,8 @@ STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR
STATUSINFO *ti = ci.TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount);
if (ti)
pTemp->iStatusCount++;
- if (ci.pSettings->TabsEnable && pTemp->hWnd)
- ci.tabSession.pStatuses = pTemp->pStatuses;
+ if (ci.OnAddStatus)
+ ci.OnAddStatus(pTemp, ti);
return ti;
}
pLast = pTemp;
@@ -585,9 +561,6 @@ static BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus)
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
pTemp->wStatus = wStatus;
- if (pTemp->hWnd && ci.pSettings->TabsEnable)
- ci.tabSession.wStatus = wStatus;
-
if (pTemp->hContact) {
if (pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
db_unset(pTemp->hContact, "CList", "Hidden");
@@ -595,8 +568,8 @@ static BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus)
db_set_w(pTemp->hContact, pTemp->pszModule, "Status", (WORD)wStatus);
}
- if (ci.pSettings->TabsEnable && ci.tabSession.hWnd)
- PostMessage(ci.tabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM)pTemp);
+ if (ci.OnSetStatus)
+ ci.OnSetStatus(pTemp, wStatus);
if (pszID)
return TRUE;
@@ -750,7 +723,7 @@ static BOOL SM_RemoveAll(void)
SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
DoEventHook(m_WndList->ptszID, m_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)m_WndList->dwItemData);
if (m_WndList->hContact)
- CList_SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
+ ci.SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
db_set_s(m_WndList->hContact, m_WndList->pszModule, "Topic", "");
db_unset(m_WndList->hContact, "CList", "StatusMsg");
db_set_s(m_WndList->hContact, m_WndList->pszModule, "StatusBar", "");
@@ -1058,50 +1031,6 @@ static BOOL MM_RemoveAll(void)
return TRUE;
}
-
-
-//---------------------------------------------------
-// Tab list manager functions
-//
-// Necessary to keep track of what tabs should
-// be restored
-//---------------------------------------------------
-
-static BOOL TabM_AddTab(const TCHAR *pszID, const char* pszModule)
-{
- TABLIST *node = NULL;
- if (!pszID || !pszModule)
- return FALSE;
-
- node = (TABLIST*)mir_alloc(sizeof(TABLIST));
- ZeroMemory(node, sizeof(TABLIST));
- node->pszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
-
- if (g_TabList == NULL) { // list is empty
- g_TabList = node;
- node->next = NULL;
- }
- else {
- node->next = g_TabList;
- g_TabList = node;
- }
- return TRUE;
-}
-
-static BOOL TabM_RemoveAll(void)
-{
- while (g_TabList != NULL) {
- TABLIST * pLast = g_TabList->next;
- mir_free(g_TabList->pszModule);
- mir_free(g_TabList->pszID);
- mir_free(g_TabList);
- g_TabList = pLast;
- }
- g_TabList = NULL;
- return TRUE;
-}
-
//---------------------------------------------------
// Status manager functions
//
@@ -1607,9 +1536,6 @@ CHAT_MANAGER ci =
MM_IconsChanged,
MM_RemoveAll,
- TabM_AddTab,
- TabM_RemoveAll,
-
TM_AddStatus,
TM_FindStatus,
TM_StringToWord,
@@ -1630,10 +1556,20 @@ CHAT_MANAGER ci =
LM_AddEvent,
LM_TrimLog,
- LM_RemoveAll
+ LM_RemoveAll,
+
+ AddRoom,
+ SetOffline,
+ SetAllOffline,
+ AddEvent,
+ FindRoom,
+ NULL, // must be implemented in a plugin
+ Log_CreateRTF,
+ LoadMsgDlgFont
};
INT_PTR SvcGetChatManager(WPARAM, LPARAM)
{
+ LoadChatModule();
return (INT_PTR)&ci;
}
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index e2775403d9..216798a3a2 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -86,7 +86,7 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord)
static void __stdcall ShowRoomFromPopup(void * pi)
{
SESSION_INFO *si = (SESSION_INFO*)pi;
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -170,43 +170,43 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
switch (iEvent) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- CList_AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
break;
case GC_EVENT_NICK:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
+ 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:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
break;
case GC_EVENT_TOPIC:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- CList_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);
+ 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:
- CList_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);
+ 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;
}
}
@@ -286,7 +286,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return FALSE;
BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != si->hWnd;
- // bInactive |= GetActiveWindow() != si->hWnd; // Removed this, because it seemed to be FALSE, even when window was focused, causing incorrect notifications
int iEvent = gce->pDest->iType;
@@ -294,16 +293,14 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
if (bInactive || !ci.pSettings->SoundsFocus)
SkinPlaySound("ChatHighlight");
- if (!ci.pSettings->TabsEnable && bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
- SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL);
if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0)
db_unset(si->hContact, "CList", "Hidden");
if (bInactive)
DoTrayIcon(si, gce);
if (bInactive || !ci.pSettings->PopupInactiveOnly)
DoPopup(si, gce);
- if (ci.pSettings->TabsEnable && bInactive && ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
+ if (ci.OnFlashWindow)
+ ci.OnFlashWindow(si, bInactive);
return TRUE;
}
@@ -343,15 +340,13 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
case GC_EVENT_MESSAGE:
if (bInactive || !ci.pSettings->SoundsFocus)
SkinPlaySound("ChatMessage");
- if (!ci.pSettings->TabsEnable && bInactive && ci.pSettings->FlashWindow && si->hWnd)
- SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL);
if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071);
}
- if (ci.pSettings->TabsEnable && bInactive && ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_SETTABHIGHLIGHT, 0, (LPARAM)si);
+ if (ci.OnFlashWindow)
+ ci.OnFlashWindow(si, bInactive);
break;
case GC_EVENT_ACTION:
if (bInactive || !ci.pSettings->SoundsFocus)
@@ -491,11 +486,8 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText)
p2 += 1;
p3 = p2;
- CharLower(szWord1);
- CharLower(szWord2);
-
// compare the words, using wildcards
- if (WCCmp(szWord1, RemoveFormatting(szWord2)))
+ if (wildcmpit(szWord1, RemoveFormatting(szWord2)))
return TRUE;
}
}