diff options
Diffstat (limited to 'src')
25 files changed, 719 insertions, 4278 deletions
diff --git a/src/core/commonheaders.h b/src/core/commonheaders.h index 1ee41ff5f1..1a8cc47235 100644 --- a/src/core/commonheaders.h +++ b/src/core/commonheaders.h @@ -66,7 +66,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <newpluginapi.h>
#include <m_database.h>
#include <m_db_int.h>
-#include <m_chat_int.h>
#include <m_clc.h>
#include <m_clui.h>
#include <m_crypto.h>
@@ -102,4 +101,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_netlib.h>
#include <m_xml.h>
+typedef struct GlobalLogSettingsBase GlobalLogSettings;
+#include <m_chat_int.h>
+
#include "../resource.h"
\ No newline at end of file diff --git a/src/core/modules.cpp b/src/core/modules.cpp index b1d7cbafcb..a6b6d2d9e3 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
#include "../modules/plugins/plugins.h"
+#include "../modules/chat/chat.h"
int CheckRestart(); // core: IDD_WAITRESTART
@@ -88,19 +89,19 @@ int LoadDescButtonModule(); int LoadDefaultModules(void)
{
//load order is very important for these
- if ( LoadSystemModule()) return 1;
- if ( LoadLangpackModule()) return 1; // langpack will be a system module in the new order so this is moved here
- if ( CheckRestart()) return 1;
- if ( LoadUtilsModule()) return 1; //order not important for this, but no dependencies and no point in pluginising
- if ( LoadIcoTabsModule()) return 1;
- if ( LoadHeaderbarModule()) return 1;
- if ( LoadDbintfModule()) return 1;
- if ( LoadEventsModule()) return 1;
+ if (LoadSystemModule()) return 1;
+ if (LoadLangpackModule()) return 1; // langpack will be a system module in the new order so this is moved here
+ if (CheckRestart()) return 1;
+ if (LoadUtilsModule()) return 1; //order not important for this, but no dependencies and no point in pluginising
+ if (LoadIcoTabsModule()) return 1;
+ if (LoadHeaderbarModule()) return 1;
+ if (LoadDbintfModule()) return 1;
+ if (LoadEventsModule()) return 1;
// load database drivers & service plugins without executing their Load()
- if ( LoadNewPluginsModuleInfos()) return 1;
+ if (LoadNewPluginsModuleInfos()) return 1;
- switch ( LoadDefaultServiceModePlugin()) {
+ switch (LoadDefaultServiceModePlugin()) {
case SERVICE_CONTINUE: // continue loading Miranda normally
case SERVICE_ONLYDB: // load database and go to the message cycle
break;
@@ -111,12 +112,12 @@ int LoadDefaultModules(void) }
// the database will select which db plugin to use, or fail if no profile is selected
- if ( LoadDatabaseModule()) return 1;
+ if (LoadDatabaseModule()) return 1;
// database is available here
- if ( LoadButtonModule()) return 1;
- if ( LoadIcoLibModule()) return 1;
- if ( LoadSkinIcons()) return 1;
+ if (LoadButtonModule()) return 1;
+ if (LoadIcoLibModule()) return 1;
+ if (LoadSkinIcons()) return 1;
// if ( LoadErrorsModule()) return 1;
@@ -132,37 +133,40 @@ int LoadDefaultModules(void) return 1;
}
- if ( LoadSkinSounds()) return 1;
- if ( LoadSkinHotkeys()) return 1;
- if ( LoadFontserviceModule()) return 1;
- if ( LoadSrmmModule()) return 1;
-
- if ( LoadDescButtonModule()) return 1;
- if ( LoadOptionsModule()) return 1;
- if ( LoadNetlibModule()) return 1;
- if ( LoadSslModule()) return 1;
- NetlibInitSsl();
- if ( LoadProtocolsModule()) return 1;
- LoadDbAccounts(); // retrieves the account array from a database
- if ( LoadContactsModule()) return 1;
- if ( LoadContactListModule()) return 1; // prepare contact list interface
- if ( LoadAddContactModule()) return 1;
- if ( LoadNewPluginsModule()) return 1; // will call Load(void) on everything, clist will load first
+ if (LoadSkinSounds()) return 1;
+ if (LoadSkinHotkeys()) return 1;
+ if (LoadFontserviceModule()) return 1;
+ if (LoadSrmmModule()) return 1;
+ InitChatModule();
+
+ if (LoadDescButtonModule()) return 1;
+ if (LoadOptionsModule()) return 1;
+ if (LoadNetlibModule()) return 1;
+ if (LoadSslModule()) return 1;
+ NetlibInitSsl();
+ if (LoadProtocolsModule()) return 1;
+ LoadDbAccounts(); // retrieves the account array from a database
+ if (LoadContactsModule()) return 1;
+ if (LoadContactListModule()) return 1; // prepare contact list interface
+ // LoadChatModule();
+ if (LoadAddContactModule()) return 1;
+ if (LoadNewPluginsModule()) return 1; // will call Load(void) on everything, clist will load first
Langpack_SortDuplicates();
- if ( LoadAccountsModule()) return 1;
+ if (LoadAccountsModule()) return 1;
//order becomes less important below here
- if ( LoadFindAddModule()) return 1;
- if ( LoadIgnoreModule()) return 1;
- if ( LoadVisibilityModule()) return 1;
- if ( LoadStdPlugins()) return 1;
+ if (LoadFindAddModule()) return 1;
+ if (LoadIgnoreModule()) return 1;
+ if (LoadVisibilityModule()) return 1;
+ if (LoadStdPlugins()) return 1;
return 0;
}
void UnloadDefaultModules(void)
{
+ UnloadChatModule();
UnloadAccountsModule();
UnloadNewPlugins();
UnloadProtocolsModule();
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h index 2bb2bd3384..ae009c1b65 100644 --- a/src/core/stdchat/src/chat.h +++ b/src/core/stdchat/src/chat.h @@ -57,8 +57,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_message.h>
#include <m_icolib.h>
#include <m_popup.h>
-#include <m_chat.h>
+#include <m_chat_int.h>
#include <m_core.h>
+#include <m_string.h>
#include "m_ieview.h"
#include "m_smileyadd.h"
@@ -67,251 +68,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "version.h"
#include "richutil.h"
-#ifndef NDEBUG
-#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
-#endif
-
-//defines
-#define OPTIONS_FONTCOUNT 17
-#define GC_UPDATETITLE (WM_USER+100)
-#define GC_SPLITTERMOVED (WM_USER+101)
-#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_SETWINDOWPOS (WM_USER+114)
-#define GC_SAVEWNDPOS (WM_USER+115)
-//#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_TABCHANGE (WM_USER+127)
-#define GC_ADDTAB (WM_USER+128)
-#define GC_SCROLLTOBOTTOM (WM_USER+129)
-#define GC_REMOVETAB (WM_USER+130)
-#define GC_SESSIONNAMECHANGE (WM_USER+131)
-#define GC_FIXTABICONS (WM_USER+132)
-#define GC_DROPPEDTAB (WM_USER+133)
-#define GC_TABCLICKED (WM_USER+134)
-#define GC_SWITCHNEXTTAB (WM_USER+135)
-#define GC_SWITCHPREVTAB (WM_USER+136)
-#define GC_SWITCHTAB (WM_USER+137)
-#define GC_SETTABHIGHLIGHT (WM_USER+138)
-#define GC_SETMESSAGEHIGHLIGHT (WM_USER+139)
-#define GC_REDRAWLOG2 (WM_USER+140)
-#define GC_REDRAWLOG3 (WM_USER+141)
-
-#define EM_SUBCLASSED (WM_USER+200)
-#define EM_UNSUBCLASSED (WM_USER+201)
-#define EM_ACTIVATE (WM_USER+202)
-
-#define TIMERID_FLASHWND 205
-
-#define GCW_TABROOM 10
-#define GCW_TABPRIVMSG 11
-
-#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
-
-// special service for tweaking performance
-#define MS_GC_GETEVENTPTR "GChat/GetNewEventPtr"
-typedef INT_PTR (*GETEVENTFUNC)(WPARAM wParam, LPARAM lParam);
-typedef struct {
- GETEVENTFUNC pfnAddEvent;
-}GCPTRS;
-
-extern HINSTANCE g_hInst;
-
-//structs
-
-typedef struct MODULE_INFO_TYPE
-{
- char* pszModule;
- TCHAR* ptszModDispName;
- char* pszHeader;
- BOOL bBold;
- BOOL bUnderline;
- BOOL bItalics;
- BOOL bColor;
- BOOL bBkgColor;
- BOOL bChanMgr;
- BOOL bAckMsg;
- int nColorCount;
- COLORREF* crColors;
- HICON hOnlineIcon;
- HICON hOfflineIcon;
- HICON hOnlineTalkIcon;
- HICON hOfflineTalkIcon;
- int OnlineIconIndex;
- int OfflineIconIndex;
- int iMaxText;
- struct MODULE_INFO_TYPE *next;
-}
- MODULEINFO;
-
-typedef struct COMMAND_INFO_TYPE
-{
- char* lpCommand;
- struct COMMAND_INFO_TYPE *last, *next;
-}
- COMMAND_INFO;
-
-typedef struct
-{
- LOGFONT lf;
- COLORREF color;
-}
- FONTINFO;
-
-typedef struct LOG_INFO_TYPE
-{
- TCHAR* ptszText;
- TCHAR* ptszNick;
- TCHAR* ptszUID;
- TCHAR* ptszStatus;
- TCHAR* ptszUserInfo;
- BOOL bIsMe;
- BOOL bIsHighlighted;
- time_t time;
- int iType;
- struct LOG_INFO_TYPE *next;
- struct LOG_INFO_TYPE *prev;
-}
- LOGINFO;
-
-typedef struct STATUSINFO_TYPE
+struct GlobalLogSettings : public GlobalLogSettingsBase
{
- TCHAR* pszGroup;
- HICON hIcon;
- WORD Status;
- struct STATUSINFO_TYPE *next;
-}
- STATUSINFO;
-
-typedef struct USERINFO_TYPE
-{
- TCHAR* pszNick;
- TCHAR* pszUID;
- WORD Status;
- int iStatusEx;
- WORD ContactStatus;
- struct USERINFO_TYPE *next;
-}
- USERINFO;
-
-typedef struct TABLIST_TYPE
-{
- TCHAR* pszID;
- char* pszModule;
- struct TABLIST_TYPE *next;
-}
- TABLIST;
-
-typedef struct SESSION_INFO_TYPE
-{
- HWND hWnd;
-
- BOOL bFGSet;
- BOOL bBGSet;
- BOOL bFilterEnabled;
- BOOL bNicklistEnabled;
- BOOL bInitDone;
-
- char* pszModule;
- TCHAR* ptszID;
- TCHAR* ptszName;
- TCHAR* ptszStatusbarText;
- TCHAR* ptszTopic;
-
- // I hate m3x, Unicode, IRC, chats etc...
- 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 nUsersInNicklist;
- int iEventCount;
- int iX;
- int iY;
- int iWidth;
- int iHeight;
- int iStatusCount;
-
- WORD wStatus;
- WORD wState;
- WORD wCommandsNum;
- DWORD dwItemData;
- DWORD dwFlags;
- HANDLE hContact;
- HWND hwndStatus;
- time_t LastTime;
-
- COMMAND_INFO* lpCommands;
- COMMAND_INFO* lpCurrentCommand;
- LOGINFO* pLog;
- LOGINFO* pLogEnd;
- USERINFO* pUsers;
- USERINFO* pMe;
- STATUSINFO* pStatuses;
-
- HWND hwndTooltip;
- int iOldItemID;
+ BOOL TabsEnable;
+ BOOL TabsAtBottom;
+ BOOL TabCloseOnDblClick;
+ BOOL TabRestore;
+};
- IAccPropServices* pAccPropServicesForNickList;
- struct SESSION_INFO_TYPE *next;
-}
- SESSION_INFO;
+extern GlobalLogSettings g_Settings;
+extern SESSION_INFO g_TabSession;
-typedef struct
-{
- char* buffer;
- int bufferOffset, bufferLen;
- HWND hwnd;
- LOGINFO* lin;
- BOOL bStripFormat;
- BOOL bRedraw;
- SESSION_INFO *si;
-}
- LOGSTREAMDATA;
+extern HINSTANCE g_hInst;
struct CREOleCallback : public IRichEditOleCallback
{
@@ -336,85 +104,28 @@ struct CREOleCallback : public IRichEditOleCallback STDMETHOD(GetContextMenu) (WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR * lpchrg, HMENU FAR * lphmenu) ;
};
-struct GlobalLogSettings_t {
- BOOL ShowTime;
- BOOL ShowTimeIfChanged;
- BOOL LoggingEnabled;
- BOOL FlashWindow;
- BOOL HighlightEnabled;
- BOOL LogIndentEnabled;
- BOOL StripFormat;
- BOOL SoundsFocus;
- BOOL PopupInactiveOnly;
- BOOL TrayIconInactiveOnly;
- BOOL AddColonToAutoComplete;
- BOOL TabsEnable;
- BOOL TabCloseOnDblClick;
- BOOL TabRestore;
- BOOL LogLimitNames;
- BOOL TabsAtBottom;
- BOOL TimeStampEventColour;
- DWORD dwIconFlags;
- DWORD dwTrayIconFlags;
- DWORD dwPopupFlags;
- int LogTextIndent;
- int LoggingLimit;
- int iEventLimit;
- int iPopupStyle;
- int iPopupTimeout;
- int iSplitterX;
- int iSplitterY;
- int iX;
- int iY;
- int iWidth;
- int iHeight;
- TCHAR* pszTimeStamp;
- TCHAR* pszTimeStampLog;
- TCHAR* pszIncomingNick;
- TCHAR* pszOutgoingNick;
- TCHAR* pszHighlightWords;
- TCHAR* pszLogDir;
- HFONT UserListFont;
- HFONT UserListHeadingsFont;
- HFONT MessageBoxFont;
- HFONT NameFont;
- COLORREF crLogBackground;
- COLORREF crUserListColor;
- COLORREF crUserListBGColor;
- COLORREF crUserListSelectedBGColor;
- COLORREF crUserListHeadingsColor;
- COLORREF crPUTextColour;
- COLORREF crPUBkgColour;
- BOOL ShowContactStatus;
- BOOL ContactStatusFirst;
-};
-extern struct GlobalLogSettings_t g_Settings;
-
-typedef struct{
+struct COLORCHOOSER
+{
MODULEINFO* pModule;
int xPosition;
int yPosition;
HWND hWndTarget;
BOOL bForeground;
SESSION_INFO *si;
-}
- COLORCHOOSER;
+};
+
+extern BOOL SmileyAddInstalled;
//main.c
-extern HGENMENU hJoinMenuItem, hLeaveMenuItem;
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);
void ValidateFilename (TCHAR * filename);
TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time);
char* Log_CreateRtfHeader(MODULEINFO * mi);
@@ -426,100 +137,11 @@ int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth); //options.c
int OptionsInit(void);
int OptionsUnInit(void);
-void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour);
-void LoadGlobalSettings(void);
void AddIcons(void);
HICON LoadIconEx(char* pszIcoLibName, BOOL big);
-void LoadLogFonts(void);
-//services.c
-void HookEvents(void);
-void UnhookEvents(void);
-void CreateServiceFunctions(void);
-void CreateHookableEvents(void);
-void DestroyHookableEvents(void);
-void TabsInit(void);
+// services.c
void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
-
-//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);
-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);
-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);
-BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd);
-HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui);
-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);
-SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);
-SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si);
-BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce);
-BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted);
-LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
-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_FindSessionByIndex(const char* pszModule, int iItem);
-char* SM_GetUsers(SESSION_INFO *si);
-USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index);
-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);
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... ) ;
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
-int WCCmp(TCHAR* wild, TCHAR*string);
-
//tools.c
TCHAR* RemoveFormatting(const TCHAR* pszText);
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
@@ -533,12 +155,14 @@ 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);
// message.c
char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si);
+BOOL TabM_AddTab(const TCHAR *pszID, const char* pszModule);
+BOOL TabM_RemoveAll(void);
+
#pragma comment(lib,"comctl32.lib")
#endif
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp index 3c44b166ea..d1dc268183 100644 --- a/src/core/stdchat/src/clist.cpp +++ b/src/core/stdchat/src/clist.cpp @@ -82,7 +82,7 @@ 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 ( pci->MM_FindModule( szProto )) {
if ( !pszModule || ( pszModule && !strcmp( pszModule, szProto ))) {
int i = db_get_b(hContact, szProto, "ChatRoom", 0);
if ( i != 0 ) {
@@ -104,7 +104,7 @@ int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam ) return 0;
szProto = GetContactProto(hContact);
- if ( MM_FindModule(szProto)) {
+ if ( pci->MM_FindModule(szProto)) {
if ( db_get_b( hContact, szProto, "ChatRoom", 0 ) == 0 )
return 0;
@@ -198,7 +198,7 @@ INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam) return CList_PrebuildContactMenu(wParam, lParam);
}
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
+BOOL pci->AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
{
CLISTEVENT cle = {0};
va_list marker;
diff --git a/src/core/stdchat/src/log.cpp b/src/core/stdchat/src/log.cpp index d3574ed603..ce1d10b9f6 100644 --- a/src/core/stdchat/src/log.cpp +++ b/src/core/stdchat/src/log.cpp @@ -20,301 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-
// The code for streaming the text is to a large extent copied from
// the srmm module and then modified to fit the chat module.
-extern FONTINFO aFonts[OPTIONS_FONTCOUNT];
-extern HICON hIcons[30];
-extern BOOL SmileyAddInstalled;
-
-static PBYTE pLogIconBmpBits[14];
-static int logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
-
-static int logPixelSY = 0;
-static int logPixelSX = 0;
-
-static int EventToIndex(LOGINFO * lin)
-{
- switch (lin->iType) {
- case GC_EVENT_MESSAGE:
- if (lin->bIsMe)
- return 10;
- else
- return 9;
-
- case GC_EVENT_JOIN: return 3;
- case GC_EVENT_PART: return 4;
- case GC_EVENT_QUIT: return 5;
- case GC_EVENT_NICK: return 7;
- case GC_EVENT_KICK: return 6;
- case GC_EVENT_NOTICE: return 8;
- case GC_EVENT_TOPIC: return 11;
- case GC_EVENT_INFORMATION:return 12;
- case GC_EVENT_ADDSTATUS: return 13;
- case GC_EVENT_REMOVESTATUS: return 14;
- case GC_EVENT_ACTION: return 15;
- }
- return 0;
-}
-
-static int EventToIcon(LOGINFO * lin)
-{
- switch (lin->iType) {
- case GC_EVENT_MESSAGE:
- if (lin->bIsMe)
- return ICON_MESSAGEOUT;
- else
- return ICON_MESSAGE;
-
- case GC_EVENT_JOIN: return ICON_JOIN;
- case GC_EVENT_PART: return ICON_PART;
- case GC_EVENT_QUIT: return ICON_QUIT;
- case GC_EVENT_NICK: return ICON_NICK;
- case GC_EVENT_KICK: return ICON_KICK;
- case GC_EVENT_NOTICE: return ICON_NOTICE;
- case GC_EVENT_TOPIC: return ICON_TOPIC;
- case GC_EVENT_INFORMATION:return ICON_INFO;
- case GC_EVENT_ADDSTATUS: return ICON_ADDSTATUS;
- case GC_EVENT_REMOVESTATUS: return ICON_REMSTATUS;
- case GC_EVENT_ACTION: return ICON_ACTION;
- }
- return 0;
-}
-
-static char *Log_SetStyle(int style, int fontindex)
-{
- static char szStyle[128];
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", style, style+1, aFonts[fontindex].lf.lfWeight >= FW_BOLD ? 1 : 0, aFonts[fontindex].lf.lfItalic, 2 * abs(aFonts[fontindex].lf.lfHeight) * 74 / logPixelSY);
- return szStyle;
-}
-
-static void Log_Append(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *fmt, ...)
-{
- va_list va;
- int charsDone = 0;
-
- va_start(va, fmt);
- for (;;) {
- charsDone = mir_vsnprintf(*buffer + *cbBufferEnd, *cbBufferAlloced - *cbBufferEnd, fmt, va);
- if (charsDone >= 0)
- break;
- *cbBufferAlloced += 4096;
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
- }
- va_end(va);
- *cbBufferEnd += charsDone;
-}
-
-static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const TCHAR *fmt, ...)
-{
- va_list va;
- int lineLen, textCharsCount=0;
- TCHAR* line = (TCHAR*)alloca(8001 * sizeof(TCHAR));
- char* d;
-
- va_start(va, fmt);
- lineLen = mir_vsntprintf( line, 8000, fmt, va);
- if (lineLen < 0) lineLen = 8000;
- line[lineLen] = 0;
- va_end(va);
-
- lineLen = lineLen*20 + 8;
- if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
- cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
- }
-
- d = *buffer + *cbBufferEnd;
-
- for (; *line; line++, textCharsCount++) {
- if (*line == '\r' && line[1] == '\n') {
- CopyMemory(d, "\\par ", 5);
- line++;
- d += 5;
- }
- else if (*line == '\n') {
- CopyMemory(d, "\\line ", 6);
- d += 6;
- }
- else if (*line == '%' && !simpleMode ) {
- char szTemp[200];
-
- szTemp[0] = '\0';
- switch ( *++line ) {
- case '\0':
- case '%':
- *d++ = '%';
- break;
-
- case 'c':
- case 'f':
- if (g_Settings.StripFormat || streamData->bStripFormat)
- line += 2;
-
- else if ( line[1] != '\0' && line[2] != '\0') {
- TCHAR szTemp3[3], c = *line;
- int col;
- szTemp3[0] = line[1];
- szTemp3[1] = line[2];
- szTemp3[2] = '\0';
- line += 2;
-
- col = _ttoi(szTemp3);
- col += (OPTIONS_FONTCOUNT + 1);
- mir_snprintf(szTemp, SIZEOF(szTemp), ( c == 'c' ) ? "\\cf%u " : "\\highlight%u ", col);
- }
- break;
- case 'C':
- case 'F':
- 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);
- else
- mir_snprintf(szTemp, SIZEOF(szTemp), "\\highlight0 ");
- }
- break;
- case 'b':
- case 'u':
- case 'i':
- if ( !streamData->bStripFormat )
- mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line );
- break;
-
- case 'B':
- case 'U':
- case 'I':
- if ( !streamData->bStripFormat ) {
- mir_snprintf( szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line );
- CharLowerA( szTemp );
- }
- break;
-
- case 'r':
- if ( !streamData->bStripFormat ) {
- int index = EventToIndex(streamData->lin);
- mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index));
- }
- break;
- }
-
- if ( szTemp[0] ) {
- int iLen = lstrlenA(szTemp);
- memcpy( d, szTemp, iLen );
- d += iLen;
- }
- }
- else if (*line == '\t' && !streamData->bStripFormat) {
- CopyMemory(d, "\\tab ", 5);
- d += 5;
- }
- else if ((*line == '\\' || *line == '{' || *line == '}') && !streamData->bStripFormat) {
- *d++ = '\\';
- *d++ = (char) *line;
- }
- else if (*line > 0 && *line < 128) {
- *d++ = (char) *line;
- }
- else d += sprintf(d, "\\u%u ?", (WORD)*line); //!!!!!!!!!!!
- }
-
- *cbBufferEnd = (int) (d - *buffer);
- return textCharsCount;
-}
-
-static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, LOGSTREAMDATA *streamData)
-{
- TCHAR szTemp[512], szTemp2[512];
- TCHAR* pszNick = NULL;
- if ( streamData->lin->ptszNick ) {
- if ( g_Settings.LogLimitNames && lstrlen( streamData->lin->ptszNick ) > 20 ) {
- lstrcpyn( szTemp2, streamData->lin->ptszNick, 20 );
- lstrcpyn( szTemp2+20, _T("..."), 4);
- }
- else lstrcpyn( szTemp2, streamData->lin->ptszNick, 511 );
-
- if ( streamData->lin->ptszUserInfo )
- mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, streamData->lin->ptszUserInfo );
- else
- mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%s"), szTemp2 );
- pszNick = szTemp;
- }
-
- if ( streamData && streamData->lin ) {
- switch ( streamData->lin->iType ) {
- case GC_EVENT_MESSAGE:
- if ( streamData->lin->ptszText )
- Log_AppendRTF( streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText );
- break;
- case GC_EVENT_ACTION:
- if ( streamData->lin->ptszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick);
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_JOIN:
- if (pszNick) {
- if (!streamData->lin->bIsMe)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has joined"), pszNick);
- else
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName);
- }
- break;
- case GC_EVENT_PART:
- if (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_QUIT:
- if (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_NICK:
- if (pszNick && streamData->lin->ptszText) {
- if (!streamData->lin->bIsMe)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText);
- else
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_KICK:
- if (streamData->lin->ptszNick && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, streamData->lin->ptszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_NOTICE:
- if (pszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s: "), pszNick );
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_TOPIC:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r"));
- if (streamData->lin->ptszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced,
- streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)"): TranslateT(" (set by %s)"),
- streamData->lin->ptszNick, streamData->lin->ptszUserInfo);
- break;
- case GC_EVENT_INFORMATION:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_ADDSTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s enables \'%s\' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s disables \'%s\' status for %s"), streamData->lin->ptszText , streamData->lin->ptszStatus, streamData->lin->ptszNick);
- break;
-} } }
-
TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time)
{
static TCHAR szTime[30];
@@ -323,128 +31,14 @@ TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time) 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);
-
- // guesstimate amount of memory for the RTF
- bufferEnd = 0;
- bufferAlloced = streamData->bRedraw ? 1024 * (streamData->si->iEventCount+2) : 2048;
- buffer = (char *) mir_alloc(bufferAlloced);
- buffer[0] = '\0';
-
- // ### RTF HEADER
- header = mi->pszHeader;
-
- if (header)
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, header);
-
-
- // ### RTF BODY (one iteration per event that should be streamed in)
- while ( lin )
- {
- // filter
- if (streamData->si->iType != GCW_CHATROOM || !streamData->si->bFilterEnabled || (streamData->si->iLogFilterFlags&lin->iType) != 0)
- {
- // create new line, and set font and color
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\par%s ", Log_SetStyle(0, 0));
-
- // Insert icon
- if (lin->iType&g_Settings.dwIconFlags || lin->bIsHighlighted&&g_Settings.dwIconFlags&GC_EVENT_HIGHLIGHT)
- {
- int iIndex = (lin->bIsHighlighted&&g_Settings.dwIconFlags&GC_EVENT_HIGHLIGHT) ? ICON_HIGHLIGHT : EventToIcon(lin);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\f0\\fs14");
- while (bufferAlloced - bufferEnd < logIconBmpSize[0])
- bufferAlloced += 4096;
- buffer = (char *) mir_realloc(buffer, bufferAlloced);
- CopyMemory(buffer + bufferEnd, pLogIconBmpBits[iIndex], logIconBmpSize[iIndex]);
- bufferEnd += logIconBmpSize[iIndex];
- }
-
- if (g_Settings.TimeStampEventColour)
- {
- // colored timestamps
- static char szStyle[256];
- 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\\fs%u", iii+1, aFonts[0].lf.lfWeight >= FW_BOLD ? 1 : 0, aFonts[0].lf.lfItalic, 2 * abs(aFonts[0].lf.lfHeight) * 74 / logPixelSY);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
- }
- else
- {
- iii = lin->bIsHighlighted?16:EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii+1, aFonts[0].lf.lfWeight >= FW_BOLD ? 1 : 0, aFonts[0].lf.lfItalic, 2 * abs(aFonts[0].lf.lfHeight) * 74 / logPixelSY);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
- }
- }
- 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.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.ShowTimeIfChanged || streamData->si->LastTime == 0 || lstrcmp(szTimeStamp, szOldTimeStamp )) {
- streamData->si->LastTime = lin->time;
- Log_AppendRTF( streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, _T("%s"), szTimeStamp );
- }
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tab ");
- }
-
- // Insert the nick
- if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE)
- {
- TCHAR pszTemp[300], *p1;
-
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsMe ? 2 : 1, lin->bIsMe ? 2 : 1));
- lstrcpyn(pszTemp, lin->bIsMe ? g_Settings.pszOutgoingNick : g_Settings.pszIncomingNick, 299);
- p1 = _tcsstr(pszTemp, _T("%n"));
- if (p1)
- p1[1] = 's';
-
- Log_AppendRTF(streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, pszTemp, lin->ptszNick);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, " ");
- }
-
- // 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);
- }
-
- }
- lin = lin->prev;
- }
-
- // ### RTF END
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}");
- return buffer;
-}
-
static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA *) dwCookie;
-
- if (lstrdat)
- {
+ if (lstrdat) {
// create the RTF
- if (lstrdat->buffer == NULL)
- {
+ if (lstrdat->buffer == NULL) {
lstrdat->bufferOffset = 0;
- lstrdat->buffer = Log_CreateRTF(lstrdat);
+ lstrdat->buffer = pci->Log_CreateRTF(lstrdat);
lstrdat->bufferLen = lstrlenA(lstrdat->buffer);
}
@@ -454,8 +48,7 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG lstrdat->bufferOffset += *pcb;
// free stuff if the streaming operation is complete
- if (lstrdat->bufferOffset == lstrdat->bufferLen)
- {
+ if (lstrdat->bufferOffset == lstrdat->bufferLen) {
mir_free(lstrdat->buffer);
lstrdat->buffer = NULL;
}
@@ -466,34 +59,30 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw, BOOL bPhaseTwo)
{
- EDITSTREAM stream;
- LOGSTREAMDATA streamData;
CHARRANGE oldsel, sel, newsel;
POINT point ={0};
- SCROLLINFO scroll;
WPARAM wp;
- HWND hwndRich;
if (hwndDlg == 0 || lin == 0 || si == 0)
return;
- hwndRich = GetDlgItem(hwndDlg, IDC_LOG);
- ZeroMemory(&streamData, sizeof(LOGSTREAMDATA));
+ HWND hwndRich = GetDlgItem(hwndDlg, IDC_LOG);
+
+ LOGSTREAMDATA streamData = { 0 };
streamData.hwnd = hwndRich;
streamData.si = si;
streamData.lin = lin;
streamData.bStripFormat = FALSE;
- // bPhaseTwo = bRedraw && bPhaseTwo;
-
- if (bRedraw || si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags&lin->iType) != 0)
- {
+ if (bRedraw || si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags & lin->iType) != 0) {
BOOL bFlag = FALSE;
- ZeroMemory(&stream, sizeof(stream));
+ EDITSTREAM stream = { 0 };
stream.pfnCallback = Log_StreamCallback;
stream.dwCookie = (DWORD_PTR) & streamData;
- scroll.cbSize= sizeof(SCROLLINFO);
+
+ SCROLLINFO scroll;
+ scroll.cbSize = sizeof(SCROLLINFO);
scroll.fMask= SIF_RANGE | SIF_POS|SIF_PAGE;
GetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &scroll);
SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM) &point);
@@ -515,16 +104,13 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedr wp = bRedraw?SF_RTF:SFF_SELECTION|SF_RTF;
//get the number of pixels per logical inch
- if (bRedraw)
- {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC (NULL, hdc);
+ if (bRedraw) {
+ HDC hdc = GetDC(NULL);
+ pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
bFlag = TRUE;
- // SetCursor(LoadCursor(NULL, IDC_ARROW));
}
// stream in the event(s)
@@ -558,157 +144,21 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedr // scroll log to bottom if the log was previously scrolled to bottom, else restore old position
if (bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax-scroll.nPage-5 || scroll.nMax-scroll.nMin-scroll.nPage < 50)
- {
SendMessage(GetParent(hwndRich), GC_SCROLLTOBOTTOM, 0, 0);
- }
else
SendMessage(hwndRich, EM_SETSCROLLPOS, 0, (LPARAM) &point);
// do we need to restore the selection
- if (oldsel.cpMax != oldsel.cpMin)
- {
+ if (oldsel.cpMax != oldsel.cpMin) {
SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) & oldsel);
SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hwndRich, NULL, TRUE);
}
// need to invalidate the window
- if (bFlag)
- {
+ if (bFlag) {
sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM) & sel);
SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hwndRich, NULL, TRUE);
} } }
-
-char * Log_CreateRtfHeader(MODULEINFO * mi)
-{
- char *buffer;
- int bufferAlloced, bufferEnd, i = 0;
-
- // guesstimate amount of memory for the RTF header
- bufferEnd = 0;
- bufferAlloced = 4096;
- buffer = (char *) mir_realloc(mi->pszHeader, bufferAlloced);
- buffer[0] = '\0';
-
-
- //get the number of pixels per logical inch
- {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC(NULL, hdc);
- }
-
- // ### RTF HEADER
-
- // 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);
-
- // 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));
-
- 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]));
-
- // new paragraph
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}\\pard");
-
- // set tabs and indents
- {
- int iIndent = 0;
-
- if (g_Settings.dwIconFlags)
- {
- iIndent += (14*1440)/logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
- }
- if (g_Settings.ShowTime)
- {
- int iSize = (g_Settings.LogTextIndent*1440)/logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
- if (g_Settings.LogIndentEnabled)
- iIndent += iSize;
- }
- /*
- { // text indent
- int iSize = (135*1440)/logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
- if (g_Settings.LogIndentEnabled)
- iIndent += iSize;
-
- }
- */
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
- }
- return buffer;
-}
-
-#define RTFPICTHEADERMAXSIZE 78
-void LoadMsgLogBitmaps(void)
-{
- HICON hIcon;
- HBITMAP hBmp, hoBmp;
- HDC hdc, hdcMem;
- BITMAPINFOHEADER bih = { 0 };
- int widthBytes, i;
- RECT rc;
- HBRUSH hBkgBrush;
- int rtfHeaderSize;
- PBYTE pBmpBits;
-
- hBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW)));
- bih.biSize = sizeof(bih);
- bih.biBitCount = 24;
- bih.biCompression = BI_RGB;
- bih.biHeight = 10; //GetSystemMetrics(SM_CYSMICON);
- bih.biPlanes = 1;
- bih.biWidth = 10; //GetSystemMetrics(SM_CXSMICON);
- widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
- rc.top = rc.left = 0;
- rc.right = bih.biWidth;
- rc.bottom = bih.biHeight;
- 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];
- size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(size);
- rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\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, 0, hIcon, bih.biWidth, bih.biHeight, 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);
-}
-
-void FreeMsgLogBitmaps(void)
-{
- int i;
- for (i = 0; i < SIZEOF(pLogIconBmpBits); i++)
- mir_free(pLogIconBmpBits[i]);
-}
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index 0a5c4bbf2f..fbd8bd8d3b 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -22,27 +22,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //globals
CLIST_INTERFACE *pcli;
+CHAT_MANAGER *pci;
+
+SESSION_INFO g_TabSession;
HINSTANCE g_hInst;
HANDLE g_hWindowList;
HMENU g_hMenu = NULL;
int hLangpack;
-FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HICON hIcons[30];
BOOL IEviewInstalled = FALSE;
-HBRUSH hListBkgBrush = NULL;
BOOL SmileyAddInstalled = FALSE;
BOOL PopupInstalled = FALSE;
-HBRUSH hEditBkgBrush = NULL;
-HBRUSH hListSelectedBkgBrush = NULL;
-HIMAGELIST hImageList = NULL;
+HBRUSH hListBkgBrush = NULL;
+HBRUSH hListSelectedBkgBrush = NULL;
-HIMAGELIST hIconsList = NULL;
+HANDLE hBuildMenuEvent, hSendEvent;
-TCHAR* pszActiveWndID = 0;
-char* pszActiveWndModule = 0;
+GlobalLogSettings g_Settings;
/* Missing MinGW GUIDs */
#ifdef __MINGW32__
@@ -50,8 +48,6 @@ const CLSID IID_IRichEditOle = { 0x00020D00, 0x00, 0x00, { 0xC0, 0x00, 0x00, 0x0 const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
#endif
-struct GlobalLogSettings_t g_Settings;
-
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -78,18 +74,229 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_CHAT, MIID_LAST};
+int OnShutdown(WPARAM, LPARAM)
+{
+ TabM_RemoveAll();
+ return 0;
+}
+
+void TabsInit(void)
+{
+ ZeroMemory(&g_TabSession, sizeof(SESSION_INFO));
+ g_TabSession.iType = GCW_TABROOM;
+ g_TabSession.iSplitterX = g_Settings.iSplitterX;
+ g_TabSession.iSplitterY = g_Settings.iSplitterY;
+ g_TabSession.iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
+ g_TabSession.bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
+ g_TabSession.bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
+ g_TabSession.iFG = 4;
+ g_TabSession.bFGSet = TRUE;
+ g_TabSession.iBG = 2;
+ g_TabSession.bBGSet = TRUE;
+
+ HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
+}
+
+static void OnAddLog(SESSION_INFO *si, int isOk)
+{
+ if (isOk && si->hWnd) {
+ g_TabSession.pLog = si->pLog;
+ g_TabSession.pLogEnd = si->pLogEnd;
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ }
+ else if (si->hWnd) {
+ g_TabSession.pLog = si->pLog;
+ g_TabSession.pLogEnd = si->pLogEnd;
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+ }
+}
+
+static void OnClearLog(SESSION_INFO *si)
+{
+ if (si->hWnd) {
+ g_TabSession.pLog = si->pLog;
+ g_TabSession.pLogEnd = si->pLogEnd;
+ }
+}
+
+static void OnSessionDblClick(SESSION_INFO *si)
+{
+ if (g_Settings.TabsEnable)
+ SendMessage(si->hWnd, GC_REMOVETAB, 1, (LPARAM)si);
+ else
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+}
+
+static void OnSessionRemove(SESSION_INFO *si)
+{
+ if (!g_Settings.TabsEnable) {
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+ }
+ else if (g_TabSession.hWnd)
+ SendMessage(g_TabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)si);
+
+ if (si->hWnd)
+ g_TabSession.nUsersInNicklist = 0;
+}
+
+static void OnSessionRename(SESSION_INFO *si)
+{
+ if (g_TabSession.hWnd && g_Settings.TabsEnable) {
+ g_TabSession.ptszName = si->ptszName;
+ SendMessage(g_TabSession.hWnd, GC_SESSIONNAMECHANGE, 0, (LPARAM)si);
+ }
+}
+
+static void OnSessionReplace(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ g_TabSession.nUsersInNicklist = 0;
+
+ if (!g_Settings.TabsEnable) {
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+ }
+ else if (g_TabSession.hWnd)
+ RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+}
+
+static void OnSessionOffline(SESSION_INFO *si)
+{
+ if (si->hWnd) {
+ g_TabSession.nUsersInNicklist = 0;
+ if (g_Settings.TabsEnable)
+ g_TabSession.pUsers = 0;
+ }
+}
+
+static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone) {
+ g_TabSession.pLog = si->pLog;
+ g_TabSession.pLogEnd = si->pLogEnd;
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ }
+ else if (si->hWnd && si->bInitDone) {
+ g_TabSession.pLog = si->pLog;
+ g_TabSession.pLogEnd = si->pLogEnd;
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+ }
+}
+
+static void OnSetStatusBar(SESSION_INFO *si)
+{
+ if (si->hWnd) {
+ g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+ }
+}
+
+static void OnAddUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd)
+ g_TabSession.nUsersInNicklist++;
+}
+
+static void OnNewUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd) {
+ g_TabSession.pUsers = si->pUsers;
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ }
+}
+
+static void OnRemoveUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd) {
+ g_TabSession.pUsers = si->pUsers;
+ g_TabSession.nUsersInNicklist--;
+ }
+}
+
+static void OnAddStatus(SESSION_INFO *si, STATUSINFO*)
+{
+ if (g_Settings.TabsEnable && si->hWnd)
+ g_TabSession.pStatuses = si->pStatuses;
+}
+
+static void OnSetStatus(SESSION_INFO *si, int wStatus)
+{
+ if (g_Settings.TabsEnable) {
+ if (si->hWnd)
+ g_TabSession.wStatus = wStatus;
+ if (g_TabSession.hWnd)
+ PostMessage(g_TabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM)si);
+ }
+}
+
+static void OnSetTopic(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ g_TabSession.ptszTopic = si->ptszTopic;
+}
+
+static void OnFlashWindow(SESSION_INFO *si, int bInactive)
+{
+ if (!bInactive)
+ return;
+
+ if (!g_Settings.TabsEnable && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
+ SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL);
+ if (g_Settings.TabsEnable && g_TabSession.hWnd)
+ SendMessage(g_TabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
+}
+
+static void OnLoadSettings()
+{
+ g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
+ g_Settings.TabRestore = db_get_b(NULL, "Chat", "TabRestore", 0);
+ g_Settings.TabsAtBottom = db_get_b(NULL, "Chat", "TabBottom", 0);
+ g_Settings.TabCloseOnDblClick = db_get_b(NULL, "Chat", "TabCloseOnDblClick", 0);
+
+ if (hListBkgBrush != NULL)
+ DeleteObject(hListBkgBrush);
+ hListBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistBG", GetSysColor(COLOR_WINDOW)));
+
+ if (hListSelectedBkgBrush != NULL)
+ DeleteObject(hListSelectedBkgBrush);
+ hListSelectedBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistSelectedBG", GetSysColor(COLOR_HIGHLIGHT)));
+}
+
extern "C" __declspec(dllexport) int Load(void)
{
// set the memory & utf8 managers
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
mir_getCLI();
-
- UpgradeCheck();
+
+ mir_getCI();
+ pci->pSettings = &g_Settings;
+ pci->OnAddUser = OnAddUser;
+ pci->OnNewUser = OnNewUser;
+ pci->OnRemoveUser = OnRemoveUser;
+
+ pci->OnAddStatus = OnAddStatus;
+ pci->OnSetStatus = OnSetStatus;
+ pci->OnSetTopic = OnSetTopic;
+
+ pci->OnAddLog = OnAddLog;
+ pci->OnClearLog = OnClearLog;
+
+ pci->OnSessionOffline = OnSessionOffline;
+ pci->OnSessionRemove = OnSessionRemove;
+ pci->OnSessionRename = OnSessionRename;
+ pci->OnSessionReplace = OnSessionReplace;
+ pci->OnSessionDblClick = OnSessionDblClick;
+
+ pci->OnEventBroadcast = OnEventBroadcast;
+ pci->OnLoadSettings = OnLoadSettings;
+ pci->OnSetStatusBar = OnSetStatusBar;
+ pci->OnFlashWindow = OnFlashWindow;
+ pci->ShowRoom = ShowRoom;
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
- HookEvents();
- CreateServiceFunctions();
- CreateHookableEvents();
+ AddIcons();
+ LoadIcons();
OptionsInit();
TabsInit();
return 0;
@@ -104,95 +311,51 @@ extern "C" __declspec(dllexport) int Unload(void) db_set_dw(NULL, "Chat", "roomwidth" , g_Settings.iWidth);
db_set_dw(NULL, "Chat", "roomheight", g_Settings.iHeight);
- CList_SetAllOffline(TRUE, NULL);
-
- mir_free(pszActiveWndID);
- mir_free(pszActiveWndModule);
-
DestroyMenu(g_hMenu);
- DestroyHookableEvents();
- FreeIcons();
OptionsUnInit();
- UnhookEvents();
return 0;
}
-void UpgradeCheck(void)
-{
- DWORD dwVersion = db_get_dw(NULL, "Chat", "OldVersion", PLUGIN_MAKE_VERSION(0,2,9,9));
- if (pluginInfo.version > dwVersion && dwVersion < PLUGIN_MAKE_VERSION(0,3,0,0)) {
- db_unset(NULL, "ChatFonts", "Font18");
- db_unset(NULL, "ChatFonts", "Font18Col");
- db_unset(NULL, "ChatFonts", "Font18Set");
- db_unset(NULL, "ChatFonts", "Font18Size");
- db_unset(NULL, "ChatFonts", "Font18Sty");
- db_unset(NULL, "ChatFonts", "Font19");
- db_unset(NULL, "ChatFonts", "Font19Col");
- db_unset(NULL, "ChatFonts", "Font19Set");
- db_unset(NULL, "ChatFonts", "Font19Size");
- db_unset(NULL, "ChatFonts", "Font19Sty");
- db_unset(NULL, "Chat", "ColorNicklistLines");
- db_unset(NULL, "Chat", "NicklistIndent");
- db_unset(NULL, "Chat", "NicklistRowDist");
- db_unset(NULL, "Chat", "ShowFormatButtons");
- db_unset(NULL, "Chat", "ShowLines");
- db_unset(NULL, "Chat", "ShowName");
- db_unset(NULL, "Chat", "ShowTopButtons");
- db_unset(NULL, "Chat", "SplitterX");
- db_unset(NULL, "Chat", "SplitterY");
- db_unset(NULL, "Chat", "IconFlags");
- db_unset(NULL, "Chat", "LogIndentEnabled");
- }
-
- db_set_dw(NULL, "Chat", "OldVersion", pluginInfo.version);
-}
-
void LoadLogIcons(void)
{
- hIcons[ICON_ACTION] = LoadIconEx( "log_action", FALSE );
- hIcons[ICON_ADDSTATUS] = LoadIconEx( "log_addstatus", FALSE );
- hIcons[ICON_HIGHLIGHT] = LoadIconEx( "log_highlight", FALSE );
- hIcons[ICON_INFO] = LoadIconEx( "log_info", FALSE );
- hIcons[ICON_JOIN] = LoadIconEx( "log_join", FALSE );
- hIcons[ICON_KICK] = LoadIconEx( "log_kick", FALSE );
- hIcons[ICON_MESSAGE] = LoadIconEx( "log_message_in", FALSE );
- hIcons[ICON_MESSAGEOUT] = LoadIconEx( "log_message_out", FALSE );
- hIcons[ICON_NICK] = LoadIconEx( "log_nick", FALSE );
- hIcons[ICON_NOTICE] = LoadIconEx( "log_notice", FALSE );
- hIcons[ICON_PART] = LoadIconEx( "log_part", FALSE );
- hIcons[ICON_QUIT] = LoadIconEx( "log_quit", FALSE );
- hIcons[ICON_REMSTATUS] = LoadIconEx( "log_removestatus", FALSE );
- hIcons[ICON_TOPIC] = LoadIconEx( "log_topic", FALSE );
- hIcons[ICON_STATUS1] = LoadIconEx( "status1", FALSE );
- hIcons[ICON_STATUS2] = LoadIconEx( "status2", FALSE );
- hIcons[ICON_STATUS3] = LoadIconEx( "status3", FALSE );
- hIcons[ICON_STATUS4] = LoadIconEx( "status4", FALSE );
- hIcons[ICON_STATUS0] = LoadIconEx( "status0", FALSE );
- hIcons[ICON_STATUS5] = LoadIconEx( "status5", FALSE );
+ pci->hIcons[ICON_ACTION] = LoadIconEx("log_action", FALSE);
+ pci->hIcons[ICON_ADDSTATUS] = LoadIconEx("log_addstatus", FALSE);
+ pci->hIcons[ICON_HIGHLIGHT] = LoadIconEx("log_highlight", FALSE);
+ pci->hIcons[ICON_INFO] = LoadIconEx("log_info", FALSE);
+ pci->hIcons[ICON_JOIN] = LoadIconEx("log_join", FALSE);
+ pci->hIcons[ICON_KICK] = LoadIconEx("log_kick", FALSE);
+ pci->hIcons[ICON_MESSAGE] = LoadIconEx("log_message_in", FALSE);
+ pci->hIcons[ICON_MESSAGEOUT] = LoadIconEx("log_message_out", FALSE);
+ pci->hIcons[ICON_NICK] = LoadIconEx("log_nick", FALSE);
+ pci->hIcons[ICON_NOTICE] = LoadIconEx("log_notice", FALSE);
+ pci->hIcons[ICON_PART] = LoadIconEx("log_part", FALSE);
+ pci->hIcons[ICON_QUIT] = LoadIconEx("log_quit", FALSE);
+ pci->hIcons[ICON_REMSTATUS] = LoadIconEx("log_removestatus", FALSE);
+ pci->hIcons[ICON_TOPIC] = LoadIconEx("log_topic", FALSE);
+ pci->hIcons[ICON_STATUS1] = LoadIconEx("status1", FALSE);
+ pci->hIcons[ICON_STATUS2] = LoadIconEx("status2", FALSE);
+ pci->hIcons[ICON_STATUS3] = LoadIconEx("status3", FALSE);
+ pci->hIcons[ICON_STATUS4] = LoadIconEx("status4", FALSE);
+ pci->hIcons[ICON_STATUS0] = LoadIconEx("status0", FALSE);
+ pci->hIcons[ICON_STATUS5] = LoadIconEx("status5", FALSE);
}
void LoadIcons(void)
{
- memset(hIcons, 0, sizeof(hIcons));
+ memset(pci->hIcons, 0, sizeof(pci->hIcons));
LoadLogIcons();
- LoadMsgLogBitmaps();
- hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 3);
- hIconsList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 100);
- ImageList_AddIcon(hIconsList,LoadSkinnedIcon( SKINICON_EVENT_MESSAGE));
- ImageList_AddIcon(hIconsList,LoadIconEx( "overlay", FALSE ));
- ImageList_SetOverlayImage(hIconsList, 1, 1);
- ImageList_AddIcon(hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
- ImageList_AddIcon(hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
+ pci->hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 3);
+ pci->hIconsList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 100);
+ ImageList_AddIcon(pci->hIconsList, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
+ ImageList_AddIcon(pci->hIconsList, LoadIconEx("overlay", FALSE));
+ ImageList_SetOverlayImage(pci->hIconsList, 1, 1);
+ ImageList_AddIcon(pci->hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
+ ImageList_AddIcon(pci->hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
}
-void FreeIcons(void)
-{
- FreeMsgLogBitmaps();
- ImageList_Destroy(hImageList);
- ImageList_Destroy(hIconsList);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
CREOleCallback reOleCallback;
diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp index 1f63a0839e..925efde9f8 100644 --- a/src/core/stdchat/src/manager.cpp +++ b/src/core/stdchat/src/manager.cpp @@ -22,1044 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-extern TCHAR* pszActiveWndID ;
-extern char* pszActiveWndModule ;
-extern SESSION_INFO g_TabSession;
-extern HICON hIcons[30];
-extern HIMAGELIST hIconsList;
-
-#define WINDOWS_COMMANDS_MAX 30
-#define STATUSICONCOUNT 6
-
-SESSION_INFO* m_WndList = 0;
-TABLIST * g_TabList = 0;
-MODULEINFO *m_ModList = 0;
-
-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 m_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)) {
- SESSION_INFO*node = (SESSION_INFO*)mir_alloc(sizeof(SESSION_INFO));
- ZeroMemory(node, sizeof(SESSION_INFO));
- node->ptszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
-
- if (m_WndList == NULL) { // list is empty
- m_WndList = node;
- node->next = NULL;
- }
- else {
- node->next = m_WndList;
- m_WndList = node;
- }
- return node;
- }
- return NULL;
-}
-
-int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL removeContact)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) // match
- {
- COMMAND_INFO *pCurComm;
- DWORD dw = pTemp->dwItemData;
-
- if (!g_Settings.TabsEnable) {
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- }
- else if (g_TabSession.hWnd)
- SendMessage(g_TabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)pTemp);
-
- if (pTemp->hWnd)
- g_TabSession.nUsersInNicklist = 0;
-
- DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
-
- if (pLast == NULL)
- m_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;
-
- // contact may have been deleted here already, since function may be called after deleting
- // contact so the handle may be invalid, therefore db_get_b shall return 0
- if (pTemp->hContact && db_get_b(pTemp->hContact, pTemp->pszModule, "ChatRoom", 0) != 0) {
- CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE);
- 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
- 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 = m_WndList;
- }
- else {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- }
- return FALSE;
-}
-
-SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
- return pTemp;
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return NULL;
-}
-
-BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_RemoveAll(&pTemp->pUsers);
- pTemp->nUsersInNicklist = 0;
- if (pTemp->hWnd)
- g_TabSession.nUsersInNicklist = 0;
- if (pTemp->iType != GCW_SERVER)
- pTemp->bInitDone = FALSE;
- if (g_Settings.TabsEnable && pTemp->hWnd)
- g_TabSession.pUsers = 0;
-
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_SetStatusEx(pTemp->pUsers, pszText, flags);
- if (pTemp->hWnd)
- RedrawWindow(GetDlgItem(pTemp->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui)
-{
- STATUSINFO * ti;
- if (!ui || !si)
- return NULL;
-
- ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status));
- if (ti) {
- if ((int)ti->hIcon < STATUSICONCOUNT) {
- int id = si->iStatusCount - (int)ti->hIcon - 1;
- if (id == 0)
- return hIcons[ICON_STATUS0];
- if (id == 1)
- return hIcons[ICON_STATUS1];
- if (id == 2)
- return hIcons[ICON_STATUS2];
- if (id == 3)
- return hIcons[ICON_STATUS3];
- if (id == 4)
- return hIcons[ICON_STATUS4];
- if (id == 5)
- return hIcons[ICON_STATUS5];
- }
- else
- return ti->hIcon;
- }
- return hIcons[ICON_STATUS0];
-}
-
-BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
- int bManyFix = 0;
-
- while (pTemp != NULL) {
- if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) {
- if (UM_FindUser(pTemp->pUsers, gce->ptszUID)) {
- if (pTemp->bInitDone) {
- if (SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE) && pTemp->hWnd && pTemp->bInitDone) {
- g_TabSession.pLog = pTemp->pLog;
- g_TabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (pTemp->hWnd && pTemp->bInitDone) {
- g_TabSession.pLog = pTemp->pLog;
- g_TabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_REDRAWLOG2, 0, 0);
- }
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(pTemp, gce, FALSE, bManyFix);
- bManyFix++;
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
- LogToFile(pTemp, gce);
- }
- }
- }
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return 0;
-}
-
-BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return TRUE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- LOGINFO * li = LM_AddEvent(&pTemp->pLog, &pTemp->pLogEnd);
- pTemp->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;
- li->time = gce->time;
- li->bIsHighlighted = bIsHighlighted;
-
- if (g_Settings.iEventLimit > 0 && pTemp->iEventCount > g_Settings.iEventLimit + 20) {
- LM_TrimLog(&pTemp->pLog, &pTemp->pLogEnd, pTemp->iEventCount - g_Settings.iEventLimit);
- pTemp->iEventCount = g_Settings.iEventLimit;
- return FALSE;
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-USERINFO * SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO * p = UM_AddUser(pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus);
- pTemp->nUsersInNicklist++;
- if (pTemp->hWnd)
- g_TabSession.nUsersInNicklist++;
- return p;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return 0;
-}
-
-BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID)
-{
- SESSION_INFO *pTemp = m_WndList;
-
- if (!pszID || !pszModule || !pszUID)
- return FALSE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_SortUser(&pTemp->pUsers, pszUID);
- return TRUE;
- }
- pTemp = pTemp->next;
- }
-
- return FALSE;
-}
-
-BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule || !pszUID)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- DWORD dw;
- USERINFO * ui = UM_FindUser(pTemp->pUsers, pszUID);
- if (ui) {
- pTemp->nUsersInNicklist--;
- if (pTemp->hWnd) {
- g_TabSession.pUsers = pTemp->pUsers;
- g_TabSession.nUsersInNicklist--;
- }
-
- dw = UM_RemoveUser(&pTemp->pUsers, pszUID);
-
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
-
- if (pszID)
- return TRUE;
- }
- }
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return 0;
-}
-
-USERINFO * SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index)
-{
- SESSION_INFO *pTemp = m_WndList;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
- return UM_FindUserFromIndex(pTemp->pUsers, index);
- pTemp = pTemp->next;
- }
-
- return NULL;
-}
-
-
-STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- STATUSINFO* ti = TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount);
- if (ti)
- pTemp->iStatusCount++;
- if (g_Settings.TabsEnable && pTemp->hWnd)
- g_TabSession.pStatuses = pTemp->pStatuses;
- return ti;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return 0;
-}
-
-BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO * ui = UM_GiveStatus(pTemp->pUsers, pszUID, TM_StringToWord(pTemp->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return FALSE;
-}
-
-BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus)
-{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO * ui = UM_SetContactStatus(pTemp->pUsers, pszUID, wStatus);
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return FALSE;
-}
-
-BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO* ui = UM_TakeStatus(pTemp->pUsers, pszUID, TM_StringToWord(pTemp->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- return FALSE;
-}
-LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- while (pTemp && pszModule) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd) {
- LRESULT i = SendMessage(pTemp->hWnd, msg, wParam, lParam);
- if (pszID)
- return i;
- }
- if (pszID)
- return 0;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-BOOL SM_PostMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszID || !pszModule)
- return 0;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd)
- return PostMessage(pTemp->hWnd, msg, wParam, lParam);
-
- return FALSE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return FALSE;
-}
-
-BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- while (pTemp != NULL) {
- if (!pszModule || !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd) {
- if (bAsync)
- PostMessage(pTemp->hWnd, msg, wParam, lParam);
- else
- SendMessage(pTemp->hWnd, msg, wParam, lParam);
- }
-
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- pTemp->wStatus = wStatus;
- if (pTemp->hWnd && g_Settings.TabsEnable)
- g_TabSession.wStatus = wStatus;
-
- if (pTemp->hContact) {
- if (pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
- db_unset(pTemp->hContact, "CList", "Hidden");
-
- db_set_w(pTemp->hContact, pTemp->pszModule, "Status", (WORD)wStatus);
- }
-
- if (g_Settings.TabsEnable && g_TabSession.hWnd)
- PostMessage(g_TabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM)pTemp);
-
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule || !pszText)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->iType == GCW_CHATROOM)
- DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_USER_MESSAGE, NULL, pszText, 0);
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
-{
- BOOL bFound = FALSE;
- SESSION_INFO* pTemp = m_WndList;
-
- if (!si)
- return NULL;
-
- while (pTemp != NULL) {
- if (si == pTemp) {
- if (bFound)
- return NULL;
- else
- bFound = TRUE;
- }
- else if (bFound == TRUE && pTemp->hWnd)
- return pTemp;
- pTemp = pTemp->next;
- if (pTemp == NULL && bFound)
- pTemp = m_WndList;
- }
- return NULL;
-}
-
-SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!si)
- return NULL;
-
- while (pTemp != NULL) {
- if (si == pTemp) {
- if (pLast) {
- if (pLast != pTemp)
- return pLast;
- else
- return NULL;
- }
- }
- if (pTemp->hWnd)
- pLast = pTemp;
- pTemp = pTemp->next;
- if (pTemp == NULL)
- pTemp = m_WndList;
- }
- return NULL;
-}
-
-BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO* ui = UM_FindUser(pTemp->pUsers, pszUID);
- if (ui)
- replaceStrT(ui->pszUID, pszNewUID);
-
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-
-BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- while (pTemp != NULL) {
- if (si && si == pTemp) {
- pTemp->hWnd = hwnd;
- }
- else
- pTemp->hWnd = NULL;
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce)
-{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
- if (!pszModule)
- return FALSE;
-
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO* ui = UM_FindUser(pTemp->pUsers, gce->ptszUID);
- if (ui) {
- replaceStrT(ui->pszNick, gce->ptszText);
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
-
- if (pszID)
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-BOOL SM_RemoveAll(void)
-{
- while (m_WndList) {
- SESSION_INFO*pLast = m_WndList->next;
-
- if (m_WndList->hWnd)
- SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- DoEventHook(m_WndList->ptszID, m_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)m_WndList->dwItemData);
- if (m_WndList->hContact)
- CList_SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
- db_set_s(m_WndList->hContact, m_WndList->pszModule, "Topic", "");
- db_unset(m_WndList->hContact, "CList", "StatusMsg");
- db_set_s(m_WndList->hContact, m_WndList->pszModule, "StatusBar", "");
-
- UM_RemoveAll(&m_WndList->pUsers);
- TM_RemoveAll(&m_WndList->pStatuses);
- LM_RemoveAll(&m_WndList->pLog, &m_WndList->pLogEnd);
- m_WndList->iStatusCount = 0;
- m_WndList->nUsersInNicklist = 0;
-
- mir_free(m_WndList->pszModule);
- mir_free(m_WndList->ptszID);
- mir_free(m_WndList->ptszName);
- mir_free(m_WndList->ptszStatusbarText);
- mir_free(m_WndList->ptszTopic);
- mir_free(m_WndList->pszID);
- mir_free(m_WndList->pszName);
-
- while (m_WndList->lpCommands != NULL) {
- COMMAND_INFO *pNext = m_WndList->lpCommands->next;
- mir_free(m_WndList->lpCommands->lpCommand);
- mir_free(m_WndList->lpCommands);
- m_WndList->lpCommands = pNext;
- }
-
- mir_free(m_WndList);
- m_WndList = pLast;
- }
- m_WndList = NULL;
- return TRUE;
-}
-
-void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand)
-{
- SESSION_INFO* pTemp = m_WndList;
- while (pTemp != NULL) {
- if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->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 (pTemp->lpCommands == NULL) {
- node->next = NULL;
- pTemp->lpCommands = node;
- }
- else {
- node->next = pTemp->lpCommands;
- pTemp->lpCommands->last = node; // hmm, weird
- pTemp->lpCommands = node;
- }
- pTemp->lpCurrentCommand = NULL; // current command
- pTemp->wCommandsNum++;
-
- if (pTemp->wCommandsNum > WINDOWS_COMMANDS_MAX) {
- COMMAND_INFO *pCurComm = pTemp->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
- pTemp->wCommandsNum--;
- }
- }
- pTemp = pTemp->next;
- }
-}
-
-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* pTemp = m_WndList;
- while (pTemp != NULL) {
- if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match
- COMMAND_INFO *pPrevCmd = NULL;
- if (pTemp->lpCurrentCommand != NULL) {
- if (pTemp->lpCurrentCommand->next != NULL) // not NULL
- pPrevCmd = pTemp->lpCurrentCommand->next; // next command (newest at beginning)
- else
- pPrevCmd = pTemp->lpCurrentCommand;
- }
- else pPrevCmd = pTemp->lpCommands;
-
- pTemp->lpCurrentCommand = pPrevCmd; // make it the new command
- return(((pPrevCmd) ? (pPrevCmd->lpCommand) : (NULL)));
- }
- pTemp = pTemp->next;
- }
- return(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* pTemp = m_WndList;
- while (pTemp != NULL) {
- if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match
- COMMAND_INFO *pNextCmd = NULL;
- if (pTemp->lpCurrentCommand != NULL)
- pNextCmd = pTemp->lpCurrentCommand->last; // last command (newest at beginning)
-
- pTemp->lpCurrentCommand = pNextCmd; // make it the new command
- return(((pNextCmd) ? (pNextCmd->lpCommand) : (NULL)));
- }
- pTemp = pTemp->next;
- }
- return(NULL);
-}
-
-int SM_GetCount(const char* pszModule)
-{
- SESSION_INFO* pTemp = m_WndList;
- int count = 0;
-
- while (pTemp != NULL) {
- if (!lstrcmpiA(pszModule, pTemp->pszModule))
- count++;
-
- pTemp = pTemp->next;
- }
- return count;
-}
-
-SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem)
-{
- SESSION_INFO* pTemp = m_WndList;
- int count = 0;
- while (pTemp != NULL) {
- if (!lstrcmpiA(pszModule, pTemp->pszModule)) {
- if (iItem == count)
- return pTemp;
- else
- count++;
- }
-
- pTemp = pTemp->next;
- }
- return NULL;
-
-}
-
-char* SM_GetUsers(SESSION_INFO *si)
-{
- SESSION_INFO* pTemp = m_WndList;
- USERINFO* utemp = NULL;
- char* p = NULL;
- int alloced = 0;
-
- if (si == NULL)
- return NULL;
-
- while (pTemp != NULL) {
- if (si == pTemp) {
- if ((utemp = pTemp->pUsers) == NULL)
- return NULL;
-
- break;
- }
- pTemp = pTemp->next;
- }
-
- do {
- 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;
- }
- while (utemp != NULL);
- 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);
-
- if (m_ModList == NULL) // list is empty
- {
- m_ModList = node;
- node->next = NULL;
- }
- else {
- node->next = m_ModList;
- m_ModList = node;
- }
- return node;
- }
- return FALSE;
-}
-
-void MM_IconsChanged(void)
-{
- MODULEINFO *pTemp = m_ModList, *pLast = NULL;
- ImageList_ReplaceIcon(hIconsList, 0, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
- ImageList_ReplaceIcon(hIconsList, 1, LoadIconEx("overlay", FALSE));
- while (pTemp != NULL) {
- pTemp->OnlineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_ONLINE));
- pTemp->OfflineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_OFFLINE));
-
- if (pTemp->hOfflineIcon)
- DestroyIcon(pTemp->hOfflineIcon);
- if (pTemp->hOnlineIcon)
- DestroyIcon(pTemp->hOnlineIcon);
- if (pTemp->hOnlineTalkIcon)
- DestroyIcon(pTemp->hOnlineTalkIcon);
- if (pTemp->hOfflineTalkIcon)
- DestroyIcon(pTemp->hOfflineTalkIcon);
- pTemp->hOfflineIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT);
- pTemp->hOnlineIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT);
-
- pTemp->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex + 1, pTemp->hOnlineTalkIcon);
-
- pTemp->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex + 1, pTemp->hOfflineTalkIcon);
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return;
-}
-void MM_FontsChanged(void)
-{
- MODULEINFO *pTemp = m_ModList;
- while (pTemp != NULL) {
- pTemp->pszHeader = Log_CreateRtfHeader(pTemp);
- pTemp = pTemp->next;
- }
- return;
-}
-MODULEINFO* MM_FindModule(const char* pszModule)
-{
- MODULEINFO *pTemp = m_ModList, *pLast = NULL;
-
- if (!pszModule)
- return NULL;
-
- while (pTemp != NULL) {
- if (lstrcmpiA(pTemp->pszModule, pszModule) == 0)
- return pTemp;
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-// stupid thing..
-void MM_FixColors()
-{
- MODULEINFO *pTemp = m_ModList;
-
- while (pTemp != NULL) {
- CheckColorsInModule(pTemp->pszModule);
- pTemp = pTemp->next;
- }
- return;
-}
-
-BOOL MM_RemoveAll(void)
-{
- while (m_ModList != NULL) {
- MODULEINFO *pLast = m_ModList->next;
- mir_free(m_ModList->pszModule);
- mir_free(m_ModList->ptszModDispName);
- mir_free(m_ModList->pszHeader);
- mir_free(m_ModList->crColors);
-
- if (m_ModList->hOfflineIcon)
- DestroyIcon(m_ModList->hOfflineIcon);
- if (m_ModList->hOnlineIcon)
- DestroyIcon(m_ModList->hOnlineIcon);
- if (m_ModList->hOnlineTalkIcon)
- DestroyIcon(m_ModList->hOnlineTalkIcon);
- if (m_ModList->hOfflineTalkIcon)
- DestroyIcon(m_ModList->hOfflineTalkIcon);
-
- mir_free(m_ModList);
- m_ModList = pLast;
- }
- m_ModList = NULL;
- return TRUE;
-}
-
-
+TABLIST *g_TabList = 0;
//---------------------------------------------------
// Tab list manager functions
@@ -1102,467 +65,3 @@ BOOL TabM_RemoveAll(void) g_TabList = 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_alloc(sizeof(STATUSINFO));
- ZeroMemory(node, sizeof(STATUSINFO));
- replaceStrT(node->pszGroup, 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)
-{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
-
- if (!pStatusList || !pszStatus)
- return NULL;
-
- while (pTemp != NULL) {
- if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0)
- return pTemp;
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus)
-{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
-
- if (!pStatusList || !pszStatus)
- return 0;
-
- while (pTemp != NULL) {
- if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0)
- return pTemp->Status;
-
- if (pTemp->next == NULL)
- return pStatusList->Status;
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status)
-{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
-
- if (!pStatusList)
- return NULL;
-
- while (pTemp != NULL) {
- if (pTemp->Status&Status) {
- Status -= pTemp->Status;
- if (Status == 0)
- return pTemp->pszGroup;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- 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
-//---------------------------------------------------
-
-
-static int UM_CompareItem(USERINFO * u1, const TCHAR* pszNick, WORD wStatus)
-{
- int i;
-
- WORD dw1 = u1->Status;
- WORD dw2 = wStatus;
-
- for (i = 0; i < 8; i++) {
- if ((dw1 & 1) && !(dw2 & 1))
- return -1;
- if ((dw2 & 1) && !(dw1 & 1))
- return 1;
- if ((dw1 & 1) && (dw2 & 1))
- return lstrcmp(u1->pszNick, pszNick);
-
- dw1 = dw1 >> 1;
- dw2 = dw2 >> 1;
- }
- return lstrcmp(u1->pszNick, pszNick);
-
-}
-
-USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
-{
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
- USERINFO * node = NULL;
-
- if (!pTemp || !pszUID)
- return NULL;
-
- while (pTemp && lstrcmpi(pTemp->pszUID, pszUID)) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- if (pTemp) {
- 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;
- }
- return NULL;
-}
-
-USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
-{
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
-
- if (!pStatusList || !ppUserList)
- return NULL;
-
- while (pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0) {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- // if (!UM_FindUser(*ppUserList, pszUI, wStatus)
- {
- USERINFO *node = (USERINFO*)mir_alloc(sizeof(USERINFO));
- ZeroMemory(node, sizeof(USERINFO));
- replaceStrT(node->pszUID, 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;
- }
- return NULL;
-}
-
-USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID)
-{
- USERINFO *pTemp = pUserList, *pLast = NULL;
-
- if (!pUserList || !pszUID)
- return NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->pszUID, pszUID))
- return pTemp;
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index)
-{
- if (!pUserList)
- return NULL;
-
- int i = 0;
- USERINFO *pTemp = pUserList;
- while (pTemp != NULL) {
- if (i == index)
- return pTemp;
-
- pTemp = pTemp->next;
- i++;
- }
- return NULL;
-}
-
-USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- USERINFO *pTemp = pUserList, *pLast = NULL;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->Status |= status;
- return pTemp;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- USERINFO *pTemp = pUserList, *pLast = NULL;
-
- if (!pUserList || !pszUID)
- return NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->ContactStatus = status;
- return pTemp;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags)
-{
- USERINFO *pTemp = pUserList, *pLast = NULL;
- int bOnlyMe = (flags & GC_SSE_ONLYLISTED) != 0, bSetStatus = (flags & GC_SSE_ONLINE) != 0;
- char cDelimiter = (flags & GC_SSE_TABDELIMITED) ? '\t' : ' ';
-
- while (pTemp != NULL) {
- if (!bOnlyMe)
- pTemp->iStatusEx = 0;
-
- if (pszText != NULL) {
- TCHAR* s = (TCHAR *)_tcsstr(pszText, pTemp->pszUID);
- if (s) {
- pTemp->iStatusEx = 0;
- if (s == pszText || s[-1] == cDelimiter) {
- int len = lstrlen(pTemp->pszUID);
- if (s[len] == cDelimiter || s[len] == '\0')
- pTemp->iStatusEx = (!bOnlyMe || bSetStatus) ? 1 : 0;
- }
- }
- }
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
-USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
-{
- if (!pUserList || !pszUID)
- return NULL;
-
- USERINFO *pTemp = pUserList, *pLast = NULL;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->pszUID, pszUID)) {
- pTemp->Status &= ~status;
- return pTemp;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return 0;
-}
-
-TCHAR* UM_FindUserAutoComplete(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
-{
- if (!pUserList || !pszOriginal || !pszCurrent)
- return NULL;
-
- TCHAR* pszName = NULL;
- USERINFO *pTemp = pUserList;
- while (pTemp != NULL) {
- if (pTemp->pszNick && my_strstri(pTemp->pszNick, pszOriginal) == pTemp->pszNick)
- if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0))
- pszName = pTemp->pszNick;
-
- pTemp = pTemp->next;
- }
- return pszName;
-}
-
-BOOL UM_RemoveUser(USERINFO** ppUserList, const TCHAR* pszUID)
-{
- USERINFO *pTemp = *ppUserList, *pLast = NULL;
-
- if (!ppUserList || !pszUID)
- return FALSE;
-
- 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/src/core/stdchat/src/message.cpp b/src/core/stdchat/src/message.cpp index 1da5c7f1ae..e5f1e4f5e2 100644 --- a/src/core/stdchat/src/message.cpp +++ b/src/core/stdchat/src/message.cpp @@ -25,7 +25,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,7 +52,7 @@ 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);
+ MODULEINFO * pMod = pci->MM_FindModule(si->pszModule);
for (i = 0; i < pMod->nColorCount ; i ++)
if (pMod->crColors[i] == RGB( atoi(szRed), atoi(szGreen), atoi(szBlue)))
pIndex[i] = iIndex;
@@ -92,8 +92,8 @@ TCHAR* 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
- pIndex = (int *)mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount);
- for(i = 0; i < MM_FindModule(si->pszModule)->nColorCount ; i++)
+ pIndex = (int *)mir_alloc(sizeof(int) * pci->MM_FindModule(si->pszModule)->nColorCount);
+ for(i = 0; i < pci->MM_FindModule(si->pszModule)->nColorCount ; i++)
pIndex[i] = -1;
CreateColorMap( pszText, pIndex, si );
diff --git a/src/core/stdchat/src/options.cpp b/src/core/stdchat/src/options.cpp index 67a37eac84..d767c96884 100644 --- a/src/core/stdchat/src/options.cpp +++ b/src/core/stdchat/src/options.cpp @@ -23,15 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_fontservice.h>
-extern HBRUSH hEditBkgBrush;
extern HBRUSH hListBkgBrush;
extern HBRUSH hListSelectedBkgBrush;
-extern HICON hIcons[30];
-extern FONTINFO aFonts[OPTIONS_FONTCOUNT];
extern BOOL PopupInstalled;
-extern SESSION_INFO g_TabSession;
-
-HANDLE g_hOptions = NULL;
#define FONTF_BOLD 1
#define FONTF_ITALIC 2
@@ -310,50 +304,6 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p return 0;
}
-void LoadLogFonts(void)
-{
- for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
- LoadMsgDlgFont(i, &aFonts[i].lf, &aFonts[i].color);
-}
-
-void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour)
-{
- char str[32];
- int style;
- DBVARIANT dbv;
-
- if (colour) {
- mir_snprintf(str, SIZEOF(str), "Font%dCol", i);
- *colour = db_get_dw(NULL, "ChatFonts", str, fontOptionsList[i].defColour);
- }
- if (lf) {
- mir_snprintf(str, SIZEOF(str), "Font%dSize", i);
- lf->lfHeight = (char)db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defSize);
- lf->lfWidth = 0;
- lf->lfEscapement = 0;
- lf->lfOrientation = 0;
- mir_snprintf(str, SIZEOF(str), "Font%dSty", i);
- style = db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defStyle);
- lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
- lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
- lf->lfUnderline = 0;
- lf->lfStrikeOut = 0;
- mir_snprintf(str, SIZEOF(str), "Font%dSet", i);
- lf->lfCharSet = db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defCharset);
- lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf->lfQuality = DEFAULT_QUALITY;
- lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- mir_snprintf(str, SIZEOF(str), "Font%d", i);
- if (db_get_ts(NULL, "ChatFonts", str, &dbv))
- lstrcpy(lf->lfFaceName, fontOptionsList[i].szDefFace);
- else {
- lstrcpyn(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName));
- db_free(&dbv);
- }
- }
-}
-
void RegisterFonts(void)
{
FontIDT fontid = { 0 };
@@ -597,10 +547,10 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
if (b != db_get_b(NULL, "Chat", "Tabs", 1)) {
- SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
+ pci->SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
}
- else SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ else pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
return TRUE;
}
@@ -689,18 +639,17 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA case IDC_FONTCHOOSE:
{
- LPITEMIDLIST idList;
- BROWSEINFO bi = { 0 };
TCHAR szDirectory[MAX_PATH];
TCHAR szTemp[MAX_PATH];
+ BROWSEINFO bi = { 0 };
bi.hwndOwner = hwndDlg;
bi.pszDisplayName = szDirectory;
bi.lpszTitle = TranslateT("Select folder");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)szDirectory;
- idList = SHBrowseForFolder(&bi);
+ LPITEMIDLIST idList = SHBrowseForFolder(&bi);
if (idList) {
SHGetPathFromIDList(idList, szDirectory);
lstrcat(szDirectory, _T("\\"));
@@ -811,9 +760,9 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA else
db_unset(NULL, "Chat", "NicklistRowDist");
- FreeMsgLogBitmaps();
- LoadMsgLogBitmaps();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ // FreeMsgLogBitmaps(); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // LoadMsgLogBitmaps(); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
return TRUE;
}
break;
@@ -925,163 +874,15 @@ static int OptionsInitialize(WPARAM wParam, LPARAM lParam) return 0;
}
-void LoadGlobalSettings(void)
-{
- LOGFONT lf;
-
- g_Settings.LogLimitNames = db_get_b(NULL, "Chat", "LogLimitNames", 1);
- g_Settings.ShowTime = db_get_b(NULL, "Chat", "ShowTimeStamp", 1);
- g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
- g_Settings.TabsAtBottom = db_get_b(NULL, "Chat", "TabBottom", 0);
- g_Settings.TabCloseOnDblClick = db_get_b(NULL, "Chat", "TabCloseOnDblClick", 0);
- g_Settings.TabRestore = db_get_b(NULL, "Chat", "TabRestore", 0);
- g_Settings.SoundsFocus = db_get_b(NULL, "Chat", "SoundsFocus", 0);
- g_Settings.ShowTimeIfChanged = (BOOL)db_get_b(NULL, "Chat", "ShowTimeStampIfChanged", 0);
- g_Settings.TimeStampEventColour = (BOOL)db_get_b(NULL, "Chat", "TimeStampEventColour", 0);
- g_Settings.iEventLimit = db_get_w(NULL, "Chat", "LogLimit", 100);
- g_Settings.dwIconFlags = db_get_dw(NULL, "Chat", "IconFlags", 0x0000);
- g_Settings.dwTrayIconFlags = db_get_dw(NULL, "Chat", "TrayIconFlags", 0x1000);
- g_Settings.dwPopupFlags = db_get_dw(NULL, "Chat", "PopupFlags", 0x0000);
- g_Settings.LoggingLimit = db_get_w(NULL, "Chat", "LoggingLimit", 100);
- g_Settings.LoggingEnabled = (BOOL)db_get_b(NULL, "Chat", "LoggingEnabled", 0);
- g_Settings.FlashWindow = (BOOL)db_get_b(NULL, "Chat", "FlashWindow", 0);
- g_Settings.HighlightEnabled = (BOOL)db_get_b(NULL, "Chat", "HighlightEnabled", 1);
- g_Settings.crUserListColor = db_get_dw(NULL, "ChatFonts", "Font18Col", RGB(0, 0, 0));
- g_Settings.crUserListBGColor = db_get_dw(NULL, "Chat", "ColorNicklistBG", GetSysColor(COLOR_WINDOW));
- g_Settings.crUserListSelectedBGColor = db_get_dw(NULL, "Chat", "ColorNicklistSelectedBG", GetSysColor(COLOR_HIGHLIGHT));
- g_Settings.crUserListHeadingsColor = db_get_dw(NULL, "ChatFonts", "Font19Col", RGB(170, 170, 170));
- g_Settings.crLogBackground = db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW));
- g_Settings.StripFormat = (BOOL)db_get_b(NULL, "Chat", "StripFormatting", 0);
- g_Settings.TrayIconInactiveOnly = (BOOL)db_get_b(NULL, "Chat", "TrayIconInactiveOnly", 1);
- g_Settings.PopupInactiveOnly = (BOOL)db_get_b(NULL, "Chat", "PopupInactiveOnly", 1);
- g_Settings.AddColonToAutoComplete = (BOOL)db_get_b(NULL, "Chat", "AddColonToAutoComplete", 1);
- g_Settings.iPopupStyle = db_get_b(NULL, "Chat", "PopupStyle", 1);
- g_Settings.iPopupTimeout = db_get_w(NULL, "Chat", "PopupTimeout", 3);
- g_Settings.crPUBkgColour = db_get_dw(NULL, "Chat", "PopupColorBG", GetSysColor(COLOR_WINDOW));
- g_Settings.crPUTextColour = db_get_dw(NULL, "Chat", "PopupColorText", 0);
- g_Settings.ShowContactStatus = db_get_b(NULL, "Chat", "ShowContactStatus", 0);
- g_Settings.ContactStatusFirst = db_get_b(NULL, "Chat", "ContactStatusFirst", 0);
-
- 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:"));
- InitSetting(&g_Settings.pszHighlightWords, "HighlightWords", _T("%m"));
-
- {
- TCHAR pszTemp[MAX_PATH];
- DBVARIANT dbv;
- g_Settings.pszLogDir = (TCHAR *)mir_realloc(g_Settings.pszLogDir, MAX_PATH*sizeof(TCHAR));
- if (!db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
- lstrcpyn(pszTemp, dbv.ptszVal, MAX_PATH);
- db_free(&dbv);
- }
- else {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat"));
- lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp) - 1);
- mir_free(tmpPath);
- }
-
- PathToAbsoluteT(pszTemp, g_Settings.pszLogDir);
- }
-
- g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
-
- if (g_Settings.MessageBoxFont)
- DeleteObject(g_Settings.MessageBoxFont);
- LoadMsgDlgFont(17, &lf, NULL);
- g_Settings.MessageBoxFont = CreateFontIndirect(&lf);
-
- if (g_Settings.UserListFont)
- DeleteObject(g_Settings.UserListFont);
- LoadMsgDlgFont(18, &lf, NULL);
- g_Settings.UserListFont = CreateFontIndirect(&lf);
-
- if (g_Settings.UserListHeadingsFont)
- DeleteObject(g_Settings.UserListHeadingsFont);
- LoadMsgDlgFont(19, &lf, NULL);
- g_Settings.UserListHeadingsFont = CreateFontIndirect(&lf);
- if (hListBkgBrush != NULL) {
- DeleteObject(hListBkgBrush);
- }
- hListBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistBG", GetSysColor(COLOR_WINDOW)));
- if (hListSelectedBkgBrush != NULL) {
- DeleteObject(hListSelectedBkgBrush);
- }
- hListSelectedBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistSelectedBG", GetSysColor(COLOR_HIGHLIGHT)));
-}
-
-static void FreeGlobalSettings(void)
-{
- mir_free(g_Settings.pszTimeStamp);
- mir_free(g_Settings.pszTimeStampLog);
- mir_free(g_Settings.pszIncomingNick);
- mir_free(g_Settings.pszOutgoingNick);
- mir_free(g_Settings.pszHighlightWords);
- mir_free(g_Settings.pszLogDir);
- if (g_Settings.MessageBoxFont)
- DeleteObject(g_Settings.MessageBoxFont);
- if (g_Settings.UserListFont)
- DeleteObject(g_Settings.UserListFont);
- if (g_Settings.UserListHeadingsFont)
- DeleteObject(g_Settings.UserListHeadingsFont);
-}
-
int OptionsInit(void)
{
- g_hOptions = HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
-
- LoadLogFonts();
- LOGFONT lf;
- LoadMsgDlgFont(18, &lf, NULL);
- lstrcpy(lf.lfFaceName, _T("MS Shell Dlg"));
- lf.lfUnderline = lf.lfItalic = lf.lfStrikeOut = 0;
- lf.lfHeight = -17;
- lf.lfWeight = FW_BOLD;
- g_Settings.NameFont = CreateFontIndirect(&lf);
- g_Settings.UserListFont = NULL;
- g_Settings.UserListHeadingsFont = NULL;
- g_Settings.MessageBoxFont = NULL;
- g_Settings.iSplitterX = db_get_w(NULL, "Chat", "SplitterX", 105);
- g_Settings.iSplitterY = db_get_w(NULL, "Chat", "SplitterY", 90);
- g_Settings.iX = db_get_dw(NULL, "Chat", "roomx", -1);
- g_Settings.iY = db_get_dw(NULL, "Chat", "roomy", -1);
- g_Settings.iWidth = db_get_dw(NULL, "Chat", "roomwidth", -1);
- g_Settings.iHeight = db_get_dw(NULL, "Chat", "roomheight", -1);
- LoadGlobalSettings();
-
- SkinAddNewSoundEx("ChatMessage", LPGEN("Group chats"), LPGEN("Incoming 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"));
-
- if (g_Settings.LoggingEnabled)
- CreateDirectoryTreeT(g_Settings.pszLogDir);
-
- LOGFONT lf2;
- LoadMsgDlgFont(0, &lf2, NULL);
- HFONT hFont = CreateFontIndirect(&lf2);
- 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;
+ HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
return 0;
}
int OptionsUnInit(void)
{
- FreeGlobalSettings();
- UnhookEvent(g_hOptions);
- DeleteObject(hEditBkgBrush);
DeleteObject(hListBkgBrush);
DeleteObject(hListSelectedBkgBrush);
- DeleteObject(g_Settings.NameFont);
return 0;
}
diff --git a/src/core/stdchat/src/services.cpp b/src/core/stdchat/src/services.cpp index e4b6ee34ae..57d6258128 100644 --- a/src/core/stdchat/src/services.cpp +++ b/src/core/stdchat/src/services.cpp @@ -22,34 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-#include "m_fontservice.h"
-
-extern HICON hIcons[30];
-extern HIMAGELIST hImageList, hIconsList;
-extern BOOL SmileyAddInstalled;
-extern BOOL PopupInstalled;
-extern BOOL IEviewInstalled;
-
-HANDLE hSendEvent;
-HANDLE hBuildMenuEvent;
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
-SESSION_INFO g_TabSession;
-CRITICAL_SECTION cs;
-
-void RegisterFonts( void );
-
-static HANDLE
- hServiceRegister = NULL,
- hServiceNewChat = NULL,
- hServiceAddEvent = NULL,
- hServiceGetAddEventPtr = NULL,
- hServiceGetInfo = NULL,
- hServiceGetCount = NULL,
- hEventPrebuildMenu = NULL,
- hEventDoubleclicked = NULL,
- hEventJoinChat = NULL,
- hEventLeaveChat = NULL;
-
void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
{
if (!si)
@@ -89,12 +61,12 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) // if the session was not the current tab we need to tell the window to
// redraw to show the contents of the current SESSION_INFO
if (!si->hWnd) {
- SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
+ pci->SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
SendMessage(g_TabSession.hWnd, GC_ADDTAB, -1, (LPARAM)si);
SendMessage(g_TabSession.hWnd, GC_TABCHANGE, 0, (LPARAM)&g_TabSession);
}
- SetActiveSession(si->ptszID, si->pszModule);
+ pci->SetActiveSession(si->ptszID, si->pszModule);
if (!IsWindowVisible(g_TabSession.hWnd) || wp == WINDOW_HIDDEN)
SendMessage(g_TabSession.hWnd, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
@@ -118,7 +90,7 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) return;
}
- //Do we need to create a window?
+ // Do we need to create a window?
if (si->hWnd == NULL)
si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), NULL, RoomWndProc, (LPARAM)si);
@@ -135,624 +107,3 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
SetFocus(GetDlgItem(si->hWnd, IDC_MESSAGE));
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Post-load event hooks
-
-static int FontsChanged(WPARAM wParam, LPARAM lParam)
-{
- LoadLogFonts();
- {
- LOGFONT lf;
- HFONT hFont;
- int iText;
-
- LoadMsgDlgFont(0, &lf, NULL);
- hFont = CreateFontIndirect(&lf);
- iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE);
- DeleteObject(hFont);
- g_Settings.LogTextIndent = iText;
- g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10;
- g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
- }
- MM_FontsChanged();
- MM_FixColors();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
- return 0;
-}
-
-static int IconsChanged(WPARAM wParam, LPARAM lParam)
-{
- FreeMsgLogBitmaps();
-
- LoadLogIcons();
- LoadMsgLogBitmaps();
- MM_IconsChanged();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, FALSE);
- return 0;
-}
-
-static int PreShutdown(WPARAM wParam, LPARAM lParam)
-{
- SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
-
- SM_RemoveAll();
- MM_RemoveAll();
- TabM_RemoveAll();
- return 0;
-}
-
-static int SmileyOptionsChanged(WPARAM wParam, LPARAM lParam)
-{
- SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE);
- return 0;
-}
-
-static INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam)
-{
- if (!lParam)
- return -1;
-
- mir_cslock lck(cs);
- return SM_GetCount((char *)lParam);
-}
-
-static INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam)
-{
- GC_INFO *gci = (GC_INFO *)lParam;
- SESSION_INFO *si = NULL;
-
- if (!gci || !gci->pszModule)
- return 1;
-
- mir_cslock lck(cs);
-
- if (gci->Flags&BYINDEX)
- si = SM_FindSessionByIndex(gci->pszModule, gci->iItem);
- else
- si = SM_FindSession(gci->pszID, gci->pszModule);
-
- if (si) {
- 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;
- }
-
- return 1;
-}
-
-static 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;
- mi->bUnderline = gcr->dwFlags & GC_UNDERLINE;
- mi->bItalics = gcr->dwFlags & GC_ITALICS;
- mi->bColor = gcr->dwFlags & GC_COLOR;
- mi->bBkgColor = gcr->dwFlags & GC_BKGCOLOR;
- mi->bAckMsg = gcr->dwFlags & GC_ACKMSG;
- mi->bChanMgr = gcr->dwFlags & GC_CHANMGR;
- 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->OnlineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_ONLINE));
- mi->hOnlineIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT);
-
- mi->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_AddIcon(hIconsList, mi->hOnlineTalkIcon);
-
- mi->OfflineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_OFFLINE));
- mi->hOfflineIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT);
-
- mi->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_AddIcon(hIconsList, mi->hOfflineTalkIcon);
-
- mi->pszHeader = Log_CreateRtfHeader(mi);
-
- CheckColorsInModule((char*)gcr->pszModule);
- CList_SetAllOffline(TRUE, gcr->pszModule);
- return 0;
-}
-
-static 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;
-
- SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule);
-
- // create a new session and set the defaults
- if (si != NULL) {
- TCHAR szTemp[256];
-
- si->dwItemData = gcw->dwItemData;
- if (gcw->iType != GCW_SERVER)
- si->wStatus = ID_STATUS_ONLINE;
- 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->iSplitterY = g_Settings.iSplitterY;
- si->iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
- si->bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
- si->bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
-
- 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", "");
- }
- else {
- SESSION_INFO* si2 = SM_FindSession(gcw->ptszID, gcw->pszModule);
- if (si2) {
- if (si2->hWnd)
- g_TabSession.nUsersInNicklist = 0;
-
- UM_RemoveAll(&si2->pUsers);
- TM_RemoveAll(&si2->pStatuses);
-
- si2->iStatusCount = 0;
- si2->nUsersInNicklist = 0;
-
- if (!g_Settings.TabsEnable) {
- if (si2->hWnd)
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- else if (g_TabSession.hWnd)
- RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- }
-
- return 0;
-}
-
-static int DoControl(GCEVENT *gce, WPARAM wp)
-{
- SESSION_INFO *si;
-
- if (gce->pDest->iType == GC_EVENT_CONTROL) {
- switch (wp) {
- case WINDOW_HIDDEN:
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- 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:
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- si->bInitDone = TRUE;
- if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0)
- ShowRoom(si, wp, TRUE);
- 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:
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- LM_RemoveAll(&si->pLog, &si->pLogEnd);
- if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = 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);
- }
-
- else if (gce->pDest->iType == GC_EVENT_CHUID && gce->ptszText) {
- SM_ChangeUID(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText);
- }
-
- else if (gce->pDest->iType == GC_EVENT_CHANGESESSIONAME && gce->ptszText) {
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- replaceStrT(si->ptszName, gce->ptszText);
- if (si->hWnd)
- SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
-
- if (g_TabSession.hWnd && g_Settings.TabsEnable) {
- g_TabSession.ptszName = si->ptszName;
- SendMessage(g_TabSession.hWnd, GC_SESSIONNAMECHANGE, 0, (LPARAM)si);
- }
- }
- }
-
- else if (gce->pDest->iType == GC_EVENT_SETITEMDATA) {
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule))
- si->dwItemData = gce->dwItemData;
- }
-
- else if (gce->pDest->iType == GC_EVENT_GETITEMDATA) {
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- gce->dwItemData = si->dwItemData;
- return si->dwItemData;
- }
- return 0;
- }
- else if (gce->pDest->iType == GC_EVENT_SETSBTEXT) {
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- 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) {
- g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
- SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
- }
- }
- }
- else if (gce->pDest->iType == GC_EVENT_ACK) {
- SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0);
- }
- else if (gce->pDest->iType == GC_EVENT_SENDMESSAGE && gce->ptszText) {
- SM_SendUserMessage(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText);
- }
- else if (gce->pDest->iType == GC_EVENT_SETSTATUSEX) {
- SM_SetStatusEx(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText, gce->dwItemData);
- }
- else return 1;
-
- return 0;
-}
-
-static void AddUser(GCEVENT *gce)
-{
- SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si == NULL) return;
-
- 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 == NULL) return;
-
- ui->pszNick = mir_tstrdup(gce->ptszNick);
-
- if (gce->bIsMe)
- si->pMe = ui;
-
- ui->Status = status;
- ui->Status |= si->pStatuses->Status;
-
- if (si->hWnd) {
- g_TabSession.pUsers = si->pUsers;
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
-}
-
-static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
-{
- GCEVENT *gce = (GCEVENT*)lParam;
- GCDEST *gcd = NULL;
- BOOL bIsHighlighted = FALSE;
- BOOL bRemoveFlag = FALSE;
-
- if (gce == NULL)
- return GC_EVENT_ERROR;
-
- 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;
-
- 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:
- {
- SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- if (gce->ptszText) {
- replaceStrT(si->ptszTopic, gce->ptszText);
- if (si->hWnd)
- g_TabSession.ptszTopic = si->ptszTopic;
- db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
- if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
- db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic));
- }
- }
- }
- break;
-
- case GC_EVENT_ADDSTATUS:
- SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
- break;
-
- case GC_EVENT_REMOVESTATUS:
- SM_TakeStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
- break;
-
- case GC_EVENT_MESSAGE:
- case GC_EVENT_ACTION:
- if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText) {
- SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si)
- if (IsHighlighted(si, gce->ptszText))
- bIsHighlighted = TRUE;
- }
- break;
-
- case GC_EVENT_NICK:
- SM_ChangeNick(gce->pDest->ptszID, gce->pDest->pszModule, gce);
- break;
-
- case GC_EVENT_JOIN:
- AddUser(gce);
- break;
-
- case GC_EVENT_PART:
- case GC_EVENT_QUIT:
- case GC_EVENT_KICK:
- bRemoveFlag = TRUE;
- break;
- }
-
- // Decide which window (log) should have the event
- LPCTSTR pWnd = NULL;
- LPCSTR pMod = NULL;
- 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);
- if (!bRemoveFlag)
- return 0;
- }
-
- // add to log
- if (pWnd) {
- SESSION_INFO *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) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
- }
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
- LogToFile(si, gce);
- }
-
- if (!bRemoveFlag)
- return 0;
- }
-
- if (bRemoveFlag)
- return SM_RemoveUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID) == 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;
-}
-
-static int ModuleLoad(WPARAM wParam, LPARAM lParam)
-{
- PopupInstalled = ServiceExists(MS_POPUP_ADDPOPUP);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Service creation
-
-static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- char* mods[3] = { "Chat", "ChatFonts" };
- CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
-
- RegisterFonts();
- AddIcons();
- 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.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_LEAVE);
- mi.flags = CMIF_NOTOFFLINE;
- mi.pszName = LPGEN("&Leave");
- mi.pszService = "GChat/LeaveChat";
- hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
-
- HookEvent(ME_FONT_RELOAD, FontsChanged);
- HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
-
- if (ServiceExists(MS_SMILEYADD_SHOWSELECTION)) {
- SmileyAddInstalled = TRUE;
- HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileyOptionsChanged);
- }
-
- ModuleLoad(0, 0);
-
- if (ServiceExists(MS_IEVIEW_WINDOW))
- IEviewInstalled = TRUE;
-
- CList_SetAllOffline(TRUE, NULL);
- return 0;
-}
-
-void HookEvents(void)
-{
- InitializeCriticalSection(&cs);
-
- HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
- HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
- HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad);
- HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
-}
-
-void UnhookEvents(void)
-{
- DeleteCriticalSection(&cs);
-}
-
-void CreateServiceFunctions(void)
-{
- CreateServiceFunction(MS_GC_REGISTER, Service_Register);
- CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
- CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
- 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);
-}
-
-void CreateHookableEvents(void)
-{
- hSendEvent = CreateHookableEvent(ME_GC_EVENT);
- hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
-}
-
-void DestroyHookableEvents(void)
-{
- DestroyHookableEvent(hSendEvent);
- DestroyHookableEvent(hBuildMenuEvent);
-}
-
-void TabsInit(void)
-{
- ZeroMemory(&g_TabSession, sizeof(SESSION_INFO));
-
- g_TabSession.iType = GCW_TABROOM;
- g_TabSession.iSplitterX = g_Settings.iSplitterX;
- g_TabSession.iSplitterY = g_Settings.iSplitterY;
- g_TabSession.iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
- g_TabSession.bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
- g_TabSession.bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
- g_TabSession.iFG = 4;
- g_TabSession.bFGSet = TRUE;
- g_TabSession.iBG = 2;
- g_TabSession.bBGSet = TRUE;
-}
diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp index 55fa601ba3..57aca9d6d3 100644 --- a/src/core/stdchat/src/tools.cpp +++ b/src/core/stdchat/src/tools.cpp @@ -22,12 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-extern HICON hIcons[30];
-extern FONTINFO aFonts[OPTIONS_FONTCOUNT];
extern HMENU g_hMenu;
extern HANDLE hBuildMenuEvent ;
extern HANDLE hSendEvent;
-extern SESSION_INFO g_TabSession;
int GetRichTextLength(HWND hwnd)
{
@@ -91,7 +88,7 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) static void __stdcall ShowRoomFromPopup(void * pi)
{
SESSION_INFO *si = (SESSION_INFO*)pi;
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -175,43 +172,43 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) switch (iEvent) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- CList_AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_MESSAGE:
- CList_AddEvent(si->hContact, hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_ACTION:
- CList_AddEvent(si->hContact, hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_JOIN:
- CList_AddEvent(si->hContact, hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_PART:
- CList_AddEvent(si->hContact, hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_QUIT:
- CList_AddEvent(si->hContact, hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
break;
case GC_EVENT_NICK:
- CList_AddEvent(si->hContact, hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
- CList_AddEvent(si->hContact, hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_NOTICE:
- CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
break;
case GC_EVENT_TOPIC:
- CList_AddEvent(si->hContact, hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- CList_AddEvent(si->hContact, hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_REMOVESTATUS:
- CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ pci->AddEvent(si->hContact, pci->hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
}
}
@@ -226,58 +223,58 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) if (iEvent & g_Settings.dwPopupFlags) {
switch (iEvent) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, pci->aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, pci->aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_MESSAGE:
- ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, pci->aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
- ShowPopup(si->hContact, si, hIcons[ICON_ACTION], si->pszModule, si->ptszName, aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_ACTION], si->pszModule, si->ptszName, pci->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, aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_JOIN], si->pszModule, si->ptszName, pci->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, aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_PART], si->pszModule, si->ptszName, pci->aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
else
- ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_PART], si->pszModule, si->ptszName, pci->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, aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_QUIT], si->pszModule, si->ptszName, pci->aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
else
- ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_QUIT], si->pszModule, si->ptszName, pci->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, aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_NICK], si->pszModule, si->ptszName, pci->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, aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_KICK], si->pszModule, si->ptszName, pci->aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
else
- ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_KICK], si->pszModule, si->ptszName, pci->aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
- ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_NOTICE], si->pszModule, si->ptszName, pci->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, aFonts[11].color, TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_TOPIC], si->pszModule, si->ptszName, pci->aFonts[11].color, TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
else
- ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, aFonts[11].color, TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_TOPIC], si->pszModule, si->ptszName, pci->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, aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_INFO], si->pszModule, si->ptszName, pci->aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ADDSTATUS:
- ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, pci->aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
- ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ ShowPopup(si->hContact, si, pci->hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, pci->aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
}
}
@@ -382,7 +379,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight int GetColorIndex(const char* pszModule, COLORREF cr)
{
- MODULEINFO * pMod = MM_FindModule(pszModule);
+ MODULEINFO * pMod = pci->MM_FindModule(pszModule);
int i = 0;
if (!pMod || pMod->nColorCount == 0)
@@ -402,12 +399,12 @@ int GetColorIndex(const char* pszModule, COLORREF cr) void CheckColorsInModule(const char* pszModule)
{
- MODULEINFO * pMod = MM_FindModule(pszModule);
+ MODULEINFO * pMod = pci->MM_FindModule(pszModule);
int i = 0;
- COLORREF crFG;
COLORREF crBG = (COLORREF)db_get_dw(NULL, "Chat", "ColorMessageBG", GetSysColor(COLOR_WINDOW));
- LoadMsgDlgFont(17, NULL, &crFG);
+ COLORREF crFG;
+ pci->LoadMsgDlgFont(17, NULL, &crFG);
if (!pMod)
return;
@@ -426,9 +423,9 @@ const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) {
int i, j, k;
for (i = 0; s1[i]; i++)
- for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++)
- if (!s2[k + 1])
- return s1 + i;
+ for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++)
+ if (!s2[k + 1])
+ return s1 + i;
return NULL;
}
@@ -500,7 +497,7 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) CharLower(szWord2);
// compare the words, using wildcards
- if (WCCmp(szWord1, RemoveFormatting(szWord2)))
+ if (wildcmpt(szWord1, RemoveFormatting(szWord2)))
return TRUE;
}
}
@@ -512,178 +509,6 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) return FALSE;
}
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
-{
- TCHAR szBuffer[4096];
- TCHAR szLine[4096];
- TCHAR szTime[100];
- TCHAR szFile[MAX_PATH];
- TCHAR szName[MAX_PATH];
- TCHAR szFolder[MAX_PATH];
- char p = '\0';
- szBuffer[0] = '\0';
-
- if (!si || !gce)
- return FALSE;
-
- MODULEINFO *mi = MM_FindModule(si->pszModule);
- if (!mi)
- return FALSE;
-
- TCHAR *szModName = mir_a2t(si->pszModule);
- mir_sntprintf(szName, MAX_PATH, _T("%s"), mi->ptszModDispName ? mi->ptszModDispName : (szModName = mir_a2t(si->pszModule)));
- mir_free(szModName);
- ValidateFilename(szName);
- mir_sntprintf(szFolder, MAX_PATH, _T("%s\\%s"), g_Settings.pszLogDir, szName );
-
- CreateDirectoryTreeT(szFolder);
-
- mir_sntprintf( szName, MAX_PATH, _T("%s.log"), si->ptszID );
- ValidateFilename(szName);
-
- mir_sntprintf(szFile, MAX_PATH, _T("%s\\%s"), szFolder, szName );
- lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99);
-
- FILE *hFile = _tfopen(szFile, _T("at+"));
- if (hFile) {
- TCHAR szTemp[512], szTemp2[512];
- TCHAR* pszNick = NULL;
- if ( gce->ptszNick ) {
- if ( g_Settings.LogLimitNames && 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"), (char *)pszNick);
- break;
- case GC_EVENT_PART:
- p = '<';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_QUIT:
- p = '<';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)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"), (char *)gce->ptszStatus, gce->ptszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NOTICE:
- p = '¤';
- 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, (char *)gce->ptszStatus, gce->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- p = '-';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
- break;
- }
- if (p)
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %c %s\n"), szTime, p, szBuffer);
- else
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %s\n"), szTime, szBuffer);
-
- if (szLine[0]) {
- char *p = mir_t2a(szLine);
- fputs(p, hFile);
- mir_free(p);
-
- if (g_Settings.LoggingLimit > 0) {
- DWORD dwSize;
- DWORD trimlimit;
-
- fseek(hFile, 0, SEEK_END);
- dwSize = ftell(hFile);
- rewind(hFile);
- trimlimit = g_Settings.LoggingLimit * 1024 + 1024 * 10;
- if (dwSize > trimlimit) {
- BYTE * pBuffer = 0;
- BYTE * pBufferTemp = 0;
- int read = 0;
-
- pBuffer = (BYTE *)mir_alloc(g_Settings.LoggingLimit * 1024 + 1);
- pBuffer[g_Settings.LoggingLimit * 1024] = '\0';
- fseek(hFile, -g_Settings.LoggingLimit * 1024, SEEK_END);
- read = (int)fread(pBuffer, 1, g_Settings.LoggingLimit * 1024, hFile);
- fclose(hFile);
- hFile = NULL;
-
- // trim to whole lines, should help with broken log files I hope.
- pBufferTemp = (BYTE *)strchr((char *)pBuffer, '\n');
- if (pBufferTemp) {
- pBufferTemp++;
- read -= pBufferTemp - pBuffer;
- }
- else pBufferTemp = pBuffer;
-
- if (read > 0) {
- hFile = _tfopen(szFile, _T("wt"));
- if (hFile) {
- fwrite(pBufferTemp, 1, read, hFile);
- fclose(hFile); hFile = NULL;
- }
- }
-
- mir_free(pBuffer);
- }
- }
- }
-
- 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)
{
GCMENUITEMS gcmi = { 0 };
@@ -776,7 +601,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;
@@ -796,7 +621,7 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int 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);
+ SESSION_INFO *si = pci->SM_FindSession(pszID, pszModule);
if (si == NULL)
return FALSE;
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 2cd58b222e..0eba9abf26 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -22,17 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-extern HBRUSH hEditBkgBrush;
-extern HBRUSH hListBkgBrush;
-extern HBRUSH hListSelectedBkgBrush;
-extern HANDLE hSendEvent;
-extern HICON hIcons[30];
-extern struct CREOleCallback reOleCallback;
-extern HIMAGELIST hImageList;
-extern HMENU g_hMenu;
-extern BOOL SmileyAddInstalled;
-extern TABLIST * g_TabList;
-extern HIMAGELIST hIconsList;
+extern TABLIST *g_TabList;
+extern HBRUSH hListBkgBrush, hListSelectedBkgBrush;
+extern HANDLE hSendEvent;
+extern CREOleCallback reOleCallback;
+extern HMENU g_hMenu;
+extern BOOL SmileyAddInstalled;
static HKL hkl = NULL;
@@ -44,31 +39,31 @@ typedef struct static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
- switch(msg) {
+ RECT rc;
+
+ switch (msg) {
case WM_NCHITTEST:
return HTCLIENT;
case WM_SETCURSOR:
- { RECT rc;
- GetClientRect(hwnd,&rc);
- SetCursor(rc.right>rc.bottom?LoadCursor(NULL, IDC_SIZENS):LoadCursor(NULL, IDC_SIZEWE));
+ GetClientRect(hwnd, &rc);
+ SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE));
return TRUE;
- }
+
case WM_LBUTTONDOWN:
SetCapture(hwnd);
return 0;
case WM_MOUSEMOVE:
- if (GetCapture()==hwnd) {
- RECT rc;
- GetClientRect(hwnd,&rc);
- SendMessage(GetParent(hwnd),GC_SPLITTERMOVED,rc.right>rc.bottom?(short)HIWORD(GetMessagePos())+rc.bottom/2:(short)LOWORD(GetMessagePos())+rc.right/2,(LPARAM)hwnd);
+ if (GetCapture() == hwnd) {
+ GetClientRect(hwnd, &rc);
+ SendMessage(GetParent(hwnd), GC_SPLITTERMOVED, rc.right > rc.bottom ? (short)HIWORD(GetMessagePos()) + rc.bottom / 2 : (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)hwnd);
}
return 0;
case WM_LBUTTONUP:
ReleaseCapture();
- PostMessage(GetParent(hwnd),WM_SIZE, 0, 0);
+ PostMessage(GetParent(hwnd), WM_SIZE, 0, 0);
return 0;
}
return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam);
@@ -117,7 +112,7 @@ static void InitButtons(HWND hwndDlg, SESSION_INFO *si) SendDlgItemMessage(hwndDlg, IDC_COLOR, BUTTONSETASPUSHBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_BKGCOLOR, BUTTONSETASPUSHBTN, TRUE, 0);
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (pInfo) {
EnableWindow(GetDlgItem(hwndDlg, IDC_BOLD), pInfo->bBold);
EnableWindow(GetDlgItem(hwndDlg, IDC_ITALICS), pInfo->bItalics);
@@ -173,7 +168,7 @@ static int RoomWndResize(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc) EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWNICKLIST), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), TRUE);
if (si->iType == GCW_CHATROOM)
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHANMGR), MM_FindModule(si->pszModule)->bChanMgr);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANMGR), pci->MM_FindModule(si->pszModule)->bChanMgr);
}
switch(urc->wId) {
@@ -348,7 +343,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (g_Settings.TabsEnable)
SendMessage(GetParent(hwnd), GC_SWITCHNEXTTAB, 0, 0);
else
- ShowRoom(SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(pci->SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
return TRUE;
}
@@ -356,7 +351,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (g_Settings.TabsEnable)
SendMessage(GetParent(hwnd), GC_SWITCHPREVTAB, 0, 0);
else
- ShowRoom(SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(pci->SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
return TRUE;
}
@@ -403,7 +398,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, pszSelName = (TCHAR *)mir_alloc( sizeof(TCHAR)*( end-start+1 ));
lstrcpyn( pszSelName, pszText+start, end-start+1);
- pszName = UM_FindUserAutoComplete(Parentsi->pUsers, dat->szTabSave, pszSelName);
+ pszName = pci->UM_FindUserAutoComplete(Parentsi->pUsers, dat->szTabSave, pszSelName);
if (pszName == NULL) {
pszName = dat->szTabSave;
SendMessage(hwnd, EM_SETSEL, start, end);
@@ -528,11 +523,11 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, GETTEXTLENGTHEX gtl = {0};
SETTEXTEX ste;
LOGFONT lf;
- char* lpPrevCmd = SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
+ char* lpPrevCmd = pci->SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
- LoadMsgDlgFont(17, &lf, NULL);
+ pci->LoadMsgDlgFont(17, &lf, NULL);
ste.flags = ST_DEFAULT;
ste.codepage = CP_ACP;
if (lpPrevCmd)
@@ -556,7 +551,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;
@@ -657,13 +652,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, UINT u2 = 0;
COLORREF cr;
- LoadMsgDlgFont(17, NULL, &cr);
+ pci->LoadMsgDlgFont(17, NULL, &cr);
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_BACKCOLOR|CFM_COLOR;
SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- if (MM_FindModule(Parentsi->pszModule) && MM_FindModule(Parentsi->pszModule)->bColor) {
+ if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bColor) {
int index = GetColorIndex(Parentsi->pszModule, cf.crTextColor);
u = IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR);
@@ -678,7 +673,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_UNCHECKED);
}
- if (MM_FindModule(Parentsi->pszModule) && MM_FindModule(Parentsi->pszModule)->bBkgColor) {
+ if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bBkgColor) {
int index = GetColorIndex(Parentsi->pszModule, cf.crBackColor);
COLORREF crB = (COLORREF)db_get_dw(NULL, "Chat", "ColorMessageBG", GetSysColor(COLOR_WINDOW));
u = IsDlgButtonChecked(GetParent(hwnd), IDC_BKGCOLOR);
@@ -693,7 +688,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, BST_UNCHECKED);
}
- if (MM_FindModule(Parentsi->pszModule) && MM_FindModule(Parentsi->pszModule)->bBold) {
+ if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bBold) {
u = IsDlgButtonChecked(GetParent(hwnd), IDC_BOLD);
u2 = cf.dwEffects;
u2 &= CFE_BOLD;
@@ -703,7 +698,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_BOLD, BST_UNCHECKED);
}
- if (MM_FindModule(Parentsi->pszModule) && MM_FindModule(Parentsi->pszModule)->bItalics) {
+ if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bItalics) {
u = IsDlgButtonChecked(GetParent(hwnd), IDC_ITALICS);
u2 = cf.dwEffects;
u2 &= CFE_ITALIC;
@@ -713,7 +708,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_ITALICS, BST_UNCHECKED);
}
- if (MM_FindModule(Parentsi->pszModule) && MM_FindModule(Parentsi->pszModule)->bUnderline) {
+ if (pci->MM_FindModule(Parentsi->pszModule) && pci->MM_FindModule(Parentsi->pszModule)->bUnderline) {
u = IsDlgButtonChecked(GetParent(hwnd), IDC_UNDERLINE);
u2 = cf.dwEffects;
u2 &= CFE_UNDERLINE;
@@ -896,7 +891,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR BOOL bOnline = db_get_w(s->hContact, s->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE?TRUE:FALSE;
bDragging = TRUE;
iBeginIndex = i;
- ImageList_BeginDrag(hIconsList, bOnline?(MM_FindModule(s->pszModule))->OnlineIconIndex:(MM_FindModule(s->pszModule))->OfflineIconIndex, 8, 8);
+ ImageList_BeginDrag(pci->hIconsList, bOnline?(pci->MM_FindModule(s->pszModule))->OnlineIconIndex:(pci->MM_FindModule(s->pszModule))->OfflineIconIndex, 8, 8);
ImageList_DragEnter(hwnd,tci.pt.x, tci.pt.y);
SetCapture(hwnd);
}
@@ -1058,7 +1053,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, else ScreenToClient(hwnd,&hti.pt);
item = LOWORD(SendMessage(GetDlgItem(GetParent(hwnd), IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
- ui = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
+ ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
// ui = (USERINFO *)SendMessage(GetDlgItem(GetParent(hwnd), IDC_LIST), LB_GETITEMDATA, item, 0);
if (ui) {
HMENU hMenu = 0;
@@ -1192,7 +1187,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) si->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP| SBT_TOOLTIPS , 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL);
SendMessage(si->hwndStatus,SB_SETMINHEIGHT,GetSystemMetrics(SM_CYSMICON),0);
TabCtrl_SetMinTabWidth(GetDlgItem(hwndDlg, IDC_TAB), 80);
- TabCtrl_SetImageList(GetDlgItem(hwndDlg, IDC_TAB), hIconsList);
+ TabCtrl_SetImageList(GetDlgItem(hwndDlg, IDC_TAB), pci->hIconsList);
// enable tooltips
si->iOldItemID = -1;
@@ -1216,9 +1211,9 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) // restore previous tabs
if (g_Settings.TabsEnable && db_get_b(NULL, "Chat", "TabRestore", 0)) {
- TABLIST * node = g_TabList;
+ TABLIST *node = g_TabList;
while (node) {
- SESSION_INFO* s = SM_FindSession(node->pszID, node->pszModule);
+ SESSION_INFO* s = pci->SM_FindSession(node->pszID, node->pszModule);
if (s)
SendMessage(hwndDlg, GC_ADDTAB, -1, (LPARAM)s);
@@ -1240,14 +1235,14 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) case GC_SETWNDPROPS:
{
- LoadGlobalSettings();
+ // LoadGlobalSettings(); !!!!!!!!!!!!!!!!!!!!!!
InitButtons(hwndDlg, si);
- HICON hIcon = si->wStatus==ID_STATUS_ONLINE?MM_FindModule(si->pszModule)->hOnlineIcon:MM_FindModule(si->pszModule)->hOfflineIcon;
+ HICON hIcon = si->wStatus==ID_STATUS_ONLINE?pci->MM_FindModule(si->pszModule)->hOnlineIcon:pci->MM_FindModule(si->pszModule)->hOfflineIcon;
// stupid hack to make icons show. I dunno why this is needed currently
if (!hIcon) {
- MM_IconsChanged();
- hIcon = si->wStatus==ID_STATUS_ONLINE?MM_FindModule(si->pszModule)->hOnlineIcon:MM_FindModule(si->pszModule)->hOfflineIcon;
+ pci->MM_IconsChanged();
+ hIcon = (si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(si->pszModule)->hOnlineIcon : pci->MM_FindModule(si->pszModule)->hOfflineIcon;
}
SendMessage(hwndDlg, GC_FIXTABICONS, 0, 0);
@@ -1270,7 +1265,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) COLORREF crFore;
CHARFORMAT2 cf;
- LoadMsgDlgFont(17, NULL, &crFore);
+ pci->LoadMsgDlgFont(17, NULL, &crFore);
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = CFM_COLOR|CFM_BOLD|CFM_UNDERLINE|CFM_BACKCOLOR;
cf.dwEffects = 0;
@@ -1329,7 +1324,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
HICON hIcon;
int iStatusbarParts[2];
- TCHAR* ptszDispName = MM_FindModule(si->pszModule)->ptszModDispName;
+ TCHAR* ptszDispName = pci->MM_FindModule(si->pszModule)->ptszModDispName;
int x = 12;
x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(si->hwndStatus,WM_GETFONT,0,0), TRUE);
@@ -1337,12 +1332,12 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) iStatusbarParts[0] = x; iStatusbarParts[1] = -1;
SendMessage(si->hwndStatus,SB_SETPARTS,2 ,(LPARAM)&iStatusbarParts);
- hIcon = si->wStatus==ID_STATUS_ONLINE?MM_FindModule(si->pszModule)->hOnlineIcon:MM_FindModule(si->pszModule)->hOfflineIcon;
+ hIcon = si->wStatus==ID_STATUS_ONLINE?pci->MM_FindModule(si->pszModule)->hOnlineIcon:pci->MM_FindModule(si->pszModule)->hOfflineIcon;
// stupid hack to make icons show. I dunno why this is needed currently
if (!hIcon) {
- MM_IconsChanged();
- hIcon = si->wStatus==ID_STATUS_ONLINE?MM_FindModule(si->pszModule)->hOnlineIcon:MM_FindModule(si->pszModule)->hOfflineIcon;
+ pci->MM_IconsChanged();
+ hIcon = si->wStatus==ID_STATUS_ONLINE?pci->MM_FindModule(si->pszModule)->hOnlineIcon:pci->MM_FindModule(si->pszModule)->hOfflineIcon;
}
SendMessage(si->hwndStatus, SB_SETICON, 0,(LPARAM)hIcon);
@@ -1358,7 +1353,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) case GC_SETWINDOWPOS:
{
- SESSION_INFO* pActive = GetActiveSession();
+ SESSION_INFO* pActive = pci->GetActiveSession();
WINDOWPLACEMENT wp;
RECT screen;
int savePerContact = db_get_b(NULL, "Chat", "SavePosition", 0);
@@ -1564,7 +1559,7 @@ END_REMOVETAB: s = (SESSION_INFO*)id.lParam;
if (s)
- ShowRoom(s, (WPARAM)WINDOW_VISIBLE, wParam == 1?FALSE:TRUE);
+ pci->ShowRoom(s, (WPARAM)WINDOW_VISIBLE, wParam == 1 ? FALSE : TRUE);
} }
break;
@@ -1649,7 +1644,7 @@ END_REMOVETAB: if (s2 && s == s2) {
int image = 0;
if (!(s2->wState&GC_EVENT_HIGHLIGHT)) {
- image = s2->wStatus==ID_STATUS_ONLINE?MM_FindModule(s2->pszModule)->OnlineIconIndex:MM_FindModule(s2->pszModule)->OfflineIconIndex;
+ image = s2->wStatus==ID_STATUS_ONLINE?pci->MM_FindModule(s2->pszModule)->OnlineIconIndex:pci->MM_FindModule(s2->pszModule)->OfflineIconIndex;
if (s2->wState&STATE_TALK)
image++;
}
@@ -1680,7 +1675,7 @@ END_REMOVETAB: s2 = (SESSION_INFO*)tci.lParam;
if (s2 && s == s2) { // highlight
s2->wState |= GC_EVENT_HIGHLIGHT;
- if (SM_FindSession(si->ptszID, si->pszModule) == s2)
+ if (pci->SM_FindSession(si->ptszID, si->pszModule) == s2)
si->wState = s2->wState;
SendMessage(hwndDlg, GC_FIXTABICONS, 0, (LPARAM)s2);
if (db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0 && GetActiveWindow() != hwndDlg && GetForegroundWindow() != hwndDlg)
@@ -1748,7 +1743,7 @@ END_REMOVETAB: SendMessage(hwndDlg, GC_FIXTABICONS, 0, (LPARAM)s);
if (!s->hWnd) {
- ShowRoom(s, (WPARAM)WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(s, (WPARAM)WINDOW_VISIBLE, TRUE);
SendMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
} } } }
break;
@@ -1847,7 +1842,7 @@ END_REMOVETAB: int offset;
int height;
int index = dis->itemID;
- USERINFO * ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
if (ui) {
int x_offset = 2;
@@ -1859,7 +1854,7 @@ END_REMOVETAB: offset = 0;
else
offset = height/2 - 4;
- hIcon = SM_GetStatusIcon(si, ui);
+ hIcon = pci->SM_GetStatusIcon(si, ui);
hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont;
hOldFont = (HFONT) SelectObject(dis->hDC, hFont);
SetBkMode(dis->hDC, TRANSPARENT);
@@ -2050,7 +2045,7 @@ LABEL_SHOWWINDOW: GetWindowRect(GetDlgItem(hwndDlg, bFG?IDC_COLOR:IDC_BKGCOLOR), &rc);
pCC->hWndTarget = GetDlgItem(hwndDlg, IDC_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;
@@ -2116,7 +2111,7 @@ LABEL_SHOWWINDOW: if (uMsg != WM_ACTIVATE)
SetFocus(GetDlgItem(hwndDlg,IDC_MESSAGE));
- SetActiveSession(si->ptszID, si->pszModule);
+ pci->SetActiveSession(si->ptszID, si->pszModule);
if (KillTimer(hwndDlg, TIMERID_FLASHWND))
FlashWindow(hwndDlg, FALSE);
@@ -2181,7 +2176,7 @@ LABEL_SHOWWINDOW: if (tabId > 0) {
if (TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB)) != i)
if (s)
- ShowRoom(s, WINDOW_VISIBLE, TRUE);
+ pci->ShowRoom(s, WINDOW_VISIBLE, TRUE);
for(tabId; tabId >= 0; tabId --) {
if (tabId == i)
@@ -2265,11 +2260,10 @@ LABEL_SHOWWINDOW: case ID_CLEARLOG:
{
- SESSION_INFO* s = SM_FindSession(si->ptszID, si->pszModule);
- if (s)
- {
+ SESSION_INFO* s = pci->SM_FindSession(si->ptszID, si->pszModule);
+ if (s) {
SetDlgItemText(hwndDlg, IDC_LOG, _T(""));
- LM_RemoveAll(&s->pLog, &s->pLogEnd);
+ pci->LM_RemoveAll(&s->pLog, &s->pLogEnd);
s->iEventCount = 0;
s->LastTime = 0;
si->iEventCount = 0;
@@ -2277,18 +2271,16 @@ LABEL_SHOWWINDOW: si->pLog = s->pLog;
si->pLogEnd = s->pLogEnd;
PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
- } }
+ }
+ }
break;
case ID_SEARCH_GOOGLE:
- {
- TCHAR szURL[4096];
- if (pszWord[0]) {
- mir_sntprintf( szURL, SIZEOF( szURL ), _T("http://www.google.com/search?q=%s"), pszWord );
- CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW|OUF_TCHAR, (LPARAM) szURL);
- }
- PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
- }
+ if (pszWord[0])
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR,
+ (LPARAM)CMString(FORMAT, _T("http://www.google.com/search?q=%s"), pszWord).GetString());
+
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
break;
case ID_SEARCH_WIKIPEDIA:
@@ -2372,26 +2364,23 @@ LABEL_SHOWWINDOW: break;
case TTN_NEEDTEXT:
- if (pNmhdr->idFrom == (UINT_PTR)GetDlgItem(hwndDlg,IDC_LIST))
- {
+ if (pNmhdr->idFrom == (UINT_PTR)GetDlgItem(hwndDlg, IDC_LIST)) {
LPNMTTDISPINFO lpttd = (LPNMTTDISPINFO)lParam;
+ SESSION_INFO* parentdat = (SESSION_INFO*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
POINT p;
- int item;
- USERINFO * ui;
- SESSION_INFO* parentdat =(SESSION_INFO*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
-
- GetCursorPos( &p );
+ GetCursorPos(&p);
ScreenToClient(GetDlgItem(hwndDlg, IDC_LIST), &p);
- item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y)));
- ui = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
- if ( ui != NULL ) {
- static TCHAR ptszBuf[ 1024 ];
- mir_sntprintf( ptszBuf, SIZEOF(ptszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"),
- TranslateT( "Nickname" ), ui->pszNick,
- TranslateT( "Unique ID" ), ui->pszUID,
- TranslateT( "Status" ), TM_WordToString( parentdat->pStatuses, ui->Status ));
+ int item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y)));
+ USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
+ if (ui != NULL) {
+ static TCHAR ptszBuf[1024];
+ mir_sntprintf(ptszBuf, SIZEOF(ptszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"),
+ TranslateT("Nickname"), ui->pszNick,
+ TranslateT("Unique ID"), ui->pszUID,
+ TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status));
lpttd->lpszText = ptszBuf;
- } }
+ }
+ }
break;
} }
break;
@@ -2401,27 +2390,24 @@ LABEL_SHOWWINDOW: case IDC_LIST:
if (HIWORD(wParam) == LBN_DBLCLK) {
TVHITTESTINFO hti;
- int item;
- USERINFO * ui;
-
- hti.pt.x=(short)LOWORD(GetMessagePos());
- hti.pt.y=(short)HIWORD(GetMessagePos());
- ScreenToClient(GetDlgItem(hwndDlg, IDC_LIST),&hti.pt);
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(GetDlgItem(hwndDlg, IDC_LIST), &hti.pt);
- item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
- ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
+ int item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
if (ui) {
if (GetKeyState(VK_SHIFT) & 0x8000) {
LRESULT lResult = (LRESULT)SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_GETSEL, 0, 0);
int start = LOWORD(lResult);
TCHAR* pszName = (TCHAR*)alloca(sizeof(TCHAR)*(lstrlen(ui->pszUID) + 3));
if (start == 0)
- mir_sntprintf(pszName, lstrlen(ui->pszUID)+3, _T("%s: "), ui->pszUID);
+ mir_sntprintf(pszName, lstrlen(ui->pszUID) + 3, _T("%s: "), ui->pszUID);
else
- mir_sntprintf(pszName, lstrlen(ui->pszUID)+2, _T("%s "), ui->pszUID);
+ mir_sntprintf(pszName, lstrlen(ui->pszUID) + 2, _T("%s "), ui->pszUID);
- SendMessage( GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM) pszName );
- PostMessage( hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM)pszName);
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
}
else DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
@@ -2434,30 +2420,25 @@ LABEL_SHOWWINDOW: break;
case IDOK:
- {
- char* pszRtf;
- TCHAR* ptszText, *p1;
- if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDOK)))
- break;
-
- pszRtf = Message_GetFromStream(hwndDlg, si);
- SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
- ptszText = DoRtfToTags(pszRtf, si);
- p1 = _tcschr(ptszText, '\0');
+ if (IsWindowEnabled(GetDlgItem(hwndDlg, IDOK))) {
+ char *pszRtf = Message_GetFromStream(hwndDlg, si);
+ pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
+ TCHAR *ptszText = DoRtfToTags(pszRtf, si);
+ TCHAR *p1 = _tcschr(ptszText, '\0');
//remove trailing linebreaks
- while ( p1 > ptszText && (*p1 == '\0' || *p1 == '\r' || *p1 == '\n')) {
+ while (p1 > ptszText && (*p1 == '\0' || *p1 == '\r' || *p1 == '\n')) {
*p1 = '\0';
p1--;
}
- if ( MM_FindModule(si->pszModule)->bAckMsg ) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_MESSAGE),FALSE);
- SendDlgItemMessage(hwndDlg,IDC_MESSAGE,EM_SETREADONLY,TRUE,0);
+ if (pci->MM_FindModule(si->pszModule)->bAckMsg) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0);
}
- else SendDlgItemMessage(hwndDlg,IDC_MESSAGE,WM_SETTEXT,0,(LPARAM)_T(""));
+ else SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETTEXT, 0, (LPARAM)_T(""));
- EnableWindow(GetDlgItem(hwndDlg,IDOK),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
mir_free(pszRtf);
@@ -2511,7 +2492,7 @@ LABEL_SHOWWINDOW: TCHAR szFile[MAX_PATH];
TCHAR szName[MAX_PATH];
TCHAR szFolder[MAX_PATH];
- MODULEINFO * pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO * pInfo = pci->MM_FindModule(si->pszModule);
if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDC_HISTORY)))
break;
@@ -2567,7 +2548,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_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
} }
else {
@@ -2591,13 +2572,12 @@ 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_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
} }
else {
COLORREF cr;
-
- LoadMsgDlgFont(17, NULL, &cr);
+ pci->LoadMsgDlgFont(17, NULL, &cr);
cf.dwMask = CFM_COLOR;
cf.crTextColor = cr;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
@@ -2672,7 +2652,7 @@ LABEL_SHOWWINDOW: case GC_CLOSEWINDOW:
if (g_Settings.TabsEnable)
- SM_SetTabbedWindowHwnd(0, 0);
+ pci->SM_SetTabbedWindowHwnd(0, 0);
DestroyWindow(hwndDlg);
break;
diff --git a/src/core/stdchat/stdchat_10.vcxproj b/src/core/stdchat/stdchat_10.vcxproj index 857c2f9094..c2413540c1 100644 --- a/src/core/stdchat/stdchat_10.vcxproj +++ b/src/core/stdchat/stdchat_10.vcxproj @@ -201,7 +201,6 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp" />
<ClCompile Include="src\colorchooser.cpp" />
<ClCompile Include="src\log.cpp" />
<ClCompile Include="src\stdafx.cpp">
diff --git a/src/core/stdchat/stdchat_10.vcxproj.filters b/src/core/stdchat/stdchat_10.vcxproj.filters index 539873fd5b..3db0ba41e8 100644 --- a/src/core/stdchat/stdchat_10.vcxproj.filters +++ b/src/core/stdchat/stdchat_10.vcxproj.filters @@ -19,9 +19,6 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\colorchooser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/src/core/stdchat/stdchat_11.vcxproj b/src/core/stdchat/stdchat_11.vcxproj index f4dc3202e8..cb7823f69e 100644 --- a/src/core/stdchat/stdchat_11.vcxproj +++ b/src/core/stdchat/stdchat_11.vcxproj @@ -204,7 +204,6 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp" />
<ClCompile Include="src\colorchooser.cpp" />
<ClCompile Include="src\log.cpp" />
<ClCompile Include="src\stdafx.cpp">
diff --git a/src/core/stdchat/stdchat_11.vcxproj.filters b/src/core/stdchat/stdchat_11.vcxproj.filters index 539873fd5b..3db0ba41e8 100644 --- a/src/core/stdchat/stdchat_11.vcxproj.filters +++ b/src/core/stdchat/stdchat_11.vcxproj.filters @@ -19,9 +19,6 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\colorchooser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/src/core/stdchat/stdchat_12.vcxproj b/src/core/stdchat/stdchat_12.vcxproj index 24f128af26..5fb59acb61 100644 --- a/src/core/stdchat/stdchat_12.vcxproj +++ b/src/core/stdchat/stdchat_12.vcxproj @@ -204,7 +204,6 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp" />
<ClCompile Include="src\colorchooser.cpp" />
<ClCompile Include="src\log.cpp" />
<ClCompile Include="src\stdafx.cpp">
diff --git a/src/core/stdchat/stdchat_12.vcxproj.filters b/src/core/stdchat/stdchat_12.vcxproj.filters index 539873fd5b..3db0ba41e8 100644 --- a/src/core/stdchat/stdchat_12.vcxproj.filters +++ b/src/core/stdchat/stdchat_12.vcxproj.filters @@ -19,9 +19,6 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\colorchooser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h index 5fe53a1a25..5b3b799d94 100644 --- a/src/modules/chat/chat.h +++ b/src/modules/chat/chat.h @@ -36,26 +36,27 @@ extern HGENMENU hJoinMenuItem, hLeaveMenuItem; extern HANDLE hChatSendEvent;
extern BOOL PopupInstalled;
-//log.c
+// log.c
void LoadMsgLogBitmaps(void);
void FreeMsgLogBitmaps(void);
-void ValidateFilename (TCHAR * filename);
-TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time);
-char* Log_CreateRtfHeader(MODULEINFO * mi);
-
-//clist.c
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType);
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide);
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule);
-int CList_RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam);
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... ) ;
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
-int WCCmp(TCHAR* wild, TCHAR*string);
+void ValidateFilename (TCHAR *filename);
+TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time);
+char* Log_CreateRtfHeader(MODULEINFO *mi);
+char* Log_CreateRTF(LOGSTREAMDATA *streamData);
+
+// clist.c
+BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ...);
+HANDLE AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType);
+HANDLE FindRoom(const char* pszModule, const TCHAR* pszRoom);
+BOOL SetAllOffline(BOOL bHide, const char *pszModule);
+BOOL SetOffline(HANDLE hContact, BOOL bHide);
+
+int RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR JoinChat(WPARAM wParam, LPARAM lParam);
+INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam);
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
+INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
// options.c
int OptionsInit(void);
@@ -66,28 +67,25 @@ HICON LoadIconEx(char* pszIcoLibName, BOOL big); void LoadLogFonts(void);
// services.c
-void HookEvents(void);
-void UnhookEvents(void);
-void CreateServiceFunctions(void);
-void CreateHookableEvents(void);
-void DestroyHookableEvents(void);
-void TabsInit(void);
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
-
-//tools.c
-int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth);
-TCHAR* RemoveFormatting(const TCHAR* pszText);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int GetColorIndex(const char* pszModule, COLORREF cr);
-void CheckColorsInModule(const char* pszModule);
-const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ;
-int GetRichTextLength(HWND hwnd);
-BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText);
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
-void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
-BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
-BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+void InitChatModule(void);
+void LoadChatModule(void);
+void UnloadChatModule(void);
+
+// tools.c
+int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth);
+TCHAR *RemoveFormatting(const TCHAR* pszText);
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+int GetColorIndex(const char* pszModule, COLORREF cr);
+void CheckColorsInModule(const char* pszModule);
+int GetRichTextLength(HWND hwnd);
+BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText);
+UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
+void DestroyGCMenu(HMENU *hMenu, int iIndex);
+BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
+BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
+BOOL IsEventSupported(int eventType);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+
+const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2);
#pragma comment(lib,"comctl32.lib")
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp index a2658f3a8f..59ca171575 100644 --- a/src/modules/chat/chat_opts.cpp +++ b/src/modules/chat/chat_opts.cpp @@ -205,14 +205,8 @@ static void InitSetting(TCHAR** ppPointer, char* pszSetting, TCHAR* pszDefault) void LoadGlobalSettings(void)
{
- LOGFONT lf;
-
ci.pSettings->LogLimitNames = db_get_b(NULL, "Chat", "LogLimitNames", 1);
ci.pSettings->ShowTime = db_get_b(NULL, "Chat", "ShowTimeStamp", 1);
- ci.pSettings->TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
- ci.pSettings->TabsAtBottom = db_get_b(NULL, "Chat", "TabBottom", 0);
- ci.pSettings->TabCloseOnDblClick = db_get_b(NULL, "Chat", "TabCloseOnDblClick", 0);
- ci.pSettings->TabRestore = db_get_b(NULL, "Chat", "TabRestore", 0);
ci.pSettings->SoundsFocus = db_get_b(NULL, "Chat", "SoundsFocus", 0);
ci.pSettings->ShowTimeIfChanged = (BOOL)db_get_b(NULL, "Chat", "ShowTimeStampIfChanged", 0);
ci.pSettings->TimeStampEventColour = (BOOL)db_get_b(NULL, "Chat", "TimeStampEventColour", 0);
@@ -246,25 +240,24 @@ void LoadGlobalSettings(void) InitSetting(&ci.pSettings->pszOutgoingNick, "HeaderOutgoing", _T("%n:"));
InitSetting(&ci.pSettings->pszHighlightWords, "HighlightWords", _T("%m"));
- {
- TCHAR pszTemp[MAX_PATH];
- DBVARIANT dbv;
- ci.pSettings->pszLogDir = (TCHAR *)mir_realloc(ci.pSettings->pszLogDir, MAX_PATH*sizeof(TCHAR));
- if (!db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
- lstrcpyn(pszTemp, dbv.ptszVal, MAX_PATH);
- db_free(&dbv);
- }
- else {
- TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat"));
- lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp) - 1);
- mir_free(tmpPath);
- }
-
- PathToAbsoluteT(pszTemp, ci.pSettings->pszLogDir);
+ TCHAR pszTemp[MAX_PATH];
+ DBVARIANT dbv;
+ ci.pSettings->pszLogDir = (TCHAR *)mir_realloc(ci.pSettings->pszLogDir, MAX_PATH*sizeof(TCHAR));
+ if (!db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
+ lstrcpyn(pszTemp, dbv.ptszVal, MAX_PATH);
+ db_free(&dbv);
}
+ else {
+ TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat"));
+ lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp) - 1);
+ mir_free(tmpPath);
+ }
+
+ PathToAbsoluteT(pszTemp, ci.pSettings->pszLogDir);
ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
+ LOGFONT lf;
if (ci.pSettings->MessageBoxFont)
DeleteObject(ci.pSettings->MessageBoxFont);
LoadMsgDlgFont(17, &lf, NULL);
@@ -299,17 +292,14 @@ static void FreeGlobalSettings(void) int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth)
{
- HDC hdc;
- HFONT hOldFont;
- RECT rc = { 0 };
- int i;
-
if (!pszText || !hFont)
return 0;
- hdc = GetDC(NULL);
- hOldFont = (HFONT)SelectObject(hdc, hFont);
- i = DrawText(hdc, pszText, -1, &rc, DT_CALCRECT);
+ HDC hdc = GetDC(NULL);
+ HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);
+
+ RECT rc = { 0 };
+ int i = DrawText(hdc, pszText, -1, &rc, DT_CALCRECT);
SelectObject(hdc, hOldFont);
ReleaseDC(NULL, hdc);
return bWidth ? rc.right - rc.left : rc.bottom - rc.top;
@@ -318,6 +308,7 @@ int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth) int OptionsInit(void)
{
LoadLogFonts();
+
LOGFONT lf;
LoadMsgDlgFont(18, &lf, NULL);
lstrcpy(lf.lfFaceName, _T("MS Shell Dlg"));
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index 5b5492987e..4532c7030b 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -22,14 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
+INT_PTR SvcGetChatManager(WPARAM, LPARAM);
+
#include "chat.h"
BOOL SmileyAddInstalled, PopupInstalled, IEviewInstalled;
-
-HANDLE hChatSendEvent;
-HANDLE hBuildMenuEvent;
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
-SESSION_INFO g_TabSession;
+HANDLE hChatSendEvent, hBuildMenuEvent;
+HGENMENU hJoinMenuItem, hLeaveMenuItem;
CRITICAL_SECTION cs;
void RegisterFonts( void );
@@ -46,111 +45,25 @@ static HANDLE hEventJoinChat = NULL,
hEventLeaveChat = NULL;
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
-{
- if (!si)
- return;
-
- if (ci.pSettings->TabsEnable) {
- // the session is not the current tab, so we copy the necessary
- // details into the SESSION_INFO for the tabbed window
- if (!si->hWnd) {
- g_TabSession.iEventCount = si->iEventCount;
- g_TabSession.iStatusCount = si->iStatusCount;
- g_TabSession.iType = si->iType;
- g_TabSession.nUsersInNicklist = si->nUsersInNicklist;
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- g_TabSession.pMe = si->pMe;
- g_TabSession.dwFlags = si->dwFlags;
- g_TabSession.pStatuses = si->pStatuses;
- g_TabSession.ptszID = si->ptszID;
- g_TabSession.pszModule = si->pszModule;
- g_TabSession.ptszName = si->ptszName;
- g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
- g_TabSession.ptszTopic = si->ptszTopic;
- g_TabSession.pUsers = si->pUsers;
- g_TabSession.hContact = si->hContact;
- g_TabSession.wStatus = si->wStatus;
- g_TabSession.lpCommands = si->lpCommands;
- g_TabSession.lpCurrentCommand = NULL;
- }
-
- //Do we need to create a tabbed window?
-// if (g_TabSession.hWnd == NULL) !!!!!!!!!!!!!!!!!!!!!!!
-// g_TabSession.hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANNEL), NULL, RoomWndProc, (LPARAM)&g_TabSession);
-
- SetWindowLongPtr(g_TabSession.hWnd, GWL_EXSTYLE, GetWindowLongPtr(g_TabSession.hWnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
-
- // if the session was not the current tab we need to tell the window to
- // redraw to show the contents of the current SESSION_INFO
- if (!si->hWnd) {
- ci.SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
- SendMessage(g_TabSession.hWnd, GC_ADDTAB, -1, (LPARAM)si);
- SendMessage(g_TabSession.hWnd, GC_TABCHANGE, 0, (LPARAM)&g_TabSession);
- }
-
- ci.SetActiveSession(si->ptszID, si->pszModule);
-
- if (!IsWindowVisible(g_TabSession.hWnd) || wp == WINDOW_HIDDEN)
- SendMessage(g_TabSession.hWnd, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
- else {
- if (IsIconic(g_TabSession.hWnd))
- ShowWindow(g_TabSession.hWnd, SW_NORMAL);
-
- PostMessage(g_TabSession.hWnd, WM_SIZE, 0, 0);
- if (si->iType != GCW_SERVER)
- SendMessage(g_TabSession.hWnd, GC_UPDATENICKLIST, 0, 0);
- else
- SendMessage(g_TabSession.hWnd, GC_UPDATETITLE, 0, 0);
- SendMessage(g_TabSession.hWnd, GC_REDRAWLOG, 0, 0);
- SendMessage(g_TabSession.hWnd, GC_UPDATESTATUSBAR, 0, 0);
- ShowWindow(g_TabSession.hWnd, SW_SHOW);
- if (bSetForeground)
- SetForegroundWindow(g_TabSession.hWnd);
- }
- SendMessage(g_TabSession.hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(g_TabSession.hWnd, IDC_MESSAGE));
- return;
- }
-
- //Do we need to create a window?
-// if (si->hWnd == NULL) !!!!!!!!!!!!!!!!!!!!!!!s
-// si->hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANNEL), NULL, RoomWndProc, (LPARAM)si);
-
- SetWindowLongPtr(si->hWnd, GWL_EXSTYLE, GetWindowLongPtr(si->hWnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
- if (!IsWindowVisible(si->hWnd) || wp == WINDOW_HIDDEN)
- SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
- else {
- if (IsIconic(si->hWnd))
- ShowWindow(si->hWnd, SW_NORMAL);
- ShowWindow(si->hWnd, SW_SHOW);
- SetForegroundWindow(si->hWnd);
- }
-
- SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(si->hWnd, IDC_MESSAGE));
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Post-load event hooks
static int FontsChanged(WPARAM wParam, LPARAM lParam)
{
LoadLogFonts();
- {
- LOGFONT lf;
- HFONT hFont;
- int iText;
-
- LoadMsgDlgFont(0, &lf, NULL);
- hFont = CreateFontIndirect(&lf);
- iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
- DeleteObject(hFont);
- ci.pSettings->LogTextIndent = iText;
- ci.pSettings->LogTextIndent = ci.pSettings->LogTextIndent * 12 / 10;
- ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
- }
+
+ LOGFONT lf;
+ HFONT hFont;
+ int iText;
+
+ LoadMsgDlgFont(0, &lf, NULL);
+ hFont = CreateFontIndirect(&lf);
+ iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
+ DeleteObject(hFont);
+ ci.pSettings->LogTextIndent = iText;
+ ci.pSettings->LogTextIndent = ci.pSettings->LogTextIndent * 12 / 10;
+ ci.pSettings->LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
+
ci.MM_FontsChanged();
ci.MM_FixColors();
ci.SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
@@ -173,7 +86,6 @@ static int PreShutdown(WPARAM wParam, LPARAM lParam) ci.SM_RemoveAll();
ci.MM_RemoveAll();
- ci.TabM_RemoveAll();
return 0;
}
@@ -265,7 +177,7 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) mi->pszHeader = Log_CreateRtfHeader(mi);
CheckColorsInModule((char*)gcr->pszModule);
- CList_SetAllOffline(TRUE, gcr->pszModule);
+ ci.SetAllOffline(TRUE, gcr->pszModule);
return 0;
}
@@ -287,8 +199,6 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) // create a new session and set the defaults
if (si != NULL) {
- TCHAR szTemp[256];
-
si->dwItemData = gcw->dwItemData;
if (gcw->iType != GCW_SERVER)
si->wStatus = ID_STATUS_ONLINE;
@@ -310,11 +220,13 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) si->iBG = 2;
si->bBGSet = TRUE;
}
+
+ TCHAR szTemp[256];
if (si->iType == GCW_SERVER)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName);
else
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
- si->hContact = CList_AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
+ si->hContact = ci.AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_unset(si->hContact, "CList", "StatusMsg");
if (si->ptszStatusbarText)
@@ -325,21 +237,14 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) else {
SESSION_INFO* si2 = ci.SM_FindSession(gcw->ptszID, gcw->pszModule);
if (si2) {
- if (si2->hWnd)
- g_TabSession.nUsersInNicklist = 0;
-
ci.UM_RemoveAll(&si2->pUsers);
ci.TM_RemoveAll(&si2->pStatuses);
si2->iStatusCount = 0;
si2->nUsersInNicklist = 0;
- if (!ci.pSettings->TabsEnable) {
- if (si2->hWnd)
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- else if (g_TabSession.hWnd)
- RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+ if (ci.OnSessionReplace)
+ ci.OnSessionReplace(si2);
}
}
@@ -357,7 +262,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp) si->bInitDone = TRUE;
ci.SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
- ShowRoom(si, wp, FALSE);
+ ci.ShowRoom(si, wp, FALSE);
}
return 0;
@@ -368,7 +273,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp) if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
si->bInitDone = TRUE;
if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0)
- ShowRoom(si, wp, TRUE);
+ ci.ShowRoom(si, wp, TRUE);
return 0;
}
break;
@@ -384,10 +289,8 @@ static int DoControl(GCEVENT *gce, WPARAM wp) case WINDOW_CLEARLOG:
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
ci.LM_RemoveAll(&si->pLog, &si->pLogEnd);
- if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- }
+ if (ci.OnClearLog)
+ ci.OnClearLog(si);
si->iEventCount = 0;
si->LastTime = 0;
}
@@ -408,11 +311,8 @@ static int DoControl(GCEVENT *gce, WPARAM wp) replaceStrT(si->ptszName, gce->ptszText);
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
-
- if (g_TabSession.hWnd && ci.pSettings->TabsEnable) {
- g_TabSession.ptszName = si->ptszName;
- SendMessage(g_TabSession.hWnd, GC_SESSIONNAMECHANGE, 0, (LPARAM)si);
- }
+ if (ci.OnSessionRename)
+ ci.OnSessionRename(si);
}
}
@@ -435,11 +335,9 @@ static int DoControl(GCEVENT *gce, WPARAM wp) db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
else
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
- if (si->hWnd) {
- g_TabSession.ptszStatusbarText = si->ptszStatusbarText;
- SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
- }
}
+ if (ci.OnSetStatusBar)
+ ci.OnSetStatusBar(si);
}
else if (gce->pDest->iType == GC_EVENT_ACK) {
ci.SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0);
@@ -472,10 +370,8 @@ static void AddUser(GCEVENT *gce) ui->Status = status;
ui->Status |= si->pStatuses->Status;
- if (si->hWnd) {
- g_TabSession.pUsers = si->pUsers;
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
+ if (ci.OnNewUser)
+ ci.OnNewUser(si, ui);
}
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
@@ -530,9 +426,9 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (si) {
if (gce->ptszText) {
replaceStrT(si->ptszTopic, gce->ptszText);
- if (si->hWnd)
- g_TabSession.ptszTopic = si->ptszTopic;
db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
+ if (ci.OnSetTopic)
+ ci.OnSetTopic(si);
if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic));
}
@@ -607,16 +503,9 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) return 0;
if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (ci.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (si->hWnd) {
- g_TabSession.pLog = si->pLog;
- g_TabSession.pLogEnd = si->pLogEnd;
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+ int isOk = ci.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
+ if (ci.OnAddLog)
+ ci.OnAddLog(si, isOk);
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && ci.pSettings->LoggingEnabled)
@@ -649,15 +538,13 @@ static int ModuleLoad(WPARAM wParam, LPARAM lParam) return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// Service creation
-
static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
char* mods[3] = { "Chat", "ChatFonts" };
CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
RegisterFonts();
+ OptionsInit();
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = -2000090001;
@@ -684,29 +571,34 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) ModuleLoad(0, 0);
- CList_SetAllOffline(TRUE, NULL);
+ ci.SetAllOffline(TRUE, NULL);
return 0;
}
-void HookEvents(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Service creation
+
+static bool bInited = false;
+
+void InitChatModule(void)
+{
+ CreateServiceFunction("GChat/GetInterface", SvcGetChatManager);
+}
+
+void LoadChatModule(void)
{
+ if (bInited)
+ return;
+
InitializeCriticalSection(&cs);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad);
HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
-}
-void UnhookEvents(void)
-{
- DeleteCriticalSection(&cs);
-}
-
-void CreateServiceFunctions(void)
-{
CreateServiceFunction(MS_GC_REGISTER, Service_Register);
CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
@@ -714,36 +606,24 @@ void CreateServiceFunctions(void) CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo);
CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount);
- CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclicked);
- CreateServiceFunction("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc);
- CreateServiceFunction("GChat/JoinChat", CList_JoinChat);
- CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat);
-}
+ CreateServiceFunction("GChat/DblClickEvent", EventDoubleclicked);
+ CreateServiceFunction("GChat/PrebuildMenuEvent", PrebuildContactMenuSvc);
+ CreateServiceFunction("GChat/JoinChat", JoinChat);
+ CreateServiceFunction("GChat/LeaveChat", LeaveChat);
-void CreateHookableEvents(void)
-{
hChatSendEvent = CreateHookableEvent(ME_GC_EVENT);
hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
+ bInited = true;
}
-void DestroyHookableEvents(void)
+void UnloadChatModule(void)
{
+ if (!bInited)
+ return;
+
+ OptionsUnInit();
+ DeleteCriticalSection(&cs);
+
DestroyHookableEvent(hChatSendEvent);
DestroyHookableEvent(hBuildMenuEvent);
}
-
-void TabsInit(void)
-{
- ZeroMemory(&g_TabSession, sizeof(SESSION_INFO));
-
- g_TabSession.iType = GCW_TABROOM;
- g_TabSession.iSplitterX = ci.pSettings->iSplitterX;
- g_TabSession.iSplitterY = ci.pSettings->iSplitterY;
- g_TabSession.iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
- g_TabSession.bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
- g_TabSession.bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
- g_TabSession.iFG = 4;
- g_TabSession.bFGSet = TRUE;
- g_TabSession.iBG = 2;
- g_TabSession.bBGSet = TRUE;
-}
diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp index a06c640c75..79c3a23dc3 100644 --- a/src/modules/chat/clist.cpp +++ b/src/modules/chat/clist.cpp @@ -22,9 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
+HANDLE AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
{
- HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
+ HANDLE hContact = ci.FindRoom(pszModule, pszRoom);
DBVARIANT dbv;
TCHAR pszGroup[50];
@@ -67,7 +67,7 @@ HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* p return hContact;
}
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide)
+BOOL SetOffline(HANDLE hContact, BOOL bHide)
{
if ( hContact ) {
char* szProto = GetContactProto(hContact);
@@ -80,7 +80,7 @@ BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) return FALSE;
}
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
+BOOL SetAllOffline(BOOL bHide, const char *pszModule)
{
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
@@ -98,7 +98,7 @@ BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule) return TRUE;
}
-int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
+int RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
{
BOOL bRedrawFlag = FALSE;
@@ -121,15 +121,14 @@ int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam ) && db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1
&& !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0)
&& IsWindowVisible(si->hWnd)
- && !IsIconic(si->hWnd)) {
- if (ci.pSettings->TabsEnable)
- SendMessage(si->hWnd, GC_REMOVETAB, 1, (LPARAM)si);
- else
- PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+ && !IsIconic(si->hWnd))
+ {
+ if (ci.OnSessionDblClick)
+ ci.OnSessionDblClick(si);
db_free(&dbv);
return 1;
}
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
db_free(&dbv);
return 1;
@@ -138,38 +137,39 @@ int CList_RoomDoubleclicked( WPARAM wParam, LPARAM lParam ) return 0;
}
-INT_PTR CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam)
+INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam)
{
- return CList_RoomDoubleclicked((WPARAM) ((CLISTEVENT*)lParam)->hContact,(LPARAM) 0);
+ return RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0);
}
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam)
+INT_PTR JoinChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
+ if (hContact) {
char* szProto = GetContactProto(hContact);
- if ( szProto ) {
- if ( db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
- CallProtoService( szProto, PS_JOINCHAT, wParam, lParam );
+ if (szProto) {
+ if (db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE)
+ CallProtoService(szProto, PS_JOINCHAT, wParam, lParam);
else
- CList_RoomDoubleclicked( wParam, 0 );
- } }
+ RoomDoubleclicked(wParam, 0);
+ }
+ }
return 0;
}
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam)
+INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
+ if (hContact) {
char* szProto = GetContactProto(hContact);
- if ( szProto )
- CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam );
+ if (szProto)
+ CallProtoService(szProto, PS_LEAVECHAT, wParam, lParam);
}
return 0;
}
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
if (hContact == NULL)
@@ -199,24 +199,24 @@ int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
+INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
{
- return CList_PrebuildContactMenu(wParam, lParam);
+ return PrebuildContactMenu(wParam, lParam);
}
-BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
+BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
{
- CLISTEVENT cle = {0};
- va_list marker;
TCHAR szBuf[4096];
if (!fmt || !fmt[0] || _tcslen(fmt) > 2000)
return FALSE;
+ va_list marker;
va_start(marker, fmt);
mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
va_end(marker);
+ CLISTEVENT cle = { 0 };
cle.cbSize = sizeof(cle);
cle.hContact = hContact;
cle.hDbEvent = hEvent;
@@ -236,7 +236,7 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR return TRUE;
}
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom)
+HANDLE FindRoom (const char* pszModule, const TCHAR* pszRoom)
{
for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
@@ -254,40 +254,3 @@ HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) return 0;
}
-
-int WCCmp(TCHAR* wild, TCHAR* string)
-{
- TCHAR *cp, *mp;
- if ( wild == NULL || !wild[0] || string == NULL || !string[0])
- return 0;
-
- while ((*string) && (*wild != '*')) {
- if ((*wild != *string) && (*wild != '?'))
- return 0;
-
- wild++;
- string++;
- }
-
- while (*string) {
- if (*wild == '*') {
- if (!*++wild)
- return 1;
-
- mp = wild;
- cp = string+1;
- }
- else if ((*wild == *string) || (*wild == '?')) {
- wild++;
- string++;
- }
- else {
- wild = mp;
- string = cp++;
- } }
-
- while (*wild == '*')
- wild++;
-
- return !*wild;
-}
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp index ea05294de5..f791809f54 100644 --- a/src/modules/chat/log.cpp +++ b/src/modules/chat/log.cpp @@ -28,9 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static PBYTE pLogIconBmpBits[14];
static int logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
-static int logPixelSY = 0;
-static int logPixelSX = 0;
-
static int EventToIndex(LOGINFO * lin)
{
switch (lin->iType) {
@@ -85,7 +82,7 @@ static char *Log_SetStyle(int style, int fontindex) static char szStyle[128];
mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u",
- style, style + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ style, style + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
return szStyle;
}
@@ -323,7 +320,7 @@ TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time) return szTime;
}
-static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
+char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
int bufferAlloced, bufferEnd, i, me = 0;
@@ -374,13 +371,13 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE)
{
iii = lin->bIsHighlighted?16:(lin->bIsMe ? 2 : 1);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
else
{
iii = lin->bIsHighlighted?16:EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
}
@@ -479,13 +476,10 @@ char* Log_CreateRtfHeader(MODULEINFO * mi) //get the number of pixels per logical inch
- {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC(NULL, hdc);
- }
+ HDC hdc = GetDC(NULL);
+ ci.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ ci.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
// ### RTF HEADER
@@ -512,12 +506,12 @@ char* Log_CreateRtfHeader(MODULEINFO * mi) if (ci.pSettings->dwIconFlags)
{
- iIndent += (14*1440)/logPixelSX;
+ iIndent += (14 * 1440) / ci.logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
if (ci.pSettings->ShowTime)
{
- int iSize = (ci.pSettings->LogTextIndent*1440)/logPixelSX;
+ int iSize = (ci.pSettings->LogTextIndent * 1440) / ci.logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
if (ci.pSettings->LogIndentEnabled)
iIndent += iSize;
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp index b50bc34598..4f6279a10b 100644 --- a/src/modules/chat/manager.cpp +++ b/src/modules/chat/manager.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define STATUSICONCOUNT 6
SESSION_INFO *m_WndList = 0;
-TABLIST *g_TabList = 0;
MODULEINFO *m_ModList = 0;
static void SetActiveSessionEx(SESSION_INFO *si)
@@ -87,27 +86,17 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule) static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL removeContact)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
- if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) // match
- {
- COMMANDINFO *pCurComm;
+ // match
+ if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
DWORD dw = pTemp->dwItemData;
- if (!ci.pSettings->TabsEnable) {
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- }
- else if (ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)pTemp);
-
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist = 0;
-
+ if (ci.OnSessionRemove)
+ ci.OnSessionRemove(pTemp);
DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
if (pLast == NULL)
@@ -124,7 +113,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo // contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (pTemp->hContact && db_get_b(pTemp->hContact, pTemp->pszModule, "ChatRoom", 0) != 0) {
- CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE);
+ ci.SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE);
db_set_s(pTemp->hContact, pTemp->pszModule, "Topic", "");
db_set_s(pTemp->hContact, pTemp->pszModule, "StatusBar", "");
db_unset(pTemp->hContact, "CList", "StatusMsg");
@@ -142,7 +131,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo mir_free(pTemp->pszName);
// delete commands
- pCurComm = pTemp->lpCommands;
+ COMMANDINFO *pCurComm = pTemp->lpCommands;
while (pCurComm != NULL) {
COMMANDINFO *pNext = pCurComm->next;
mir_free(pCurComm->lpCommand);
@@ -168,11 +157,10 @@ static int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL remo static SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return NULL;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
return pTemp;
@@ -185,22 +173,18 @@ static SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule) static BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule)
{
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
+ SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
ci.UM_RemoveAll(&pTemp->pUsers);
pTemp->nUsersInNicklist = 0;
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist = 0;
if (pTemp->iType != GCW_SERVER)
pTemp->bInitDone = FALSE;
- if (ci.pSettings->TabsEnable && pTemp->hWnd)
- ci.tabSession.pUsers = 0;
-
+ if (ci.OnSessionOffline)
+ ci.OnSessionOffline(pTemp);
if (pszID)
return TRUE;
}
@@ -267,18 +251,12 @@ static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce) if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) {
if (ci.UM_FindUser(pTemp->pUsers, gce->ptszUID)) {
if (pTemp->bInitDone) {
- if (ci.SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE) && pTemp->hWnd && pTemp->bInitDone) {
- ci.tabSession.pLog = pTemp->pLog;
- ci.tabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (pTemp->hWnd && pTemp->bInitDone) {
- ci.tabSession.pLog = pTemp->pLog;
- ci.tabSession.pLogEnd = pTemp->pLogEnd;
- SendMessage(pTemp->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+ if (ci.OnEventBroadcast)
+ ci.OnEventBroadcast(pTemp, gce);
+
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
DoSoundsFlashPopupTrayStuff(pTemp, gce, FALSE, bManyFix);
+
bManyFix++;
if ((gce->dwFlags & GCEF_ADDTOLOG) && ci.pSettings->LoggingEnabled)
LogToFile(pTemp, gce);
@@ -339,8 +317,8 @@ static USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCH if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO *p = ci.UM_AddUser(pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus);
pTemp->nUsersInNicklist++;
- if (pTemp->hWnd)
- ci.tabSession.nUsersInNicklist++;
+ if (ci.OnAddUser)
+ ci.OnAddUser(pTemp, p);
return p;
}
pLast = pTemp;
@@ -381,10 +359,8 @@ static BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR USERINFO *ui = ci.UM_FindUser(pTemp->pUsers, pszUID);
if (ui) {
pTemp->nUsersInNicklist--;
- if (pTemp->hWnd) {
- ci.tabSession.pUsers = pTemp->pUsers;
- ci.tabSession.nUsersInNicklist--;
- }
+ if (ci.OnRemoveUser)
+ ci.OnRemoveUser(pTemp, ui);
dw = ci.UM_RemoveUser(&pTemp->pUsers, pszUID);
@@ -420,7 +396,7 @@ static USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, }
-STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
+STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus)
{
SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
@@ -432,8 +408,8 @@ STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR STATUSINFO *ti = ci.TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount);
if (ti)
pTemp->iStatusCount++;
- if (ci.pSettings->TabsEnable && pTemp->hWnd)
- ci.tabSession.pStatuses = pTemp->pStatuses;
+ if (ci.OnAddStatus)
+ ci.OnAddStatus(pTemp, ti);
return ti;
}
pLast = pTemp;
@@ -585,9 +561,6 @@ static BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus) while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
pTemp->wStatus = wStatus;
- if (pTemp->hWnd && ci.pSettings->TabsEnable)
- ci.tabSession.wStatus = wStatus;
-
if (pTemp->hContact) {
if (pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
db_unset(pTemp->hContact, "CList", "Hidden");
@@ -595,8 +568,8 @@ static BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus) db_set_w(pTemp->hContact, pTemp->pszModule, "Status", (WORD)wStatus);
}
- if (ci.pSettings->TabsEnable && ci.tabSession.hWnd)
- PostMessage(ci.tabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM)pTemp);
+ if (ci.OnSetStatus)
+ ci.OnSetStatus(pTemp, wStatus);
if (pszID)
return TRUE;
@@ -750,7 +723,7 @@ static BOOL SM_RemoveAll(void) SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
DoEventHook(m_WndList->ptszID, m_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)m_WndList->dwItemData);
if (m_WndList->hContact)
- CList_SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
+ ci.SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
db_set_s(m_WndList->hContact, m_WndList->pszModule, "Topic", "");
db_unset(m_WndList->hContact, "CList", "StatusMsg");
db_set_s(m_WndList->hContact, m_WndList->pszModule, "StatusBar", "");
@@ -1058,50 +1031,6 @@ static BOOL MM_RemoveAll(void) return TRUE;
}
-
-
-//---------------------------------------------------
-// Tab list manager functions
-//
-// Necessary to keep track of what tabs should
-// be restored
-//---------------------------------------------------
-
-static BOOL TabM_AddTab(const TCHAR *pszID, const char* pszModule)
-{
- TABLIST *node = NULL;
- if (!pszID || !pszModule)
- return FALSE;
-
- node = (TABLIST*)mir_alloc(sizeof(TABLIST));
- ZeroMemory(node, sizeof(TABLIST));
- node->pszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
-
- if (g_TabList == NULL) { // list is empty
- g_TabList = node;
- node->next = NULL;
- }
- else {
- node->next = g_TabList;
- g_TabList = node;
- }
- return TRUE;
-}
-
-static BOOL TabM_RemoveAll(void)
-{
- while (g_TabList != NULL) {
- TABLIST * pLast = g_TabList->next;
- mir_free(g_TabList->pszModule);
- mir_free(g_TabList->pszID);
- mir_free(g_TabList);
- g_TabList = pLast;
- }
- g_TabList = NULL;
- return TRUE;
-}
-
//---------------------------------------------------
// Status manager functions
//
@@ -1607,9 +1536,6 @@ CHAT_MANAGER ci = MM_IconsChanged,
MM_RemoveAll,
- TabM_AddTab,
- TabM_RemoveAll,
-
TM_AddStatus,
TM_FindStatus,
TM_StringToWord,
@@ -1630,10 +1556,20 @@ CHAT_MANAGER ci = LM_AddEvent,
LM_TrimLog,
- LM_RemoveAll
+ LM_RemoveAll,
+
+ AddRoom,
+ SetOffline,
+ SetAllOffline,
+ AddEvent,
+ FindRoom,
+ NULL, // must be implemented in a plugin
+ Log_CreateRTF,
+ LoadMsgDlgFont
};
INT_PTR SvcGetChatManager(WPARAM, LPARAM)
{
+ LoadChatModule();
return (INT_PTR)&ci;
}
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index e2775403d9..216798a3a2 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -86,7 +86,7 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) static void __stdcall ShowRoomFromPopup(void * pi)
{
SESSION_INFO *si = (SESSION_INFO*)pi;
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
+ ci.ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -170,43 +170,43 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) switch (iEvent) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- CList_AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_MESSAGE:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_ACTION:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_ACTION], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_JOIN:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_JOIN], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_PART:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_PART], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_QUIT:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
break;
case GC_EVENT_NICK:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_NOTICE:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
break;
case GC_EVENT_TOPIC:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_TOPIC], "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_REMOVESTATUS:
- CList_AddEvent(si->hContact, ci.hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ ci.AddEvent(si->hContact, ci.hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
}
}
@@ -286,7 +286,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight return FALSE;
BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != si->hWnd;
- // bInactive |= GetActiveWindow() != si->hWnd; // Removed this, because it seemed to be FALSE, even when window was focused, causing incorrect notifications
int iEvent = gce->pDest->iType;
@@ -294,16 +293,14 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
if (bInactive || !ci.pSettings->SoundsFocus)
SkinPlaySound("ChatHighlight");
- if (!ci.pSettings->TabsEnable && bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
- SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL);
if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0)
db_unset(si->hContact, "CList", "Hidden");
if (bInactive)
DoTrayIcon(si, gce);
if (bInactive || !ci.pSettings->PopupInactiveOnly)
DoPopup(si, gce);
- if (ci.pSettings->TabsEnable && bInactive && ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
+ if (ci.OnFlashWindow)
+ ci.OnFlashWindow(si, bInactive);
return TRUE;
}
@@ -343,15 +340,13 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight case GC_EVENT_MESSAGE:
if (bInactive || !ci.pSettings->SoundsFocus)
SkinPlaySound("ChatMessage");
- if (!ci.pSettings->TabsEnable && bInactive && ci.pSettings->FlashWindow && si->hWnd)
- SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL);
if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071);
}
- if (ci.pSettings->TabsEnable && bInactive && ci.tabSession.hWnd)
- SendMessage(ci.tabSession.hWnd, GC_SETTABHIGHLIGHT, 0, (LPARAM)si);
+ if (ci.OnFlashWindow)
+ ci.OnFlashWindow(si, bInactive);
break;
case GC_EVENT_ACTION:
if (bInactive || !ci.pSettings->SoundsFocus)
@@ -491,11 +486,8 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) p2 += 1;
p3 = p2;
- CharLower(szWord1);
- CharLower(szWord2);
-
// compare the words, using wildcards
- if (WCCmp(szWord1, RemoveFormatting(szWord2)))
+ if (wildcmpit(szWord1, RemoveFormatting(szWord2)))
return TRUE;
}
}
|