summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-16 21:40:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-16 21:40:14 +0000
commit831ad8a0121f9f9ee5c4f38d4a0d209b3c2bdb60 (patch)
treee362f0459b19341b213e5ca7de87af699564beab
parent41ba18e9cb1c340cb80c637817231b487c54562e (diff)
kernel chats, part 3, tabsrmm
git-svn-id: http://svn.miranda-ng.org/main/trunk@7684 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_chat_int.h8
-rw-r--r--plugins/Scriver/src/Version.h4
-rw-r--r--plugins/Scriver/src/msgwindow.cpp11
-rw-r--r--plugins/TabSRMM/src/chat/chat.h242
-rw-r--r--plugins/TabSRMM/src/chat/chatprototypes.h171
-rw-r--r--plugins/TabSRMM/src/chat/clist.cpp264
-rw-r--r--plugins/TabSRMM/src/chat/log.cpp157
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp284
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp1248
-rw-r--r--plugins/TabSRMM/src/chat/message.cpp95
-rw-r--r--plugins/TabSRMM/src/chat/muchighlight.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/options.cpp215
-rw-r--r--plugins/TabSRMM/src/chat/services.cpp539
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp658
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp112
-rw-r--r--plugins/TabSRMM/src/commonheaders.h11
-rw-r--r--plugins/TabSRMM/src/functions.h22
-rw-r--r--plugins/TabSRMM/src/globals.cpp6
-rw-r--r--plugins/TabSRMM/src/hotkeyhandler.cpp2
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp4
-rw-r--r--plugins/TabSRMM/src/msgs.cpp9
-rw-r--r--plugins/TabSRMM/src/msgs.h1
-rw-r--r--plugins/TabSRMM/src/taskbar.cpp2
-rw-r--r--plugins/TabSRMM/src/themeio.cpp2
-rw-r--r--plugins/TabSRMM/src/version.h4
-rw-r--r--plugins/TabSRMM/tabsrmm_10.vcxproj4
-rw-r--r--plugins/TabSRMM/tabsrmm_10.vcxproj.filters15
-rw-r--r--plugins/TabSRMM/tabsrmm_11.vcxproj4
-rw-r--r--plugins/TabSRMM/tabsrmm_11.vcxproj.filters6
-rw-r--r--plugins/TabSRMM/tabsrmm_12.vcxproj4
-rw-r--r--plugins/TabSRMM/tabsrmm_12.vcxproj.filters19
-rw-r--r--src/core/stdchat/src/log.cpp4
-rw-r--r--src/core/stdchat/src/window.cpp66
-rw-r--r--src/modules/chat/chat.h2
-rw-r--r--src/modules/chat/chat_svc.cpp6
-rw-r--r--src/modules/chat/clist.cpp78
-rw-r--r--src/modules/chat/manager.cpp11
-rw-r--r--src/modules/chat/tools.cpp4
38 files changed, 697 insertions, 3599 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 46c62a3917..550b4fcdaa 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -148,6 +148,7 @@ struct LOGINFO
BOOL bIsHighlighted;
time_t time;
int iType;
+ DWORD dwFlags;
LOGINFO *next, *prev;
};
@@ -178,6 +179,7 @@ struct GCSessionInfoBase
BOOL bFilterEnabled;
BOOL bNicklistEnabled;
BOOL bInitDone;
+ BOOL bTrimmed;
char* pszModule;
TCHAR* ptszID;
@@ -363,6 +365,10 @@ struct CHAT_MANAGER
char* (*Log_CreateRTF)(LOGSTREAMDATA *streamData);
void (*LoadMsgDlgFont)(int i, LOGFONT *lf, COLORREF *color);
TCHAR* (*MakeTimeStamp)(TCHAR *pszStamp, time_t time);
+ 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, ...);
+ TCHAR* (*RemoveFormatting)(const TCHAR *pszText);
+ BOOL (*DoSoundsFlashPopupTrayStuff)(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
int logPixelSY, logPixelSX;
char *szActiveWndModule;
@@ -376,6 +382,7 @@ struct CHAT_MANAGER
// user-defined custom callbacks
void (*OnCreateModule)(MODULEINFO*);
+ void (*OnCreateSession)(SESSION_INFO*, MODULEINFO*);
void (*OnSessionDblClick)(SESSION_INFO*);
void (*OnSessionOffline)(SESSION_INFO*);
void (*OnSessionRemove)(SESSION_INFO*);
@@ -393,6 +400,7 @@ struct CHAT_MANAGER
void (*OnAddUser)(SESSION_INFO*, USERINFO*);
void (*OnNewUser)(SESSION_INFO*, USERINFO*);
void (*OnRemoveUser)(SESSION_INFO *si, USERINFO*);
+ void (*OnChangeNick)(SESSION_INFO *si);
void (*OnAddStatus)(SESSION_INFO *si, STATUSINFO*);
void (*OnSetStatus)(SESSION_INFO *si, int);
diff --git a/plugins/Scriver/src/Version.h b/plugins/Scriver/src/Version.h
index 061117ee47..406bbd5d7f 100644
--- a/plugins/Scriver/src/Version.h
+++ b/plugins/Scriver/src/Version.h
@@ -1,6 +1,6 @@
#define __MAJOR_VERSION 2
-#define __MINOR_VERSION 10
-#define __RELEASE_NUM 1
+#define __MINOR_VERSION 11
+#define __RELEASE_NUM 0
#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp
index b791a24541..18706d3c9b 100644
--- a/plugins/Scriver/src/msgwindow.cpp
+++ b/plugins/Scriver/src/msgwindow.cpp
@@ -828,13 +828,14 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_DESTROY:
{
char szSettingName[64];
- for (int i=dat->childrenCount; --i >= 0;) {
+ for (int i = dat->childrenCount; i >= 0; i--) {
TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE;
- TabCtrl_GetItem(dat->hwndTabs, i, &tci);
- TabCtrl_DeleteItem(dat->hwndTabs, i);
- mir_free((MessageWindowTabData *) tci.lParam);
- ReleaseIcon(tci.iImage);
+ if (TabCtrl_GetItem(dat->hwndTabs, i, &tci)) {
+ mir_free((MessageWindowTabData *)tci.lParam);
+ ReleaseIcon(tci.iImage);
+ TabCtrl_DeleteItem(dat->hwndTabs, i);
+ }
}
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
WindowList_Remove(g_dat.hParentWindowList, hwndDlg);
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 2bba66c842..e2bc495ffa 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -36,61 +36,6 @@
#define _CHAT_H_
//defines
-#define OPTIONS_FONTCOUNT 20
-#define GC_UPDATETITLE (WM_USER+100)
-#define GC_CLOSEWINDOW (WM_USER+103)
-#define GC_GETITEMDATA (WM_USER+104)
-#define GC_SETITEMDATA (WM_USER+105)
-#define GC_UPDATESTATUSBAR (WM_USER+106)
-#define GC_SETVISIBILITY (WM_USER+107)
-#define GC_SETWNDPROPS (WM_USER+108)
-#define GC_REDRAWLOG (WM_USER+109)
-#define GC_FIREHOOK (WM_USER+110)
-#define GC_FILTERFIX (WM_USER+111)
-#define GC_CHANGEFILTERFLAG (WM_USER+112)
-#define GC_SHOWFILTERMENU (WM_USER+113)
-//#define GC_NICKLISTCLEAR (WM_USER+117)
-#define GC_REDRAWWINDOW (WM_USER+118)
-#define GC_SHOWCOLORCHOOSER (WM_USER+119)
-#define GC_ADDLOG (WM_USER+120)
-#define GC_ACKMESSAGE (WM_USER+121)
-//#define GC_ADDUSER (WM_USER+122)
-//#define GC_REMOVEUSER (WM_USER+123)
-//#define GC_NICKCHANGE (WM_USER+124)
-#define GC_UPDATENICKLIST (WM_USER+125)
-//#define GC_MODECHANGE (WM_USER+126)
-#define GC_SCROLLTOBOTTOM (WM_USER+129)
-#define GC_SESSIONNAMECHANGE (WM_USER+131)
-#define GC_SETMESSAGEHIGHLIGHT (WM_USER+139)
-#define GC_REDRAWLOG2 (WM_USER+140)
-#define GC_REDRAWLOG3 (WM_USER+141)
-
-#define EM_ACTIVATE (WM_USER+202)
-
-#define GC_EVENT_HIGHLIGHT 0x1000
-#define STATE_TALK 0x0001
-
-#define ICON_ACTION 0
-#define ICON_ADDSTATUS 1
-#define ICON_HIGHLIGHT 2
-#define ICON_INFO 3
-#define ICON_JOIN 4
-#define ICON_KICK 5
-#define ICON_MESSAGE 6
-#define ICON_MESSAGEOUT 7
-#define ICON_NICK 8
-#define ICON_NOTICE 9
-#define ICON_PART 10
-#define ICON_QUIT 11
-#define ICON_REMSTATUS 12
-#define ICON_TOPIC 13
-
-#define ICON_STATUS1 14
-#define ICON_STATUS2 15
-#define ICON_STATUS3 16
-#define ICON_STATUS4 17
-#define ICON_STATUS0 18
-#define ICON_STATUS5 19
enum TChatStatusEx
{
@@ -111,16 +56,8 @@ class CMUCHighlight;
//structs
-struct MODULEINFO
+struct MODULEINFO : public GCModuleInfoBase
{
- char *pszModule;
- TCHAR *ptszModDispName;
- char *pszHeader;
- bool bBold, bUnderline, bItalics, bColor, bBkgColor, bChanMgr, bAckMsg;
- int nColorCount;
- COLORREF *crColors;
-
- int iMaxText;
DWORD idleTimeStamp;
DWORD lastIdleCheck;
TCHAR tszIdleMsg[60];
@@ -128,148 +65,40 @@ struct MODULEINFO
MODULEINFO * next;
};
-struct COMMAND_INFO
+struct SESSION_INFO : public GCSessionInfoBase
{
- char* lpCommand;
- COMMAND_INFO *last, *next;
-};
-
-struct FONTINFO
-{
- LOGFONT lf;
- COLORREF color;
-};
-
-struct LOGINFO
-{
- TCHAR *ptszText, *ptszNick, *ptszUID, *ptszStatus, *ptszUserInfo;
- bool bIsMe, bIsHighlighted;
- time_t time;
- int iType;
- DWORD dwFlags;
- LOGINFO *next, *prev;
-};
-
-struct STATUSINFO
-{
- TCHAR *pszGroup;
- HICON hIcon;
- WORD Status;
- STATUSINFO *next;
-};
+ TCHAR pszLogFileName[MAX_PATH + 50];
-struct USERINFO
-{
- TCHAR *pszNick, *pszUID;
- WORD Status;
- WORD ContactStatus;
- TChatStatusEx iStatusEx;
- USERINFO *next;
-};
+ int iLogTrayFlags, iLogPopupFlags;
-struct SESSION_INFO
-{
- HWND hWnd;
-
- bool bFGSet, bBGSet, bFilterEnabled, bNicklistEnabled, bInitDone;
-
- char *pszModule;
- TCHAR *ptszID;
- TCHAR *ptszName;
- TCHAR *ptszStatusbarText;
- TCHAR *ptszTopic;
- TCHAR pszLogFileName[MAX_PATH + 50];
-
- char *pszID; // ugly fix for returning static ANSI strings in GC_INFO
- char *pszName; // just to fix a bug quickly, should die after porting IRC to Unicode
-
- int iType;
- int iFG;
- int iBG;
- int iSplitterY;
- int iSplitterX;
- int iLogFilterFlags;
- int iLogPopupFlags;
- int iLogTrayFlags;
- int iDiskLogFlags;
- int nUsersInNicklist;
- int iEventCount;
- int iStatusCount;
-
- WORD wStatus;
- WORD wState;
- WORD wCommandsNum;
- DWORD dwItemData;
- DWORD dwFlags;
- HANDLE hContact;
- HWND hwndFilter;
- time_t LastTime;
int iSearchItem;
TCHAR szSearch[255];
CMUCHighlight *Highlight;
- COMMAND_INFO *lpCommands;
- COMMAND_INFO *lpCurrentCommand;
- LOGINFO *pLog;
- LOGINFO *pLogEnd;
- USERINFO *pUsers;
- USERINFO *pMe;
- STATUSINFO *pStatuses;
+
TContainerData *pContainer;
TWindowData *dat;
- int wasTrimmed;
SESSION_INFO *next;
};
-struct LOGSTREAMDATA
+struct LOGSTREAMDATA : public GCLogStreamDataBase
{
- char *buffer;
- int bufferOffset, bufferLen;
- HWND hwnd;
- LOGINFO *lin;
- bool bStripFormat, bRedraw;
- SESSION_INFO *si;
int crCount;
TWindowData *dat;
};
-struct TMUCSettings
+struct TMUCSettings : public GlobalLogSettingsBase
{
HICON hIconOverlay;
- bool bShowTime, bShowTimeIfChanged, bLoggingEnabled;
- bool bFlashWindow, bFlashWindowHightlight;
- bool bOpenInDefault;
- bool bLogIndentEnabled;
- bool bStripFormat;
- bool bBBCodeInPopups;
- bool bTrayIconInactiveOnly;
- bool bAddColonToAutoComplete;
- bool bLogLimitNames;
- bool bTimeStampEventColour;
DWORD dwIconFlags;
- int LogTextIndent;
- long LoggingLimit;
- int iEventLimit;
- int iEventLimitThreshold;
- int iPopupStyle;
- int iPopupTimeout;
- int iSplitterX;
- int iSplitterY;
- TCHAR *pszTimeStamp;
- TCHAR *pszTimeStampLog;
- TCHAR *pszIncomingNick;
- TCHAR *pszOutgoingNick;
- TCHAR pszLogDir[MAX_PATH + 20];
LONG iNickListFontHeight;
- HFONT NameFont;
- COLORREF crUserListBGColor;
- COLORREF crPUTextColour;
- COLORREF crPUBkgColour;
+ int iEventLimitThreshold;
HFONT UserListFonts[CHAT_STATUS_MAX];
COLORREF UserListColors[CHAT_STATUS_MAX];
COLORREF nickColors[8];
HBRUSH SelectionBGBrush;
+ bool bOpenInDefault, bFlashWindowHightlight, bBBCodeInPopups;
bool bDoubleClick4Privat, bShowContactStatus, bContactStatusFirst;
bool bLogClassicIndicators, bAlternativeSorting, bAnnoyingHighlight, bCreateWindowOnHighlight;
@@ -305,7 +134,58 @@ struct COLORCHOOSER
//////////////////////////////////////////////////////////////////////////////////
-#include "chatprototypes.h"
+// colorchooser.c
+INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// log.c
+void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
+TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
+char* Log_CreateRtfHeader(MODULEINFO * mi);
+void Log_SetStyles();
+
+// window.c
+INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+int GetTextPixelSize(TCHAR* pszText, HFONT hFont, bool bWidth);
+
+// options.c
+enum { FONTSECTION_AUTO, FONTSECTION_CHAT, FONTSECTION_IM, FONTSECTION_IP };
+int OptionsInit(void);
+int OptionsUnInit(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);
+
+// services.c
+void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
+
+HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup);
+
+// manager.c
+SESSION_INFO* SM_FindSessionByHWND(HWND h);
+SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h);
+SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
+
+void SM_RemoveContainer(TContainerData *pContainer);
+BOOL SM_ReconfigureFilters();
+BOOL SM_InvalidateLogDirectories();
+
+//clist.c
+
+//tools.c
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+int Chat_GetColorIndex(const char* pszModule, COLORREF cr);
+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);
+void Chat_SetFilters(SESSION_INFO *si);
+void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p);
+// message.c
+char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
+TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si);
+
#include "chat_resource.h"
extern char *szChatIconString;
diff --git a/plugins/TabSRMM/src/chat/chatprototypes.h b/plugins/TabSRMM/src/chat/chatprototypes.h
deleted file mode 100644
index ace57346bf..0000000000
--- a/plugins/TabSRMM/src/chat/chatprototypes.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-Chat module plugin for Miranda NG
-
-Copyright (C) 2003-2009 Joergen Persson and others
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-void LoadIcons(void);
-void LoadLogIcons(void);
-void FreeIcons(void);
-void UpgradeCheck(void);
-
-//colorchooser.c
-INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-//log.c
-void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
-void LoadMsgLogBitmaps(void);
-void FreeMsgLogBitmaps(void);
-TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
-TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time);
-char* Log_CreateRtfHeader(MODULEINFO * mi);
-
-//window.c
-INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
-int GetTextPixelSize( TCHAR* pszText, HFONT hFont, bool bWidth);
-
-//options.c
-enum { FONTSECTION_AUTO, FONTSECTION_CHAT, FONTSECTION_IM, FONTSECTION_IP };
-int OptionsInit(void);
-int OptionsUnInit(void);
-void LoadMsgDlgFont(int section, int i, LOGFONT * lf, COLORREF * colour, char* szMod );
-void LoadGlobalSettings(void);
-void AddIcons(void);
-HICON LoadIconEx(int iIndex, char * pszIcoLibName, int iX, int iY);
-
-//services.c
-void HookEvents(void);
-void UnhookEvents(void);
-int CreateServiceFunctions(void);
-void CreateHookableEvents(void);
-void DestroyHookableEvents(void);
-void TabsInit(void);
-int ModulesLoaded(WPARAM wParam,LPARAM lParam);
-int SmileyOptionsChanged(WPARAM wParam,LPARAM lParam);
-int PreShutdown(WPARAM wParam,LPARAM lParam);
-int IconsChanged(WPARAM wParam,LPARAM lParam);
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
-INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam);
-int Service_ItemData(WPARAM wParam, LPARAM lParam);
-int Service_SetSBText(WPARAM wParam, LPARAM lParam);
-int Service_SetVisibility(WPARAM wParam, LPARAM lParam);
-INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam);
-
-HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup);
-
-//manager.c
-void SetActiveSession(const TCHAR *pszID, const char* pszModule);
-void SetActiveSessionEx(SESSION_INFO *si);
-SESSION_INFO* GetActiveSession(void);
-SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule);
-int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, bool removeContact);
-void SM_RemoveContainer(TContainerData *pData);
-SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule);
-USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus);
-SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
-BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID);
-BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce);
-BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID);
-BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule);
-HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO* ui, char* szIndicator);
-BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus);
-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);
-BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bisHighLight = FALSE);
-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);
-BOOL SM_PostMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
-BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync);
-BOOL SM_RemoveAll (void);
-BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus);
-BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD pszStatus);
-BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus);
-BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID);
-void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand);
-char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule);
-char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule);
-int SM_GetCount(const char* pszModule);
-SESSION_INFO* SM_FindSessionByHWND(HWND h);
-SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h);
-SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem);
-char* SM_GetUsers(SESSION_INFO *si);
-USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index);
-BOOL SM_ReconfigureFilters();
-BOOL SM_InvalidateLogDirectories();
-MODULEINFO* MM_AddModule(const char* pszModule);
-MODULEINFO* MM_FindModule(const char* pszModule);
-void MM_FixColors();
-void MM_FontsChanged(void);
-void MM_IconsChanged(void);
-BOOL MM_RemoveAll (void);
-BOOL TabM_AddTab(const TCHAR *pszID, const char* pszModule);
-BOOL TabM_RemoveAll (void);
-STATUSINFO* TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int* iCount);
-STATUSINFO* TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus);
-WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus);
-TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status);
-BOOL TM_RemoveAll (STATUSINFO** pStatusList);
-BOOL UM_SetStatusEx(USERINFO* pUserList,const TCHAR* pszText, int onlyMe );
-USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** pUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus);
-USERINFO* UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID);
-USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID);
-USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index);
-USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status);
-USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status);
-USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status);
-TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
-BOOL UM_RemoveUser(USERINFO** pUserList, const TCHAR* pszUID);
-BOOL UM_RemoveAll (USERINFO** ppUserList);
-LOGINFO* LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd);
-BOOL LM_TrimLog(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd, int iCount);
-BOOL LM_RemoveAll (LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd);
-
-//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);
-void CList_CreateGroup(TCHAR* group);
-BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const TCHAR* fmt, ... ) ;
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
-int WCCmp(TCHAR* wild, TCHAR*string);
-
-//tools.c
-TCHAR* RemoveFormatting(const TCHAR* pszText, bool fLower = false, bool fStripCR = false, TCHAR* buf = 0, const size_t len = 0);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int Chat_GetColorIndex(const char* pszModule, COLORREF cr);
-void CheckColorsInModule(const char* pszModule);
-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 Chat_SetFilters(SESSION_INFO *si);
-void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p);
-// 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/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp
deleted file mode 100644
index fc233ec946..0000000000
--- a/plugins/TabSRMM/src/chat/clist.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
-astyle --force-indent=tab=4 --brackets=linux --indent-switches
- --pad=oper --one-line=keep-blocks --unpad=paren
-
-Chat module plugin for Miranda NG
-
-Copyright (C) 2003 Jörgen Persson
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Group chat module: contact list support functions. Add chat rooms as
-contacts and handle default action for such contacts.
-
-This code was taken in almost unmodified from from the chat.dll
-plugin, originally written by Jörgen Persson
-
-*/
-
-/*
- * handles interaction of the group chat implementation with the contact list plugin
- */
-
-#include "..\commonheaders.h"
-
-char *szChatIconString = "chaticon";
-
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
-{
- TCHAR pszGroup[50]; *pszGroup = '\0';
-
- ptrT groupName( db_get_tsa(NULL, "Chat", "AddToGroup"));
- if (groupName)
- _tcsncpy_s(pszGroup, SIZEOF(pszGroup), groupName, _TRUNCATE);
- else
- _tcscpy(pszGroup, _T("Chat rooms"));
-
- if (pszGroup[0])
- CList_CreateGroup(pszGroup);
-
- HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
- if (hContact)
- return hContact;
-
- // here we create a new one since no one is to be found
- if ((hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
- return NULL;
-
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)pszModule);
- if (pszGroup && lstrlen(pszGroup) > 0)
- CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, (LPARAM)g_Settings.hGroup);
- else
- db_unset(hContact, "CList", "Group");
-
- db_set_ts(hContact, pszModule, "Nick", pszDisplayName);
- db_set_ts(hContact, pszModule, "ChatRoomID", pszRoom);
- db_set_b(hContact, pszModule, "ChatRoom", (BYTE)iType);
- db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
- return hContact;
-}
-
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide)
-{
- if (hContact) {
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- db_set_w(hContact, szProto, "ApparentMode", 0);
- db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- return TRUE;
- }
- return FALSE;
-}
-
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
-{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (MM_FindModule(szProto)) {
- if (!pszModule || (pszModule && !strcmp(pszModule, szProto))) {
- int i = db_get_b(hContact, szProto, "ChatRoom", 0);
- if (i != 0) {
- db_set_w(hContact, szProto, "ApparentMode", (LPARAM)(WORD) 0);
- db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- }
- }
- }
- }
- return TRUE;
-}
-
-int CList_RoomDoubleclicked(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if (!hContact)
- return 0;
-
- char *szProto = GetContactProto(hContact);
- if ( !MM_FindModule(szProto) || !db_get_b(hContact, szProto, "ChatRoom", 0))
- return 0;
-
- ptrT roomid( db_get_tsa(hContact, szProto, "ChatRoomID"));
- if (roomid == NULL)
- return 0;
-
- SESSION_INFO *si = SM_FindSession(roomid, szProto);
- if (si) {
- // is the "toggle visibility option set, so we need to close the window?
- if (si->hWnd != NULL &&
- M.GetByte("Chat", "ToggleVisibility", 0) == 1 &&
- !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0) &&
- IsWindowVisible(si->hWnd) && !IsIconic(si->pContainer->hwnd))
- {
- PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
- return 1;
- }
-
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
- if (lParam) {
- SendMessage(si->hWnd, DM_ACTIVATEME, 0, 0);
- if (si->dat)
- SetForegroundWindow(si->dat->pContainer->hwnd);
- }
- }
- return 1;
-}
-
-INT_PTR CList_EventDoubleclicked(WPARAM wParam, LPARAM lParam)
-{
- return CList_RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0);
-}
-
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- 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);
- else
- CList_RoomDoubleclicked(wParam, 0);
- }
- }
-
- return 0;
-}
-
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if (hContact) {
- char *szProto = GetContactProto(hContact);
- if (szProto)
- CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam );
- }
- return 0;
-}
-
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if (hContact == NULL)
- return 0;
-
- bool bEnabled = false;
- char *szProto = GetContactProto(hContact);
- if (szProto) {
- // display this menu item only for chats
- if ( db_get_b(hContact, szProto, "ChatRoom", 0 )) {
- // still hide it for offline protos
- if (CallProtoService( szProto, PS_GETSTATUS, 0, 0 ) != ID_STATUS_OFFLINE) {
- CLISTMENUITEM clmi = { sizeof(clmi) };
- clmi.flags = CMIM_NAME;
- if (db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE)
- clmi.pszName = (char*)LPGEN("Join chat");
- else
- clmi.pszName = (char*)LPGEN("Open chat window");
- Menu_ModifyItem(hJoinMenuItem, &clmi);
- bEnabled = true;
- } } }
-
- Menu_ShowItem(hJoinMenuItem, bEnabled);
- Menu_ShowItem(hLeaveMenuItem, bEnabled);
- return 0;
-}
-
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
-{
- return CList_PrebuildContactMenu(wParam, lParam);
-}
-
-void CList_CreateGroup(TCHAR* group)
-{
- if (!group)
- return;
-
- g_Settings.hGroup = Clist_GroupExists(group);
- if (g_Settings.hGroup == 0) {
- g_Settings.hGroup = Clist_CreateGroup(0, group);
-
- if (g_Settings.hGroup) {
- CallService(MS_CLUI_GROUPADDED, (WPARAM)g_Settings.hGroup, 0);
- CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)g_Settings.hGroup, 1);
- }
- }
-}
-
-BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const TCHAR* fmt, ...)
-{
- if (!fmt || lstrlen(fmt) < 1 || lstrlen(fmt) > 2000)
- return FALSE;
-
- TCHAR* szBuf = (TCHAR*)_alloca(4096 * sizeof(TCHAR));
-
- va_list marker;
- va_start(marker, fmt);
- mir_vsntprintf(szBuf, 4096, fmt, marker);
- va_end(marker);
-
- CLISTEVENT cle;
- cle.cbSize = sizeof(cle);
- cle.hContact = (HANDLE)hContact;
- cle.hDbEvent = (HANDLE)event;
- cle.flags = type + CLEF_TCHAR;
- cle.hIcon = Icon;
- cle.pszService = "GChat/DblClickEvent" ;
- cle.ptszTooltip = TranslateTS(szBuf);
- if (type) {
- if (!CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
- CallService(MS_CLIST_ADDEVENT, (WPARAM)hContact, (LPARAM)&cle);
- }
- else {
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)"chaticon");
- CallService(MS_CLIST_ADDEVENT, (WPARAM)hContact, (LPARAM)&cle);
- }
- return TRUE;
-}
-
-HANDLE CList_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))
- continue;
-
- ptrT roomid( db_get_tsa(hContact, pszModule, "ChatRoomID"));
- if (roomid != NULL && !lstrcmpi(roomid, pszRoom))
- return hContact;
- }
- return 0;
-}
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp
index e2f0d56fa0..88d00c2fce 100644
--- a/plugins/TabSRMM/src/chat/log.cpp
+++ b/plugins/TabSRMM/src/chat/log.cpp
@@ -89,7 +89,7 @@ static int Log_AppendIEView(LOGSTREAMDATA* streamData, BOOL simpleMode, TCHAR **
int lineLen, textCharsCount=0;
TCHAR* line = (TCHAR*)_alloca( 8001 * sizeof(TCHAR));
TCHAR* d;
- MODULEINFO *mi = MM_FindModule(streamData->si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(streamData->si->pszModule);
va_start(va, fmt);
lineLen = mir_vsntprintf( line, 8000, fmt, va);
@@ -556,7 +556,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
case 'c':
case 'f':
- if (g_Settings.bStripFormat || streamData->bStripFormat)
+ if (g_Settings.StripFormat || streamData->bStripFormat)
line += 2;
else if (line[1] != '\0' && line[2] != '\0') {
TCHAR szTemp3[3], c = *line;
@@ -573,7 +573,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
break;
case 'C':
case 'F':
- if (!g_Settings.bStripFormat && !streamData->bStripFormat) {
+ if (!g_Settings.StripFormat && !streamData->bStripFormat) {
int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin);
if (*line == 'C')
mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j + 1);
@@ -638,10 +638,11 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced,
return;
if (streamData->lin->ptszNick) {
- if (g_Settings.bLogLimitNames && lstrlen(streamData->lin->ptszNick) > 20) {
+ if (g_Settings.LogLimitNames && lstrlen(streamData->lin->ptszNick) > 20) {
lstrcpyn(szTemp, streamData->lin->ptszNick, 20);
lstrcpyn(szTemp + 20, _T("..."), 4);
- } else lstrcpyn(szTemp, streamData->lin->ptszNick, 511);
+ }
+ else lstrcpyn(szTemp, streamData->lin->ptszNick, 511);
if (g_Settings.bClickableNicks)
mir_sntprintf(szTemp2, SIZEOF(szTemp2), _T("~~++#%s#++~~"), szTemp);
@@ -738,20 +739,12 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced,
}
}
-TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time)
-{
- static TCHAR szTime[30];
- if ( !_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time)))
- _tcsncpy(szTime, TranslateT("<invalid>"), SIZEOF(szTime));
- return szTime;
-}
-
static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
int bufferAlloced, bufferEnd, i, me = 0;
LOGINFO * lin = streamData->lin;
- MODULEINFO *mi = MM_FindModule(streamData->si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(streamData->si->pszModule);
// guesstimate amount of memory for the RTF
bufferEnd = 0;
@@ -805,32 +798,35 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
bufferEnd += logIconBmpSize[iIndex];
}
- if (g_Settings.bTimeStampEventColour) {
+ if (g_Settings.TimeStampEventColour) {
// colored timestamps
static char szStyle[256];
+ LOGFONT &F = pci->aFonts[0].lf;
int iii;
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\\ul%d\\fs%u", iii + 1, aFonts[0].lf.lfWeight >= FW_BOLD ? 1 : 0,aFonts[0].lf.lfItalic,aFonts[0].lf.lfUnderline, 2 * abs(aFonts[0].lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0,F.lfItalic,F.lfUnderline, 2 * abs(F.lfHeight) * 74 / logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
- } else {
+ }
+ else {
iii = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, aFonts[0].lf.lfWeight >= FW_BOLD ? 1 : 0, aFonts[0].lf.lfItalic,aFonts[0].lf.lfUnderline ,2 * abs(aFonts[0].lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic,F.lfUnderline ,2 * abs(F.lfHeight) * 74 / logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
- } else
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(0, 0));
+ }
+ else Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(0, 0));
+
// insert a TAB if necessary to put the timestamp in the right position
if (g_Settings.dwIconFlags)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tab ");
//insert timestamp
- if (g_Settings.bShowTime) {
+ if (g_Settings.ShowTime) {
TCHAR szTimeStamp[30], szOldTimeStamp[30];
- lstrcpyn(szTimeStamp, MakeTimeStamp(g_Settings.pszTimeStamp, lin->time), 30);
- lstrcpyn(szOldTimeStamp, MakeTimeStamp(g_Settings.pszTimeStamp, streamData->si->LastTime), 30);
- if (!g_Settings.bShowTimeIfChanged || streamData->si->LastTime == 0 || lstrcmp(szTimeStamp, szOldTimeStamp)) {
+ lstrcpyn(szTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, lin->time), 30);
+ lstrcpyn(szOldTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, streamData->si->LastTime), 30);
+ if (!g_Settings.ShowTimeIfChanged || streamData->si->LastTime == 0 || lstrcmp(szTimeStamp, szOldTimeStamp)) {
streamData->si->LastTime = lin->time;
Log_AppendRTF(streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, _T("%s"), szTimeStamp);
}
@@ -840,7 +836,6 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
// Insert the nick
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) {
TCHAR pszTemp[300], *p1;
- STATUSINFO *ti;
char pszIndicator[3] = "\0\0";
int crNickIndex = 0;
//mad
@@ -848,7 +843,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
USERINFO *ui = streamData->si->pUsers;
while (ui) {
if (!lstrcmp(ui->pszNick, lin->ptszNick)) {
- ti = TM_FindStatus(streamData->si->pStatuses, TM_WordToString(streamData->si->pStatuses, ui->Status));
+ STATUSINFO *ti = pci->TM_FindStatus(streamData->si->pStatuses, pci->TM_WordToString(streamData->si->pStatuses, ui->Status));
if (ti && (int)ti->hIcon < streamData->si->iStatusCount) {
int id = streamData->si->iStatusCount - (int)ti->hIcon - 1;
switch (id) {
@@ -897,7 +892,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
_tcsnrplc(pszTemp, 300, _T("%s"), _T("~~++#%s#++~~"));
pszTemp[299] = 0;
}
- //Log_Append(&buffer, &bufferEnd, &bufferAlloced, "~~++#");
+
if (g_Settings.bColorizeNicksInLog && pszIndicator[0])
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex + 1);
}
@@ -907,12 +902,10 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
}
// Insert the message
- {
- i = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
- streamData->lin = lin;
- AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
- }
+ i = lin->bIsHighlighted ? 16 : EventToIndex(lin);
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
+ streamData->lin = lin;
+ AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
}
lin = lin->prev;
}
@@ -963,7 +956,8 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr
HWND hwndRich = GetDlgItem(hwndDlg, IDC_CHAT_LOG);
- LOGSTREAMDATA streamData = { 0 };
+ LOGSTREAMDATA streamData;
+ ZeroMemory(&streamData, sizeof(streamData));
streamData.hwnd = hwndRich;
streamData.si = si;
streamData.lin = lin;
@@ -1090,7 +1084,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr
* trim the message log to the number of most recent events
* this uses hidden marks in the rich text to find the events which should be deleted
*/
- if (si->wasTrimmed) {
+ if (si->bTrimmed) {
TCHAR szPattern[50];
FINDTEXTEX fi;
@@ -1105,7 +1099,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr
SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1);
SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
}
- si->wasTrimmed = FALSE;
+ si->bTrimmed = FALSE;
}
// scroll log to bottom if the log was previously scrolled to bottom, else restore old position
@@ -1157,13 +1151,13 @@ char * Log_CreateRtfHeader(MODULEINFO * mi)
// font table
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
for (i=0; i < OPTIONS_FONTCOUNT ; i++)
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, aFonts[i].lf.lfCharSet, aFonts[i].lf.lfFaceName);
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, pci->aFonts[i].lf.lfCharSet, pci->aFonts[i].lf.lfFaceName);
// colour table
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ;");
for (i=0; i < OPTIONS_FONTCOUNT; i++)
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(aFonts[i].color), GetGValue(aFonts[i].color), GetBValue(aFonts[i].color));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
for (i=0; i < mi->nColorCount; i++)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
@@ -1196,10 +1190,10 @@ char * Log_CreateRtfHeader(MODULEINFO * mi)
iIndent += ((g_Settings.bScaleIcons ? 14 : 20) * 1440) / logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
- if (g_Settings.bShowTime) {
+ if (g_Settings.ShowTime) {
int iSize = (g_Settings.LogTextIndent * 1440) / logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
- if (g_Settings.bLogIndentEnabled)
+ if (g_Settings.LogIndentEnabled)
iIndent += iSize;
}
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
@@ -1207,75 +1201,8 @@ char * Log_CreateRtfHeader(MODULEINFO * mi)
return buffer;
}
-#define RTFPICTHEADERMAXSIZE 78
-void LoadMsgLogBitmaps(void)
+void Log_SetStyles()
{
- HICON hIcon;
- HBITMAP hBmp, hoBmp;
- HDC hdc, hdcMem;
- BITMAPINFOHEADER bih = { 0 };
- int widthBytes, i;
- RECT rc;
- HBRUSH hBkgBrush;
- int rtfHeaderSize;
- PBYTE pBmpBits;
- int iIconSize;
- int sizeX = 0, sizeY = 0;
-
- if (hIcons[0])
- Utils::getIconSize(hIcons[0], sizeX, sizeY);
- else
- sizeX = 16;
-
- if (sizeX >= 12)
- iIconSize = g_Settings.bScaleIcons ? 12 : 16;
- else
- iIconSize = sizeX;
-
- hBkgBrush = CreateSolidBrush(M.GetDword(FONTMODULE, SRMSGSET_BKGCOLOUR_MUC, SRMSGDEFSET_BKGCOLOUR));
- bih.biSize = sizeof(bih);
- bih.biBitCount = 24;
- bih.biCompression = BI_RGB;
- bih.biHeight = iIconSize;
- bih.biPlanes = 1;
- bih.biWidth = iIconSize;
- widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
- rc.top = rc.left = 0;
- rc.right = iIconSize;
- rc.bottom = iIconSize;
- hdc = GetDC(NULL);
- hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
- hdcMem = CreateCompatibleDC(hdc);
- pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
- for (i=0; i < SIZEOF(pLogIconBmpBits); i++) {
- hIcon = hIcons[i];
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
- rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); //!!!!!!!!!!
- hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
- FillRect(hdcMem, &rc, hBkgBrush);
- DrawIconEx(hdcMem, 0, 1, hIcon, iIconSize, iIconSize, 0, NULL, DI_NORMAL);
-
- SelectObject(hdcMem, hoBmp);
- GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *) & bih, DIB_RGB_COLORS);
- {
- int n;
- for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!
- for (n = 0; n < widthBytes * bih.biHeight; n += 4)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
- }
- logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
- pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
- }
- mir_free(pBmpBits);
- DeleteDC(hdcMem);
- DeleteObject(hBmp);
- ReleaseDC(NULL, hdc);
- DeleteObject(hBkgBrush);
-
- /* cache RTF font headers */
-
- //get the number of pixels per logical inch
if (logPixelSY == 0) {
HDC hdc;
hdc = GetDC(NULL);
@@ -1284,13 +1211,11 @@ void LoadMsgLogBitmaps(void)
ReleaseDC(NULL, hdc);
}
- for (i=0; i < OPTIONS_FONTCOUNT; i++)
- mir_snprintf(CHAT_rtfFontsGlobal[i], RTFCACHELINESIZE, "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", i, i + 1, aFonts[i].lf.lfWeight >= FW_BOLD ? 1 : 0, aFonts[i].lf.lfItalic,aFonts[i].lf.lfUnderline ,2 * abs(aFonts[i].lf.lfHeight) * 74 / logPixelSY);
+ for (int i = 0; i < OPTIONS_FONTCOUNT; i++) {
+ LOGFONT &F = pci->aFonts[i].lf;
+ mir_snprintf(CHAT_rtfFontsGlobal[i], RTFCACHELINESIZE,
+ "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", i, i + 1,
+ F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / logPixelSY);
+ }
CHAT_rtffonts = &(CHAT_rtfFontsGlobal[0][0]);
}
-
-void FreeMsgLogBitmaps(void)
-{
- for (int i=0; i < SIZEOF(pLogIconBmpBits); i++)
- mir_free(pLogIconBmpBits[i]);
-}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 63d41a9599..4adb98d5f3 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -36,88 +36,242 @@
HANDLE g_hWindowList;
HMENU g_hMenu = NULL;
-FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HICON hIcons[30];
-HBRUSH hListBkgBrush = NULL;
-
+CHAT_MANAGER *pci;
TMUCSettings g_Settings;
-TCHAR *pszActiveWndID = 0;
-char *pszActiveWndModule = 0;
+static void OnAddLog(SESSION_INFO *si, int isOk)
+{
+ if (isOk && si->hWnd)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
-/*
- * load the group chat module
- */
+static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi)
+{
+ si->Highlight = g_Settings.Highlight;
+ if (mi) {
+ mi->idleTimeStamp = time(0);
+ pci->SM_BroadcastMessage(mi->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
+ }
+}
-int Chat_Load()
+static void OnSessionDblClick(SESSION_INFO *si)
{
- g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
- if (CreateServiceFunctions()) {
- HookEvents();
- CreateHookableEvents();
- OptionsInit();
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+}
+
+static void OnSessionRemove(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+}
+
+static void OnSessionRename(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
+}
+
+static void OnSessionReplace(SESSION_INFO *si)
+{
+ if (si->hContact)
+ Chat_SetFilters(si);
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+}
+
+static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSetTopic(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_INVALIDATEPANEL, 0, 0);
+}
+
+static void OnSetStatusBar(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+}
+
+static void OnNewUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd) {
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ if (si->dat)
+ GetMyNick(si->dat);
}
- return 0;
}
-/*
- * unload the module. final cleanup
- */
+static void OnChangeNick(SESSION_INFO *si)
+{
+ if (si->hWnd) {
+ if (si->dat)
+ GetMyNick(si->dat);
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+ }
+}
-int Chat_Unload(void)
+static void OnSetStatus(SESSION_INFO *si, int wStatus)
{
- db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
- db_set_w(NULL, "Chat", "splitY", (WORD)g_Settings.iSplitterY);
+ PostMessage(si->hWnd, GC_FIXTABICONS, 0, 0);
+}
- CList_SetAllOffline(TRUE, NULL);
+static void OnCreateModule(MODULEINFO *mi)
+{
+ mi->idleTimeStamp = time(0);
+}
- mir_free(pszActiveWndID);
- mir_free(pszActiveWndModule);
+static void OnLoadSettings()
+{
+ LOGFONT lf;
+ char szBuf[40];
- DestroyMenu(g_hMenu);
- DestroyHookableEvents();
- FreeIcons();
- OptionsUnInit();
- UnhookEvents();
- return 0;
+ g_Settings.iEventLimitThreshold = db_get_w(NULL, "Chat", "LogLimitThreshold", 20);
+ g_Settings.dwIconFlags = M.GetDword("Chat", "IconFlags", 0x0000);
+ g_Settings.bOpenInDefault = M.GetBool("Chat", "DefaultContainer", true);
+ g_Settings.bFlashWindowHightlight = M.GetBool("Chat", "FlashWindowHighlight", false);
+ g_Settings.UserListColors[CHAT_STATUS_NORMAL] = M.GetDword(CHAT_FONTMODULE, "Font18Col", RGB(0, 0, 0));
+ g_Settings.UserListColors[CHAT_STATUS_AWAY] = M.GetDword(CHAT_FONTMODULE, "Font19Col", RGB(170, 170, 170));
+ g_Settings.UserListColors[CHAT_STATUS_OFFLINE] = M.GetDword(CHAT_FONTMODULE, "Font5Col", RGB(160, 90, 90));
+ g_Settings.bBBCodeInPopups = M.GetByte("Chat", "BBCodeInPopups", 0) != 0;
+ g_Settings.bClassicIndicators = M.GetBool("Chat", "ClassicIndicators", false);
+ g_Settings.bLogClassicIndicators = M.GetBool("Chat", "LogClassicIndicators", false);
+ g_Settings.bAlternativeSorting = M.GetBool("Chat", "AlternativeSorting", true);
+ g_Settings.bAnnoyingHighlight = M.GetBool("Chat", "AnnoyingHighlight", false);
+ g_Settings.bCreateWindowOnHighlight = M.GetBool("Chat", "CreateWindowOnHighlight", true);
+
+ g_Settings.bLogSymbols = M.GetBool("Chat", "LogSymbols", true);
+ g_Settings.bClickableNicks = M.GetBool("Chat", "ClickableNicks", true);
+ g_Settings.bColorizeNicks = M.GetBool("Chat", "ColorizeNicks", true);
+ g_Settings.bColorizeNicksInLog = M.GetBool("Chat", "ColorizeNicksInLog", true);
+ g_Settings.bScaleIcons = M.GetBool("Chat", "ScaleIcons", true);
+ g_Settings.bUseDividers = M.GetBool("Chat", "UseDividers", true);
+ g_Settings.bDividersUsePopupConfig = M.GetBool("Chat", "DividersUsePopupConfig", true);
+
+ g_Settings.bDoubleClick4Privat = M.GetBool("Chat", "DoubleClick4Privat", false);
+ g_Settings.bShowContactStatus = M.GetBool("Chat", "ShowContactStatus", true);
+ g_Settings.bContactStatusFirst = M.GetBool("Chat", "ContactStatusFirst", false);
+
+ // nicklist
+ if (g_Settings.UserListFonts[0]) {
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_NORMAL]);
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_AWAY]);
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_OFFLINE]);
+ }
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 18, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_NORMAL] = CreateFontIndirect(&lf);
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 19, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_AWAY] = CreateFontIndirect(&lf);
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 5, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_OFFLINE] = CreateFontIndirect(&lf);
+
+ int ih = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
+ int ih2 = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_AWAY], false);
+ g_Settings.iNickListFontHeight = max(M.GetByte("Chat", "NicklistRowDist", 12), (ih > ih2 ? ih : ih2));
+
+ for (int i = 0; i < 7; i++) {
+ mir_snprintf(szBuf, 20, "NickColor%d", i);
+ g_Settings.nickColors[i] = M.GetDword("Chat", szBuf, g_Settings.UserListColors[0]);
+ }
+ g_Settings.nickColors[5] = M.GetDword("Chat", "NickColor5", GetSysColor(COLOR_HIGHLIGHT));
+ g_Settings.nickColors[6] = M.GetDword("Chat", "NickColor6", GetSysColor(COLOR_HIGHLIGHTTEXT));
+
+ if (g_Settings.SelectionBGBrush)
+ DeleteObject(g_Settings.SelectionBGBrush);
+ g_Settings.SelectionBGBrush = CreateSolidBrush(g_Settings.nickColors[5]);
+
+ Log_SetStyles();
}
-void LoadLogIcons(void)
-{
- ZeroMemory(hIcons, sizeof(HICON) * (ICON_STATUS5 - ICON_ACTION));
- hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
- hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
- hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
- hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
- hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
- hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
- hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
- hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
- hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
- hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
- hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
- hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
- hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
- hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
- hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
- hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
- hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
- hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
- hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
- hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
-}
-
-void LoadIcons(void)
-{
- for (int i=0; i < 20; i++)
- hIcons[i] = NULL;
-
- LoadLogIcons();
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void Chat_ModulesLoaded()
+{
+ ZeroMemory(pci->hIcons, sizeof(HICON)* (ICON_STATUS5 - ICON_ACTION));
+ pci->hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
+ pci->hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
+ pci->hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
+ pci->hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
+ pci->hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
+ pci->hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
+ pci->hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
+ pci->hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
+ pci->hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
+ pci->hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
+ pci->hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
+ pci->hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
+ pci->hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
+ pci->hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
+ pci->hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
+ pci->hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
+ pci->hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
+ pci->hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
+ pci->hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
+ pci->hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
+
g_Settings.hIconOverlay = LoadIconEx(IDI_OVERLAY, "overlay", 16, 16);
- LoadMsgLogBitmaps();
}
-void FreeIcons(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+// load the group chat module
+
+static CHAT_MANAGER saveCI;
+
+int Chat_Load()
{
- FreeMsgLogBitmaps();
+ mir_getCI(&g_Settings);
+ saveCI = *pci;
+ pci->cbModuleInfo = sizeof(MODULEINFO);
+ pci->cbSession = sizeof(SESSION_INFO);
+ pci->OnCreateModule = OnCreateModule;
+ pci->OnNewUser = OnNewUser;
+
+ pci->OnSetStatus = OnSetStatus;
+ pci->OnSetTopic = OnSetTopic;
+
+ pci->OnAddLog = OnAddLog;
+
+ pci->OnCreateSession = OnCreateSession;
+ pci->OnSessionRemove = OnSessionRemove;
+ pci->OnSessionRename = OnSessionRename;
+ pci->OnSessionReplace = OnSessionReplace;
+ pci->OnSessionDblClick = OnSessionDblClick;
+
+ pci->OnEventBroadcast = OnEventBroadcast;
+ pci->OnSetStatusBar = OnSetStatusBar;
+ pci->OnChangeNick = OnChangeNick;
+ pci->ShowRoom = ShowRoom;
+ pci->OnLoadSettings = OnLoadSettings;
+
+ // this operation is unsafe, that's why we restore the old pci state on exit
+ pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
+
+ g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
+
+ OnLoadSettings();
+ OptionsInit();
+ return 0;
+}
+
+/*
+ * unload the module. final cleanup
+ */
+
+int Chat_Unload(void)
+{
+ *pci = saveCI;
+ DestroyMenu(g_hMenu);
+ OptionsUnInit();
+ return 0;
}
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp
index 928a821a2d..b14d53dbbf 100644
--- a/plugins/TabSRMM/src/chat/manager.cpp
+++ b/plugins/TabSRMM/src/chat/manager.cpp
@@ -23,482 +23,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\commonheaders.h"
-#define WINDOWS_COMMANDS_MAX 30
-#define STATUSICONCOUNT 6
-
-static SESSION_INFO *s_WndList = NULL;
-static MODULEINFO *s_ModList = NULL;
-
-void SetActiveSession(const TCHAR *pszID, const char* pszModule)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si)
- SetActiveSessionEx(si);
-}
-
-void SetActiveSessionEx(SESSION_INFO *si)
-{
- if (si) {
- replaceStrT(pszActiveWndID, si->ptszID);
- replaceStr(pszActiveWndModule, si->pszModule);
- }
-}
-
-SESSION_INFO* GetActiveSession(void)
-{
- SESSION_INFO *si = SM_FindSession(pszActiveWndID, pszActiveWndModule);
- if (si)
- return si;
-
- return s_WndList;
-}
-
//---------------------------------------------------
// Session Manager functions
//
// Keeps track of all sessions and its windows
//---------------------------------------------------
-SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule)
-{
- if (!pszID || !pszModule)
- return NULL;
-
- if (SM_FindSession(pszID, pszModule))
- return NULL;
-
- SESSION_INFO *node = (SESSION_INFO*)mir_calloc(sizeof(SESSION_INFO));
- node->ptszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
-
- MODULEINFO *mi = MM_FindModule(pszModule);
- if (mi) {
- mi->idleTimeStamp = time(0);
- SM_BroadcastMessage(pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
- }
-
- if (s_WndList == NULL) { // list is empty
- s_WndList = node;
- node->next = NULL;
- }
- else {
- node->next = s_WndList;
- s_WndList = node;
- }
- node->Highlight = g_Settings.Highlight;
- return node;
-}
-
-int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, bool removeContact)
-{
- if (!pszModule)
- return FALSE;
-
- SESSION_INFO* pTemp = s_WndList, *pLast = NULL;
- while (pTemp != NULL) {
- if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { // match
- DWORD dw = pTemp->dwItemData;
-
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
-
- DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
-
- if (pLast == NULL)
- s_WndList = pTemp->next;
- else
- pLast->next = pTemp->next;
-
- UM_RemoveAll(&pTemp->pUsers);
- TM_RemoveAll(&pTemp->pStatuses);
- LM_RemoveAll(&pTemp->pLog, &pTemp->pLogEnd);
- pTemp->iStatusCount = 0;
- pTemp->nUsersInNicklist = 0;
-
- if (pTemp->hContact)
- CList_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");
-
- if (removeContact)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->hContact, 0);
-
- mir_free(pTemp->pszModule);
- mir_free(pTemp->ptszID);
- mir_free(pTemp->ptszName);
- mir_free(pTemp->ptszStatusbarText);
- mir_free(pTemp->ptszTopic);
- mir_free(pTemp->pszID);
- mir_free(pTemp->pszName);
-
- // delete commands
- COMMAND_INFO *pCurComm = pTemp->lpCommands;
- while (pCurComm != NULL) {
- COMMAND_INFO *pNext = pCurComm->next;
- mir_free(pCurComm->lpCommand);
- mir_free(pCurComm);
- pCurComm = pNext;
- }
-
- mir_free(pTemp);
- if (pszID)
- return (int)dw;
- if (pLast)
- pTemp = pLast->next;
- else
- pTemp = s_WndList;
- }
- else {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- }
- return FALSE;
-}
-
void SM_RemoveContainer(TContainerData *pContainer)
{
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
if (si->pContainer == pContainer)
si->pContainer = NULL;
}
-SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule)
-{
- if (!pszID || !pszModule)
- return NULL;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
- if (!lstrcmpi(si->ptszID, pszID) && !lstrcmpiA(si->pszModule, pszModule))
- return si;
-
- return NULL;
-}
-
-BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- UM_RemoveAll(&si->pUsers);
- si->nUsersInNicklist = 0;
- if (si->iType != GCW_SERVER)
- si->bInitDone = FALSE;
-
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- UM_SetStatusEx(si->pUsers, pszText, flags);
- if (si->hWnd)
- RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO* ui, char *szIndicator)
-{
- if (!ui || !si)
- return NULL;
-
- *szIndicator = 0;
-
- STATUSINFO *ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status));
- if (ti == NULL)
- return hIcons[ICON_STATUS0];
-
- if ((INT_PTR)ti->hIcon >= STATUSICONCOUNT)
- return ti->hIcon;
-
- int id = si->iStatusCount - (int)ti->hIcon - 1;
- if (id == 0) {
- *szIndicator = 0;
- return hIcons[ICON_STATUS0];
- }
- if (id == 1) {
- *szIndicator = '+';
- return hIcons[ICON_STATUS1];
- }
- if (id == 2) {
- *szIndicator = '%';
- return hIcons[ICON_STATUS2];
- }
- if (id == 3) {
- *szIndicator = '@';
- return hIcons[ICON_STATUS3];
- }
- if (id == 4) {
- *szIndicator = '!';
- return hIcons[ICON_STATUS4];
- }
- if (id == 5) {
- *szIndicator = '*';
- return hIcons[ICON_STATUS5];
- }
-
- return hIcons[ICON_STATUS0];
-}
-
-BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bIsHighLight)
-{
- int bManyFix = 0;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if (!lstrcmpiA(si->pszModule, gce->pDest->pszModule)) {
- if (UM_FindUser(si->pUsers, gce->ptszUID)) {
- if (si->bInitDone) {
- if (SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- else if (si->hWnd && si->bInitDone)
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
-
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(si, gce, bIsHighLight, bManyFix);
- bManyFix ++;
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.bLoggingEnabled)
- LogToFile(si, gce);
- }
- }
- }
- }
-
- return 0;
-}
-
-BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted)
-{
- if (!pszID || !pszModule)
- return TRUE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return TRUE;
-
- if (!lstrcmpi(si->ptszID, pszID) && !lstrcmpiA(si->pszModule, pszModule)) {
- LOGINFO *li = LM_AddEvent(&si->pLog, &si->pLogEnd);
- si->iEventCount += 1;
-
- li->iType = gce->pDest->iType;
- li->ptszNick = mir_tstrdup(gce->ptszNick);
- li->ptszText = mir_tstrdup(gce->ptszText);
- li->ptszStatus = mir_tstrdup(gce->ptszStatus);
- li->ptszUserInfo = mir_tstrdup(gce->ptszUserInfo);
-
- li->bIsMe = gce->bIsMe != 0;
- li->bIsHighlighted = bIsHighlighted != 0;
- li->time = gce->time;
-
- if (g_Settings.iEventLimit > 0 && si->iEventCount > g_Settings.iEventLimit + g_Settings.iEventLimitThreshold) {
- LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings.iEventLimit);
- si->wasTrimmed = TRUE;
- si->iEventCount = g_Settings.iEventLimit;
- }
- }
-
- return TRUE;
-}
-
-USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
-{
- if (!pszID || !pszModule)
- return NULL;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si) {
- USERINFO *p = UM_AddUser(si->pStatuses, &si->pUsers, pszUID, pszNick, wStatus);
- si->nUsersInNicklist++;
- return p;
- }
-
- return 0;
-}
-
-BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID)
-{
- if (!pszID || !pszModule || !pszUID)
- return FALSE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- UM_SortUser(&si->pUsers, pszUID);
- return TRUE;
-}
-
-BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID)
-{
- if (!pszModule || !pszUID)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- USERINFO *ui = UM_FindUser(si->pUsers, pszUID);
- if (ui) {
- si->nUsersInNicklist--;
-
- UM_RemoveUser(&si->pUsers, pszUID);
-
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
-
- if (pszID)
- return TRUE;
- }
- }
- }
-
- return 0;
-}
-
-USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index)
-{
- if (!pszModule)
- return NULL;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- return UM_FindUserFromIndex(si->pUsers, index);
-}
-
-STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
-{
- if (!pszID || !pszModule)
- return NULL;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- STATUSINFO *ti = TM_AddStatus(&si->pStatuses, pszStatus, &si->iStatusCount);
- if (ti)
- si->iStatusCount++;
- return ti;
-}
-
-BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
-{
- if (!pszID || !pszModule)
- return FALSE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- USERINFO *ui = UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
-}
-
-BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus)
-{
- if (!pszID || !pszModule)
- return FALSE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- USERINFO *ui = UM_SetContactStatus(si->pUsers, pszUID, wStatus);
- if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
-}
-
-BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
-{
- if (!pszID || !pszModule)
- return FALSE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- USERINFO* ui = UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
-}
-
-LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- for (SESSION_INFO *si = s_WndList; si && pszModule; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- if (si->hWnd) {
- LRESULT i = SendMessage(si->hWnd, msg, wParam, lParam);
- if (pszID)
- return i;
- }
- if (pszID)
- return 0;
- }
- }
-
- return 0;
-}
-
-BOOL SM_PostMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (!pszID || !pszModule)
- return 0;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si && si->hWnd)
- return PostMessage(si->hWnd, msg, wParam, lParam);
-
- return FALSE;
-}
-
-BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
-{
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if (!pszModule || !lstrcmpiA(si->pszModule, pszModule)) {
- if (si->hWnd) {
- if (bAsync)
- PostMessage(si->hWnd, msg, wParam, lParam);
- else
- SendMessage(si->hWnd, msg, wParam, lParam);
- }
- }
- }
-
- return TRUE;
-}
-
BOOL SM_ReconfigureFilters()
{
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
Chat_SetFilters(si);
return TRUE;
@@ -506,224 +46,15 @@ BOOL SM_ReconfigureFilters()
BOOL SM_InvalidateLogDirectories()
{
- mir_cslock lck(cs);
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
si->pszLogFileName[0] = si->pszLogFileName[1] = 0;
return TRUE;
}
-BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- si->wStatus = wStatus;
-
- if (si->hContact) {
- if (si->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
- db_unset(si->hContact, "CList", "Hidden");
-
- db_set_w(si->hContact, si->pszModule, "Status", (WORD)wStatus);
- }
-
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText)
-{
- if (!pszModule || !pszText)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- if (si->iType == GCW_CHATROOM)
- DoEventHook(si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, pszText, 0);
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- USERINFO* ui = UM_FindUser(si->pUsers, pszUID);
- if (ui)
- replaceStrT(ui->pszUID, pszNewUID);
-
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
- USERINFO* ui = UM_FindUser(si->pUsers, gce->ptszUID);
- if (ui) {
- replaceStrT(ui->pszNick, gce->ptszText);
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
- if (si->hWnd) {
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- if (si->dat)
- GetMyNick(si->dat);
- SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
- }
- }
- if (pszID)
- return TRUE;
- }
- }
-
- return TRUE;
-}
-
-BOOL SM_RemoveAll(void)
-{
- while (s_WndList) {
- SESSION_INFO *pLast = s_WndList->next;
-
- if (s_WndList->hWnd)
- SendMessage(s_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- DoEventHook(s_WndList->ptszID, s_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)s_WndList->dwItemData);
- if (s_WndList->hContact)
- CList_SetOffline(s_WndList->hContact, s_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
- db_set_s(s_WndList->hContact, s_WndList->pszModule , "Topic", "");
- db_unset(s_WndList->hContact, "CList", "StatusMsg");
- db_set_s(s_WndList->hContact, s_WndList->pszModule, "StatusBar", "");
-
- UM_RemoveAll(&s_WndList->pUsers);
- TM_RemoveAll(&s_WndList->pStatuses);
- LM_RemoveAll(&s_WndList->pLog, &s_WndList->pLogEnd);
- s_WndList->iStatusCount = 0;
- s_WndList->nUsersInNicklist = 0;
-
- mir_free(s_WndList->pszModule);
- mir_free(s_WndList->ptszID);
- mir_free(s_WndList->ptszName);
- mir_free(s_WndList->ptszStatusbarText);
- mir_free(s_WndList->ptszTopic);
-
- while (s_WndList->lpCommands != NULL) {
- COMMAND_INFO *pNext = s_WndList->lpCommands->next;
- mir_free(s_WndList->lpCommands->lpCommand);
- mir_free(s_WndList->lpCommands);
- s_WndList->lpCommands = pNext;
- }
-
- mir_free(s_WndList);
- s_WndList = pLast;
- }
- s_WndList = NULL;
- return TRUE;
-}
-
-void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand)
-{
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if (lstrcmpi(si->ptszID, pszID) == 0 && lstrcmpiA(si->pszModule, pszModule) == 0) { // match
- COMMAND_INFO *node = (COMMAND_INFO *)mir_alloc(sizeof(COMMAND_INFO));
- node->lpCommand = mir_strdup(lpNewCommand);
- node->last = NULL; // always added at beginning!
- // new commands are added at start
- if (si->lpCommands == NULL) {
- node->next = NULL;
- si->lpCommands = node;
- }
- else {
- node->next = si->lpCommands;
- si->lpCommands->last = node; // hmm, weird
- si->lpCommands = node;
- }
- si->lpCurrentCommand = NULL; // current command
- si->wCommandsNum++;
-
- if (si->wCommandsNum > WINDOWS_COMMANDS_MAX) {
- COMMAND_INFO *pCurComm = si->lpCommands;
- COMMAND_INFO *pLast;
- while (pCurComm->next != NULL) {
- pCurComm = pCurComm->next;
- }
- pLast = pCurComm->last;
- mir_free(pCurComm->lpCommand);
- mir_free(pCurComm);
- pLast->next = NULL;
- // done
- si->wCommandsNum--;
- }
- }
- }
-}
-
-char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was.
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- COMMAND_INFO *pPrevCmd = NULL;
- if (si->lpCurrentCommand != NULL) {
- if (si->lpCurrentCommand->next != NULL) // not NULL
- pPrevCmd = si->lpCurrentCommand->next; // next command (newest at beginning)
- else
- pPrevCmd = si->lpCurrentCommand;
- }
- else pPrevCmd = si->lpCommands;
-
- si->lpCurrentCommand = pPrevCmd; // make it the new command
- return pPrevCmd ? pPrevCmd->lpCommand : NULL;
-}
-
-char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- COMMAND_INFO *pNextCmd = NULL;
- if (si->lpCurrentCommand != NULL)
- pNextCmd = si->lpCurrentCommand->last; // last command (newest at beginning)
-
- si->lpCurrentCommand = pNextCmd; // make it the new command
- return pNextCmd ? pNextCmd->lpCommand : NULL;
-}
-
-int SM_GetCount(const char* pszModule)
-{
- int count = 0;
-
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
- if (!lstrcmpiA(pszModule, si->pszModule))
- count++;
-
- return count;
-}
-
SESSION_INFO* SM_FindSessionByHWND(HWND hWnd)
{
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
if (si->hWnd == hWnd)
return si;
@@ -732,28 +63,13 @@ SESSION_INFO* SM_FindSessionByHWND(HWND hWnd)
SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h)
{
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
if (si->hContact == h)
return si;
return NULL;
}
-SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem)
-{
- int count = 0;
- for (SESSION_INFO *si = s_WndList; si; si = si->next) {
- if (!lstrcmpiA(pszModule, si->pszModule)) {
- if (iItem == count)
- return si;
-
- count++;
- }
- }
-
- return NULL;
-}
-
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
@@ -764,7 +80,7 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
pszCurrent = pszOriginal;
SESSION_INFO *pResult = NULL;
- for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ for (SESSION_INFO *si = pci->wndList; si; si = si->next)
if (si != currSession && !lstrcmpiA(pszModule, si->pszModule))
if (my_strstri(si->ptszName, pszOriginal) == si->ptszName)
if (prevSession != si && lstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(si->ptszName, pszName) < 0)) {
@@ -774,555 +90,3 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
return pResult;
}
-
-char* SM_GetUsers(SESSION_INFO *si)
-{
- if (si == NULL)
- return NULL;
-
- for (SESSION_INFO *psi = s_WndList; psi; psi = psi->next)
- if (psi == si)
- goto LBL_Found;
- return NULL;
-
-LBL_Found:
- USERINFO *utemp = si->pUsers;
- if (utemp == NULL)
- return NULL;
-
- char* p = NULL;
- int alloced = 0;
-
- while (utemp != NULL) {
- int pLen = lstrlenA(p), nameLen = lstrlen(utemp->pszUID);
- if (pLen + nameLen + 2 > alloced)
- p = (char *)mir_realloc(p, alloced += 4096);
- WideCharToMultiByte(CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen + 1, 0, 0);
- lstrcpyA(p + pLen + nameLen, " ");
- utemp = utemp->next;
- }
-
- return p;
-}
-
-//---------------------------------------------------
-// Module Manager functions
-//
-// Necessary to keep track of all modules
-// that has registered with the plugin
-//---------------------------------------------------
-
-MODULEINFO* MM_AddModule(const char* pszModule)
-{
- if (!pszModule)
- return NULL;
- if (!MM_FindModule(pszModule)) {
- MODULEINFO *node = (MODULEINFO*) mir_alloc(sizeof(MODULEINFO));
- ZeroMemory(node, sizeof(MODULEINFO));
-
- node->pszModule = (char*)mir_alloc(lstrlenA(pszModule) + 1);
- lstrcpyA(node->pszModule, pszModule);
- node->idleTimeStamp = time(0);
- if (s_ModList == NULL) { // list is empty
- s_ModList = node;
- node->next = NULL;
- } else {
- node->next = s_ModList;
- s_ModList = node;
- }
- return node;
- }
- return FALSE;
-}
-
-void MM_FontsChanged(void)
-{
- MODULEINFO *pTemp = s_ModList;
- while (pTemp != NULL) {
- pTemp->pszHeader = Log_CreateRtfHeader(pTemp);
- pTemp = pTemp->next;
- }
- return;
-}
-
-MODULEINFO* MM_FindModule(const char* pszModule)
-{
- MODULEINFO *pTemp = s_ModList;
-
- if (!pszModule)
- return NULL;
-
- while (pTemp != NULL) {
- if (lstrcmpiA(pTemp->pszModule, pszModule) == 0)
- return pTemp;
-
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-// stupid thing..
-void MM_FixColors()
-{
- MODULEINFO *pTemp = s_ModList;
-
- while (pTemp != NULL) {
- CheckColorsInModule(pTemp->pszModule);
- pTemp = pTemp->next;
- }
- return;
-}
-
-BOOL MM_RemoveAll(void)
-{
- while (s_ModList != NULL) {
- MODULEINFO *pLast = s_ModList->next;
- mir_free(s_ModList->pszModule);
- mir_free(s_ModList->ptszModDispName);
- if (s_ModList->pszHeader)
- mir_free(s_ModList->pszHeader);
- mir_free(s_ModList->crColors);
-
- mir_free(s_ModList);
- s_ModList = pLast;
- }
- s_ModList = NULL;
- return TRUE;
-}
-
-//---------------------------------------------------
-// Status manager functions
-//
-// Necessary to keep track of what user statuses
-// per window nicklist that is available
-//---------------------------------------------------
-
-STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int* iCount)
-{
- if (!ppStatusList || !pszStatus)
- return NULL;
-
- if (!TM_FindStatus(*ppStatusList, pszStatus)) {
- STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
- node->pszGroup = mir_tstrdup(pszStatus);
- node->hIcon = (HICON)(*iCount);
- while ((int)node->hIcon > STATUSICONCOUNT - 1)
- node->hIcon--;
-
- if (*ppStatusList == NULL) { // list is empty
- node->Status = 1;
- *ppStatusList = node;
- node->next = NULL;
- } else {
- node->Status = ppStatusList[0]->Status * 2;
- node->next = *ppStatusList;
- *ppStatusList = node;
- }
- return node;
-
- }
- return FALSE;
-}
-
-STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus)
-{
- if (!pStatusList || !pszStatus)
- return NULL;
-
- for (STATUSINFO *si = pStatusList; si != NULL; si = si->next)
- if (lstrcmpi(si->pszGroup, pszStatus) == 0)
- return si;
-
- return 0;
-}
-
-WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus)
-{
- if (!pStatusList || !pszStatus)
- return 0;
-
- for (STATUSINFO *si = pStatusList; si != NULL; si = si->next) {
- if (lstrcmpi(si->pszGroup, pszStatus) == 0)
- return si->Status;
-
- if (si->next == NULL)
- return pStatusList->Status;
- }
- return 0;
-}
-
-TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status)
-{
- if (!pStatusList)
- return NULL;
-
- for (STATUSINFO *si = pStatusList; si != NULL; si = si->next)
- if (si->Status&Status) {
- Status -= si->Status;
- if (Status == 0)
- return si->pszGroup;
- }
-
- return 0;
-}
-
-BOOL TM_RemoveAll(STATUSINFO** ppStatusList)
-{
- if (!ppStatusList)
- return FALSE;
-
- while (*ppStatusList != NULL) {
- STATUSINFO *pLast = ppStatusList[0]->next;
- mir_free(ppStatusList[0]->pszGroup);
- if ((int)ppStatusList[0]->hIcon > 10)
- DestroyIcon(ppStatusList[0]->hIcon);
- mir_free(*ppStatusList);
- *ppStatusList = pLast;
- }
- *ppStatusList = NULL;
- return TRUE;
-}
-
-//---------------------------------------------------
-// User manager functions
-//
-// Necessary to keep track of the users
-// in a window nicklist
-//---------------------------------------------------
-
-//MAD: alternative sorting by Nullbie
-static int sttCompareNicknames(const TCHAR *s1, const TCHAR *s2)
-{
- if (!s1 && !s2) return 0;
- if (!s1 && s2) return +1;
- if (s1 && !s2) return -1;
-
- // skip rubbish
- while (*s1 && !_istalpha(*s1)) ++s1;
- while (*s2 && !_istalpha(*s2)) ++s2;
-
- // are there ~0veRy^kEwL_n1kz?
- if (!*s1 && !*s2) return 0;
- if (!*s1 && *s2) return +1;
- if (*s1 && !*s2) return -1;
-
- // compare tails
- return lstrcmpi(s1, s2);
-}
-//
-
-static int UM_CompareItem(USERINFO * u1, const TCHAR* pszNick, WORD wStatus)
-{
- WORD dw1 = u1->Status;
- WORD dw2 = wStatus;
-
- for (int i=0; i < 8; i++) {
- if ((dw1 & 1) && !(dw2 & 1))
- return -1;
-
- if ((dw2 & 1) && !(dw1 & 1))
- return 1;
-
- if ((dw1 & 1) && (dw2 & 1)) {
- if (g_Settings.bAlternativeSorting)
- return sttCompareNicknames(u1->pszNick, pszNick);
- return lstrcmp(u1->pszNick, pszNick);
- }
- dw1 = dw1 >> 1;
- dw2 = dw2 >> 1;
- }
- if (g_Settings.bAlternativeSorting)
- return sttCompareNicknames(u1->pszNick, pszNick);
- return lstrcmp(u1->pszNick, pszNick);
-}
-
-USERINFO* UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
-{
- USERINFO *pTemp = *ppUserList, *pLast = NULL;
- if (!pTemp || !pszUID)
- return NULL;
-
- while (pTemp && lstrcmpi(pTemp->pszUID, pszUID)) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- if (pTemp == NULL)
- return NULL;
-
- USERINFO *node = pTemp;
- if (pLast)
- pLast->next = pTemp->next;
- else
- *ppUserList = pTemp->next;
- pTemp = *ppUserList;
-
- pLast = NULL;
-
- while (pTemp && UM_CompareItem(pTemp, node->pszNick, node->Status) <= 0) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- if (*ppUserList == NULL) { // list is empty
- *ppUserList = node;
- node->next = NULL;
- }
- else if (pLast) {
- node->next = pTemp;
- pLast->next = node;
- }
- else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
-
- return node;
-}
-
-USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
-{
- if (!pStatusList || !ppUserList)
- return NULL;
-
- USERINFO *pTemp = *ppUserList, *pLast = NULL;
- while (pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
- node->pszUID = mir_tstrdup(pszUID);
-
- if (*ppUserList == NULL) { // list is empty
- *ppUserList = node;
- node->next = NULL;
- }
- else if (pLast) {
- node->next = pTemp;
- pLast->next = node;
- }
- else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
-
- return node;
-}
-
-USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
- if (!lstrcmpi(pTemp->pszUID, pszUID))
- return pTemp;
-
- return 0;
-}
-
-USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index)
-{
- if (!pUserList)
- return NULL;
-
- int i=0;
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next, i++)
- if (i == index)
- return pTemp;
-
- return NULL;
-}
-
-USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->Status |= status;
- return pTemp;
- }
-
- return 0;
-}
-
-USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->ContactStatus = status;
- return pTemp;
- }
-
- return 0;
-}
-
-BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags)
-{
- bool bOnlyMe = (flags & GC_SSE_ONLYLISTED) != 0, bAwaySetStatus = (flags & GC_SSE_ONLINE) != 0, bOfflineSetStatus = (flags & GC_SSE_OFFLINE) != 0;
- char cDelimiter = (flags & GC_SSE_TABDELIMITED) ? '\t' : ' ';
-
- for (USERINFO *p = pUserList; p != NULL; p = p->next) {
- if (!bOnlyMe)
- p->iStatusEx = CHAT_STATUS_NORMAL;
-
- if (pszText == NULL)
- continue;
-
- TCHAR* s = (TCHAR*)_tcsstr(pszText, p->pszUID);
- if (s == NULL)
- continue;
-
- p->iStatusEx = CHAT_STATUS_NORMAL;
- if (s == pszText || s[-1] == cDelimiter) {
- int len = lstrlen(p->pszUID);
- if (s[len] == cDelimiter || s[len] == '\0') {
- if (!bOnlyMe || bAwaySetStatus)
- p->iStatusEx = CHAT_STATUS_AWAY;
- else if (bOfflineSetStatus)
- p->iStatusEx = CHAT_STATUS_OFFLINE;
- }
- }
- }
- return TRUE;
-}
-
-USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->Status &= ~status;
- return pTemp;
- }
-
- return 0;
-}
-
-TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
-{
- if (!pUserList || !pszOriginal || !pszCurrent)
- return NULL;
-
- TCHAR *pszName = NULL;
- for (USERINFO *pTemp = pUserList; pTemp != NULL; pTemp = pTemp->next)
- if (my_strstri(pTemp->pszNick, pszOriginal) == pTemp->pszNick)
- if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0))
- pszName = pTemp->pszNick;
-
- return pszName;
-}
-
-BOOL UM_RemoveUser(USERINFO** ppUserList, const TCHAR* pszUID)
-{
- if (!ppUserList || !pszUID)
- return FALSE;
-
- USERINFO *pTemp = *ppUserList, *pLast = NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- if (pLast == NULL)
- *ppUserList = pTemp->next;
- else
- pLast->next = pTemp->next;
- mir_free(pTemp->pszNick);
- mir_free(pTemp->pszUID);
- mir_free(pTemp);
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return FALSE;
-}
-
-BOOL UM_RemoveAll(USERINFO** ppUserList)
-{
- if (!ppUserList)
- return FALSE;
-
- while (*ppUserList != NULL) {
- USERINFO *pLast = ppUserList[0]->next;
- mir_free(ppUserList[0]->pszUID);
- mir_free(ppUserList[0]->pszNick);
- mir_free(*ppUserList);
- *ppUserList = pLast;
- }
- *ppUserList = NULL;
- return TRUE;
-}
-
-//---------------------------------------------------
-// Log manager functions
-//
-// Necessary to keep track of events
-// in a window log
-//---------------------------------------------------
-
-LOGINFO * LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
-{
- if (!ppLogListStart || !ppLogListEnd)
- return NULL;
-
- LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO));
-
- if (*ppLogListStart == NULL) { // list is empty
- *ppLogListStart = node;
- *ppLogListEnd = node;
- node->next = NULL;
- node->prev = NULL;
- } else {
- ppLogListStart[0]->prev = node;
- node->next = *ppLogListStart;
- *ppLogListStart = node;
- ppLogListStart[0]->prev = NULL;
- }
-
- return node;
-}
-
-BOOL LM_TrimLog(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd, int iCount)
-{
- LOGINFO *pTemp = *ppLogListEnd;
- while (pTemp != NULL && iCount > 0) {
- *ppLogListEnd = pTemp->prev;
- if (*ppLogListEnd == NULL)
- *ppLogListStart = NULL;
-
- mir_free(pTemp->ptszNick);
- mir_free(pTemp->ptszUserInfo);
- mir_free(pTemp->ptszText);
- mir_free(pTemp->ptszStatus);
- mir_free(pTemp);
- pTemp = *ppLogListEnd;
- iCount--;
- }
- ppLogListEnd[0]->next = NULL;
-
- return TRUE;
-}
-
-BOOL LM_RemoveAll(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
-{
- while (*ppLogListStart != NULL) {
- LOGINFO *pLast = ppLogListStart[0]->next;
- mir_free(ppLogListStart[0]->ptszText);
- mir_free(ppLogListStart[0]->ptszNick);
- mir_free(ppLogListStart[0]->ptszStatus);
- mir_free(ppLogListStart[0]->ptszUserInfo);
- mir_free(*ppLogListStart);
- *ppLogListStart = pLast;
- }
- *ppLogListStart = NULL;
- *ppLogListEnd = NULL;
- return TRUE;
-}
diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp
index 8a564fb0e7..605341583d 100644
--- a/plugins/TabSRMM/src/chat/message.cpp
+++ b/plugins/TabSRMM/src/chat/message.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO *si)
{
int i;
- MODULEINFO * pMod = MM_FindModule(si->pszModule);
+ MODULEINFO *pMod = pci->MM_FindModule(si->pszModule);
for (i=0; i < pMod->nColorCount ; i++)
if (pIndex[i] == iCol)
@@ -52,9 +52,8 @@ static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO *si)
while (p2 && p2 < pEnd) {
if (sscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
- int i;
- MODULEINFO * pMod = MM_FindModule(si->pszModule);
- for (i=0; i < pMod->nColorCount ; i ++)
+ MODULEINFO * pMod = pci->MM_FindModule(si->pszModule);
+ for (int i=0; i < pMod->nColorCount ; i ++)
if (pMod->crColors[i] == RGB(atoi(szRed), atoi(szGreen), atoi(szBlue)))
pIndex[i] = iIndex;
}
@@ -92,8 +91,9 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
// create an index of colors in the module and map them to
// corresponding colors in the RTF color table
- mir_ptr<int> pIndex((int*)mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount));
- for (i=0; i < MM_FindModule(si->pszModule)->nColorCount ; i++)
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
+ mir_ptr<int> pIndex((int*)mir_alloc(sizeof(int)*mi->nColorCount));
+ for (i = 0; i < mi->nColorCount; i++)
pIndex[i] = -1;
CreateColorMap(pszText, pIndex, si);
@@ -123,52 +123,63 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
iInd = RTFColorToIndex(pIndex, iCol, si);
bJustRemovedRTF = TRUE;
- if (bTextHasStarted || iInd >= 0)
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd);
- } else if (!memcmp(p1, "\\highlight", 10)) { //background color
+ // if (bTextHasStarted || iInd >= 0)
+ // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd);
+ }
+ else if (!memcmp(p1, "\\highlight", 10)) { //background color
int iCol, iInd;
iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol);
iInd = RTFColorToIndex(pIndex, iCol, si);
bJustRemovedRTF = TRUE;
- if (bTextHasStarted || iInd >= 0)
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd);
- } else if (!memcmp(p1, "\\lang", 5)) { // language id
+ // if (bTextHasStarted || iInd >= 0)
+ // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd);
+ }
+ else if (!memcmp(p1, "\\lang", 5)) { // language id
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 5 + ReadInteger(p1 + 5, NULL);
- } else if (!memcmp(p1, "\\par", 4)) { // newline
+ }
+ else if (!memcmp(p1, "\\par", 4)) { // newline
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 4;
strcpy(InsertThis, "\n");
- } else if (!memcmp(p1, "\\endash", 7)) {
+ }
+ else if (!memcmp(p1, "\\endash", 7)) {
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x93");
- } else if (!memcmp(p1, "\\emdash", 7)) {
+ }
+ else if (!memcmp(p1, "\\emdash", 7)) {
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x94");
- } else if (!memcmp(p1, "\\bullet", 7)) {
+ }
+ else if (!memcmp(p1, "\\bullet", 7)) {
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\xA2");
- } else if (!memcmp(p1, "\\line", 5)) { // newline
+ }
+ else if (!memcmp(p1, "\\line", 5)) { // newline
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 5;
strcpy(InsertThis, "\n");
- } else if (!memcmp(p1, "\\b", 2)) { //bold
+ }
+ else if (!memcmp(p1, "\\b", 2)) { //bold
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = (p1[2] != '0') ? 2 : 3;
strcpy(InsertThis, (p1[2] != '0') ? "%b" : "%B");
- } else if (!memcmp(p1, "\\i", 2)) { // italics
+ }
+ else if (!memcmp(p1, "\\i", 2)) { // italics
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = (p1[2] != '0') ? 2 : 3;
strcpy(InsertThis, (p1[2] != '0') ? "%i" : "%I");
- } else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars
+ }
+ else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars
bTextHasStarted = bJustRemovedRTF = TRUE;
iUcMode = p1[3] - '0';
iRemoveChars = 4;
- } else if (!memcmp(p1, "\\ul", 3)) { // underlined
+ }
+ else if (!memcmp(p1, "\\ul", 3)) { // underlined
bTextHasStarted = bJustRemovedRTF = TRUE;
if (p1[3] == 'n')
iRemoveChars = 7;
@@ -177,22 +188,23 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
else
iRemoveChars = 3;
mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U");
- } else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char
+ }
+ else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 2 + ReadInteger(p1 + 2, NULL);
- } else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
+ }
+ else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
iRemoveChars = 2;
mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]);
- } else if (p1[1] == '~') { // non-breaking space
+ }
+ else if (p1[1] == '~') { // non-breaking space
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
iRemoveChars = 2;
strcpy(InsertThis, "\xC2\xA0");
}
-
-
else if (!memcmp(p1, "\\tab",4)) { // tab
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
@@ -223,7 +235,6 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x99");
}
-
else if (p1[1] == '\'') { // special character
char tmp[4], *p3 = tmp;
bTextHasStarted = TRUE;
@@ -239,8 +250,10 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
sscanf(tmp, "%x", InsertThis);
InsertThis[1] = 0;
- } else iRemoveChars = 2;
- } else if (bJustRemovedRTF) { // remove unknown RTF command
+ }
+ else iRemoveChars = 2;
+ }
+ else if (bJustRemovedRTF) { // remove unknown RTF command
int j = 1;
bJustRemovedRTF = TRUE;
while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0')
@@ -266,6 +279,7 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
iRemoveChars = 1;
strcpy(InsertThis, "%%");
break;
+
case ' ': // remove spaces following a RTF command
if (bJustRemovedRTF)
iRemoveChars = 1;
@@ -284,25 +298,26 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
MoveMemory(p1 + lstrlenA(InsertThis) , p1 + iRemoveChars, lstrlenA(p1) - iRemoveChars + 1);
CopyMemory(p1, InsertThis, lstrlenA(InsertThis));
p1 += lstrlenA(InsertThis);
- } else p1++;
+ }
+ else p1++;
}
return mir_utf8decodeW(pszText);
}
-static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
+static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
static DWORD dwRead;
- char ** ppText = (char **) dwCookie;
-
+ char **ppText = (char**)dwCookie;
if (*ppText == NULL) {
*ppText = (char *)mir_alloc(cb + 1);
memcpy(*ppText, pbBuff, cb);
(*ppText)[cb] = 0;
*pcb = cb;
dwRead = cb;
- } else {
- char *p = (char *)mir_alloc(dwRead + cb + 1);
+ }
+ else {
+ char *p = (char*)mir_alloc(dwRead + cb + 1);
memcpy(p, *ppText, dwRead);
memcpy(p + dwRead, pbBuff, cb);
p[dwRead + cb] = 0;
@@ -316,18 +331,16 @@ static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbB
char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si)
{
- EDITSTREAM stream;
- char* pszText = NULL;
- DWORD dwFlags;
-
if (hwndDlg == 0 || si == 0)
return NULL;
+ char* pszText = NULL;
+ EDITSTREAM stream;
ZeroMemory(&stream, sizeof(stream));
stream.pfnCallback = Chat_Message_StreamCallback;
- stream.dwCookie = (DWORD_PTR) & pszText; // pass pointer to pointer
+ stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
- dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16);
+ DWORD dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16);
SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), EM_STREAMOUT, dwFlags, (LPARAM)&stream);
return pszText; // pszText contains the text
}
diff --git a/plugins/TabSRMM/src/chat/muchighlight.cpp b/plugins/TabSRMM/src/chat/muchighlight.cpp
index 079eddc6a8..f2161f769d 100644
--- a/plugins/TabSRMM/src/chat/muchighlight.cpp
+++ b/plugins/TabSRMM/src/chat/muchighlight.cpp
@@ -132,7 +132,7 @@ int CMUCHighlight::match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dwF
int words = 0;
M.startTimer();
#endif
- TCHAR *tszCleaned = ::RemoveFormatting(pgce->ptszText, true, true);
+ TCHAR *tszCleaned = pci->RemoveFormatting(pgce->ptszText);
TCHAR *p = tszCleaned;
TCHAR *p1;
UINT i = 0;
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp
index 0d2e849f18..4ea5b77987 100644
--- a/plugins/TabSRMM/src/chat/options.cpp
+++ b/plugins/TabSRMM/src/chat/options.cpp
@@ -398,7 +398,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p
static void LoadLogFonts(void)
{
for (int i=0; i < OPTIONS_FONTCOUNT; i++)
- LoadMsgDlgFont(FONTSECTION_CHAT, i, &aFonts[i].lf, &aFonts[i].color, CHAT_FONTMODULE);
+ LoadMsgDlgFont(FONTSECTION_CHAT, i, &pci->aFonts[i].lf, &pci->aFonts[i].color, CHAT_FONTMODULE);
}
static IconItem _icons[] =
@@ -586,11 +586,8 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, SIZEOF(branch1));
SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, SIZEOF(branch2));
- LoadGlobalSettings();
- MM_FontsChanged();
- FreeMsgLogBitmaps();
- LoadMsgLogBitmaps();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->MM_FontsChanged();
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
SM_ReconfigureFilters();
}
return TRUE;
@@ -807,22 +804,19 @@ void RegisterFontServiceFonts() {
int FontServiceFontsChanged(WPARAM,LPARAM)
{
LoadLogFonts();
- FreeMsgLogBitmaps();
- LoadMsgLogBitmaps();
LOGFONT lf;
LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE);
HFONT hFont = CreateFontIndirect(&lf);
- int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, true);
+ int iText = GetTextPixelSize(pci->MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, true);
DeleteObject(hFont);
g_Settings.LogTextIndent = iText;
g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10;
- g_Settings.bLogIndentEnabled = M.GetBool("Chat", "LogIndentEnabled", true);
+ g_Settings.LogIndentEnabled = M.GetBool("Chat", "LogIndentEnabled", true);
- LoadGlobalSettings();
- MM_FontsChanged();
- MM_FixColors();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->MM_FontsChanged();
+ pci->MM_FixColors();
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
PluginConfig.reloadSettings();
CSkin::initAeroEffect();
@@ -857,13 +851,13 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
SetDlgItemText(hwndDlg, IDC_TIMESTAMP, g_Settings.pszTimeStamp);
SetDlgItemText(hwndDlg, IDC_OUTSTAMP, g_Settings.pszOutgoingNick);
SetDlgItemText(hwndDlg, IDC_INSTAMP, g_Settings.pszIncomingNick);
- CheckDlgButton(hwndDlg, IDC_LOGGING, g_Settings.bLoggingEnabled);
+ CheckDlgButton(hwndDlg, IDC_LOGGING, g_Settings.LoggingEnabled);
SetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, g_Settings.pszLogDir);
- Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, g_Settings.bLoggingEnabled);
- Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, g_Settings.bLoggingEnabled);
+ Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, g_Settings.LoggingEnabled);
+ Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, g_Settings.LoggingEnabled);
SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETRANGE, 0, MAKELONG(10000, 0));
SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LoggingLimit", 100), 0));
- Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.bLoggingEnabled);
+ Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.LoggingEnabled);
if (ServiceExists(MS_UTILS_REPLACEVARS)) {
TCHAR tszTooltipText[2048];
@@ -924,7 +918,6 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
*/
case IDC_MUC_OPENLOGBASEDIR: {
OPENFILENAME ofn = {0};
- SESSION_INFO si = {0};
TCHAR tszReturnName[MAX_PATH];
TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10];
TCHAR tszTemp[MAX_PATH + 20], *p = 0, *p1 = 0;
@@ -1015,8 +1008,8 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText1, iLen + 1);
db_set_ts(NULL, "Chat", "LogDirectory", pszText1);
mir_free(pszText1);
- g_Settings.bLoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED;
- db_set_b(0, "Chat", "LoggingEnabled", g_Settings.bLoggingEnabled);
+ g_Settings.LoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED;
+ db_set_b(0, "Chat", "LoggingEnabled", g_Settings.LoggingEnabled);
}
else {
db_unset(NULL, "Chat", "LogDirectory");
@@ -1065,27 +1058,24 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
db_set_w(NULL, "Chat", "LogLimit", (WORD)iLen);
mir_free(pszText);
- if (hListBkgBrush)
- DeleteObject(hListBkgBrush);
- hListBkgBrush = CreateSolidBrush(M.GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR));
+ if (pci->hListBkgBrush)
+ DeleteObject(pci->hListBkgBrush);
+ pci->hListBkgBrush = CreateSolidBrush(M.GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR));
LoadLogFonts();
- FreeMsgLogBitmaps();
- LoadMsgLogBitmaps();
LOGFONT lf;
LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE);
HFONT hFont = CreateFontIndirect(&lf);
- int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, true);
+ int iText = GetTextPixelSize(pci->MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, true);
DeleteObject(hFont);
g_Settings.LogTextIndent = iText;
g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10;
- g_Settings.bLogIndentEnabled = M.GetBool("Chat", "LogIndentEnabled", true);
+ g_Settings.LogIndentEnabled = M.GetBool("Chat", "LogIndentEnabled", true);
- LoadGlobalSettings();
- MM_FontsChanged();
- MM_FixColors();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->MM_FontsChanged();
+ pci->MM_FixColors();
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
PluginConfig.reloadSettings();
CacheMsgLogIcons();
@@ -1201,9 +1191,9 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
db_set_b(0, "Chat", "SkipWhenNoWindow", IsDlgButtonChecked(hwndDlg, IDC_NOPOPUPSFORCLOSEDWINDOWS) ? 1 : 0);
db_set_b(0, "Chat", "TrayIconInactiveOnly", IsDlgButtonChecked(hwndDlg, IDC_TRAYONLYFORINACTIVE) ? 1 : 0);
- LoadGlobalSettings();
- MM_FontsChanged();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+
+ pci->MM_FontsChanged();
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
SM_ReconfigureFilters();
return TRUE;
}
@@ -1213,171 +1203,16 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
return FALSE;
}
-void LoadGlobalSettings(void)
-{
- LOGFONT lf;
- char szBuf[40];
-
- g_Settings.bLogLimitNames = M.GetBool("Chat", "LogLimitNames", true);
- g_Settings.bShowTime = M.GetBool("Chat", "ShowTimeStamp", true);
- g_Settings.bShowTimeIfChanged = M.GetBool("Chat", "ShowTimeStampIfChanged", false);
- g_Settings.bTimeStampEventColour = M.GetBool("Chat", "TimeStampEventColour", false);
- g_Settings.iEventLimit = db_get_w(NULL, "Chat", "LogLimit", 100);
- g_Settings.iEventLimitThreshold = db_get_w(NULL, "Chat", "LogLimitThreshold", 20);
- g_Settings.dwIconFlags = M.GetDword("Chat", "IconFlags", 0x0000);
- g_Settings.LoggingLimit = (size_t)db_get_w(NULL, "Chat", "LoggingLimit", 100);
- g_Settings.bLoggingEnabled = M.GetBool("Chat", "LoggingEnabled", false);
- g_Settings.bOpenInDefault = M.GetBool("Chat", "DefaultContainer", true);
- g_Settings.bFlashWindow = M.GetBool("Chat", "FlashWindow", false);
- g_Settings.bFlashWindowHightlight = M.GetBool("Chat", "FlashWindowHighlight", false);
- g_Settings.UserListColors[CHAT_STATUS_NORMAL] = M.GetDword(CHAT_FONTMODULE, "Font18Col", RGB(0, 0, 0));
- g_Settings.UserListColors[CHAT_STATUS_AWAY] = M.GetDword(CHAT_FONTMODULE, "Font19Col", RGB(170, 170, 170));
- g_Settings.UserListColors[CHAT_STATUS_OFFLINE] = M.GetDword(CHAT_FONTMODULE, "Font5Col", RGB(160, 90, 90));
- g_Settings.crUserListBGColor = M.GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR);
- g_Settings.bStripFormat = M.GetBool("Chat", "StripFormatting", false);
- g_Settings.bTrayIconInactiveOnly = M.GetBool("Chat", "TrayIconInactiveOnly", true);
- g_Settings.bBBCodeInPopups = M.GetByte("Chat", "BBCodeInPopups", 0) != 0;
- g_Settings.bAddColonToAutoComplete = M.GetBool("Chat", "AddColonToAutoComplete", true);
- g_Settings.iPopupStyle = M.GetByte("Chat", "PopupStyle", 1);
- g_Settings.iPopupTimeout = db_get_w(NULL, "Chat", "PopupTimeout", 3);
- g_Settings.crPUBkgColour = M.GetDword("Chat", "PopupColorBG", GetSysColor(COLOR_WINDOW));
- g_Settings.crPUTextColour = M.GetDword("Chat", "PopupColorText", 0);
- g_Settings.bClassicIndicators = M.GetBool("Chat", "ClassicIndicators", false);
-
- g_Settings.bLogClassicIndicators = M.GetBool("Chat", "LogClassicIndicators", false);
- g_Settings.bAlternativeSorting = M.GetBool("Chat", "AlternativeSorting", true);
- g_Settings.bAnnoyingHighlight = M.GetBool("Chat", "AnnoyingHighlight", false);
- g_Settings.bCreateWindowOnHighlight = M.GetBool("Chat", "CreateWindowOnHighlight", true);
-
- g_Settings.bLogSymbols = M.GetBool("Chat", "LogSymbols", true);
- g_Settings.bClickableNicks = M.GetBool("Chat", "ClickableNicks", true);
- g_Settings.bColorizeNicks = M.GetBool("Chat", "ColorizeNicks", true);
- g_Settings.bColorizeNicksInLog = M.GetBool("Chat", "ColorizeNicksInLog", true);
- g_Settings.bScaleIcons = M.GetBool("Chat", "ScaleIcons", true);
- g_Settings.bUseDividers = M.GetBool("Chat", "UseDividers", true);
- g_Settings.bDividersUsePopupConfig = M.GetBool("Chat", "DividersUsePopupConfig", true);
-
- g_Settings.bDoubleClick4Privat = M.GetBool("Chat", "DoubleClick4Privat", false);
- g_Settings.bShowContactStatus = M.GetBool("Chat", "ShowContactStatus", true);
- g_Settings.bContactStatusFirst = M.GetBool("Chat", "ContactStatusFirst", false);
-
- if (hListBkgBrush)
- DeleteObject(hListBkgBrush);
- hListBkgBrush = CreateSolidBrush(M.GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR));
-
- InitSetting(g_Settings.pszTimeStamp, "HeaderTime", _T("[%H:%M]"));
- InitSetting(g_Settings.pszTimeStampLog, "LogTimestamp", _T("[%d %b %y %H:%M]"));
- InitSetting(g_Settings.pszIncomingNick, "HeaderIncoming", _T("%n:"));
- InitSetting(g_Settings.pszOutgoingNick, "HeaderOutgoing", _T("%n:"));
-
- DBVARIANT dbv;
-
- if (!db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
- lstrcpyn(g_Settings.pszLogDir, dbv.ptszVal, MAX_PATH);
- db_free(&dbv);
- }
- else lstrcpyn(g_Settings.pszLogDir, DEFLOGFILENAME, MAX_PATH);
-
- g_Settings.pszLogDir[MAX_PATH - 1] = 0;
-
- g_Settings.bLogIndentEnabled = M.GetBool("Chat", "LogIndentEnabled", true);
-
- // nicklist
-
- if (g_Settings.UserListFonts[0]) {
- DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_NORMAL]);
- DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_AWAY]);
- DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_OFFLINE]);
- }
-
- LoadMsgDlgFont(FONTSECTION_CHAT, 18, &lf, NULL, CHAT_FONTMODULE);
- g_Settings.UserListFonts[CHAT_STATUS_NORMAL] = CreateFontIndirect(&lf);
-
- LoadMsgDlgFont(FONTSECTION_CHAT, 19, &lf, NULL, CHAT_FONTMODULE);
- g_Settings.UserListFonts[CHAT_STATUS_AWAY] = CreateFontIndirect(&lf);
-
- LoadMsgDlgFont(FONTSECTION_CHAT, 5, &lf, NULL, CHAT_FONTMODULE);
- g_Settings.UserListFonts[CHAT_STATUS_OFFLINE] = CreateFontIndirect(&lf);
-
- int ih = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
- int ih2 = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_AWAY], false);
- g_Settings.iNickListFontHeight = max(M.GetByte("Chat", "NicklistRowDist", 12), (ih > ih2 ? ih : ih2));
-
- for (int i=0; i < 7; i++) {
- mir_snprintf(szBuf, 20, "NickColor%d", i);
- g_Settings.nickColors[i] = M.GetDword("Chat", szBuf, g_Settings.UserListColors[0]);
- }
- g_Settings.nickColors[5] = M.GetDword("Chat", "NickColor5", GetSysColor(COLOR_HIGHLIGHT));
- g_Settings.nickColors[6] = M.GetDword("Chat", "NickColor6", GetSysColor(COLOR_HIGHLIGHTTEXT));
- if (g_Settings.SelectionBGBrush)
- DeleteObject(g_Settings.SelectionBGBrush);
- g_Settings.SelectionBGBrush = CreateSolidBrush(g_Settings.nickColors[5]);
-}
-
-static void FreeGlobalSettings(void)
-{
- mir_free(g_Settings.pszTimeStamp);
- mir_free(g_Settings.pszTimeStampLog);
- mir_free(g_Settings.pszIncomingNick);
- mir_free(g_Settings.pszOutgoingNick);
- for (int i=0; i < SIZEOF(g_Settings.UserListFonts); i++)
- if (g_Settings.UserListFonts[i])
- DeleteObject(g_Settings.UserListFonts[i]);
-
- if (g_Settings.SelectionBGBrush)
- DeleteObject(g_Settings.SelectionBGBrush);
-
- delete g_Settings.Highlight;
-}
-
int OptionsInit(void)
{
LoadLogFonts();
- LOGFONT lf;
- LoadMsgDlgFont(FONTSECTION_CHAT, 17, &lf, NULL, CHAT_FONTMODULE);
- lstrcpy(lf.lfFaceName, _T("MS Shell Dlg"));
- lf.lfUnderline = lf.lfItalic = lf.lfStrikeOut = 0;
- lf.lfHeight = -17;
- lf.lfWeight = FW_BOLD;
- ZeroMemory(&g_Settings, sizeof(TMUCSettings));
- g_Settings.NameFont = CreateFontIndirect(&lf);
- g_Settings.iSplitterX = db_get_w(NULL, "Chat", "SplitterX", 105);
- if (g_Settings.iSplitterX <= 50)
- g_Settings.iSplitterX = 105;
- g_Settings.iSplitterY = db_get_w(NULL, "Chat", "splitY", 50);
- if (g_Settings.iSplitterY <= 20)
- g_Settings.iSplitterY = 50;
- g_Settings.hGroup = 0;
- LoadGlobalSettings();
g_Settings.Highlight = new CMUCHighlight();
- SkinAddNewSoundEx("ChatMessage", LPGEN("Group chats"), LPGEN("Incoming message"));
- SkinAddNewSoundEx("ChatSent", LPGEN("Group chats"), LPGEN("Outgoing message"));
- SkinAddNewSoundEx("ChatHighlight", LPGEN("Group chats"), LPGEN("Message is highlighted"));
- SkinAddNewSoundEx("ChatAction", LPGEN("Group chats"), LPGEN("User has performed an action"));
- SkinAddNewSoundEx("ChatJoin", LPGEN("Group chats"), LPGEN("User has joined"));
- SkinAddNewSoundEx("ChatPart", LPGEN("Group chats"), LPGEN("User has left"));
- SkinAddNewSoundEx("ChatKick", LPGEN("Group chats"), LPGEN("User has kicked some other user"));
- SkinAddNewSoundEx("ChatMode", LPGEN("Group chats"), LPGEN("User's status was changed"));
- SkinAddNewSoundEx("ChatNick", LPGEN("Group chats"), LPGEN("User has changed name"));
- SkinAddNewSoundEx("ChatNotice", LPGEN("Group chats"), LPGEN("User has sent a notice"));
- SkinAddNewSoundEx("ChatQuit", LPGEN("Group chats"), LPGEN("User has disconnected"));
- SkinAddNewSoundEx("ChatTopic", LPGEN("Group chats"), LPGEN("The topic has been changed"));
-
- LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE);
- HFONT hFont = CreateFontIndirect(&lf);
- int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, true);
- DeleteObject(hFont);
- g_Settings.LogTextIndent = iText;
- g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10;
return 0;
}
int OptionsUnInit(void)
{
- FreeGlobalSettings();
- DeleteObject(hListBkgBrush);
- DeleteObject(g_Settings.NameFont);
return 0;
}
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp
index 41c9c9d5be..5457c2edce 100644
--- a/plugins/TabSRMM/src/chat/services.cpp
+++ b/plugins/TabSRMM/src/chat/services.cpp
@@ -33,336 +33,6 @@
#include "..\commonheaders.h"
-CRITICAL_SECTION cs;
-
-HANDLE hSendEvent, hBuildMenuEvent;
-
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
-
-int Chat_ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- char * mods[3] = {"Chat", CHAT_FONTMODULE};
- CallService("DBEditorpp/RegisterModule", (WPARAM)mods, (LPARAM)2);
-
- LoadIcons();
-
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = -2000090001;
- mi.flags = CMIF_DEFAULT;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_JOIN );
- mi.pszName = LPGEN("&Join");
- mi.pszService = "GChat/JoinChat";
- hJoinMenuItem = Menu_AddContactMenuItem(&mi);
-
- mi.position = -2000090000;
- mi.flags = CMIF_NOTOFFLINE;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_LEAVE );
- mi.pszName = LPGEN("&Leave");
- mi.pszService = "GChat/LeaveChat";
- hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
-
- CList_SetAllOffline(TRUE, NULL);
- return 0;
-}
-
-int Chat_PreShutdown()
-{
- SM_RemoveAll();
- MM_RemoveAll();
- return 0;
-}
-
-int Chat_IconsChanged(WPARAM wParam, LPARAM lParam)
-{
- FreeMsgLogBitmaps();
-
- LoadLogIcons();
- LoadMsgLogBitmaps();
- //MM_IconsChanged();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, FALSE);
- return 0;
-}
-
-INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam)
-{
- if (!lParam)
- return -1;
-
- mir_cslock lck(cs);
- return SM_GetCount((char *)lParam);
-}
-
-INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam)
-{
- GC_INFO *gci = (GC_INFO *) lParam;
- if (!gci || !gci->pszModule)
- return 1;
-
- mir_cslock lck(cs);
- SESSION_INFO *si;
- if (gci->Flags & BYINDEX)
- si = SM_FindSessionByIndex(gci->pszModule, gci->iItem);
- else
- si = SM_FindSession(gci->pszID, gci->pszModule);
- if (si == NULL)
- return 1;
-
- if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
- if (gci->Flags & HCONTACT) gci->hContact = si->hContact;
- if (gci->Flags & TYPE) gci->iType = si->iType;
- if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist;
- if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si);
-
- if (gci->Flags & ID) gci->pszID = si->ptszID;
- if (gci->Flags & NAME) gci->pszName = si->ptszName;
- return 0;
-}
-
-INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
-{
- GCREGISTER *gcr = (GCREGISTER *)lParam;
- if (gcr == NULL)
- return GC_REGISTER_ERROR;
-
- if (gcr->cbSize != sizeof(GCREGISTER))
- return GC_REGISTER_WRONGVER;
-
- mir_cslock lck(cs);
- MODULEINFO *mi = MM_AddModule(gcr->pszModule);
- if (mi == NULL)
- return GC_REGISTER_ERROR;
-
- mi->ptszModDispName = mir_tstrdup(gcr->ptszDispName);
- mi->bBold = (gcr->dwFlags & GC_BOLD) != 0;
- mi->bUnderline = (gcr->dwFlags & GC_UNDERLINE) != 0;
- mi->bItalics = (gcr->dwFlags & GC_ITALICS) != 0;
- mi->bColor = (gcr->dwFlags & GC_COLOR) != 0;
- mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0;
- mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
- mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
- mi->iMaxText = gcr->iMaxText;
- mi->nColorCount = gcr->nColors;
- if (gcr->nColors > 0) {
- mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF)* gcr->nColors);
- memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors);
- }
- mi->pszHeader = 0;
-
- CheckColorsInModule((char*)gcr->pszModule);
- CList_SetAllOffline(TRUE, gcr->pszModule);
- return 0;
-}
-
-INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
-{
- GCSESSION *gcw = (GCSESSION *)lParam;
- if (gcw == NULL)
- return GC_NEWSESSION_ERROR;
-
- if (gcw->cbSize != sizeof(GCSESSION))
- return GC_NEWSESSION_WRONGVER;
-
- mir_cslock lck(cs);
- MODULEINFO *mi = MM_FindModule(gcw->pszModule);
- if (mi == NULL)
- return GC_NEWSESSION_ERROR;
-
- // create a new session and set the defaults
- SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule);
- if (si != NULL) {
- TCHAR szTemp[256];
-
- si->dwItemData = gcw->dwItemData;
- if (gcw->iType != GCW_SERVER)
- si->wStatus = ID_STATUS_ONLINE;
- si->iType = gcw->iType;
- si->dwFlags = gcw->dwFlags;
- si->ptszName = mir_tstrdup(gcw->ptszName);
- si->ptszStatusbarText = mir_tstrdup(gcw->ptszStatusbarText);
- si->iSplitterX = g_Settings.iSplitterX;
- si->bFilterEnabled = db_get_b(si->hContact, "Chat", "FilterEnabled", M.GetByte("Chat", "FilterEnabled", 0)) != 0;
- si->bNicklistEnabled = M.GetByte("Chat", "ShowNicklist", 1) != 0;
-
- if (mi->bColor) {
- si->iFG = 4;
- si->bFGSet = TRUE;
- }
- if (mi->bBkgColor) {
- si->iBG = 2;
- si->bBGSet = TRUE;
- }
- 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);
- db_set_s(si->hContact, si->pszModule , "Topic", "");
- db_unset(si->hContact, "CList", "StatusMsg");
- if (si->ptszStatusbarText)
- db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->hContact, si->pszModule, "StatusBar", "");
- if (si->hContact)
- Chat_SetFilters(si);
- }
- else {
- SESSION_INFO* si2 = SM_FindSession(gcw->ptszID, gcw->pszModule);
- if (si2) {
- UM_RemoveAll(&si2->pUsers);
- TM_RemoveAll(&si2->pStatuses);
-
- si2->iStatusCount = 0;
- si2->nUsersInNicklist = 0;
-
- if (si2->hContact)
- Chat_SetFilters(si2);
- if (si2->hWnd)
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- }
-
- return 0;
-}
-
-static int DoControl(GCEVENT *gce, WPARAM wp)
-{
- SESSION_INFO *si;
-
- switch(gce->pDest->iType) {
- case GC_EVENT_CONTROL:
- switch (wp) {
- case WINDOW_HIDDEN:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- si->bInitDone = TRUE;
- SetActiveSession(si->ptszID, si->pszModule);
- if (si->hWnd)
- ShowRoom(si, wp, FALSE);
- }
- return 0;
-
- case WINDOW_MINIMIZE:
- case WINDOW_MAXIMIZE:
- case WINDOW_VISIBLE:
- case SESSION_INITDONE:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- si->bInitDone = TRUE;
- if (wp != SESSION_INITDONE || M.GetByte("Chat", "PopupOnJoin", 0) == 0)
- ShowRoom(si, wp, TRUE);
- return 0;
- }
- break;
-
- case SESSION_OFFLINE:
- SM_SetOffline(gce->pDest->ptszID, gce->pDest->pszModule);
- // fall through
-
- case SESSION_ONLINE:
- SM_SetStatus(gce->pDest->ptszID, gce->pDest->pszModule, wp == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
- break;
-
- case WINDOW_CLEARLOG:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- LM_RemoveAll(&si->pLog, &si->pLogEnd);
- si->iEventCount = 0;
- si->LastTime = 0;
- }
- break;
-
- case SESSION_TERMINATE:
- return SM_RemoveSession(gce->pDest->ptszID, gce->pDest->pszModule, (gce->dwFlags & GCEF_REMOVECONTACT) != 0);
- }
- SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
- break;
-
- case GC_EVENT_CHUID:
- if (gce->ptszText)
- SM_ChangeUID(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText);
- break;
-
- case GC_EVENT_CHANGESESSIONAME:
- if (gce->ptszText) {
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- replaceStrT(si->ptszName, gce->ptszText);
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
- }
- }
- break;
-
- case GC_EVENT_SETITEMDATA:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si)
- si->dwItemData = gce->dwItemData;
- break;
-
- case GC_EVENT_GETITEMDATA:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- gce->dwItemData = si->dwItemData;
- return si->dwItemData;
- }
- return 0;
-
- case GC_EVENT_SETSBTEXT:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- replaceStrT(si->ptszStatusbarText, gce->ptszText);
- if (si->ptszStatusbarText)
- db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->hContact, si->pszModule, "StatusBar", "");
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
- }
- break;
-
- case GC_EVENT_ACK:
- SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0);
- break;
-
- case GC_EVENT_SENDMESSAGE:
- if (gce->ptszText)
- SM_SendUserMessage(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText);
- break;
-
- case GC_EVENT_SETSTATUSEX:
- SM_SetStatusEx(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText, gce->dwItemData);
- break;
-
- default:
- return 1;
- }
- return 0;
-}
-
-static void AddUser(GCEVENT *gce)
-{
- SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO *ui = SM_AddUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszNick, status);
- if (ui) {
- ui->pszNick = mir_tstrdup(gce->ptszNick);
-
- if (gce->bIsMe)
- si->pMe = ui;
-
- ui->Status = status;
- ui->Status |= si->pStatuses->Status;
-
- if (si->hWnd) {
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- if (si->dat)
- GetMyNick(si->dat);
- }
- }
- }
-}
-
HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup)
{
HANDLE hContact = si->hContact;
@@ -520,212 +190,3 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
if (pContainer)
si->hWnd = CreateNewRoom(pContainer, si, TRUE, TRUE, FALSE);
}
-
-INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
-{
- if (CMimAPI::m_shutDown)
- return 0;
-
- GCEVENT *gce = (GCEVENT*)lParam;
- if (gce == NULL)
- return GC_EVENT_ERROR;
-
- GCDEST *gcd = gce->pDest;
- if (gcd == NULL)
- return GC_EVENT_ERROR;
-
- if (gce->cbSize != sizeof(GCEVENT))
- return GC_EVENT_WRONGVER;
-
- if (!IsEventSupported(gcd->iType))
- return GC_EVENT_ERROR;
-
- LPCSTR pMod = NULL;
- LPCTSTR pWnd = NULL;
- SESSION_INFO *si = NULL;
- bool bIsHighlighted = false, bRemoveFlag = false;
-
- mir_cslock lck(cs);
-
- // Do different things according to type of event
- switch (gcd->iType) {
- case GC_EVENT_ADDGROUP:
- {
- STATUSINFO *si = SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
- if (si && gce->dwItemData)
- si->hIcon = CopyIcon((HICON)gce->dwItemData);
- }
- return 0;
-
- case GC_EVENT_CHUID:
- case GC_EVENT_CHANGESESSIONAME:
- case GC_EVENT_SETITEMDATA:
- case GC_EVENT_GETITEMDATA:
- case GC_EVENT_CONTROL:
- case GC_EVENT_SETSBTEXT:
- case GC_EVENT_ACK:
- case GC_EVENT_SENDMESSAGE :
- case GC_EVENT_SETSTATUSEX :
- return DoControl(gce, wParam);
-
- case GC_EVENT_SETCONTACTSTATUS:
- return SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
-
- case GC_EVENT_TOPIC:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- if (gce->ptszText) {
- replaceStrT(si->ptszTopic, RemoveFormatting(gce->ptszText));
- db_set_ts(si->hContact, si->pszModule , "Topic", /*RemoveFormatting*/(si->ptszTopic));
- if (M.GetByte("Chat", "TopicOnClist", 1))
- db_set_ts(si->hContact, "CList" , "StatusMsg", /*RemoveFormatting*/(si->ptszTopic));
- if (si->hWnd)
- SendMessage(si->hWnd, DM_INVALIDATEPANEL, 0, 0);
- }
- }
- break;
-
- case GC_EVENT_ADDSTATUS:
- SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
- if (!gce->bIsMe)
- bIsHighlighted = g_Settings.Highlight->match(gce, 0, CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
-
- case GC_EVENT_REMOVESTATUS:
- SM_TakeStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
- if (!gce->bIsMe)
- bIsHighlighted = g_Settings.Highlight->match(gce, 0, CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
-
- case GC_EVENT_MESSAGE:
- case GC_EVENT_ACTION:
- si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText && si)
- bIsHighlighted = si->Highlight->match(gce, si, CMUCHighlight::MATCH_TEXT | CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
-
- case GC_EVENT_NICK:
- SM_ChangeNick(gce->pDest->ptszID, gce->pDest->pszModule, gce);
- if (!gce->bIsMe)
- bIsHighlighted = g_Settings.Highlight->match(gce, 0, CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
-
- case GC_EVENT_JOIN:
- AddUser(gce);
- if (!gce->bIsMe)
- bIsHighlighted = g_Settings.Highlight->match(gce, 0, CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
-
- case GC_EVENT_PART:
- case GC_EVENT_QUIT:
- case GC_EVENT_KICK:
- bRemoveFlag = true;
- if (!gce->bIsMe)
- bIsHighlighted = g_Settings.Highlight->match(gce, 0, CMUCHighlight::MATCH_NICKNAME) != 0;
- break;
- }
-
- // Decide which window (log) should have the event
- if (gcd->ptszID) {
- pWnd = gcd->ptszID;
- pMod = gcd->pszModule;
- }
- else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) {
- SESSION_INFO *si = GetActiveSession();
- if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) {
- pWnd = si->ptszID;
- pMod = si->pszModule;
- }
- else return 0;
- }
- else {
- // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
- SM_AddEventToAllMatchingUID(gce, bIsHighlighted);
- if (!bRemoveFlag)
- return 0;
- }
-
- // add to log
- if (pWnd) {
- if (si == NULL)
- si = SM_FindSession(pWnd, pMod);
-
- // fix for IRC's old stuyle mode notifications. Should not affect any other protocol
- if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
- return 0;
-
- if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0)
- return 0;
-
- if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd)
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- else if (si->hWnd)
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
-
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.bLoggingEnabled)
- LogToFile(si, gce);
- }
-
- if (!bRemoveFlag)
- return 0;
- }
-
- if (bRemoveFlag)
- return (SM_RemoveUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID) == 0) ? 1 : 0;
-
- return GC_EVENT_ERROR;
-}
-
-static INT_PTR Service_GetAddEventPtr(WPARAM wParam, LPARAM lParam)
-{
- GCPTRS * gp = (GCPTRS *) lParam;
-
- mir_cslock lck(cs);
- gp->pfnAddEvent = Service_AddEvent;
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Service creation
-
-void HookEvents(void)
-{
- InitializeCriticalSection(&cs);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu); // MIRANDAHOOK should return INT_PTR too
-}
-
-void UnhookEvents(void)
-{
- DeleteCriticalSection(&cs);
-}
-
-int CreateServiceFunctions(void)
-{
- CreateServiceFunction(MS_GC_REGISTER, Service_Register);
- CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
- CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
- CreateServiceFunction(MS_GC_GETEVENTPTR, Service_GetAddEventPtr);
- 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);
- return 1;
-}
-
-void CreateHookableEvents(void)
-{
- hSendEvent = CreateHookableEvent(ME_GC_EVENT);
- hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
-}
-
-void DestroyHookableEvents(void)
-{
- DestroyHookableEvent(hSendEvent);
- DestroyHookableEvent(hBuildMenuEvent);
-}
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 7230a6298f..ee2b54b374 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -33,6 +33,8 @@
#include "..\commonheaders.h"
+char *szChatIconString = "chaticon";
+
int GetRichTextLength(HWND hwnd)
{
GETTEXTLENGTHEX gtl;
@@ -41,97 +43,6 @@ int GetRichTextLength(HWND hwnd)
return (int) SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
}
-/**
- * @param pszWord string to strip of any IRC-style
- * formatting
- * @param fToLower convert to lowercase
- * @param fStripCR strip cr/lf sequences (only for highlighter, defaults to false)
- * @param buf caller-provided buffer, use a static one
- * when the caller does not provide a
- * buffer
- * caller provided buffer is NEEDED to make
- * this thread-safe.
- *
- * @return TCHAR* the stripped string
- */
-TCHAR* RemoveFormatting(const TCHAR* pszWord, bool fToLower, bool fStripCR, TCHAR* buf, const size_t len)
-{
- static TCHAR _szTemp[20000];
- TCHAR* szTemp = 0;
- size_t _buflen = 0;
-
- if (0 == buf) {
- szTemp = _szTemp;
- _buflen = 20000;
- }
- else {
- szTemp = buf;
- _buflen = len;
- szTemp[len - 1] = 0;
- }
-
- size_t i = 0;
- size_t j = 0;
-
- if (pszWord == 0)
- return NULL;
-
- size_t wordlen = lstrlen(pszWord);
-
- while (j < _buflen && i <= wordlen) {
- if (pszWord[i] == '%') {
- switch (pszWord[i+1]) {
- case '%':
- szTemp[j] = '%';
- j++;
- i++;
- i++;
- break;
- case 'b':
- case 'u':
- case 'i':
- case 'B':
- case 'U':
- case 'I':
- case 'r':
- case 'C':
- case 'F':
- i++;
- i++;
- break;
-
- case 'c':
- case 'f':
- i += 4;
- break;
-
- default:
- szTemp[j] = pszWord[i];
- j++;
- i++;
- break;
- }
- }
- else {
- if (fStripCR) {
- if (0x0a == pszWord[i] || 0x0c == pszWord[i]) {
- szTemp[j++] = ' ';
- i++;
- continue;
- }
- }
- szTemp[j] = pszWord[i];
- j++;
- i++;
- }
- }
- if (fToLower) {
- _wsetlocale(LC_ALL, L"");
- wcslwr(szTemp);
- }
- return(szTemp);
-}
-
static void __stdcall ShowRoomFromPopup(void * pi)
{
SESSION_INFO *si = (SESSION_INFO*) pi;
@@ -185,50 +96,6 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
return DefWindowProc(hWnd, message, wParam, lParam);
}
-static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
-{
- POPUPDATAT pd = {0};
- va_list marker;
- static TCHAR szBuf[4*1024];
-
- if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
- return 0;
-
- va_start(marker, fmt);
- mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
- va_end(marker);
-
- pd.lchContact = hContact;
-
- if (hIcon)
- pd.lchIcon = hIcon ;
- else
- pd.lchIcon = LoadIconEx(IDI_CHANMGR, "window", 0, 0);
-
- PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%s - %s"),
- (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
- pcli->pfnGetContactDisplayName(hContact, 0));
-
- lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
- pd.iSeconds = g_Settings.iPopupTimeout;
-
- if (g_Settings.iPopupStyle == 2) {
- pd.colorBack = 0;
- pd.colorText = 0;
- } else if (g_Settings.iPopupStyle == 3) {
- pd.colorBack = g_Settings.crPUBkgColour;
- pd.colorText = g_Settings.crPUTextColour;
- } else {
- pd.colorBack = M.GetDword(FONTMODULE, SRMSGSET_BKGCOLOUR_MUC, SRMSGDEFSET_BKGCOLOUR);
- pd.colorText = crBkg;
- }
-
- pd.PluginWindowProc = PopupDlgProc;
- pd.PluginData = si;
- return PUAddPopupT(&pd);
-}
-
static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
int iEvent = gce->pDest->iType;
@@ -237,55 +104,55 @@ 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, PluginConfig.g_IconMsgEvent, szChatIconString, 0,
+ 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 :
- CList_AddEvent(si->hContact, hIcons[ICON_MESSAGE], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_ACTION], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_JOIN], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_PART], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_QUIT], szChatIconString, CLEF_ONLYAFEW,
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_QUIT], szChatIconString, CLEF_ONLYAFEW,
TranslateT("%s has disconnected"), gce->ptszNick);
break;
case GC_EVENT_NICK:
- CList_AddEvent(si->hContact, hIcons[ICON_NICK], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_KICK], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW,
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW,
TranslateT("Notice from %s"), gce->ptszNick);
break;
case GC_EVENT_TOPIC:
- CList_AddEvent(si->hContact, hIcons[ICON_TOPIC], szChatIconString, CLEF_ONLYAFEW,
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_TOPIC], szChatIconString, CLEF_ONLYAFEW,
TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- CList_AddEvent(si->hContact, hIcons[ICON_INFO], szChatIconString, CLEF_ONLYAFEW,
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_INFO], szChatIconString, CLEF_ONLYAFEW,
TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], szChatIconString, CLEF_ONLYAFEW,
+ 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:
- CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], szChatIconString, CLEF_ONLYAFEW,
+ 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;
}
@@ -296,6 +163,9 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
static BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce, TWindowData *dat)
{
int iEvent = gce->pDest->iType;
+ if (si == NULL || !(iEvent & si->iLogPopupFlags))
+ return true;
+
TContainerData *pContainer = dat ? dat->pContainer : NULL;
TCHAR *bbStart, *bbEnd;
@@ -305,121 +175,60 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce, TWindowData *dat)
}
else bbStart = bbEnd = _T("");
- if (si && (iEvent & si->iLogPopupFlags)) {
- if (nen_options.iMUCDisable) // no popups at all. Period
- return 0;
- /*
- * check the status mode against the status mask
- */
-
- char *szProto = dat ? dat->szProto : si->pszModule;
- if (nen_options.dwStatusMask != -1) {
- DWORD dwStatus = 0;
- if (szProto != NULL) {
- dwStatus = (DWORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
- if (!(dwStatus == 0 || dwStatus <= ID_STATUS_OFFLINE || ((1 << (dwStatus - ID_STATUS_ONLINE)) & nen_options.dwStatusMask))) // should never happen, but...
- return 0;
- }
+ if (nen_options.iMUCDisable) // no popups at all. Period
+ return 0;
+ /*
+ * check the status mode against the status mask
+ */
+
+ char *szProto = dat ? dat->szProto : si->pszModule;
+ if (nen_options.dwStatusMask != -1) {
+ DWORD dwStatus = 0;
+ if (szProto != NULL) {
+ dwStatus = (DWORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+ if (!(dwStatus == 0 || dwStatus <= ID_STATUS_OFFLINE || ((1 << (dwStatus - ID_STATUS_ONLINE)) & nen_options.dwStatusMask))) // should never happen, but...
+ return 0;
}
- if (dat && pContainer != 0) { // message window is open, need to check the container config if we want to see a popup nonetheless
- if (nen_options.bWindowCheck) { // no popups at all for open windows... no exceptions
- if (!PluginConfig.m_HideOnClose)
- return 0;
- if (pContainer->fHidden)
- goto passed;
+ }
+ if (dat && pContainer != 0) { // message window is open, need to check the container config if we want to see a popup nonetheless
+ if (nen_options.bWindowCheck) { // no popups at all for open windows... no exceptions
+ if (!PluginConfig.m_HideOnClose)
return 0;
- }
- if (pContainer->dwFlags & CNT_DONTREPORT && IsIconic(pContainer->hwnd)) // in tray counts as "minimised"
+ if (pContainer->fHidden)
+ goto passed;
+ return 0;
+ }
+ if (pContainer->dwFlags & CNT_DONTREPORT && IsIconic(pContainer->hwnd)) // in tray counts as "minimised"
+ goto passed;
+ if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) {
+ if (!IsIconic(pContainer->hwnd) && GetForegroundWindow() != pContainer->hwnd && GetActiveWindow() != pContainer->hwnd)
+ goto passed;
+ }
+ if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
+ if (pContainer->dwFlags & CNT_DONTREPORTFOCUSED)
goto passed;
- if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) {
- if (!IsIconic(pContainer->hwnd) && GetForegroundWindow() != pContainer->hwnd && GetActiveWindow() != pContainer->hwnd)
- goto passed;
- }
- if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
- if (pContainer->dwFlags & CNT_DONTREPORTFOCUSED)
- goto passed;
- if (pContainer->hwndActive == si->hWnd)
- return 0;
+ if (pContainer->hwndActive == si->hWnd)
+ return 0;
- goto passed;
- }
- return 0;
+ goto passed;
}
+ return 0;
+ }
passed:
- int iNewEvent = iEvent;
- COLORREF clr = 0;
+ int iNewEvent = iEvent;
+ COLORREF clr = 0;
- if ((iNewEvent & GC_EVENT_HIGHLIGHT)) {
- clr = aFonts[16].color;
- iNewEvent &= ~GC_EVENT_HIGHLIGHT;
- }
+ if ((iNewEvent & GC_EVENT_HIGHLIGHT)) {
+ clr = pci->aFonts[16].color;
+ iNewEvent &= ~GC_EVENT_HIGHLIGHT;
+ }
- switch (iNewEvent) {
- case GC_EVENT_MESSAGE :
- ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : aFonts[9].color,
- TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ACTION:
- ShowPopup(si->hContact, si, hIcons[ICON_ACTION], si->pszModule, si->ptszName, clr ? clr : aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_JOIN:
- ShowPopup(si->hContact, si, hIcons[ICON_JOIN], si->pszModule, si->ptszName, clr ? clr : aFonts[3].color,
- TranslateT("%s has joined"), gce->ptszNick);
- break;
- case GC_EVENT_PART:
- if (!gce->ptszText)
- ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color,
- TranslateT("%s has left"), gce->ptszNick);
- else
- ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : 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, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color,
- TranslateT("%s has disconnected"), gce->ptszNick);
- else
- ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color,
- TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NICK:
- ShowPopup(si->hContact, si, hIcons[ICON_NICK], si->pszModule, si->ptszName, clr ? clr : 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, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color,
- TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
- else
- ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color,
- TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NOTICE:
- ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, clr ? clr : 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, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : aFonts[11].color,
- TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
- else
- ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : 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, hIcons[ICON_INFO], si->pszModule, si->ptszName, clr ? clr : aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ADDSTATUS:
- ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[13].color,
- TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[14].color,
- TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- }
+ if (iNewEvent == GC_EVENT_MESSAGE) {
+ pci->ShowPopup(si->hContact, si, pci->hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : pci->aFonts[9].color,
+ TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, pci->RemoveFormatting(gce->ptszText));
}
+ else pci->DoPopup(si, gce);
return TRUE;
}
@@ -445,14 +254,14 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p)
if (dat) {
HWND hwndTab = GetParent(si->hWnd);
- BOOL bForcedIcon = (p->hNotifyIcon == hIcons[ICON_HIGHLIGHT] || p->hNotifyIcon == hIcons[ICON_MESSAGE]);
+ BOOL bForcedIcon = (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT] || p->hNotifyIcon == pci->hIcons[ICON_MESSAGE]);
if ((p->iEvent & si->iLogTrayFlags) || bForcedIcon) {
if (!p->bActiveTab) {
- if (p->hNotifyIcon == hIcons[ICON_HIGHLIGHT])
+ if (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT])
dat->iFlashIcon = p->hNotifyIcon;
else {
- if (dat->iFlashIcon != hIcons[ICON_HIGHLIGHT] && dat->iFlashIcon != hIcons[ICON_MESSAGE])
+ if (dat->iFlashIcon != pci->hIcons[ICON_HIGHLIGHT] && dat->iFlashIcon != pci->hIcons[ICON_MESSAGE])
dat->iFlashIcon = p->hNotifyIcon;
}
dat->mayFlashTab = TRUE;
@@ -498,7 +307,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p)
}
HICON hIcon = (HICON)SendMessage(dat->pContainer->hwnd, WM_GETICON, ICON_BIG, 0);
- if (p->hNotifyIcon == hIcons[ICON_HIGHLIGHT] || (hIcon != hIcons[ICON_MESSAGE] && hIcon != hIcons[ICON_HIGHLIGHT])) {
+ if (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT] || (hIcon != pci->hIcons[ICON_MESSAGE] && hIcon != pci->hIcons[ICON_HIGHLIGHT])) {
SendMessage(dat->pContainer->hwnd, DM_SETICON, (WPARAM)dat, (LPARAM)p->hNotifyIcon);
dat->pContainer->dwFlags |= CNT_NEED_UPDATETITLE;
}
@@ -517,7 +326,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return FALSE;
TWindowData *dat = NULL;
- FLASH_PARAMS *params = (FLASH_PARAMS*)mir_calloc( sizeof(FLASH_PARAMS));
+ FLASH_PARAMS *params = (FLASH_PARAMS*)mir_calloc(sizeof(FLASH_PARAMS));
params->hContact = si->hContact;
params->bInactive = TRUE;
if (si->hWnd && si->dat) {
@@ -557,11 +366,11 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
if (g_Settings.bFlashWindowHightlight && params->bInactive)
params->bMustFlash = TRUE;
params->bMustAutoswitch = TRUE;
- params->hNotifyIcon = hIcons[ICON_HIGHLIGHT];
+ params->hNotifyIcon = pci->hIcons[ICON_HIGHLIGHT];
}
else {
// do blinking icons in tray
- if (params->bInactive || !g_Settings.bTrayIconInactiveOnly) {
+ if (params->bInactive || !g_Settings.TrayIconInactiveOnly) {
DoTrayIcon(si, gce);
if (params->iEvent == GC_EVENT_MESSAGE)
bFlagUnread = true;
@@ -577,28 +386,28 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
case GC_EVENT_JOIN:
params->sound = "ChatJoin";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_JOIN];
+ params->hNotifyIcon = pci->hIcons[ICON_JOIN];
break;
case GC_EVENT_PART:
params->sound = "ChatPart";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_PART];
+ params->hNotifyIcon = pci->hIcons[ICON_PART];
break;
case GC_EVENT_QUIT:
params->sound = "ChatQuit";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_QUIT];
+ params->hNotifyIcon = pci->hIcons[ICON_QUIT];
break;
case GC_EVENT_ADDSTATUS:
case GC_EVENT_REMOVESTATUS:
params->sound = "ChatMode";
if (params->bInactive)
- params->hNotifyIcon = hIcons[params->iEvent == GC_EVENT_ADDSTATUS ? ICON_ADDSTATUS : ICON_REMSTATUS];
+ params->hNotifyIcon = pci->hIcons[params->iEvent == GC_EVENT_ADDSTATUS ? ICON_ADDSTATUS : ICON_REMSTATUS];
break;
case GC_EVENT_KICK:
params->sound = "ChatKick";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_KICK];
+ params->hNotifyIcon = pci->hIcons[ICON_KICK];
break;
case GC_EVENT_MESSAGE:
params->sound = "ChatMessage";
@@ -610,65 +419,65 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
case GC_EVENT_ACTION:
params->sound = "ChatAction";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_ACTION];
+ params->hNotifyIcon = pci->hIcons[ICON_ACTION];
break;
case GC_EVENT_NICK:
params->sound = "ChatNick";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_NICK];
+ params->hNotifyIcon = pci->hIcons[ICON_NICK];
break;
case GC_EVENT_NOTICE:
params->sound = "ChatNotice";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_NOTICE];
+ params->hNotifyIcon = pci->hIcons[ICON_NOTICE];
break;
case GC_EVENT_TOPIC:
params->sound = "ChatTopic";
if (params->bInactive)
- params->hNotifyIcon = hIcons[ICON_TOPIC];
+ params->hNotifyIcon = pci->hIcons[ICON_TOPIC];
break;
}
}
else {
switch (params->iEvent) {
case GC_EVENT_JOIN:
- params->hNotifyIcon = hIcons[ICON_JOIN];
+ params->hNotifyIcon = pci->hIcons[ICON_JOIN];
break;
case GC_EVENT_PART:
- params->hNotifyIcon = hIcons[ICON_PART];
+ params->hNotifyIcon = pci->hIcons[ICON_PART];
break;
case GC_EVENT_QUIT:
- params->hNotifyIcon = hIcons[ICON_QUIT];
+ params->hNotifyIcon = pci->hIcons[ICON_QUIT];
break;
case GC_EVENT_KICK:
- params->hNotifyIcon = hIcons[ICON_KICK];
+ params->hNotifyIcon = pci->hIcons[ICON_KICK];
break;
case GC_EVENT_ACTION:
- params->hNotifyIcon = hIcons[ICON_ACTION];
+ params->hNotifyIcon = pci->hIcons[ICON_ACTION];
break;
case GC_EVENT_NICK:
- params->hNotifyIcon = hIcons[ICON_NICK];
+ params->hNotifyIcon = pci->hIcons[ICON_NICK];
break;
case GC_EVENT_NOTICE:
- params->hNotifyIcon = hIcons[ICON_NOTICE];
+ params->hNotifyIcon = pci->hIcons[ICON_NOTICE];
break;
case GC_EVENT_TOPIC:
- params->hNotifyIcon = hIcons[ICON_TOPIC];
+ params->hNotifyIcon = pci->hIcons[ICON_TOPIC];
break;
case GC_EVENT_ADDSTATUS:
- params->hNotifyIcon = hIcons[ICON_ADDSTATUS];
+ params->hNotifyIcon = pci->hIcons[ICON_ADDSTATUS];
break;
case GC_EVENT_REMOVESTATUS:
- params->hNotifyIcon = hIcons[ICON_REMSTATUS];
+ params->hNotifyIcon = pci->hIcons[ICON_REMSTATUS];
break;
}
}
if (params->iEvent == GC_EVENT_MESSAGE) {
params->bMustAutoswitch = TRUE;
- if (g_Settings.bFlashWindow)
+ if (g_Settings.FlashWindow)
params->bMustFlash = TRUE;
- params->hNotifyIcon = hIcons[ICON_MESSAGE];
+ params->hNotifyIcon = pci->hIcons[ICON_MESSAGE];
}
}
if (dat && bFlagUnread) {
@@ -682,7 +491,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
int Chat_GetColorIndex(const char* pszModule, COLORREF cr)
{
- MODULEINFO *pMod = MM_FindModule(pszModule);
+ MODULEINFO *pMod = pci->MM_FindModule(pszModule);
if (!pMod || pMod->nColorCount == 0)
return -1;
@@ -693,32 +502,6 @@ int Chat_GetColorIndex(const char* pszModule, COLORREF cr)
return -1;
}
-// obscure function that is used to make sure that any of the colors
-// passed by the protocol is used as fore- or background color
-// in the messagebox. THis is to vvercome limitations in the richedit
-// that I do not know currently how to fix
-
-void CheckColorsInModule(const char* pszModule)
-{
- MODULEINFO * pMod = MM_FindModule(pszModule);
- COLORREF crFG;
- COLORREF crBG = (COLORREF)M.GetDword(FONTMODULE, "inputbg", SRMSGDEFSET_BKGCOLOUR);
-
- LoadLogfont(MSGFONTID_MESSAGEAREA, NULL, &crFG, FONTMODULE);
-
- if (!pMod)
- return;
-
- for (int i=0; i < pMod->nColorCount; i++) {
- if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) {
- if (pMod->crColors[i] == RGB(255, 255, 255))
- pMod->crColors[i]--;
- else
- pMod->crColors[i]++;
- }
- }
-}
-
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2)
{
int i, j, k;
@@ -732,187 +515,9 @@ 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)
-{
- TCHAR szBuffer[4096];
- TCHAR szLine[4096];
- TCHAR p = '\0';
-
- if (!si || !gce)
- return FALSE;
-
- MODULEINFO *mi = MM_FindModule(si->pszModule);
- if (!mi)
- return FALSE;
-
- /*
- * check whether we have to log this event
- */
- if (!(gce->pDest->iType & si->iDiskLogFlags))
- return FALSE;
-
- szBuffer[0] = '\0';
-
- GetChatLogsFilename(si, gce->time);
- BOOL bFileJustCreated = !PathFileExists(si->pszLogFileName);
-
- TCHAR tszFolder[MAX_PATH];
- _tcscpy(tszFolder, si->pszLogFileName);
- PathRemoveFileSpec(tszFolder);
- if (!PathIsDirectory(tszFolder))
- CreateDirectoryTreeT(tszFolder);
-
- TCHAR szTime[100];
- lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99);
-
- FILE *hFile = _tfopen(si->pszLogFileName, _T("ab+"));
- if (hFile) {
- TCHAR szTemp[512], szTemp2[512];
- TCHAR* pszNick = NULL;
- if (bFileJustCreated)
- fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE
- if (gce->ptszNick) {
- if (g_Settings.bLogLimitNames && lstrlen(gce->ptszNick) > 20) {
- lstrcpyn(szTemp2, gce->ptszNick, 20);
- lstrcpyn(szTemp2 + 20, _T("..."), 4);
- }
- else lstrcpyn(szTemp2, gce->ptszNick, 511);
-
- if (gce->ptszUserInfo)
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->ptszUserInfo);
- else
- 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:
- p = '*';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ACTION:
- case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- p = '*';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_JOIN:
- p = '>';
- 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"), pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), pszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_QUIT:
- p = '<';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), pszNick, 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);
- break;
- case GC_EVENT_KICK:
- p = '~';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NOTICE:
- p = 'o';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, 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));
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
- break;
- case GC_EVENT_INFORMATION:
- p = '!';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ADDSTATUS:
- p = '+';
- 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, 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), _T("%s %c %s\r\n"), szTime, p, szBuffer);
- else
- mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %s\r\n"), szTime, szBuffer);
-
- if (szLine[0]) {
- _fputts(szLine, hFile);
-
- if (g_Settings.LoggingLimit > 0) {
- fseek(hFile, 0, SEEK_END);
- long dwSize = ftell(hFile);
- rewind(hFile);
-
- long trimlimit = g_Settings.LoggingLimit * 1024;
- if (dwSize > trimlimit) {
- 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 = 0;
- if (!PathFileExists(tszNewName))
- CopyFile(si->pszLogFileName, tszNewName, TRUE);
- DeleteFile(si->pszLogFileName);
- }
- }
- }
-
- if (hFile)
- fclose(hFile);
- hFile = NULL;
- return TRUE;
- }
- return FALSE;
-}
-
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
HMENU hSubMenu = 0;
- DWORD codepage = M.GetDword(si->hContact, "ANSIcodepage", 0);
*hMenu = GetSubMenu(g_hMenu, iIndex);
TranslateMenu(*hMenu);
@@ -956,7 +561,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO
gcmi.Type = MENU_ON_NICKLIST;
}
- NotifyEventHooks(hBuildMenuEvent, 0, (WPARAM)&gcmi);
+ NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi);
if (gcmi.nItems > 0)
AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
@@ -1012,7 +617,7 @@ 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 = SM_FindSession(pszID, pszModule);
+ SESSION_INFO *si = pci->SM_FindSession(pszID, pszModule);
if (si == NULL)
return FALSE;
@@ -1029,56 +634,6 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int
return TRUE;
}
-BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCDEST gcd = { pszModule, pszID, iType };
- GCHOOK gch = { 0 };
- gch.ptszUID = (LPTSTR)pszUID;
- gch.ptszText = (LPTSTR)pszText;
- gch.dwData = dwItem;
- gch.pDest = &gcd;
- NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch);
- return TRUE;
-}
-
-BOOL IsEventSupported(int eventType)
-{
- // Supported events
- switch (eventType) {
- case GC_EVENT_JOIN:
- case GC_EVENT_PART:
- case GC_EVENT_QUIT:
- case GC_EVENT_KICK:
- case GC_EVENT_NICK:
- case GC_EVENT_NOTICE:
- case GC_EVENT_MESSAGE:
- case GC_EVENT_TOPIC:
- case GC_EVENT_INFORMATION:
- case GC_EVENT_ACTION:
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- case GC_EVENT_CHUID:
- case GC_EVENT_CHANGESESSIONAME:
- case GC_EVENT_ADDGROUP:
- case GC_EVENT_SETITEMDATA:
- case GC_EVENT_GETITEMDATA:
- case GC_EVENT_SETSBTEXT:
- case GC_EVENT_ACK:
- case GC_EVENT_SENDMESSAGE:
- case GC_EVENT_SETSTATUSEX:
- case GC_EVENT_CONTROL:
- case GC_EVENT_SETCONTACTSTATUS:
- return TRUE;
- }
-
- // Other events
- return FALSE;
-}
-
/*
* set all filters and notification config for a session
* uses per channel mask + filterbits, default config as backup
@@ -1116,14 +671,11 @@ void Chat_SetFilters(SESSION_INFO *si)
if (dwMask & (1 << i))
si->iLogTrayFlags = (dwFlags_local & (1 << i) ? si->iLogTrayFlags | (1 << i) : si->iLogTrayFlags & ~(1 << i));
- dwFlags_default = M.GetDword("Chat", "DiskLogFlags", 0xFFFF);
- si->iDiskLogFlags = dwFlags_default;
-
if (si->iLogFilterFlags == 0)
si->bFilterEnabled = 0;
}
-static TCHAR tszOldTimeStamp[30] = _T("\0");
+static TCHAR tszOldTimeStamp[30];
TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
{
@@ -1135,7 +687,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
* we have to reparse the filename
*/
- TCHAR *tszNow = MakeTimeStamp(_T("%a%d%m%Y"), tTime);
+ TCHAR *tszNow = pci->MakeTimeStamp(_T("%a%d%m%Y"), tTime);
bool fReparse = false;
if (_tcscmp(tszOldTimeStamp, tszNow)) {
@@ -1147,34 +699,34 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
if (fReparse || 0 == si->pszLogFileName[0]) {
REPLACEVARSARRAY rva[11];
rva[0].lptzKey = _T("d");
- rva[0].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%#d"), tTime));
+ rva[0].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%#d"), tTime));
// day 01-31
rva[1].lptzKey = _T("dd");
- rva[1].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%d"), tTime));
+ rva[1].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%d"), tTime));
// month 1-12
rva[2].lptzKey = _T("m");
- rva[2].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%#m"), tTime));
+ rva[2].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%#m"), tTime));
// month 01-12
rva[3].lptzKey = _T("mm");
- rva[3].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%m"), tTime));
+ rva[3].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%m"), tTime));
// month text short
rva[4].lptzKey = _T("mon");
- rva[4].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%b"), tTime));
+ rva[4].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%b"), tTime));
// month text
rva[5].lptzKey = _T("month");
- rva[5].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%B"), tTime));
+ rva[5].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%B"), tTime));
// year 01-99
rva[6].lptzKey = _T("yy");
- rva[6].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%y"), tTime));
+ rva[6].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%y"), tTime));
// year 1901-9999
rva[7].lptzKey = _T("yyyy");
- rva[7].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%Y"), tTime));
+ rva[7].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%Y"), tTime));
// weekday short
rva[8].lptzKey = _T("wday");
- rva[8].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%a"), tTime));
+ rva[8].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%a"), tTime));
// weekday
rva[9].lptzKey = _T("weekday");
- rva[9].lptzValue = mir_tstrdup(MakeTimeStamp(_T("%A"), tTime));
+ rva[9].lptzValue = mir_tstrdup(pci->MakeTimeStamp(_T("%A"), tTime));
// end of array
rva[10].lptzKey = NULL;
rva[10].lptzValue = NULL;
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 35d66b459c..59c6f052a9 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -41,10 +41,7 @@ extern REOLECallback *mREOLECallback;
int g_cLinesPerPage=0;
int g_iWheelCarryover=0;
-extern HBRUSH hListBkgBrush;
-extern HANDLE hSendEvent;
-extern HICON hIcons[30];
-extern HMENU g_hMenu;
+extern HMENU g_hMenu;
static HKL hkl = NULL;
static HCURSOR hCurHyperlinkHand;
@@ -243,15 +240,15 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
}
}
- if (si->hwndFilter) {
+ if (si->hwndStatus) {
POINT pt;
GetCursorPos(&pt);
RECT rcFilter;
- GetWindowRect(si->hwndFilter, &rcFilter);
+ GetWindowRect(si->hwndStatus, &rcFilter);
if (!PtInRect(&rcFilter, pt)) {
- SendMessage(si->hwndFilter, WM_CLOSE, 1, 1);
- si->hwndFilter = 0;
+ SendMessage(si->hwndStatus, WM_CLOSE, 1, 1);
+ si->hwndStatus = 0;
}
}
@@ -273,7 +270,7 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
dat->pContainer->hwndSaved = hwndDlg;
- SetActiveSession(si->ptszID, si->pszModule);
+ pci->SetActiveSession(si->ptszID, si->pszModule);
dat->hTabIcon = dat->hTabStatusIcon;
if (dat->iTabID >= 0) {
@@ -336,7 +333,7 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
static void InitButtons(HWND hwndDlg, SESSION_INFO *si)
{
- MODULEINFO *pInfo = si ? MM_FindModule(si->pszModule) : NULL;
+ MODULEINFO *pInfo = si ? pci->MM_FindModule(si->pszModule) : NULL;
if (pInfo) {
Utils::enableDlgControl(hwndDlg, IDC_CHAT_BOLD, pInfo->bBold);
Utils::enableDlgControl(hwndDlg, IDC_ITALICS, pInfo->bItalics);
@@ -403,7 +400,7 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
Utils::enableDlgControl(hwndDlg, IDC_SHOWNICKLIST, TRUE);
Utils::enableDlgControl(hwndDlg, IDC_FILTER, TRUE);
if (si->iType == GCW_CHATROOM) {
- MODULEINFO* tmp = MM_FindModule(si->pszModule);
+ MODULEINFO* tmp = pci->MM_FindModule(si->pszModule);
if (tmp)
Utils::enableDlgControl(hwndDlg, IDC_CHANMGR, tmp->bChanMgr);
}
@@ -570,7 +567,7 @@ LBL_SkipEnd:
if (dat->lastSession != NULL)
pszName = dat->lastSession->ptszName;
}
- else pszName = UM_FindUserAutoComplete(si->pUsers, dat->szSearchQuery, dat->szSearchResult);
+ else pszName = pci->UM_FindUserAutoComplete(si->pUsers, dat->szSearchQuery, dat->szSearchResult);
replaceStrT(dat->szSearchResult, NULL);
@@ -578,7 +575,7 @@ LBL_SkipEnd:
dat->szSearchResult = mir_tstrdup(pszName);
if (end != start) {
ptrT szReplace;
- if (!isRoom && !isTopic && g_Settings.bAddColonToAutoComplete && start == 0) {
+ if (!isRoom && !isTopic && g_Settings.AddColonToAutoComplete && start == 0) {
szReplace = (TCHAR*)Utils::safeMirAlloc((wcslen(pszName) + 4) * sizeof(TCHAR));
wcscpy(szReplace, pszName);
wcscat(szReplace, L": ");
@@ -627,7 +624,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_CONTEXTMENU:
{
- MODULEINFO *mi = MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
CHARRANGE sel, all = { 0, -1};
int iPrivateBG = M.GetByte(mwdat->hContact, "private_bg", 0);
int idFrom = IDC_CHAT_MESSAGE;
@@ -734,7 +731,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
SkinPlaySound("SoundOnTyping");
if (isCtrl && !isAlt && !isShift) {
- MODULEINFO *mi = MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
switch(wParam) {
case 0x09: // ctrl-i (italics)
@@ -914,7 +911,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
GETTEXTLENGTHEX gtl = {0};
SETTEXTEX ste;
LOGFONTA lf;
- char* lpPrevCmd = SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
+ char *lpPrevCmd = pci->SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
@@ -941,7 +938,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
GETTEXTLENGTHEX gtl = {0};
SETTEXTEX ste;
- char* lpPrevCmd = SM_GetNextCommand(Parentsi->ptszID, Parentsi->pszModule);
+ char *lpPrevCmd = pci->SM_GetNextCommand(Parentsi->ptszID, Parentsi->pszModule);
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
ste.flags = ST_DEFAULT;
@@ -980,7 +977,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
UINT u = 0;
UINT u2 = 0;
COLORREF cr;
- MODULEINFO *mi = MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
LoadLogfont(MSGFONTID_MESSAGEAREA, NULL, &cr, FONTMODULE);
@@ -1397,7 +1394,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS
TCHAR tszBuf[1024]; tszBuf[0] = 0;
- USERINFO *ui1 = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
+ USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
if (ui1) {
if ( ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID);
@@ -1411,7 +1408,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"),
TranslateT("Nickname"), ui1->pszNick,
TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), TM_WordToString( parentdat->pStatuses, ui1->Status));
+ TranslateT("Status"), pci->TM_WordToString( parentdat->pStatuses, ui1->Status));
ti.lpszText = tszBuf;
}
@@ -1464,7 +1461,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (rc.bottom - rc.top > items * height) {
rc.top = items * height;
- FillRect(dc, &rc, hListBkgBrush);
+ FillRect(dc, &rc, pci->hListBkgBrush);
}
}
}
@@ -1563,7 +1560,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
*/
int i, iItems = SendMessage(hwnd, LB_GETCOUNT, 0, 0);
for (i=0; i < iItems; i++) {
- USERINFO *ui = UM_FindUserFromIndex(si->pUsers, i);
+ USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, i);
if (ui) {
if (!_tcsnicmp(ui->pszNick, si->szSearch, lstrlen(si->szSearch))) {
SendMessage(hwnd, LB_SETSEL, FALSE, -1);
@@ -1636,7 +1633,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
else
item &= 0xFFFF;
- USERINFO *ui = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
if (ui) {
HMENU hMenu = 0;
USERINFO uinew;
@@ -1679,7 +1676,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (pItems) {
if (SendMessage(hwnd, LB_GETSELITEMS, (WPARAM)iSelectedItems, (LPARAM)pItems) != LB_ERR) {
for (int i=0; i < iSelectedItems; i++) {
- USERINFO *ui1 = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, pItems[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);
}
@@ -1760,7 +1757,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
- USERINFO *ui1 = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
+ USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
if (ui1) {
TCHAR tszBuf[1024]; tszBuf[0] = 0;
if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
@@ -1774,7 +1771,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s"),
TranslateT("Nick"), ui1->pszNick,
TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), TM_WordToString(parentdat->pStatuses, ui1->Status));
+ TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui1->Status));
CLCINFOTIP ti = { sizeof(ti) };
if (CallService("mToolTip/ShowTipW", (WPARAM)tszBuf, (LPARAM)&ti))
@@ -2069,7 +2066,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
TCHAR szFinalStatusBarText[512];
//Mad: strange rare crash here...
- MODULEINFO *mi = MM_FindModule(si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
if (!mi)
break;
@@ -2224,7 +2221,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC) wParam, g_Settings.crUserListBGColor);
- return (INT_PTR) hListBkgBrush;
+ return (INT_PTR)pci->hListBkgBrush;
case WM_MEASUREITEM:
{
@@ -2257,7 +2254,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
int index = dis->itemID;
char szIndicator = 0;
- USERINFO *ui = UM_FindUserFromIndex(si->pUsers, index);
+ USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, index);
if (ui == NULL)
return TRUE;
@@ -2266,7 +2263,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
height++;
int offset = (height == 10) ? 0 : height/2;
- HICON hIcon = SM_GetStatusIcon(si, ui, &szIndicator);
+ HICON hIcon = pci->SM_GetStatusIcon(si, ui);
HFONT hFont = g_Settings.UserListFonts[ui->iStatusEx];
HFONT hOldFont = (HFONT) SelectObject(dis->hDC, hFont);
SetBkMode(dis->hDC, TRANSPARENT);
@@ -2276,27 +2273,14 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
SetTextColor(dis->hDC, g_Settings.nickColors[6]);
}
else {
- FillRect(dis->hDC, &dis->rcItem, hListBkgBrush);
+ FillRect(dis->hDC, &dis->rcItem, pci->hListBkgBrush);
if (g_Settings.bColorizeNicks && szIndicator != 0) {
- COLORREF clr;
- switch (szIndicator) {
- case '@':
- clr = g_Settings.nickColors[0];
- break;
- case '%':
- clr = g_Settings.nickColors[1];
- break;
- case '+':
- clr = g_Settings.nickColors[2];
- break;
- case '!':
- clr = g_Settings.nickColors[3];
- break;
- case '*':
- clr = g_Settings.nickColors[4];
- break;
+ for (int i = 0; i < 6; i++) {
+ if (hIcon == pci->hIcons[ICON_STATUS0 + i]) {
+ SetTextColor(dis->hDC, g_Settings.nickColors[i]);
+ break;
+ }
}
- SetTextColor(dis->hDC, clr);
}
else SetTextColor(dis->hDC, g_Settings.UserListColors[ui->iStatusEx]);
}
@@ -2478,7 +2462,7 @@ LABEL_SHOWWINDOW:
case GC_FIREHOOK:
if (lParam) {
GCHOOK* gch = (GCHOOK*) lParam;
- NotifyEventHooks(hSendEvent, 0, (WPARAM)gch);
+ NotifyEventHooks(pci->hSendEvent, 0, (WPARAM)gch);
if (gch->pDest) {
mir_free((void*)gch->pDest->ptszID);
mir_free((void*)gch->pDest->pszModule);
@@ -2496,16 +2480,16 @@ LABEL_SHOWWINDOW:
break;
case GC_SHOWFILTERMENU:
- si->hwndFilter = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), dat->pContainer->hwnd, FilterWndProc, (LPARAM)si);
- TranslateDialogDefault(si->hwndFilter);
+ si->hwndStatus = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), dat->pContainer->hwnd, FilterWndProc, (LPARAM)si);
+ TranslateDialogDefault(si->hwndStatus);
{
RECT rcFilter, rcLog;
- GetClientRect(si->hwndFilter, &rcFilter);
+ GetClientRect(si->hwndStatus, &rcFilter);
GetWindowRect(GetDlgItem(hwndDlg, IDC_CHAT_LOG), &rcLog);
POINT pt = { rcLog.right, rcLog.bottom };
ScreenToClient(dat->pContainer->hwnd, &pt);
- SetWindowPos(si->hwndFilter, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetWindowPos(si->hwndStatus, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
@@ -2521,7 +2505,7 @@ LABEL_SHOWWINDOW:
GetWindowRect(GetDlgItem(hwndDlg, bFG ? IDC_COLOR : IDC_BKGCOLOR), &rc);
COLORCHOOSER *pCC = (COLORCHOOSER *)mir_alloc(sizeof(COLORCHOOSER));
pCC->hWndTarget = GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE);
- pCC->pModule = MM_FindModule(si->pszModule);
+ pCC->pModule = pci->MM_FindModule(si->pszModule);
pCC->xPosition = rc.left + 3;
pCC->yPosition = IsWindowVisible(GetDlgItem(hwndDlg, IDC_COLOR)) ? rc.top - 1 : rc.top + 20;
pCC->bForeground = bFG;
@@ -2937,7 +2921,7 @@ LABEL_SHOWWINDOW:
ScreenToClient(GetDlgItem(hwndDlg, IDC_LIST), &hti.pt);
int item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
- USERINFO *ui = UM_FindUserFromIndex(si->pUsers, item);
+ USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, item);
if (ui) {
if (g_Settings.bDoubleClick4Privat ? GetKeyState(VK_SHIFT) & 0x8000 : !(GetKeyState(VK_SHIFT) & 0x8000)) {
LRESULT lResult = (LRESULT)SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), EM_GETSEL, 0, 0);
@@ -2970,12 +2954,12 @@ LABEL_SHOWWINDOW:
case IDOK:
if (GetSendButtonState(hwndDlg) != PBS_DISABLED) {
- MODULEINFO *mi = MM_FindModule(si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
- ptrA pszRtf( Chat_Message_GetFromStream(hwndDlg, si));
- SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
+ ptrA pszRtf(Chat_Message_GetFromStream(hwndDlg, si));
+ pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
- ptrT ptszText( Chat_DoRtfToTags(pszRtf, si));
+ ptrT ptszText(Chat_DoRtfToTags(pszRtf, si));
if (ptszText == NULL)
break;
@@ -2995,7 +2979,7 @@ LABEL_SHOWWINDOW:
DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
mi->idleTimeStamp = time(0);
mi->lastIdleCheck = 0;
- SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
+ pci->SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
if (dat && dat->pContainer)
if (fSound && !nen_options.iNoSounds && !(dat->pContainer->dwFlags & CNT_NOSOUND))
SkinPlaySound("ChatSent");
@@ -3055,7 +3039,7 @@ LABEL_SHOWWINDOW:
case IDC_CHAT_HISTORY:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHAT_HISTORY))) {
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (ServiceExists("MSP/HTMLlog/ViewLog") && strstr(si->pszModule, "IRC")) {
char szName[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, si->ptszName, -1, szName, MAX_PATH, 0, 0);
@@ -3111,7 +3095,7 @@ LABEL_SHOWWINDOW:
SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_BKGCOLOR);
else if (si->bBGSet) {
cf.dwMask = CFM_BACKCOLOR;
- cf.crBackColor = MM_FindModule(si->pszModule)->crColors[si->iBG];
+ cf.crBackColor = pci->MM_FindModule(si->pszModule)->crColors[si->iBG];
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
@@ -3134,7 +3118,7 @@ LABEL_SHOWWINDOW:
SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_COLOR);
else if (si->bFGSet) {
cf.dwMask = CFM_COLOR;
- cf.crTextColor = MM_FindModule(si->pszModule)->crColors[si->iFG];
+ cf.crTextColor = pci->MM_FindModule(si->pszModule)->crColors[si->iFG];
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
diff --git a/plugins/TabSRMM/src/commonheaders.h b/plugins/TabSRMM/src/commonheaders.h
index 2a3b608cb7..b05930662e 100644
--- a/plugins/TabSRMM/src/commonheaders.h
+++ b/plugins/TabSRMM/src/commonheaders.h
@@ -78,7 +78,7 @@
#include <m_file.h>
#include <m_fontservice.h>
#include <m_acc.h>
-#include <m_chat.h>
+#include <m_chat_int.h>
#include <m_protomod.h>
#include <m_hotkeys.h>
#include <m_genmenu.h>
@@ -245,7 +245,6 @@ extern ButtonSet g_ButtonSet;
extern HANDLE g_hEvent;
extern RECT rcLastStatusBarClick;
extern PLUGININFOEX pluginInfo;
-extern HICON hIcons[];
extern TTemplateSet RTL_Active, LTR_Active;
extern LOGFONTA logfonts[MSGDLGFONTCOUNT + 2];
extern COLORREF fontcolors[MSGDLGFONTCOUNT + 2];
@@ -258,16 +257,8 @@ extern const TCHAR *pszIDCSAVE_save, *pszIDCSAVE_close;
extern char *TemplateNames[];
extern HANDLE hUserPrefsWindowList;
extern TCpTable cpTable[];
-extern HGENMENU hJoinMenuItem, hLeaveMenuItem;
-extern FONTINFO aFonts[OPTIONS_FONTCOUNT];
-extern TCHAR *pszActiveWndID;
-extern char *pszActiveWndModule;
-extern CRITICAL_SECTION cs;
-extern HBRUSH hListBkgBrush;
extern HMODULE g_hIconDLL;
extern HMENU g_hMenu;
-extern HANDLE hBuildMenuEvent;
-extern HANDLE hSendEvent;
extern int LoadSendRecvMessageModule(void);
extern int SplitmsgShutdown(void);
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h
index f095c0fb18..a7369efe7e 100644
--- a/plugins/TabSRMM/src/functions.h
+++ b/plugins/TabSRMM/src/functions.h
@@ -33,17 +33,17 @@
#ifndef _TABSRMM_FUNCTIONS_H
#define _TABSRMM_FUNCTIONS_H
-int Chat_PreShutdown();
-int Chat_ModulesLoaded(WPARAM wp, LPARAM lp);
-int AvatarChanged(WPARAM wParam, LPARAM lParam);
-int MyAvatarChanged(WPARAM wParam, LPARAM lParam);
-int IcoLibIconsChanged(WPARAM wParam, LPARAM lParam);
-int FontServiceFontsChanged(WPARAM wParam, LPARAM lParam);
-int SmileyAddOptionsChanged(WPARAM wParam, LPARAM lParam);
-int IEViewOptionsChanged(WPARAM wParam, LPARAM lParam);
-void RegisterFontServiceFonts();
-int ModPlus_PreShutdown(WPARAM wparam, LPARAM lparam);
-int ModPlus_Init(WPARAM wparam, LPARAM lparam);
+int AvatarChanged(WPARAM wParam, LPARAM lParam);
+int MyAvatarChanged(WPARAM wParam, LPARAM lParam);
+int IconsChanged(WPARAM wParam, LPARAM lParam);
+int IcoLibIconsChanged(WPARAM wParam, LPARAM lParam);
+int FontServiceFontsChanged(WPARAM wParam, LPARAM lParam);
+int SmileyAddOptionsChanged(WPARAM wParam, LPARAM lParam);
+int IEViewOptionsChanged(WPARAM wParam, LPARAM lParam);
+int ModPlus_PreShutdown(WPARAM wparam, LPARAM lparam);
+int ModPlus_Init(WPARAM wparam, LPARAM lparam);
+
+void RegisterFontServiceFonts();
LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 01c572e268..e10b9d2253 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -30,6 +30,8 @@
#include "commonheaders.h"
+void Chat_ModulesLoaded();
+
CGlobals PluginConfig;
CGlobals* pConfig = &PluginConfig;
@@ -339,6 +341,7 @@ int CGlobals::ModulesLoaded(WPARAM wParam, LPARAM lParam)
PluginConfig.reloadSystemModulesChanged();
+ ::Chat_ModulesLoaded();
::BuildContainerMenu();
::CB_InitDefaultButtons();
@@ -375,7 +378,6 @@ int CGlobals::ModulesLoaded(WPARAM wParam, LPARAM lParam)
::RegisterFontServiceFonts();
::CacheLogFonts();
- ::Chat_ModulesLoaded(wParam, lParam);
if (PluginConfig.g_PopupAvail)
TN_ModuleInit();
@@ -537,8 +539,6 @@ int CGlobals::MetaContactEvent(WPARAM wParam, LPARAM lParam)
int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam)
{
- ::Chat_PreShutdown();
-
::TN_ModuleDeInit();
while(pFirstContainer){
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp
index 68ecab4cf4..a92858d9e1 100644
--- a/plugins/TabSRMM/src/hotkeyhandler.cpp
+++ b/plugins/TabSRMM/src/hotkeyhandler.cpp
@@ -220,7 +220,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
HICON hIcon;
if (dis->itemData > 0)
- hIcon = dis->itemData & 0x10000000 ? hIcons[ICON_HIGHLIGHT] : PluginConfig.g_IconMsgEvent;
+ hIcon = dis->itemData & 0x10000000 ? pci->hIcons[ICON_HIGHLIGHT] : PluginConfig.g_IconMsgEvent;
else if (dat != NULL) {
hIcon = MY_GetContactIcon(dat);
idle = dat->idle;
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 0811526d45..bda8ca2170 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -2263,10 +2263,10 @@ void TSAPI ClearLog(TWindowData *dat)
}
else if (dat && dat->bType == SESSIONTYPE_CHAT && dat->si) {
SESSION_INFO *si = dat->si;
- SESSION_INFO* s = SM_FindSession(si->ptszID, si->pszModule);
+ SESSION_INFO* s = pci->SM_FindSession(si->ptszID, si->pszModule);
if (s) {
SetDlgItemText(dat->hwnd, IDC_CHAT_LOG, _T(""));
- LM_RemoveAll(&s->pLog, &s->pLogEnd);
+ pci->LM_RemoveAll(&s->pLog, &s->pLogEnd);
s->iEventCount = 0;
s->LastTime = 0;
si->iEventCount = 0;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index ec1ff5c391..bd7d9f9bf1 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -39,9 +39,7 @@ HMODULE g_hIconDLL = 0;
static void UnloadIcons();
-int Chat_IconsChanged(WPARAM wp, LPARAM lp);
-void Chat_AddIcons(void);
-int Chat_PreShutdown(WPARAM wParam, LPARAM lParam);
+void Chat_AddIcons(void);
/*
* fired event when user changes IEView plugin options. Apply them to all open tabs
@@ -60,7 +58,7 @@ int IEViewOptionsChanged(WPARAM,LPARAM)
int SmileyAddOptionsChanged(WPARAM,LPARAM)
{
M.BroadcastMessage(DM_SMILEYOPTIONSCHANGED, 0, 0);
- SM_BroadcastMessage(NULL, DM_SMILEYOPTIONSCHANGED, 0, 0, FALSE);
+ pci->SM_BroadcastMessage(NULL, DM_SMILEYOPTIONSCHANGED, 0, 0, FALSE);
return 0;
}
@@ -499,7 +497,6 @@ int IcoLibIconsChanged(WPARAM wParam, LPARAM lParam)
{
LoadFromIconLib();
CacheMsgLogIcons();
- Chat_IconsChanged(wParam, lParam);
return 0;
}
@@ -509,8 +506,6 @@ int IconsChanged(WPARAM wParam, LPARAM lParam)
CacheMsgLogIcons();
M.BroadcastMessage(DM_OPTIONSAPPLIED, 0, 0);
M.BroadcastMessage(DM_UPDATEWINICON, 0, 0);
- Chat_IconsChanged(wParam, lParam);
-
return 0;
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index fd88db1c62..12943f05fd 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -746,7 +746,6 @@ extern const int msgDlgFontCount;
// rtl support
#define SRMSGDEFSET_MOD_RTL 0
-#define TIMERID_FLASHWND 1
#define TIMEOUT_FLASHWND 900
#define TIMERID_HEARTBEAT 2
#define TIMEOUT_HEARTBEAT 20000
diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp
index 845db5d2da..06acd7a1e5 100644
--- a/plugins/TabSRMM/src/taskbar.cpp
+++ b/plugins/TabSRMM/src/taskbar.cpp
@@ -869,7 +869,7 @@ void CThumbMUC::update()
void CThumbMUC::renderContent()
{
if (m_dat->si) {
- const MODULEINFO* mi = MM_FindModule(m_dat->si->pszModule);
+ const MODULEINFO* mi = pci->MM_FindModule(m_dat->si->pszModule);
wchar_t szTemp[250];
const wchar_t* szStatusMsg = 0;
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp
index b04cb9cd2b..4a610c3b27 100644
--- a/plugins/TabSRMM/src/themeio.cpp
+++ b/plugins/TabSRMM/src/themeio.cpp
@@ -419,7 +419,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in
}
}
}
- LoadGlobalSettings();
+
mir_free(szIniFilename);
}
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h
index 0a635936e8..fa9627da4a 100644
--- a/plugins/TabSRMM/src/version.h
+++ b/plugins/TabSRMM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 3
-#define __MINOR_VERSION 2
+#define __MINOR_VERSION 3
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/plugins/TabSRMM/tabsrmm_10.vcxproj b/plugins/TabSRMM/tabsrmm_10.vcxproj
index abaa2f20f9..5f95b095b2 100644
--- a/plugins/TabSRMM/tabsrmm_10.vcxproj
+++ b/plugins/TabSRMM/tabsrmm_10.vcxproj
@@ -194,9 +194,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\buttonsbar.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
@@ -269,7 +266,6 @@
<ClInclude Include="src\buttonbar.h" />
<ClInclude Include="src\chat\chat.h" />
<ClInclude Include="src\chat\chat_resource.h" />
- <ClInclude Include="src\chat\chatprototypes.h" />
<ClInclude Include="src\chat\muchighlight.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\contactcache.h" />
diff --git a/plugins/TabSRMM/tabsrmm_10.vcxproj.filters b/plugins/TabSRMM/tabsrmm_10.vcxproj.filters
index 24ae2ebf8e..83d79be3e6 100644
--- a/plugins/TabSRMM/tabsrmm_10.vcxproj.filters
+++ b/plugins/TabSRMM/tabsrmm_10.vcxproj.filters
@@ -16,14 +16,8 @@
<UniqueIdentifier>{c6aa9273-8563-4007-afa1-63e8d2164122}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
- <Filter Include="Header Files\Chat">
- <UniqueIdentifier>{2ea6d9e6-399a-44c2-a431-9560e18f31fc}</UniqueIdentifier>
- </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\Chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
@@ -237,16 +231,13 @@
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\chat\chat.h">
- <Filter>Header Files\Chat</Filter>
+ <Filter>Source Files\Chat</Filter>
</ClInclude>
<ClInclude Include="src\chat\chat_resource.h">
- <Filter>Header Files\Chat</Filter>
- </ClInclude>
- <ClInclude Include="src\chat\chatprototypes.h">
- <Filter>Header Files\Chat</Filter>
+ <Filter>Source Files\Chat</Filter>
</ClInclude>
<ClInclude Include="src\chat\muchighlight.h">
- <Filter>Header Files\Chat</Filter>
+ <Filter>Source Files\Chat</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
diff --git a/plugins/TabSRMM/tabsrmm_11.vcxproj b/plugins/TabSRMM/tabsrmm_11.vcxproj
index 114daa0607..f4c57dd9c7 100644
--- a/plugins/TabSRMM/tabsrmm_11.vcxproj
+++ b/plugins/TabSRMM/tabsrmm_11.vcxproj
@@ -197,9 +197,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\buttonsbar.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
@@ -272,7 +269,6 @@
<ClInclude Include="src\buttonbar.h" />
<ClInclude Include="src\chat\chat.h" />
<ClInclude Include="src\chat\chat_resource.h" />
- <ClInclude Include="src\chat\chatprototypes.h" />
<ClInclude Include="src\chat\muchighlight.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\contactcache.h" />
diff --git a/plugins/TabSRMM/tabsrmm_11.vcxproj.filters b/plugins/TabSRMM/tabsrmm_11.vcxproj.filters
index 24ae2ebf8e..4cea943887 100644
--- a/plugins/TabSRMM/tabsrmm_11.vcxproj.filters
+++ b/plugins/TabSRMM/tabsrmm_11.vcxproj.filters
@@ -21,9 +21,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\Chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
@@ -242,9 +239,6 @@
<ClInclude Include="src\chat\chat_resource.h">
<Filter>Header Files\Chat</Filter>
</ClInclude>
- <ClInclude Include="src\chat\chatprototypes.h">
- <Filter>Header Files\Chat</Filter>
- </ClInclude>
<ClInclude Include="src\chat\muchighlight.h">
<Filter>Header Files\Chat</Filter>
</ClInclude>
diff --git a/plugins/TabSRMM/tabsrmm_12.vcxproj b/plugins/TabSRMM/tabsrmm_12.vcxproj
index 82e2902078..cdde3ce0b2 100644
--- a/plugins/TabSRMM/tabsrmm_12.vcxproj
+++ b/plugins/TabSRMM/tabsrmm_12.vcxproj
@@ -197,9 +197,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\buttonsbar.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
@@ -272,7 +269,6 @@
<ClInclude Include="src\buttonbar.h" />
<ClInclude Include="src\chat\chat.h" />
<ClInclude Include="src\chat\chat_resource.h" />
- <ClInclude Include="src\chat\chatprototypes.h" />
<ClInclude Include="src\chat\muchighlight.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\contactcache.h" />
diff --git a/plugins/TabSRMM/tabsrmm_12.vcxproj.filters b/plugins/TabSRMM/tabsrmm_12.vcxproj.filters
index 24ae2ebf8e..b49df8a9bd 100644
--- a/plugins/TabSRMM/tabsrmm_12.vcxproj.filters
+++ b/plugins/TabSRMM/tabsrmm_12.vcxproj.filters
@@ -16,14 +16,8 @@
<UniqueIdentifier>{c6aa9273-8563-4007-afa1-63e8d2164122}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
- <Filter Include="Header Files\Chat">
- <UniqueIdentifier>{2ea6d9e6-399a-44c2-a431-9560e18f31fc}</UniqueIdentifier>
- </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\Chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
@@ -237,16 +231,13 @@
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\chat\chat.h">
- <Filter>Header Files\Chat</Filter>
- </ClInclude>
- <ClInclude Include="src\chat\chat_resource.h">
- <Filter>Header Files\Chat</Filter>
- </ClInclude>
- <ClInclude Include="src\chat\chatprototypes.h">
- <Filter>Header Files\Chat</Filter>
+ <Filter>Source Files\Chat</Filter>
</ClInclude>
<ClInclude Include="src\chat\muchighlight.h">
- <Filter>Header Files\Chat</Filter>
+ <Filter>Source Files\Chat</Filter>
+ </ClInclude>
+ <ClInclude Include="src\chat\chat_resource.h">
+ <Filter>Source Files\Chat</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
diff --git a/src/core/stdchat/src/log.cpp b/src/core/stdchat/src/log.cpp
index 10b6f8097e..0e5a94edb5 100644
--- a/src/core/stdchat/src/log.cpp
+++ b/src/core/stdchat/src/log.cpp
@@ -87,7 +87,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedr
//set the insertion point at the bottom
sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) & sel);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) &sel);
// fix for the indent... must be a M$ bug
if (sel.cpMax == 0)
@@ -151,7 +151,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedr
// need to invalidate the window
if (bFlag) {
sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) & sel);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) &sel);
SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hwndRich, NULL, TRUE);
} } }
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp
index 181dfa24e2..4c622eee41 100644
--- a/src/core/stdchat/src/window.cpp
+++ b/src/core/stdchat/src/window.cpp
@@ -399,7 +399,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (pszName == NULL) {
pszName = dat->szTabSave;
SendMessage(hwnd, EM_SETSEL, start, end);
- if (end !=start)
+ if (end != start)
SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) pszName);
dat->szTabSave[0] = '\0';
}
@@ -417,9 +417,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return 0;
}
- if (dat->szTabSave[0] != '\0' && wParam != VK_RIGHT && wParam != VK_LEFT
- && wParam != VK_SPACE && wParam != VK_RETURN && wParam != VK_BACK
- && wParam != VK_DELETE ) {
+ if (dat->szTabSave[0] != '\0' && wParam != VK_RIGHT && wParam != VK_LEFT &&
+ wParam != VK_SPACE && wParam != VK_RETURN && wParam != VK_BACK && wParam != VK_DELETE)
+ {
if (g_Settings.AddColonToAutoComplete && start == 0)
SendMessageA(hwnd, EM_REPLACESEL, FALSE, (LPARAM) ": ");
@@ -432,25 +432,25 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == 0x49 && isCtrl && !isAlt) { // ctrl-i (italics)
- CheckDlgButton(GetParent(hwnd), IDC_ITALICS, IsDlgButtonChecked(GetParent(hwnd), IDC_ITALICS) == BST_UNCHECKED?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_ITALICS, IsDlgButtonChecked(GetParent(hwnd), IDC_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_ITALICS, 0), 0);
return TRUE;
}
if (wParam == 0x42 && isCtrl && !isAlt) { // ctrl-b (bold)
- CheckDlgButton(GetParent(hwnd), IDC_BOLD, IsDlgButtonChecked(GetParent(hwnd), IDC_BOLD) == BST_UNCHECKED?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BOLD, IsDlgButtonChecked(GetParent(hwnd), IDC_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BOLD, 0), 0);
return TRUE;
}
if (wParam == 0x55 && isCtrl && !isAlt) { // ctrl-u (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, IsDlgButtonChecked(GetParent(hwnd), IDC_UNDERLINE) == BST_UNCHECKED?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, IsDlgButtonChecked(GetParent(hwnd), IDC_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_UNDERLINE, 0), 0);
return TRUE;
}
if (wParam == 0x4b && isCtrl && !isAlt) { // ctrl-k (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_COLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR) == BST_UNCHECKED?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_COLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_COLOR, 0), 0);
return TRUE;
}
@@ -470,7 +470,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == 0x4c && isCtrl && !isAlt) { // ctrl-l (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_BKGCOLOR) == BST_UNCHECKED?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BKGCOLOR, 0), 0);
return TRUE;
}
@@ -498,7 +498,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return TRUE;
}
- if ((wParam == 45 && isShift || wParam == 0x56 && isCtrl )&& !isAlt) { // ctrl-v (paste clean text)
+ if ((wParam == 45 && isShift || wParam == 0x56 && isCtrl) && !isAlt) { // ctrl-v (paste clean text)
SendMessage(hwnd, EM_PASTESPECIAL, CF_TEXT, 0);
return TRUE;
}
@@ -535,7 +535,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
- SendMessage(hwnd, EM_SCROLLCARET, 0,0);
+ SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
SendMessage(hwnd, EM_SETSEL, iLen, iLen);
@@ -583,18 +583,18 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
CHARRANGE sel, all = { 0, -1 };
HMENU hSubMenu = GetSubMenu(g_hMenu, 4);
TranslateMenu(hSubMenu);
- SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
- EnableMenuItem(hSubMenu, ID_MESSAGE_UNDO, SendMessage(hwnd, EM_CANUNDO, 0,0)?MF_ENABLED:MF_GRAYED);
- EnableMenuItem(hSubMenu, ID_MESSAGE_REDO, SendMessage(hwnd, EM_CANREDO, 0,0)?MF_ENABLED:MF_GRAYED);
- EnableMenuItem(hSubMenu, ID_MESSAGE_COPY, sel.cpMax!=sel.cpMin?MF_ENABLED:MF_GRAYED);
- EnableMenuItem(hSubMenu, ID_MESSAGE_CUT, sel.cpMax!=sel.cpMin?MF_ENABLED:MF_GRAYED);
+ EnableMenuItem(hSubMenu, ID_MESSAGE_UNDO, SendMessage(hwnd, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(hSubMenu, ID_MESSAGE_REDO, SendMessage(hwnd, EM_CANREDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(hSubMenu, ID_MESSAGE_COPY, sel.cpMax != sel.cpMin ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(hSubMenu, ID_MESSAGE_CUT, sel.cpMax != sel.cpMin ? MF_ENABLED : MF_GRAYED);
dat->lastEnterTime = 0;
POINT pt;
pt.x = (short)LOWORD(lParam);
- pt.y = (short) HIWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
ClientToScreen(hwnd, &pt);
UINT uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
@@ -623,14 +623,14 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case ID_MESSAGE_SELECTALL:
- SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM) & all);
+ SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)& all);
break;
case ID_MESSAGE_CLEAR:
- SetWindowText(hwnd, _T( "" ));
+ SetWindowText(hwnd, _T(""));
break;
}
- PostMessage(hwnd, WM_KEYUP, 0, 0 );
+ PostMessage(hwnd, WM_KEYUP, 0, 0);
}
break;
@@ -644,7 +644,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_BACKCOLOR|CFM_COLOR;
+ cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bColor) {
@@ -811,11 +811,11 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_LBUTTONUP:
{
CHARRANGE sel;
- SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM) &sel);
+ SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax) {
SendMessage(hwnd, WM_COPY, 0, 0);
- sel.cpMin = sel.cpMax ;
- SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM) & sel);
+ sel.cpMin = sel.cpMax;
+ SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel);
}
SetFocus(GetDlgItem(GetParent(hwnd), IDC_MESSAGE));
}
@@ -830,10 +830,10 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_ACTIVATE:
if (LOWORD(wParam) == WA_INACTIVE) {
CHARRANGE sel;
- SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM) &sel);
+ SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax) {
- sel.cpMin = sel.cpMax ;
- SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM) & sel);
+ sel.cpMin = sel.cpMax;
+ SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel);
}
}
break;
@@ -922,8 +922,8 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_LBUTTONDBLCLK:
{
TCHITTESTINFO tci = {0};
- tci.pt.x=(short)LOWORD(GetMessagePos());
- tci.pt.y=(short)HIWORD(GetMessagePos());
+ tci.pt.x = (short)LOWORD(GetMessagePos());
+ tci.pt.y = (short)HIWORD(GetMessagePos());
tci.flags = TCHT_ONITEM;
ScreenToClient(hwnd, &tci.pt);
@@ -1983,7 +1983,7 @@ LABEL_SHOWWINDOW:
si.nPos = si.nMax - si.nPage + 1;
SetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &si, TRUE);
sel.cpMin = sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG));
- SendMessage(GetDlgItem(hwndDlg, IDC_LOG), EM_EXSETSEL, 0, (LPARAM) & sel);
+ SendMessage(GetDlgItem(hwndDlg, IDC_LOG), EM_EXSETSEL, 0, (LPARAM) &sel);
PostMessage(GetDlgItem(hwndDlg, IDC_LOG), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
} }
break;
@@ -2164,10 +2164,10 @@ LABEL_SHOWWINDOW:
break;
case ID_COPYALL:
- SendMessage(pNmhdr->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendMessage(pNmhdr->hwndFrom, EM_EXGETSEL, 0, (LPARAM) &sel);
SendMessage(pNmhdr->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
SendMessage(pNmhdr->hwndFrom, WM_COPY, 0, 0);
- SendMessage(pNmhdr->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & sel);
+ SendMessage(pNmhdr->hwndFrom, EM_EXSETSEL, 0, (LPARAM) &sel);
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
break;
@@ -2226,7 +2226,7 @@ LABEL_SHOWWINDOW:
TEXTRANGE tr;
CHARRANGE sel;
- SendMessage(pNmhdr->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendMessage(pNmhdr->hwndFrom, EM_EXGETSEL, 0, (LPARAM) &sel);
if (sel.cpMin != sel.cpMax)
break;
tr.chrg = ((ENLINK *) lParam)->chrg;
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h
index c916ca565a..91caba9bde 100644
--- a/src/modules/chat/chat.h
+++ b/src/modules/chat/chat.h
@@ -87,6 +87,8 @@ 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, DWORD dwItem);
BOOL IsEventSupported(int eventType);
BOOL LogToFile(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, ...);
const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2);
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index a89d70cc3e..f39318bc32 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -397,12 +397,12 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
case GC_EVENT_TOPIC:
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
if (gce->ptszText) {
- replaceStrT(si->ptszTopic, gce->ptszText);
- db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
+ replaceStrT(si->ptszTopic, RemoveFormatting(gce->ptszText));
+ db_set_ts(si->hContact, si->pszModule, "Topic", 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));
+ db_set_ts(si->hContact, "CList", "StatusMsg", si->ptszTopic);
}
}
break;
diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp
index f8b30bcc68..07dace2d3b 100644
--- a/src/modules/chat/clist.cpp
+++ b/src/modules/chat/clist.cpp
@@ -24,21 +24,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
HANDLE AddRoom(const char *pszModule, const TCHAR *pszRoom, const TCHAR *pszDisplayName, int iType)
{
- HANDLE hContact = ci.FindRoom(pszModule, pszRoom);
- DBVARIANT dbv;
- TCHAR pszGroup[50];
-
- *pszGroup = '\0';
- if (!db_get_ts(NULL, "Chat", "AddToGroup", &dbv)) {
- if (lstrlen(dbv.ptszVal) > 0)
- lstrcpyn(pszGroup, dbv.ptszVal, 50);
- db_free(&dbv);
+ TCHAR pszGroup[50]; *pszGroup = '\0';
+ ptrT groupName(db_get_tsa(NULL, "Chat", "AddToGroup"));
+ if (groupName)
+ _tcsncpy_s(pszGroup, SIZEOF(pszGroup), groupName, _TRUNCATE);
+ else
+ _tcscpy(pszGroup, _T("Chat rooms"));
+
+ if (pszGroup[0]) {
+ HANDLE hGroup = Clist_GroupExists(pszGroup);
+ if (hGroup == 0) {
+ hGroup = Clist_CreateGroup(0, pszGroup);
+ if (hGroup) {
+ CallService(MS_CLUI_GROUPADDED, (WPARAM)hGroup, 0);
+ CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)hGroup, 1);
+ }
+ }
}
- else lstrcpyn(pszGroup, _T("Chat rooms"), 50);
-
- if (pszGroup[0])
- Clist_CreateGroup(0, pszGroup);
+ HANDLE hContact = ci.FindRoom(pszModule, pszRoom);
if (hContact) { //contact exist, make sure it is in the right group
if (pszGroup[0]) {
ptrT grpName(db_get_tsa(hContact, "CList", "Group"));
@@ -109,28 +113,25 @@ int RoomDoubleclicked(WPARAM wParam, LPARAM lParam)
if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
return 0;
- DBVARIANT dbv;
- if (!db_get_ts(hContact, szProto, "ChatRoomID", &dbv)) {
- SESSION_INFO *si = ci.SM_FindSession(dbv.ptszVal, szProto);
- if (si) {
- // is the "toggle visibility option set, so we need to close the window?
- if (si->hWnd != NULL
- && db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1
- && !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0)
- && IsWindowVisible(si->hWnd) && !IsIconic(si->hWnd))
- {
- if (ci.OnSessionDblClick)
- ci.OnSessionDblClick(si);
- db_free(&dbv);
- return 1;
- }
- ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ ptrT roomid(db_get_tsa(hContact, szProto, "ChatRoomID"));
+ if (roomid == NULL)
+ return 0;
+
+ SESSION_INFO *si = ci.SM_FindSession(roomid, szProto);
+ if (si) {
+ // is the "toggle visibility option set, so we need to close the window?
+ if (si->hWnd != NULL &&
+ db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1 &&
+ !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0) &&
+ IsWindowVisible(si->hWnd) && !IsIconic(si->hWnd))
+ {
+ if (ci.OnSessionDblClick)
+ ci.OnSessionDblClick(si);
+ return 1;
}
- db_free(&dbv);
- return 1;
+ ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
-
- return 0;
+ return 1;
}
INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam)
@@ -238,14 +239,9 @@ HANDLE FindRoom(const char *pszModule, const TCHAR *pszRoom)
if (!db_get_b(hContact, pszModule, "ChatRoom", 0))
continue;
- DBVARIANT dbv;
- if (!db_get_ts(hContact, pszModule, "ChatRoomID", &dbv)) {
- if (!lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free(&dbv);
- return hContact;
- }
- db_free(&dbv);
- }
+ ptrT roomid(db_get_tsa(hContact, pszModule, "ChatRoomID"));
+ if (roomid != NULL && !lstrcmpi(roomid, pszRoom))
+ return hContact;
}
return 0;
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index 488b038a7d..7dd26e8713 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -70,6 +70,9 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char *pszModule)
node->ptszID = mir_tstrdup(pszID);
node->pszModule = mir_strdup(pszModule);
+ if (ci.OnCreateSession)
+ ci.OnCreateSession(node, ci.MM_FindModule(pszModule));
+
if (ci.wndList == NULL) { // list is empty
ci.wndList = node;
node->next = NULL;
@@ -292,6 +295,7 @@ static BOOL SM_AddEvent(const TCHAR *pszID, const char *pszModule, GCEVENT *gce,
if (ci.pSettings->iEventLimit > 0 && pTemp->iEventCount > ci.pSettings->iEventLimit + 20) {
ci.LM_TrimLog(&pTemp->pLog, &pTemp->pLogEnd, pTemp->iEventCount - ci.pSettings->iEventLimit);
+ pTemp->bTrimmed = true;
pTemp->iEventCount = ci.pSettings->iEventLimit;
return FALSE;
}
@@ -652,6 +656,8 @@ static BOOL SM_ChangeNick(const TCHAR *pszID, const char *pszModule, GCEVENT *gc
SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
if (pTemp->hWnd)
SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
+ if (ci.OnChangeNick)
+ ci.OnChangeNick(pTemp);
}
if (pszID)
@@ -1455,7 +1461,10 @@ CHAT_MANAGER ci =
FindRoom,
Log_CreateRTF,
LoadMsgDlgFont,
- MakeTimeStamp
+ MakeTimeStamp,
+ DoPopup,
+ ShowPopup,
+ RemoveFormatting
};
INT_PTR SvcGetChatManager(WPARAM, LPARAM lParam)
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index 665bd61ecb..c34c1064bb 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -116,7 +116,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
return DefWindowProc(hWnd, message, wParam, lParam);
}
-static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
+int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
{
static TCHAR szBuf[4 * 1024];
@@ -214,7 +214,7 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
return TRUE;
}
-static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
+BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
{
int iEvent = gce->pDest->iType;