diff options
Diffstat (limited to 'plugins/Scriver')
26 files changed, 872 insertions, 4862 deletions
diff --git a/plugins/Scriver/scriver_10.vcxproj b/plugins/Scriver/scriver_10.vcxproj index c75c25bcdc..00b4eac9db 100644 --- a/plugins/Scriver/scriver_10.vcxproj +++ b/plugins/Scriver/scriver_10.vcxproj @@ -211,9 +211,6 @@ <ClCompile Include="src\statusicon.cpp" />
<ClCompile Include="src\srmm.cpp" />
<ClCompile Include="src\utils.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_10.vcxproj.filters b/plugins/Scriver/scriver_10.vcxproj.filters index b6e855c27f..d885ad0667 100644 --- a/plugins/Scriver/scriver_10.vcxproj.filters +++ b/plugins/Scriver/scriver_10.vcxproj.filters @@ -12,9 +12,6 @@ <UniqueIdentifier>{c6f77fbc-2b2a-48c9-b9c9-73d4f0f73fb3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
- <Filter Include="Header Files\chat">
- <UniqueIdentifier>{b1d0ab9c-9a6b-4f3b-9697-560060e476ec}</UniqueIdentifier>
- </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{8b31b6e6-ed45-4468-b82e-965e2154ef0c}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
@@ -66,9 +63,6 @@ <ClCompile Include="src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
@@ -137,12 +131,12 @@ <ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\chat\chat.h">
- <Filter>Header Files\chat</Filter>
- </ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\chat\chat.h">
+ <Filter>Source Files\chat</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
diff --git a/plugins/Scriver/scriver_11.vcxproj b/plugins/Scriver/scriver_11.vcxproj index e294bc5749..7e1999adea 100644 --- a/plugins/Scriver/scriver_11.vcxproj +++ b/plugins/Scriver/scriver_11.vcxproj @@ -214,9 +214,6 @@ <ClCompile Include="src\statusicon.cpp" />
<ClCompile Include="src\srmm.cpp" />
<ClCompile Include="src\utils.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_11.vcxproj.filters b/plugins/Scriver/scriver_11.vcxproj.filters index b6e855c27f..d885ad0667 100644 --- a/plugins/Scriver/scriver_11.vcxproj.filters +++ b/plugins/Scriver/scriver_11.vcxproj.filters @@ -12,9 +12,6 @@ <UniqueIdentifier>{c6f77fbc-2b2a-48c9-b9c9-73d4f0f73fb3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
- <Filter Include="Header Files\chat">
- <UniqueIdentifier>{b1d0ab9c-9a6b-4f3b-9697-560060e476ec}</UniqueIdentifier>
- </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{8b31b6e6-ed45-4468-b82e-965e2154ef0c}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
@@ -66,9 +63,6 @@ <ClCompile Include="src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
@@ -137,12 +131,12 @@ <ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\chat\chat.h">
- <Filter>Header Files\chat</Filter>
- </ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\chat\chat.h">
+ <Filter>Source Files\chat</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
diff --git a/plugins/Scriver/scriver_12.vcxproj b/plugins/Scriver/scriver_12.vcxproj index e3eaaecfcd..bb6c401951 100644 --- a/plugins/Scriver/scriver_12.vcxproj +++ b/plugins/Scriver/scriver_12.vcxproj @@ -214,9 +214,6 @@ <ClCompile Include="src\statusicon.cpp" />
<ClCompile Include="src\srmm.cpp" />
<ClCompile Include="src\utils.cpp" />
- <ClCompile Include="src\chat\clist.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_12.vcxproj.filters b/plugins/Scriver/scriver_12.vcxproj.filters index b6e855c27f..d885ad0667 100644 --- a/plugins/Scriver/scriver_12.vcxproj.filters +++ b/plugins/Scriver/scriver_12.vcxproj.filters @@ -12,9 +12,6 @@ <UniqueIdentifier>{c6f77fbc-2b2a-48c9-b9c9-73d4f0f73fb3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
- <Filter Include="Header Files\chat">
- <UniqueIdentifier>{b1d0ab9c-9a6b-4f3b-9697-560060e476ec}</UniqueIdentifier>
- </Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{8b31b6e6-ed45-4468-b82e-965e2154ef0c}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
@@ -66,9 +63,6 @@ <ClCompile Include="src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\chat\clist.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\colorchooser.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
@@ -137,12 +131,12 @@ <ClInclude Include="src\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\chat\chat.h">
- <Filter>Header Files\chat</Filter>
- </ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\chat\chat.h">
+ <Filter>Source Files\chat</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h index 7f26cb3437..9e2d97cc98 100644 --- a/plugins/Scriver/src/chat/chat.h +++ b/plugins/Scriver/src/chat/chat.h @@ -23,7 +23,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define _CHAT_H_
#include <m_protomod.h>
-#include <m_chat.h>
+#include <m_chat_int.h>
+
+#define EM_ACTIVATE (WM_USER+202)
+
+#define TIMERID_MSGSEND 1
+#define TIMERID_TYPE 2
+#define TIMERID_UNREAD 3
+#define TIMEOUT_TYPEOFF 10000 // send type off after 10 seconds of inactivity
+#define TIMEOUT_UNREAD 800 // multiple-send bombproofing: send max 3 messages every 4 seconds
#ifndef TVM_GETITEMSTATE
#define TVM_GETITEMSTATE (TV_FIRST + 39)
@@ -38,249 +46,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CFM_BACKCOLOR 0x04000000
#endif
-//defines
-#define OPTIONS_FONTCOUNT 17
-#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_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_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_SCROLLTOBOTTOM (WM_USER+129)
-#define GC_FIXTABICONS (WM_USER+132)
-#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 GCW_TABROOM 10
-#define GCW_TABPRIVMSG 11
-
-#define GC_EVENT_HIGHLIGHT 0x1000
-#define STATE_TALK 0x0001
-
-
-// special service for tweaking performance
-#define MS_GC_GETEVENTPTR "GChat/GetNewEventPtr"
-typedef INT_PTR (*GETEVENTFUNC)(WPARAM wParam, LPARAM lParam);
-typedef struct {
- GETEVENTFUNC pfnAddEvent;
-}GCPTRS;
-
//structs
-typedef struct MODULE_INFO_TYPE
-{
- char* pszModule;
- TCHAR* ptszModDispName;
- BOOL bBold;
- BOOL bUnderline;
- BOOL bItalics;
- BOOL bColor;
- BOOL bBkgColor;
- BOOL bFontSize;
- BOOL bChanMgr;
- BOOL bAckMsg;
- BOOL bSingleFormat;
- int nColorCount;
- COLORREF* crColors;
- HICON hOnlineIcon;
- HICON hOfflineIcon;
- HICON hOnlineIconBig;
- HICON hOfflineIconBig;
- HICON hOnlineTalkIcon;
- HICON hOfflineTalkIcon;
- int iMaxText;
- struct MODULE_INFO_TYPE *next;
-}
- MODULEINFO;
-
-typedef struct COMMAND_INFO_TYPE
-{
- char* lpCommand;
- struct COMMAND_INFO_TYPE *prev, *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
-{
- TCHAR* pszGroup;
- HICON hIcon;
- WORD Status;
- struct STATUSINFO_TYPE *next;
-}
- STATUSINFO;
-
-typedef struct USERINFO_TYPE
+struct MODULEINFO : public GCModuleInfoBase
{
- TCHAR* pszNick;
- TCHAR* pszUID;
- WORD Status;
- int iStatusEx;
- WORD ContactStatus;
- struct USERINFO_TYPE *next;
-}
- USERINFO;
+ HICON hOnlineIconBig;
+ HICON hOfflineIconBig;
+};
-typedef struct TABLIST_TYPE
+struct LOGSTREAMDATA : public GCLogStreamDataBase
{
- TCHAR* pszID;
- char* pszModule;
- struct TABLIST_TYPE *next;
-}
- TABLIST;
+ BOOL isFirst;
+};
-typedef struct SESSION_INFO_TYPE
+struct SESSION_INFO : public GCSessionInfoBase
{
- HWND hWnd;
+ char* pszHeader;
+ TCHAR szSearch[255];
+ int desiredInputAreaHeight;
- BOOL bFGSet;
- BOOL bBGSet;
- BOOL bFilterEnabled;
- BOOL bNicklistEnabled;
- BOOL bInitDone;
-
- char* pszModule;
- char* pszHeader;
- TCHAR* ptszID;
- TCHAR* ptszName;
- TCHAR* ptszStatusbarText;
- TCHAR* ptszTopic;
-
- 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 desiredInputAreaHeight;
- int iSplitterX;
- int iLogFilterFlags;
- int nUsersInNicklist;
- int iEventCount;
- int iStatusCount;
-
- WORD wStatus;
- WORD wState;
- WORD wCommandsNum;
- DWORD dwItemData;
- DWORD dwFlags;
- time_t LastTime;
CommonWindowData windowData;
- LOGINFO* pLog;
- LOGINFO* pLogEnd;
- USERINFO* pUsers;
- USERINFO* pMe;
- STATUSINFO* pStatuses;
- TCHAR szSearch[255];
-
- struct SESSION_INFO_TYPE *next;
-
-}SESSION_INFO;
-
-typedef struct
-{
- char* buffer;
- int bufferOffset, bufferLen;
- HWND hwnd;
- LOGINFO* lin;
- BOOL bStripFormat;
- BOOL bRedraw;
- BOOL isFirst;
- SESSION_INFO *si;
-}
- LOGSTREAMDATA;
-
-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 LogLimitNames;
- BOOL TimeStampEventColour;
- DWORD dwIconFlags;
- DWORD dwTrayIconFlags;
- DWORD dwPopupFlags;
- int LogTextIndent;
- int LoggingLimit;
- int iEventLimit;
- int iPopupStyle;
- int iPopupTimeout;
- int iSplitterX;
- int iSplitterY;
- 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;
+
+struct GlobalLogSettings : public GlobalLogSettingsBase {};
+extern GlobalLogSettings g_Settings;
typedef struct{
MODULEINFO* pModule;
@@ -294,7 +83,6 @@ typedef struct{ //main.c
void LoadIcons(void);
-void FreeIcons(void);
void UpgradeCheck(void);
//colorchooser.c
@@ -315,114 +103,22 @@ int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth); //options.c
int OptionsInit(void);
int OptionsUnInit(void);
-void LoadGlobalSettings(void);
-void LoadLogFonts(void);
-void SetIndentSize();
-//services.c
-void HookEvents(void);
-void UnhookEvents(void);
-void CreateServiceFunctions(void);
-void DestroyServiceFunctions(void);
-void DestroyHookableEvents(void);
-void CreateHookableEvents(void);
-int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam);
-int Chat_FontsChanged(WPARAM wParam,LPARAM lParam);
-int Chat_SmileyOptionsChanged(WPARAM wParam,LPARAM lParam);
-int Chat_PreShutdown(WPARAM wParam,LPARAM lParam);
-int Chat_IconsChanged(WPARAM wParam,LPARAM lParam);
+// 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);
+// manager.c
HWND SM_FindWindowByContact(HANDLE hContact);
-USERINFO* SM_AddUser(SESSION_INFO *si, 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);
-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);
-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);
-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);
-char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui);
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
-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 CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_EventDoubleclickedSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam);
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
-BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR* fmt, ... ) ;
-HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
-int WCCmp(TCHAR* wild, TCHAR*string);
+char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui);
-//tools.c
-TCHAR* RemoveFormatting(const TCHAR* pszText);
+// tools.c
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
int GetColorIndex(const char* pszModule, COLORREF cr);
-void CheckColorsInModule(const char* pszModule);
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ;
-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);
// message.c
TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si);
diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp deleted file mode 100644 index 25ea62df58..0000000000 --- a/plugins/Scriver/src/chat/clist.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/*
-Chat module plugin for Miranda IM
-
-Copyright (C) 2003 Jörgen Persson
-Copyright 2003-2009 Miranda ICQ/IM project,
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../commonheaders.h"
-
-extern HGENMENU hJoinMenuItem, hLeaveMenuItem;
-
-HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
-{
- HANDLE hContact = CList_FindRoom(pszModule, pszRoom);
- DBVARIANT dbv;
- TCHAR pszGroup[50];
-
- *pszGroup = '\0';
- if ( !db_get_ts(NULL, "Chat", "AddToGroup", &dbv)) {
- if ( lstrlen(dbv.ptszVal) > 0 )
- lstrcpyn( pszGroup, dbv.ptszVal, 50);
- db_free(&dbv);
- }
- else lstrcpyn( pszGroup, _T("Chat rooms"), 50);
-
- if (pszGroup[0])
- Clist_CreateGroup(0, pszGroup);
-
- if (hContact) { //contact exist, make sure it is in the right group
- if (pszGroup[0]) {
- ptrT grpName( db_get_tsa(hContact, "CList", "Group"));
- if ( !lstrcmp(pszGroup, grpName))
- db_set_ts(hContact, "CList", "Group", pszGroup);
- }
-
- db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
- db_set_ts(hContact, pszModule, "Nick", pszDisplayName );
- return hContact;
- }
-
- // here we create a new one since no one is to be found
- if ((hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
- return NULL;
-
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM)pszModule);
- if ( lstrlen( pszGroup ) > 0 )
- db_set_ts(hContact, "CList", "Group", pszGroup);
- else
- db_unset(hContact, "CList", "Group");
- db_set_ts( hContact, pszModule, "Nick", pszDisplayName);
- db_set_ts( hContact, pszModule, "ChatRoomID", pszRoom);
- db_set_b(hContact, pszModule, "ChatRoom", (BYTE)iType);
- db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
- return hContact;
-}
-
-BOOL CList_SetOffline(HANDLE hContact, BOOL bHide)
-{
- if (hContact) {
- char *szProto = GetContactProto(hContact);
- db_set_w(hContact, szProto,"ApparentMode",(LPARAM)0);
- db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- return TRUE;
- }
-
- return FALSE;
-}
-
-BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
-{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if ( MM_FindModule(szProto)) {
- if (!pszModule || (pszModule && !strcmp(pszModule, szProto))) {
- int i = db_get_b(hContact, szProto, "ChatRoom", 0);
- if (i != 0) {
- db_set_w(hContact, szProto, "ApparentMode", 0);
- db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- }
- }
- }
- }
- return TRUE;
-}
-
-int CList_RoomDoubleclicked(WPARAM wParam,LPARAM lParam)
-{
- DBVARIANT dbv;
- char *szProto;
-
- HANDLE hContact = (HANDLE)wParam;
- if (!hContact)
- return 0;
-
- szProto = GetContactProto(hContact);
- if ( MM_FindModule(szProto)) {
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
- return 0;
-
- if ( !db_get_ts( hContact, szProto, "ChatRoomID", &dbv )) {
- SESSION_INFO *si = SM_FindSession( dbv.ptszVal, szProto );
- if ( si ) {
- // is the "toggle visibility option set, so we need to close the window?
- if (si->hWnd != NULL &&
- db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1 &&
- !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0) &&
- IsWindowVisible(si->hWnd) && !IsIconic(si->hWnd))
- {
- PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
- db_free(&dbv);
- return 1;
- }
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
- }
- db_free(&dbv);
- return 1;
- }
- }
- return 0;
-}
-
-int CList_EventDoubleclicked(WPARAM wParam,LPARAM lParam)
-{
- return CList_RoomDoubleclicked((WPARAM) ((CLISTEVENT*)lParam)->hContact,(LPARAM)0);
-}
-
-INT_PTR CList_EventDoubleclickedSvc(WPARAM wParam,LPARAM lParam)
-{
- return CList_EventDoubleclicked(wParam, lParam);
-}
-
-INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if (hContact == NULL)
- return 0;
-
- char* szProto = GetContactProto(hContact);
- if ( szProto ) {
- if ( db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
- CallProtoService( szProto, PS_JOINCHAT, wParam, lParam );
- else
- CList_RoomDoubleclicked( wParam, 0 );
- }
- return 0;
-}
-
-INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
- char* szProto = GetContactProto(hContact);
- if ( szProto )
- CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam );
- }
- return 0;
-}
-
-int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- if (hContact == NULL)
- return 0;
-
- bool bEnabled = false;
- char *szProto = GetContactProto(hContact);
- if (szProto) {
- // display this menu item only for chats
- if (db_get_b(hContact, szProto, "ChatRoom", 0)) {
- // still hide it for offline protos
- if (CallProtoService(szProto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) {
- CLISTMENUITEM clmi = { sizeof(clmi) };
- clmi.flags = CMIM_NAME;
- if (db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE)
- clmi.pszName = (char*)LPGEN("Join chat");
- else
- clmi.pszName = (char*)LPGEN("Open chat window");
- Menu_ModifyItem(hJoinMenuItem, &clmi);
- bEnabled = true;
- } } }
-
- Menu_ShowItem(hJoinMenuItem, bEnabled);
- Menu_ShowItem(hLeaveMenuItem, bEnabled);
- return 0;
-}
-
-INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
-{
- return CList_PrebuildContactMenu(wParam, lParam);
-}
-
-BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR* fmt, ... )
-{
- if (!fmt || lstrlen(fmt) < 1 || lstrlen(fmt) > 2000)
- return FALSE;
-
- TCHAR* szBuf = (TCHAR*)alloca(4096 * sizeof(TCHAR));
- va_list marker;
- va_start(marker, fmt);
- mir_vsntprintf(szBuf, 4096, fmt, marker);
- va_end(marker);
-
- CLISTEVENT cle = { sizeof(cle) };
- cle.hContact = (HANDLE)hContact;
- cle.hDbEvent = (HANDLE)event;
- cle.flags = type | CLEF_TCHAR;
- cle.hIcon = Icon;
- cle.pszService = "GChat/DblClickEvent" ;
- cle.ptszTooltip = TranslateTS(szBuf);
- if (type) {
- if (!CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
- CallService(MS_CLIST_ADDEVENT,(WPARAM) hContact,(LPARAM)&cle);
- }
- else {
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)event);
- CallService(MS_CLIST_ADDEVENT,(WPARAM) hContact,(LPARAM)&cle);
- }
- return TRUE;
-}
-
-HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom)
-{
- for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
- if ( !db_get_b( hContact, pszModule, "ChatRoom", 0))
- continue;
-
- DBVARIANT dbv;
- if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv)) {
- if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free(&dbv);
- return hContact;
- }
- db_free(&dbv);
- }
- }
- return 0;
-}
-
-int WCCmp(TCHAR* wild, TCHAR* string)
-{
- TCHAR *cp = NULL, *mp = NULL;
- if ( wild == NULL || !lstrlen(wild) || string == NULL || !lstrlen(string))
- 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/plugins/Scriver/src/chat/colorchooser.cpp b/plugins/Scriver/src/chat/colorchooser.cpp index a4a90f4286..0eff2d4b3a 100644 --- a/plugins/Scriver/src/chat/colorchooser.cpp +++ b/plugins/Scriver/src/chat/colorchooser.cpp @@ -26,10 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int CalculateCoordinatesToButton(COLORCHOOSER * pCC, POINT pt)
{
int iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
- int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount?iSquareRoot+1:iSquareRoot;
+ int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot;
int col = pt.x / 25;
- int row = (pt.y-20) / 20;
+ int row = (pt.y - 20) / 20;
int pos = nCols * row + col;
if (pt.y < 20 && pos >= pCC->pModule->nColorCount)
@@ -42,14 +42,14 @@ static RECT CalculateButtonToCoordinates(COLORCHOOSER * pCC, int buttonPosition) {
RECT pt;
int iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
- int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount?iSquareRoot+1:iSquareRoot;
+ int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot;
int row = buttonPosition / nCols;
int col = buttonPosition % nCols;
- pt.left = col * 25+1;
+ pt.left = col * 25 + 1;
pt.top = row * 20 + 20;
- pt.right = pt.left + 25-1;
+ pt.right = pt.left + 25 - 1;
pt.bottom = pt.top + 20;
return pt;
@@ -64,57 +64,52 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L static int iColumns;
static HWND hPreviousActiveWindow;
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
- {
- RECT rc;
- int iSquareRoot;
- int width ;
- int height;
-
TranslateDialogDefault(hwndDlg);
- pCC = (COLORCHOOSER*) lParam;
-
- iCurrentHotTrack = -2;
- bChoosing = FALSE;
+ {
+ pCC = (COLORCHOOSER*)lParam;
- iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
+ iCurrentHotTrack = -2;
+ bChoosing = FALSE;
- iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount?iSquareRoot:iSquareRoot+1;
- iRows = iSquareRoot;
+ int iSquareRoot = (int)sqrt((double)pCC->pModule->nColorCount);
- rc.top = rc.left = 100;
- rc.right = 100 + iColumns * 25 + 1;
- rc.bottom = iRows * 20 + 100 + 20;
+ iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount ? iSquareRoot : iSquareRoot + 1;
+ iRows = iSquareRoot;
- AdjustWindowRectEx(&rc, GetWindowLongPtr(hwndDlg, GWL_STYLE), FALSE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE));
+ RECT rc;
+ rc.top = rc.left = 100;
+ rc.right = 100 + iColumns * 25 + 1;
+ rc.bottom = iRows * 20 + 100 + 20;
- width = rc.right - rc.left;
- height = rc.bottom - rc.top;
+ AdjustWindowRectEx(&rc, GetWindowLongPtr(hwndDlg, GWL_STYLE), FALSE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE));
- pCC->yPosition -= height;
+ int width = rc.right - rc.left;
+ int height = rc.bottom - rc.top;
+ pCC->yPosition -= height;
- SetDlgItemText(hwndDlg, IDC_CHAT_COLORTEXT, pCC->bForeground?TranslateT("Text color"):TranslateT("Background color"));
- SetWindowPos(GetDlgItem(hwndDlg, IDC_CHAT_COLORTEXT), NULL, 0, 0, width, 20, 0);
- SetWindowPos(hwndDlg, NULL, pCC->xPosition, pCC->yPosition, width, height, SWP_SHOWWINDOW);
+ SetDlgItemText(hwndDlg, IDC_CHAT_COLORTEXT, pCC->bForeground ? TranslateT("Text color") : TranslateT("Background color"));
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_CHAT_COLORTEXT), NULL, 0, 0, width, 20, 0);
+ SetWindowPos(hwndDlg, NULL, pCC->xPosition, pCC->yPosition, width, height, SWP_SHOWWINDOW);
}
break;
case WM_CTLCOLOREDIT:
case WM_CTLCOLORSTATIC:
- if ((HWND)lParam==GetDlgItem(hwndDlg,IDC_CHAT_COLORTEXT)) {
- SetTextColor((HDC)wParam,RGB(60,60,150));
- SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
+ if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_CHAT_COLORTEXT)) {
+ SetTextColor((HDC)wParam, RGB(60, 60, 150));
+ SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
}
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
- case IDOK:
+ switch (LOWORD(wParam)) {
+ case IDOK:
if (iCurrentHotTrack >= 0)
- PostMessage(hwndDlg, WM_LBUTTONUP, 0, 0);
+ PostMessage(hwndDlg, WM_LBUTTONUP, 0, 0);
break;
case IDCANCEL:
DestroyWindow(hwndDlg);
@@ -131,17 +126,16 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L cf.dwEffects = 0;
hWindow = GetParent(pCC->hWndTarget);
- if ( pCC->bForeground ) {
+ if (pCC->bForeground) {
pCC->si->bFGSet = TRUE;
pCC->si->iFG = iCurrentHotTrack;
- if ( IsDlgButtonChecked( hWindow, IDC_CHAT_COLOR )) {
+ if (IsDlgButtonChecked(hWindow, IDC_CHAT_COLOR)) {
cf.dwMask = CFM_COLOR;
cf.crTextColor = pCC->pModule->crColors[iCurrentHotTrack];
- if (pCC->pModule->bSingleFormat) {
+ if (pCC->pModule->bSingleFormat)
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- } else {
+ else
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
}
}
else {
@@ -150,11 +144,10 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L if (IsDlgButtonChecked(hWindow, IDC_CHAT_BKGCOLOR)) {
cf.dwMask = CFM_BACKCOLOR;
cf.crBackColor = pCC->pModule->crColors[iCurrentHotTrack];
- if (pCC->pModule->bSingleFormat) {
+ if (pCC->pModule->bSingleFormat)
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- } else {
+ else
SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
}
}
}
diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp index 2865e43164..31ec53b3db 100644 --- a/plugins/Scriver/src/chat/log.cpp +++ b/plugins/Scriver/src/chat/log.cpp @@ -24,548 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef EM_GETSCROLLPOS
#define EM_GETSCROLLPOS (WM_USER+221)
#endif
-// 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];
-
-static PBYTE pLogIconBmpBits[14];
-static const char *logIconNames[14] = {
- "chat_log_action", "chat_log_addstatus", "chat_log_highlight", "chat_log_info", "chat_log_join",
- "chat_log_kick", "chat_log_message_in", "chat_log_message_out", "chat_log_nick", "chat_log_notice",
- "chat_log_part", "chat_log_quit", "chat_log_removestatus", "chat_log_topic"
-};
-static int logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
-
-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 7;
- else
- return 6;
-
- case GC_EVENT_JOIN: return 4;
- case GC_EVENT_PART: return 10;
- case GC_EVENT_QUIT: return 11;
- case GC_EVENT_NICK: return 8;
- case GC_EVENT_KICK: return 5;
- case GC_EVENT_NOTICE: return 9;
- case GC_EVENT_TOPIC: return 13;
- case GC_EVENT_INFORMATION:return 3;
- case GC_EVENT_ADDSTATUS: return 1;
- case GC_EVENT_REMOVESTATUS: return 12;
- case GC_EVENT_ACTION: return 0;
- }
- 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 / g_dat.logPixelSY);
- return szStyle;
-}
-
-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 int Log_AppendIEView(LOGSTREAMDATA* streamData, BOOL simpleMode, TCHAR **buffer, int *cbBufferEnd, int *cbBufferAlloced, const TCHAR *fmt, ...)
-{
- va_list va;
- int lineLen, textCharsCount=0;
- TCHAR* line = (TCHAR*)alloca( 8001 * sizeof(TCHAR));
- TCHAR* d;
- MODULEINFO *mi = MM_FindModule(streamData->si->pszModule);
-
- va_start(va, fmt);
- lineLen = mir_vsntprintf(line, 8000, fmt, va);
- if (lineLen < 0)
- return 0;
- line[lineLen] = 0;
- va_end(va);
-
- lineLen = lineLen*9 + 8;
- if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
- cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (TCHAR *) mir_realloc(*buffer, *cbBufferAlloced * sizeof(TCHAR));
- }
-
- d = *buffer + *cbBufferEnd;
-
- for (; *line; line++, textCharsCount++) {
- if (*line == '%' && !simpleMode ) {
- TCHAR szTemp[200];
-
- szTemp[0] = '\0';
- switch ( *++line ) {
- case '\0':
- case '%':
- *d++ = '%';
- break;
-
- case 'c':
- case 'f':
- if (!g_Settings.StripFormat && !streamData->bStripFormat) {
- 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';
- col = _ttoi(szTemp3);
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%%c#%02X%02X%02X"), c, GetRValue(mi->crColors[col]), GetGValue(mi->crColors[col]), GetBValue(mi->crColors[col]));
- }
- }
- line += 2;
- break;
- case 'C':
- case 'F':
- if ( !g_Settings.StripFormat && !streamData->bStripFormat) {
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%%c"), *line );
- }
- break;
- case 'b':
- case 'u':
- case 'i':
- case 'B':
- case 'U':
- case 'I':
- case 'r':
- if ( !streamData->bStripFormat ) {
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%%c"), *line );
- }
- break;
- }
-
- if ( szTemp[0] ) {
- size_t iLen = _tcslen(szTemp);
- memcpy( d, szTemp, iLen * sizeof(TCHAR));
- d += iLen;
- }
- }
- else if (*line == '%') {
- *d++ = '%';
- *d++ = (char) *line;
- }
- else {
- *d++ = (char) *line;
- }
- }
- *d = '\0';
- *cbBufferEnd = (int) (d - *buffer);
- return textCharsCount;
-}
-
-
-static void AddEventTextToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, LOGSTREAMDATA *streamData)
-{
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
-}
-
-static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, LOGSTREAMDATA *streamData, TCHAR *pszNick)
-{
-
- if ( streamData && streamData->lin ) {
- switch ( streamData->lin->iType ) {
- case GC_EVENT_MESSAGE:
- if ( streamData->lin->ptszText ) {
- TCHAR *ptszTemp = NULL;
- TCHAR *ptszText = streamData->lin->ptszText;
- if (streamData->si->windowData.codePage != CP_ACP) {
- char *aText = mir_t2a_cp(streamData->lin->ptszText, CP_ACP);
- ptszText = ptszTemp = mir_a2t_cp(aText, streamData->si->windowData.codePage);
- mir_free(aText);
- }
-
- Log_AppendRTF( streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), ptszText );
- mir_free(ptszTemp);
- }
- break;
- case GC_EVENT_ACTION:
- if ( pszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), pszNick);
- 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, TRUE, 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);
- AddEventTextToBuffer(buffer, bufferEnd, bufferAlloced, streamData);
- break;
- case GC_EVENT_QUIT:
- if (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick);
- AddEventTextToBuffer(buffer, bufferEnd, bufferAlloced, streamData);
- 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 (pszNick && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, pszNick);
- AddEventTextToBuffer(buffer, bufferEnd, bufferAlloced, streamData);
- break;
- case GC_EVENT_NOTICE:
- if (pszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s"), pszNick );
- AddEventTextToBuffer(buffer, bufferEnd, bufferAlloced, streamData);
- }
- 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 (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced,
- streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)"): TranslateT(" (set by %s)"),
- pszNick, 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 (pszNick && 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, pszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- if (pszNick && 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, pszNick);
- break;
-} } }
-
-
-static void AddEventTextToBufferIEView(TCHAR **buffer, int *bufferEnd, int *bufferAlloced, LOGSTREAMDATA *streamData)
-{
- if (streamData->lin->ptszText)
- Log_AppendIEView(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
-}
-
-
-static void AddEventToBufferIEView(TCHAR **buffer, int *bufferEnd, int *bufferAlloced, LOGSTREAMDATA *streamData, TCHAR *pszNick)
-{
-
- if ( streamData && streamData->lin ) {
- switch ( streamData->lin->iType ) {
- case GC_EVENT_MESSAGE:
- if ( streamData->lin->ptszText ) {
- TCHAR *ptszTemp = NULL;
- TCHAR *ptszText = streamData->lin->ptszText;
- if (streamData->si->windowData.codePage != CP_ACP) {
- char *aText = mir_t2a_cp(streamData->lin->ptszText, CP_ACP);
- ptszText = ptszTemp = mir_a2t_cp(aText, streamData->si->windowData.codePage);
- mir_free(aText);
- }
-
- Log_AppendIEView( streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), ptszText );
- mir_free(ptszTemp);
- }
- break;
- case GC_EVENT_ACTION:
- if ( pszNick && streamData->lin->ptszText) {
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick);
- Log_AppendIEView(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_JOIN:
- if (pszNick) {
- if (!streamData->lin->bIsMe)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has joined"), pszNick);
- else
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName);
- }
- break;
- case GC_EVENT_PART:
- if (pszNick)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick);
- AddEventTextToBufferIEView(buffer, bufferEnd, bufferAlloced, streamData);
- break;
- case GC_EVENT_QUIT:
- if (pszNick)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick);
- AddEventTextToBufferIEView(buffer, bufferEnd, bufferAlloced, streamData);
- break;
- case GC_EVENT_NICK:
- if (pszNick && streamData->lin->ptszText) {
- if (!streamData->lin->bIsMe)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText);
- else
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_KICK:
- if (pszNick && streamData->lin->ptszStatus)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, streamData->lin->ptszNick);
- AddEventTextToBufferIEView(buffer, bufferEnd, bufferAlloced, streamData);
- break;
- case GC_EVENT_NOTICE:
- if (pszNick && streamData->lin->ptszText) {
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s"), pszNick );
- AddEventTextToBufferIEView(buffer, bufferEnd, bufferAlloced, streamData);
- }
- break;
- case GC_EVENT_TOPIC:
- if (streamData->lin->ptszText)
- Log_AppendIEView(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r"));
- if (pszNick)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced,
- streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)"): TranslateT(" (set by %s)"),
- pszNick, streamData->lin->ptszUserInfo);
- break;
- case GC_EVENT_INFORMATION:
- if (streamData->lin->ptszText)
- Log_AppendIEView(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_ADDSTATUS:
- if (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendIEView(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 (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendIEView(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s disables \'%s\' status for %s"), streamData->lin->ptszText , streamData->lin->ptszStatus, streamData->lin->ptszNick);
- break;
- }
- }
-}
-
-
-static void LogEventIEView(LOGSTREAMDATA *streamData, TCHAR *ptszNick)
-{
- TCHAR *buffer = NULL;
- int bufferEnd = 0;
- int bufferAlloced = 0;
-
- IEVIEWEVENTDATA ied = { 0 };
-
- IEVIEWEVENT event = { sizeof(event) };
- event.hwnd = streamData->si->windowData.hwndLog;
- event.hContact = streamData->si->windowData.hContact;
- event.codepage = streamData->si->windowData.codePage;
- event.pszProto = streamData->si->pszModule;
- event.iType = IEE_LOG_MEM_EVENTS;
- event.eventData = &ied;
- event.count = 1;
-
- AddEventToBufferIEView(&buffer, &bufferEnd, &bufferAlloced, streamData, ptszNick);
- ied.ptszNick = ptszNick;
- ied.ptszText = buffer;
- ied.time = streamData->lin->time;
- ied.bIsMe = streamData->lin->bIsMe;
-
- switch ( streamData->lin->iType ) {
- case GC_EVENT_MESSAGE:
- ied.iType = IEED_GC_EVENT_MESSAGE;
- ied.dwData = IEEDD_GC_SHOW_NICK;
- break;
- case GC_EVENT_ACTION:
- ied.iType = IEED_GC_EVENT_ACTION;
- break;
- case GC_EVENT_JOIN:
- ied.iType = IEED_GC_EVENT_JOIN;
- break;
- case GC_EVENT_PART:
- ied.iType = IEED_GC_EVENT_PART;
- break;
- case GC_EVENT_QUIT:
- ied.iType = IEED_GC_EVENT_QUIT;
- break;
- case GC_EVENT_NICK:
- ied.iType = IEED_GC_EVENT_NICK;
- break;
- case GC_EVENT_KICK:
- ied.iType = IEED_GC_EVENT_KICK;
- break;
- case GC_EVENT_NOTICE:
- ied.iType = IEED_GC_EVENT_NOTICE;
- break;
- case GC_EVENT_TOPIC:
- ied.iType = IEED_GC_EVENT_TOPIC;
- break;
- case GC_EVENT_INFORMATION:
- ied.iType = IEED_GC_EVENT_INFORMATION;
- break;
- case GC_EVENT_ADDSTATUS:
- ied.iType = IEED_GC_EVENT_ADDSTATUS;
- break;
- case GC_EVENT_REMOVESTATUS:
- ied.iType = IEED_GC_EVENT_REMOVESTATUS;
- break;
- }
- ied.dwData |= g_Settings.ShowTime ? IEEDD_GC_SHOW_TIME : 0;
- ied.dwData |= IEEDD_GC_SHOW_ICON;
- ied.dwFlags = IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2;
- ied.next = NULL;
- /*
- ied.color = event->color;
- ied.fontSize = event->iFontSize;
- ied.fontStyle = event->dwFlags;
- ied.fontName = getFontName(event->iFont);
- */
- CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
- mir_free(buffer);
-/*
- iew.cbSize = sizeof(IEVIEWWINDOW);
- iew.iType = IEW_SCROLLBOTTOM;
- iew.hwnd = hWndLog;
- CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&iew);
-*/
-}
-
TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time)
{
static TCHAR szTime[30];
@@ -574,152 +32,15 @@ TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time) return szTime;
}
-static char* Log_CreateRTF(LOGSTREAMDATA *streamData, BOOL ieviewMode)
-{
- char *buffer, *header;
- int bufferAlloced, bufferEnd, i;
- LOGINFO * lin = streamData->lin;
-
- // 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 = streamData->si->pszHeader;
-
- if (header)
- AppendToBuffer(&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)
- {
- TCHAR szTemp[512], szTemp2[512];
- TCHAR* pszNick = NULL;
- streamData->lin = lin;
-
- if ( lin->ptszNick ) {
- if ( g_Settings.LogLimitNames && lstrlen( lin->ptszNick ) > 20 ) {
- lstrcpyn( szTemp2, lin->ptszNick, 20 );
- lstrcpyn( szTemp2+20, _T("..."), 4);
- }
- else lstrcpyn( szTemp2, lin->ptszNick, 511 );
-
- if ( lin->ptszUserInfo && lin->iType != GC_EVENT_TOPIC)
- mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, lin->ptszUserInfo );
- else
- mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%s"), szTemp2 );
- pszNick = szTemp;
- }
-
- if (streamData->si->windowData.hwndLog != NULL) {
- LogEventIEView(streamData, pszNick);
- }
- {
- // create new line, and set font and color
- if (!streamData->isFirst) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
- }
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%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) ? 2 : EventToIcon(lin);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fs1 ");
- while (bufferAlloced - bufferEnd < logIconBmpSize[0])
- bufferAlloced += 4096;
- buffer = (char*) mir_realloc(buffer, bufferAlloced);
- CopyMemory(buffer + bufferEnd, pLogIconBmpBits[iIndex], logIconBmpSize[iIndex]);
- bufferEnd += logIconBmpSize[iIndex];
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " ");
- }
-
- 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 / g_dat.logPixelSY);
- AppendToBuffer(&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 / g_dat.logPixelSY);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
- }
- }
- else
- AppendToBuffer(&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)
-// AppendToBuffer(&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 );
- }
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tab ");
- }
-
- // Insert the nick
-
- if (pszNick && lin->iType == GC_EVENT_MESSAGE)
- {
- TCHAR pszTemp[300], *p1;
-
- AppendToBuffer(&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, pszNick);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " ");
- }
-
- // Insert the message
- i = lin->bIsHighlighted?16:EventToIndex(lin);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
- AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData, pszNick);
- }
- streamData->isFirst = FALSE;
-
- }
- lin = lin->prev;
- }
-
- // ### RTF END
- AppendToBuffer(&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)
- {
+ LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA*)dwCookie;
+ if (lstrdat) {
// create the RTF
- if (lstrdat->buffer == NULL)
- {
+ if (lstrdat->buffer == NULL) {
lstrdat->bufferOffset = 0;
- lstrdat->buffer = Log_CreateRTF(lstrdat, lstrdat->si->windowData.hwndLog != NULL);
+ lstrdat->buffer = pci->Log_CreateRTF(lstrdat);
lstrdat->bufferLen = lstrlenA(lstrdat->buffer);
}
@@ -729,8 +50,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;
}
@@ -741,117 +61,108 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw)
{
- 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_CHAT_LOG);
+ HWND hwndRich = GetDlgItem(hwndDlg, IDC_CHAT_LOG);
- LOGSTREAMDATA streamData = { 0 };
+ LOGSTREAMDATA streamData;
+ ZeroMemory(&streamData, sizeof(streamData));
streamData.hwnd = hwndRich;
streamData.si = si;
streamData.lin = lin;
streamData.bStripFormat = FALSE;
streamData.isFirst = bRedraw ? 1 : (GetRichTextLength(hwndRich, CP_ACP, FALSE) == 0);
- if (bRedraw || si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags&lin->iType) != 0)
- {
- BOOL bFlag = FALSE;
-
- EDITSTREAM stream = { 0 };
- stream.pfnCallback = Log_StreamCallback;
- stream.dwCookie = (DWORD_PTR) & streamData;
- scroll.cbSize= sizeof(SCROLLINFO);
- scroll.fMask= SIF_RANGE | SIF_POS|SIF_PAGE;
- GetScrollInfo(hwndRich, SB_VERT, &scroll);
- SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point);
-
- // do not scroll to bottom if there is a selection
- SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel);
- if (oldsel.cpMax != oldsel.cpMin)
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
-
- //set the insertion point at the bottom
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich, CP_ACP, FALSE);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)& sel);
- SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)& sel);
+ if (!bRedraw && si->iType == GCW_CHATROOM && si->bFilterEnabled && !(si->iLogFilterFlags & lin->iType))
+ return;
- // fix for the indent... must be a M$ bug
- if (sel.cpMax == 0)
- bRedraw = TRUE;
+ BOOL bFlag = FALSE;
- // should the event(s) be appended to the current log
- wp = bRedraw?SF_RTF:SFF_SELECTION|SF_RTF;
+ EDITSTREAM stream = { 0 };
+ stream.pfnCallback = Log_StreamCallback;
+ stream.dwCookie = (DWORD_PTR)& streamData;
- //get the number of pixels per logical inch
- if (bRedraw)
- {
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
- bFlag = TRUE;
-// SetCursor(LoadCursor(NULL, IDC_CHAT_ARROW));
- }
+ SCROLLINFO scroll;
+ scroll.cbSize = sizeof(SCROLLINFO);
+ scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
+ GetScrollInfo(hwndRich, SB_VERT, &scroll);
- // stream in the event(s)
- streamData.lin = lin;
- streamData.bRedraw = bRedraw;
- SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)& stream);
-
- // do smileys
- if (g_dat.smileyAddInstalled && (bRedraw
- || (lin->ptszText
- && lin->iType != GC_EVENT_JOIN
- && lin->iType != GC_EVENT_NICK
- && lin->iType != GC_EVENT_ADDSTATUS
- && lin->iType != GC_EVENT_REMOVESTATUS )))
- {
- newsel.cpMax = -1;
- newsel.cpMin = sel.cpMin;
- if (newsel.cpMin < 0)
- newsel.cpMin = 0;
-
- SMADD_RICHEDIT3 sm = { sizeof(sm) };
- sm.hwndRichEditControl = hwndRich;
- sm.Protocolname = si->pszModule;
- sm.rangeToReplace = bRedraw?NULL:&newsel;
- sm.flags = 0;
- sm.disableRedraw = TRUE;
- sm.hContact = si->windowData.hContact;
- CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
- }
+ POINT point = { 0 };
+ SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point);
- // 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)
- {
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)& oldsel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, NULL, TRUE);
- }
+ // do not scroll to bottom if there is a selection
+ CHARRANGE oldsel, sel, newsel;
+ SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel);
+ if (oldsel.cpMax != oldsel.cpMin)
+ SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+
+ // set the insertion point at the bottom
+ sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich, CP_ACP, FALSE);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
+ SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&sel);
+
+ // fix for the indent... must be a M$ bug
+ if (sel.cpMax == 0)
+ bRedraw = TRUE;
+
+ // should the event(s) be appended to the current log
+ WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF;
+
+ // get the number of pixels per logical inch
+ if (bRedraw) {
+ SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+ bFlag = TRUE;
+ }
+
+ // stream in the event(s)
+ streamData.lin = lin;
+ streamData.bRedraw = bRedraw;
+ SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream);
+
+ // do smileys
+ if (g_dat.smileyAddInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN
+ && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS)))
+ {
+ newsel.cpMax = -1;
+ newsel.cpMin = sel.cpMin;
+ if (newsel.cpMin < 0)
+ newsel.cpMin = 0;
+
+ SMADD_RICHEDIT3 sm = { sizeof(sm) };
+ sm.hwndRichEditControl = hwndRich;
+ sm.Protocolname = si->pszModule;
+ sm.rangeToReplace = bRedraw ? NULL : &newsel;
+ sm.flags = 0;
+ sm.disableRedraw = TRUE;
+ sm.hContact = si->windowData.hContact;
+ CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
+ }
+
+ // 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) {
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)& oldsel);
+ SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(hwndRich, NULL, TRUE);
+ }
- // need to invalidate the window
- if (bFlag)
- {
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich, CP_ACP, FALSE);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)& sel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, NULL, TRUE);
-} } }
+ // need to invalidate the window
+ if (bFlag) {
+ sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich, CP_ACP, FALSE);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)& sel);
+ SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(hwndRich, NULL, TRUE);
+ }
+}
-char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si)
+char* Log_CreateRtfHeader(MODULEINFO *mi, SESSION_INFO *si)
{
- char *buffer;
int bufferAlloced, bufferEnd, i = 0;
int charset = 0;
BOOL forceCharset = FALSE;
@@ -859,7 +170,7 @@ char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si) // guesstimate amount of memory for the RTF header
bufferEnd = 0;
bufferAlloced = 4096;
- buffer = (char*) mir_realloc(si->pszHeader, bufferAlloced);
+ char *buffer = (char*)mir_realloc(si->pszHeader, bufferAlloced);
buffer[0] = '\0';
// ### RTF HEADER
@@ -867,93 +178,34 @@ char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si) // font table
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
for (i = 0; i < OPTIONS_FONTCOUNT; i++)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, (!forceCharset) ? aFonts[i].lf.lfCharSet : charset, aFonts[i].lf.lfFaceName);
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, (!forceCharset) ? pci->aFonts[i].lf.lfCharSet : charset, pci->aFonts[i].lf.lfFaceName);
// colour table
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ;");
for (i = 0; i < OPTIONS_FONTCOUNT; i++)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(aFonts[i].color), GetGValue(aFonts[i].color), GetBValue(aFonts[i].color));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
- for(i = 0; i < mi->nColorCount; i++)
+ for (i = 0; i < mi->nColorCount; i++)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
// new paragraph
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}\\pard");
// set tabs and indents
- {
- int iIndent = 0;
+ int iIndent = 0;
- if (g_Settings.dwIconFlags)
- {
- iIndent += (14*1440)/g_dat.logPixelSX;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
- }
- if (g_Settings.ShowTime)
- {
- int iSize = (g_Settings.LogTextIndent*1440)/g_dat.logPixelSX;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
- if (g_Settings.LogIndentEnabled)
- iIndent += iSize;
- }
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
+ if (g_Settings.dwIconFlags) {
+ iIndent += (14 * 1440) / g_dat.logPixelSX;
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
- return buffer;
-}
-
-#define RTFPICTHEADERMAXSIZE 78
-void LoadMsgLogBitmaps(void)
-{
- HBRUSH hBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW)));
-
- BITMAPINFOHEADER bih = { 0 };
- 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);
-
- int widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
-
- RECT rc;
- rc.top = rc.left = 0;
- rc.right = bih.biWidth;
- rc.bottom = bih.biHeight;
-
- HDC hdc = GetDC(NULL);
- HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
- HDC hdcMem = CreateCompatibleDC(hdc);
- PBYTE pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
- for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
- HICON hIcon = GetCachedIcon(logIconNames[i]);
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
- int rtfHeaderSize = sprintf((char*)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, (unsigned int)bih.biWidth, (unsigned int)bih.biHeight); //!!!!!!!!!!
- HBITMAP 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] = '}';
+ if (g_Settings.ShowTime) {
+ int iSize = (g_Settings.LogTextIndent * 1440) / g_dat.logPixelSX;
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
+ if (g_Settings.LogIndentEnabled)
+ iIndent += iSize;
}
- mir_free(pBmpBits);
- DeleteDC(hdcMem);
- DeleteObject(hBmp);
- ReleaseDC(NULL, hdc);
- DeleteObject(hBkgBrush);
-}
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
-void FreeMsgLogBitmaps(void)
-{
- for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++)
- mir_free(pLogIconBmpBits[i]);
+ return buffer;
}
diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp index 9973b86497..a563b99aaf 100644 --- a/plugins/Scriver/src/chat/main.cpp +++ b/plugins/Scriver/src/chat/main.cpp @@ -24,26 +24,113 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void RegisterChatFonts( void );
//globals
-HMENU g_hMenu = NULL;
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
+CHAT_MANAGER *pci;
+HMENU g_hMenu = NULL;
-FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HBRUSH hListBkgBrush = NULL;
-HBRUSH hListSelectedBkgBrush = NULL;
+HBRUSH hListBkgBrush = NULL;
+HBRUSH hListSelectedBkgBrush = NULL;
-TCHAR* pszActiveWndID = 0;
-char* pszActiveWndModule = 0;
+GlobalLogSettings g_Settings;
-struct GlobalLogSettings_t g_Settings;
+static void OnAddLog(SESSION_INFO *si, int isOk)
+{
+ if (isOk && si->hWnd)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSessionDblClick(SESSION_INFO *si)
+{
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+}
+
+static void OnSessionRemove(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+}
+
+static void OnSessionRename(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
+}
+
+static void OnSessionReplace(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
+}
+
+static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSetStatusBar(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
+}
+
+static void OnNewUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+}
+
+static void OnSetStatus(SESSION_INFO *si, int wStatus)
+{
+ PostMessage(si->hWnd, GC_FIXTABICONS, 0, 0);
+}
+
+static void OnLoadSettings()
+{
+ 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 OnFlashWindow(SESSION_INFO *si, int bInactive)
+{
+ if (bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
+ SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
+ if (bInactive && si->hWnd)
+ SendMessage(si->hWnd, GC_SETMESSAGEHIGHLIGHT, 0, 0);
+}
int Chat_Load()
{
- InitializeCriticalSection(&cs);
+ mir_getCI(&g_Settings);
+ pci->cbModuleInfo = sizeof(MODULEINFO);
+ pci->cbSession = sizeof(SESSION_INFO);
+ pci->OnNewUser = OnNewUser;
+
+ pci->OnSetStatus = OnSetStatus;
+
+ pci->OnAddLog = OnAddLog;
+ pci->OnLoadSettings = OnLoadSettings;
+
+ pci->OnSessionRemove = OnSessionRemove;
+ pci->OnSessionRename = OnSessionRename;
+ pci->OnSessionReplace = OnSessionReplace;
+ pci->OnSessionDblClick = OnSessionDblClick;
+
+ pci->OnEventBroadcast = OnEventBroadcast;
+ pci->OnSetStatusBar = OnSetStatusBar;
+ pci->OnFlashWindow = OnFlashWindow;
+ pci->ShowRoom = ShowRoom;
+
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
TranslateMenu(g_hMenu);
- HookEvents();
- CreateServiceFunctions();
- CreateHookableEvents();
return 0;
}
@@ -51,54 +138,13 @@ int Chat_Unload(void) {
db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
- CList_SetAllOffline(TRUE, NULL);
-
- mir_free( pszActiveWndID );
- mir_free( pszActiveWndModule );
-
- DestroyHookableEvents();
-
DestroyMenu(g_hMenu);
- FreeIcons();
OptionsUnInit();
- DeleteCriticalSection(&cs);
return 0;
}
int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- char* mods[3] = { "Chat", "ChatFonts" };
- CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
- RegisterChatFonts();
OptionsInit();
- LoadIcons();
- {
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.cbSize = sizeof(mi);
- mi.position = -2000090001;
- mi.flags = CMIF_DEFAULT;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_JOIN );
- mi.pszName = LPGEN("&Join");
- mi.pszService = "GChat/JoinChat";
- hJoinMenuItem = Menu_AddContactMenuItem(&mi);
-
- mi.position = -2000090000;
- mi.flags = CMIF_NOTOFFLINE;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_LEAVE );
- mi.pszName = LPGEN("&Leave");
- mi.pszService = "GChat/LeaveChat";
- hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
- }
- CList_SetAllOffline(TRUE, NULL);
return 0;
}
-
-void LoadIcons(void)
-{
- LoadMsgLogBitmaps();
-}
-
-void FreeIcons(void)
-{
- FreeMsgLogBitmaps();
-}
diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp index d0ab53966b..192906fb40 100644 --- a/plugins/Scriver/src/chat/manager.cpp +++ b/plugins/Scriver/src/chat/manager.cpp @@ -21,161 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../commonheaders.h"
-void LoadModuleIcons(MODULEINFO * mi);
-
-#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_calloc(sizeof(SESSION_INFO));
- node->ptszID = mir_tstrdup( pszID );
- node->pszModule = mir_strdup( pszModule );
- node->windowData.flags = CWDF_RTF_INPUT;
-
- 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
- {
- DWORD dw = pTemp->dwItemData;
-
- if (pTemp->hWnd )
- SendMessage(pTemp->hWnd, GC_EVENT_CONTROL+WM_USER+500, SESSION_TERMINATE, 0);
-
- DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
-
- if (pLast == NULL)
- 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;
-
- if (pTemp->windowData.hContact)
- {
- CList_SetOffline(pTemp->windowData.hContact, pTemp->iType == GCW_CHATROOM?TRUE:FALSE);
-/* if (pTemp->iType != GCW_SERVER)
- db_set_b(pTemp->windowData.hContact, "CList", "Hidden", 1);*/
- }
- db_set_s(pTemp->windowData.hContact, pTemp->pszModule , "Topic", "");
- db_set_s(pTemp->windowData.hContact, pTemp->pszModule, "StatusBar", "");
- db_unset(pTemp->windowData.hContact, "CList", "StatusMsg");
-
- if (removeContact)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->windowData.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->pszHeader);
- mir_free(pTemp->pszID);
- mir_free(pTemp->pszName);
-
- // delete commands
- tcmdlist_free(pTemp->windowData.cmdList);
- 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;
-
- if ( !pszID || !pszModule )
- return NULL;
-
- while ( pTemp != NULL ) {
- if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA(pTemp->pszModule,pszModule))
- return pTemp;
-
- pTemp = pTemp->next;
- }
- return NULL;
-}
-
HWND SM_FindWindowByContact(HANDLE hContact)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = pci->wndList;
- while ( pTemp != NULL ) {
- if ( pTemp->windowData.hContact == hContact)
+ while (pTemp != NULL) {
+ if (pTemp->windowData.hContact == hContact)
return pTemp->hWnd;
pTemp = pTemp->next;
@@ -183,50 +34,30 @@ HWND SM_FindWindowByContact(HANDLE hContact) 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->iType != GCW_SERVER)
- pTemp->bInitDone = FALSE;
-
- 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* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
- 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_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
- if (pszID)
- return TRUE;
+ SESSION_INFO* pResult = NULL;
+ if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
+ pResult = currSession;
+ else {
+ TCHAR* pszName = NULL;
+ SESSION_INFO* pTemp = pci->wndList;
+ if (currSession == prevSession)
+ pszCurrent = pszOriginal;
+
+ while (pTemp != NULL) {
+ if (pTemp != currSession && !lstrcmpiA(pszModule, pTemp->pszModule)) {
+ if (my_strstri(pTemp->ptszName, pszOriginal) == pTemp->ptszName) {
+ if (prevSession != pTemp && lstrcmpi(pTemp->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->ptszName, pszName) < 0)) {
+ pResult = pTemp;
+ pszName = pTemp->ptszName;
+ }
+ }
+ }
+ pTemp = pTemp->next;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
- return TRUE;
+ return pResult;
}
char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui)
@@ -235,11 +66,9 @@ char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui) if (!ui || !si)
return '\0';
- ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status));
- if (ti)
- {
- if ((INT_PTR)ti->hIcon < STATUSICONCOUNT)
- {
+ ti = pci->TM_FindStatus(si->pStatuses, pci->TM_WordToString(si->pStatuses, ui->Status));
+ if (ti) {
+ if ((INT_PTR)ti->hIcon < STATUSICONCOUNT) {
INT_PTR id = si->iStatusCount - (INT_PTR)ti->hIcon - 1;
if (id == 0)
return '\0';
@@ -259,1127 +88,3 @@ char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui) }
return '\0';
}
-
-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_PTR)ti->hIcon < STATUSICONCOUNT)
- {
- INT_PTR id = si->iStatusCount - (INT_PTR)ti->hIcon - 1;
- char name[128];
- mir_snprintf(name, SIZEOF(name), "chat_status%d", id);
- return GetCachedIcon(name);
- }
- else
- return ti->hIcon;
- }
- return GetCachedIcon("chat_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) {
- SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (pTemp->hWnd && pTemp->bInitDone) {
- 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( SESSION_INFO * si, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
-{
- USERINFO * p = UM_AddUser( si->pStatuses, &si->pUsers, pszUID, pszNick, wStatus);
- si->nUsersInNicklist++;
- return p;
-}
-
-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--;
-
- 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++;
- 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->windowData.hContact ) {
- if ( pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE )
- db_unset(pTemp->windowData.hContact, "CList", "Hidden");
-
- db_set_w(pTemp->windowData.hContact, pTemp->pszModule, "Status", (WORD)wStatus);
- }
-
- PostMessage(pTemp->hWnd, GC_FIXTABICONS, 0, 0);
-
- 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;
-}
-
-
-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_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->windowData.hContact)
- CList_SetOffline(m_WndList->windowData.hContact, m_WndList->iType == GCW_CHATROOM?TRUE:FALSE);
- db_set_s(m_WndList->windowData.hContact, m_WndList->pszModule , "Topic", "");
- db_unset(m_WndList->windowData.hContact, "CList", "StatusMsg");
- db_set_s(m_WndList->windowData.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->pszHeader);
- tcmdlist_free(m_WndList->windowData.cmdList);
- mir_free(m_WndList);
- m_WndList = pLast;
- }
- m_WndList = NULL;
- return TRUE;
-}
-
-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;
-}
-
-
-SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
-{
- SESSION_INFO* pResult = NULL;
- if (prevSession == NULL && my_strstri( currSession->ptszName, pszOriginal) == currSession->ptszName) {
- pResult = currSession;
- } else {
- TCHAR* pszName = NULL;
- SESSION_INFO* pTemp = m_WndList;
- if (currSession == prevSession) {
- pszCurrent = pszOriginal;
- }
- while (pTemp != NULL) {
- if (pTemp != currSession && !lstrcmpiA(pszModule, pTemp->pszModule)) {
- if ( my_strstri( pTemp->ptszName, pszOriginal) == pTemp->ptszName ) {
- if ( prevSession != pTemp && lstrcmpi( pTemp->ptszName, pszCurrent ) > 0 && ( !pszName || lstrcmpi( pTemp->ptszName, pszName ) < 0)) {
- pResult = pTemp;
- pszName = pTemp->ptszName;
- }
- }
- }
- pTemp = pTemp->next;
- }
- }
- return pResult;
-
-}
-
-
-//---------------------------------------------------
-// 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_calloc(sizeof(MODULEINFO));
-
- node->pszModule = mir_strdup(pszModule);
-
- if (m_ModList == NULL) // list is empty
- {
- m_ModList = node;
- }
- else
- {
- node->next = m_ModList;
- m_ModList = node;
- }
- return node;
- }
- return FALSE;
-}
-
-void MM_IconsChanged(void)
-{
- MODULEINFO *pTemp = m_ModList;
-
- while (pTemp != NULL)
- {
- if (pTemp->hOnlineTalkIcon)
- DestroyIcon(pTemp->hOnlineTalkIcon);
- if (pTemp->hOfflineTalkIcon)
- DestroyIcon(pTemp->hOfflineTalkIcon);
-
- LoadModuleIcons(pTemp);
- pTemp = pTemp->next;
- }
- return;
-}
-void MM_FontsChanged(void)
-{
- SESSION_INFO* pTemp = m_WndList;
- SetIndentSize();
- while (pTemp != NULL)
- {
- pTemp->pszHeader = Log_CreateRtfHeader(MM_FindModule(pTemp->pszModule), 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->crColors);
-
- 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;
-}
-
-//---------------------------------------------------
-// Status manager functions
-//
-// Necessary to keep track of what user statuses
-// per window nicklist that is available
-//---------------------------------------------------
-
-STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int* iCount)
-{
- if (!ppStatusList || !pszStatus)
- return NULL;
-
- if ( !TM_FindStatus(*ppStatusList, pszStatus)) {
- STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
- replaceStrT(node->pszGroup, pszStatus);
- node->hIcon = (HICON)(*iCount);
- while ((INT_PTR)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_PTR)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)
-{
- if (!pStatusList || !ppUserList)
- return NULL;
-
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
- while(pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0)
- {
- pLast = pTemp;
- pTemp = pTemp->next;
- }
-
- // if (!UM_FindUser(*ppUserList, pszUI, wStatus)
- {
- USERINFO *node = (USERINFO*)mir_calloc(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)
-{
- int i = 0;
- USERINFO *pTemp = pUserList;
-
- if (!pUserList)
- return NULL;
-
- while (pTemp != NULL)
- {
- if (i == index)
- {
- return pTemp;
- }
- pTemp = pTemp->next;
- i++;
- }
- return NULL;
-}
-
-USERINFO* UM_GiveStatus(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->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)
-{
- USERINFO *pTemp = pUserList, *pLast = NULL;
-
- if (!pUserList || !pszUID)
- return 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)
-{
- TCHAR* pszName = NULL;
- USERINFO *pTemp = pUserList;
-
- if (!pUserList || !pszOriginal || !pszCurrent)
- return NULL;
-
- while ( pTemp != NULL ) {
- if ( 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)
-{
- if (!ppUserList || !pszUID)
- return FALSE;
-
- USERINFO *pTemp = *ppUserList, *pLast = NULL;
-
- while (pTemp != NULL) {
- if (!lstrcmpi( pTemp->pszUID, pszUID )) {
- if (pLast == NULL)
- *ppUserList = pTemp->next;
- else
- pLast->next = pTemp->next;
- mir_free(pTemp->pszNick);
- mir_free(pTemp->pszUID);
- mir_free(pTemp);
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return FALSE;
-}
-
-BOOL UM_RemoveAll (USERINFO** ppUserList)
-{
- if (!ppUserList)
- return FALSE;
-
- while (*ppUserList != NULL)
- {
- USERINFO *pLast = ppUserList[0]->next;
- mir_free( ppUserList[0]->pszUID );
- mir_free( ppUserList[0]->pszNick );
- mir_free( *ppUserList );
- *ppUserList = pLast;
- }
- *ppUserList = NULL;
- return TRUE;
-}
-
-//---------------------------------------------------
-// Log manager functions
-//
-// Necessary to keep track of events
-// in a window log
-//---------------------------------------------------
-
-LOGINFO * LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
-{
- if (!ppLogListStart || !ppLogListEnd)
- return NULL;
-
- LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO));
- if (*ppLogListStart == NULL) // list is empty
- {
- *ppLogListStart = node;
- *ppLogListEnd = node;
- node->next = NULL;
- node->prev = NULL;
- }
- else
- {
- ppLogListStart[0]->prev = node;
- node->next = *ppLogListStart;
- *ppLogListStart = node;
- ppLogListStart[0]->prev=NULL;
- }
-
- return node;
-}
-
-BOOL LM_TrimLog(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd, int iCount)
-{
- LOGINFO *pTemp = *ppLogListEnd;
- while (pTemp != NULL && iCount > 0) {
- *ppLogListEnd = pTemp->prev;
- if (*ppLogListEnd == NULL)
- *ppLogListStart = NULL;
-
- mir_free(pTemp->ptszNick);
- mir_free(pTemp->ptszUserInfo);
- mir_free(pTemp->ptszText);
- mir_free(pTemp->ptszStatus);
- mir_free(pTemp);
- pTemp = *ppLogListEnd;
- iCount--;
- }
- ppLogListEnd[0]->next = NULL;
-
- return TRUE;
-}
-
-BOOL LM_RemoveAll (LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
-{
- while ( *ppLogListStart != NULL ) {
- LOGINFO *pLast = ppLogListStart[0]->next;
- mir_free( ppLogListStart[0]->ptszText );
- mir_free( ppLogListStart[0]->ptszNick );
- mir_free( ppLogListStart[0]->ptszStatus );
- mir_free( ppLogListStart[0]->ptszUserInfo );
- mir_free( *ppLogListStart );
- *ppLogListStart = pLast;
- }
- *ppLogListStart = NULL;
- *ppLogListEnd = NULL;
- return TRUE;
-}
diff --git a/plugins/Scriver/src/chat/message.cpp b/plugins/Scriver/src/chat/message.cpp index c87e67674b..1bcc285f79 100644 --- a/plugins/Scriver/src/chat/message.cpp +++ b/plugins/Scriver/src/chat/message.cpp @@ -23,131 +23,123 @@ 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);
-
- for (i = 0; i < pMod->nColorCount ; i++)
- if ( pIndex[i] == iCol )
+ MODULEINFO *pMod = pci->MM_FindModule(si->pszModule);
+ for (int i = 0; i < pMod->nColorCount; i++)
+ if (pIndex[i] == iCol)
return i;
return -1;
}
-static void CreateColorMap( char* Text, int *pIndex, SESSION_INFO *si)
+static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO *si)
{
- char *p1, *p2, *pEnd;
- int iIndex = 1;
-
static const char* lpszFmt = "\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];";
char szRed[10], szGreen[10], szBlue[10];
- p1 = strstr(Text, "\\colortbl" );
- if ( !p1 )
+ char *p1 = strstr(Text, "\\colortbl");
+ if (!p1)
return;
- pEnd = strchr(p1, '}');
- p2 = strstr(p1, "\\red" );
+ char *pEnd = strchr(p1, '}');
+ char *p2 = strstr(p1, "\\red");
+ int iIndex = 1;
while (p2 && p2 < pEnd) {
- if ( sscanf( p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0 ) {
- int i;
- MODULEINFO * pMod = MM_FindModule(si->pszModule);
- for (i = 0; i < pMod->nColorCount ; i ++)
- if (pMod->crColors[i] == RGB( atoi(szRed), atoi(szGreen), atoi(szBlue)))
+ if (sscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
+ MODULEINFO *pMod = pci->MM_FindModule(si->pszModule);
+ for (int i = 0; i < pMod->nColorCount; i++)
+ if (pMod->crColors[i] == RGB(atoi(szRed), atoi(szGreen), atoi(szBlue)))
pIndex[i] = iIndex;
}
iIndex++;
p1 = p2;
- p1 ++;
- p2 = strstr(p1, "\\red" );
-} }
+ p1++;
+ p2 = strstr(p1, "\\red");
+ }
+}
-static int ReadInteger( const char* p, int* result )
+static int ReadInteger(const char *p, int *result)
{
char temp[10];
- int i=0;
- while ( isdigit( *p ))
+ int i = 0;
+ while (isdigit(*p))
temp[i++] = *p++;
temp[i] = 0;
- if ( result != NULL )
- *result = atoi( temp );
+ if (result != NULL)
+ *result = atoi(temp);
return i;
}
-TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si)
+TCHAR* DoRtfToTags(char *pszText, SESSION_INFO *si)
{
- char *p1;
- int* pIndex;
- int i, iRemoveChars;
- char InsertThis[50];
- BOOL bJustRemovedRTF = TRUE;
- BOOL bTextHasStarted = FALSE;
- TCHAR *ptszResult;
- int iUcMode = 0;
-
- if ( !pszText )
+ if (!pszText)
return FALSE;
// 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++)
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
+ int *pIndex = (int *)mir_alloc(sizeof(int)*mi->nColorCount);
+ for (int i = 0; i < mi->nColorCount; i++)
pIndex[i] = -1;
- CreateColorMap( pszText, pIndex, si );
+ CreateColorMap(pszText, pIndex, si);
// scan the file for rtf commands and remove or parse them
- p1 = strstr( pszText, "\\pard" );
- if ( p1 == NULL ) {
+ char *p1 = strstr(pszText, "\\pard");
+ if (p1 == NULL) {
mir_free(pIndex);
return FALSE;
}
p1 += 5;
- MoveMemory( pszText, p1, lstrlenA( p1 ) + 1 );
+ MoveMemory(pszText, p1, lstrlenA(p1) + 1);
p1 = pszText;
// iterate through all characters, if rtf control character found then take action
- while ( *p1 != '\0' ) {
+ BOOL bJustRemovedRTF = TRUE;
+ BOOL bTextHasStarted = FALSE;
+ char InsertThis[50];
+
+ while (*p1 != '\0') {
InsertThis[0] = 0;
- iRemoveChars = 0;
+ int iRemoveChars = 0;
switch (*p1) {
case '\\':
- if ( !memcmp(p1, "\\cf", 3 )) { // foreground color
- int iCol, iInd;
- iRemoveChars = 3 + ReadInteger(p1+3, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
+ if (!memcmp(p1, "\\cf", 3)) { // foreground color
+ int iCol;
+ iRemoveChars = 3 + ReadInteger(p1 + 3, &iCol);
bJustRemovedRTF = TRUE;
- if (bTextHasStarted || iInd >= 0)
- mir_snprintf( InsertThis, SIZEOF(InsertThis), ( iInd >= 0 ) ? "%%c%02u" : "%%C", iInd);
+ // int iInd = RTFColorToIndex(pIndex, iCol, si);
+ // if (bTextHasStarted || iInd >= 0)
+ // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd);
}
- else if ( !memcmp(p1, "\\highlight", 10 )) { //background color
- int iCol, iInd;
- iRemoveChars = 10 + ReadInteger(p1+10, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
+ else if (!memcmp(p1, "\\highlight", 10)) { //background color
+ int iCol;
+ iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol);
bJustRemovedRTF = TRUE;
- if (bTextHasStarted || iInd >= 0)
- mir_snprintf( InsertThis, SIZEOF(InsertThis), ( iInd >= 0 ) ? "%%f%02u" : "%%F", iInd);
+ // int iInd = RTFColorToIndex(pIndex, iCol, si);
+ // if (bTextHasStarted || iInd >= 0)
+ // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd);
}
- else if ( !memcmp(p1, "\\lang", 5 )) { // language id
+ else if (!memcmp(p1, "\\lang", 5)) { // language id
bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 5 + ReadInteger( p1+5, NULL );
+ iRemoveChars = 5 + ReadInteger(p1 + 5, NULL);
}
- else if ( !memcmp(p1, "\\par", 4 )) { // newline
+ else if (!memcmp(p1, "\\par", 4)) { // newline
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 4;
- strcpy(InsertThis, "\n" );
+ strcpy(InsertThis, "\n");
}
- else if ( !memcmp(p1, "\\line", 5 )) { // newline
+ else if (!memcmp(p1, "\\line", 5)) { // newline
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 5;
- strcpy(InsertThis, "\n" );
+ strcpy(InsertThis, "\n");
}
else if (!memcmp(p1, "\\bullet", 7)) {
bTextHasStarted = TRUE;
@@ -155,22 +147,21 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\xA2");
}
- else if ( !memcmp(p1, "\\b", 2 )) { //bold
+ else if (!memcmp(p1, "\\b", 2)) { //bold
bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0')?2:3;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? "%%b": "%%B" );
+ iRemoveChars = (p1[2] != '0') ? 2 : 3;
+ mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? "%%b" : "%%B");
}
- else if ( !memcmp(p1, "\\i", 2 )) { // italics
+ else if (!memcmp(p1, "\\i", 2)) { // italics
bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0')?2:3;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? "%%i" : "%%I" );
+ iRemoveChars = (p1[2] != '0') ? 2 : 3;
+ mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? "%%i" : "%%I");
}
- else if ( !memcmp(p1, "\\uc", 3 )) { // number of Unicode chars
+ else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars
bTextHasStarted = bJustRemovedRTF = TRUE;
- iUcMode = p1[3] - '0';
iRemoveChars = 4;
}
- else if ( !memcmp(p1, "\\ul", 3 )) { // underlined
+ else if (!memcmp(p1, "\\ul", 3)) { // underlined
bTextHasStarted = bJustRemovedRTF = TRUE;
if (p1[3] == 'n')
iRemoveChars = 7;
@@ -178,17 +169,17 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) iRemoveChars = 4;
else
iRemoveChars = 3;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U" );
+ mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U");
}
- else if ( p1[1] == 'f' && isdigit( p1[2] )) { // unicode char
+ else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char
bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 2 + ReadInteger( p1+2, NULL );
+ iRemoveChars = 2 + ReadInteger(p1 + 2, NULL);
}
- else if ( !memcmp(p1, "\\tab", 4 )) { // tab
+ else if (!memcmp(p1, "\\tab", 4)) { // tab
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 4;
- strcpy(InsertThis, " " );
+ strcpy(InsertThis, " ");
}
else if (!memcmp(p1, "\\endash", 7)) {
bTextHasStarted = TRUE;
@@ -201,64 +192,64 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x94");
- }
- else if (!memcmp(p1, "\\lquote",7)) {
+ }
+ else if (!memcmp(p1, "\\lquote", 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x98");
}
- else if (!memcmp(p1, "\\rquote",7)) {
+ else if (!memcmp(p1, "\\rquote", 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
strcpy(InsertThis, "\xE2\x80\x99");
}
- else if (!memcmp(p1, "\\ldblquote",10)) {
+ else if (!memcmp(p1, "\\ldblquote", 10)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 10;
strcpy(InsertThis, "\xe2\x80\x9c");
}
- else if (!memcmp(p1, "\\rdblquote",10)) {
+ else if (!memcmp(p1, "\\rdblquote", 10)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 10;
strcpy(InsertThis, "\xe2\x80\x9d");
}
- else if ( p1[1] == '\\' || p1[1] == '{' || p1[1] == '}' ) { // escaped characters
+ else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
iRemoveChars = 2;
mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]);
}
- else if ( p1[1] == '~' ) { // non-breaking space
+ else if (p1[1] == '~') { // non-breaking space
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
iRemoveChars = 2;
strcpy(InsertThis, "\xC2\xA0");
}
- else if ( p1[1] == '\'' ) { // special character
+ else if (p1[1] == '\'') { // special character
char tmp[4], *p3 = tmp;
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
if (p1[2] != ' ' && p1[2] != '\\') {
*p3++ = p1[2];
iRemoveChars = 3;
- if ( p1[3] != ' ' && p1[3] != '\\') {
+ if (p1[3] != ' ' && p1[3] != '\\') {
*p3++ = p1[3];
iRemoveChars++;
}
*p3 = 0;
- sscanf( tmp, "%x", InsertThis );
+ sscanf(tmp, "%x", InsertThis);
InsertThis[1] = 0;
}
else iRemoveChars = 2;
}
- else if ( bJustRemovedRTF ) { // remove unknown RTF command
+ else if (bJustRemovedRTF) { // remove unknown RTF command
int j = 1;
bJustRemovedRTF = TRUE;
- while(p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0')
+ while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0')
j++;
iRemoveChars = j;
}
@@ -279,7 +270,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
iRemoveChars = 1;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), "%%%%" );
+ mir_snprintf(InsertThis, SIZEOF(InsertThis), "%%%%");
break;
case ' ': // remove spaces following a RTF command
if (bJustRemovedRTF)
@@ -295,8 +286,8 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) }
// move the memory and paste in new commands instead of the old RTF
- if ( InsertThis[0] || iRemoveChars ) {
- MoveMemory(p1 + lstrlenA(InsertThis) , p1 + iRemoveChars, lstrlenA(p1) - iRemoveChars +1 );
+ if (InsertThis[0] || iRemoveChars) {
+ MoveMemory(p1 + lstrlenA(InsertThis), p1 + iRemoveChars, lstrlenA(p1) - iRemoveChars + 1);
CopyMemory(p1, InsertThis, lstrlenA(InsertThis));
p1 += lstrlenA(InsertThis);
}
@@ -304,7 +295,5 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO *si) }
mir_free(pIndex);
- mir_utf8decode(pszText, &ptszResult);
- return ptszResult;
+ return mir_utf8decodeT(pszText);
}
-
diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp index 2d5370980f..79622ae681 100644 --- a/plugins/Scriver/src/chat/options.cpp +++ b/plugins/Scriver/src/chat/options.cpp @@ -226,7 +226,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p void LoadLogFonts(void)
{
for (int i = 0; i<OPTIONS_FONTCOUNT; i++)
- LoadMsgDlgFont(i, &aFonts[i].lf, &aFonts[i].color, TRUE);
+ LoadMsgDlgFont(i, &pci->aFonts[i].lf, &pci->aFonts[i].color, TRUE);
}
@@ -308,11 +308,11 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa SendMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)hti.hItem);
}
- } else if (((LPNMHDR) lParam)->code == TVN_KEYDOWN) {
- if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) {
+ }
+ else if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) {
+ if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE)
SendMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom,
(LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom));
- }
}
break;
@@ -341,7 +341,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa SaveBranch(GetDlgItem(hwndDlg, IDC_CHAT_CHECKBOXES), branch1, SIZEOF(branch1));
SaveBranch(GetDlgItem(hwndDlg, IDC_CHAT_CHECKBOXES), branch4, SIZEOF(branch4));
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
}
return TRUE;
}
@@ -621,8 +621,8 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa g_Settings.PopupInactiveOnly = (BOOL)db_get_b(NULL, "Chat", "PopUpInactiveOnly", 1);
g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0)?TRUE:FALSE;
- MM_FontsChanged();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->MM_FontsChanged();
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
return TRUE;
}
break;
@@ -767,150 +767,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.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"));
-
- DBVARIANT dbv;
- g_Settings.pszLogDir = (TCHAR *)mir_realloc(g_Settings.pszLogDir, MAX_PATH*sizeof(TCHAR));
- if ( !db_get_ts(NULL, "Chat", "LogDirectory", &dbv)) {
- lstrcpyn(g_Settings.pszLogDir, dbv.ptszVal, MAX_PATH);
- db_free(&dbv);
- }
- else lstrcpyn(g_Settings.pszLogDir, DEFLOGFILENAME, MAX_PATH);
-
- g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0)?TRUE:FALSE;
-
- if (g_Settings.MessageBoxFont)
- DeleteObject(g_Settings.MessageBoxFont);
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, NULL, FALSE);
- g_Settings.MessageBoxFont = CreateFontIndirect(&lf);
-
- if (g_Settings.UserListFont)
- DeleteObject(g_Settings.UserListFont);
- LoadMsgDlgFont(18, &lf, NULL, TRUE);
- g_Settings.UserListFont = CreateFontIndirect(&lf);
-
- if (g_Settings.UserListHeadingsFont)
- DeleteObject(g_Settings.UserListHeadingsFont);
- LoadMsgDlgFont(19, &lf, NULL, TRUE);
- 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);
-}
-
-void SetIndentSize()
-{
- if (g_Settings.ShowTime) {
- LOGFONT lf;
- HFONT hFont;
- int iText;
-
- LoadMsgDlgFont(0, &lf, NULL, TRUE);
- hFont = CreateFontIndirect(&lf);
- iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)),hFont, TRUE);
- DeleteObject(hFont);
- g_Settings.LogTextIndent = iText*12/10;
- }
- else g_Settings.LogTextIndent = 0;
-}
-
int OptionsInit(void)
{
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
-
- LoadLogFonts();
-
- LOGFONT lf;
- LoadMsgDlgFont(18, &lf, NULL, TRUE);
- 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);
- 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"));
- SetIndentSize();
return 0;
}
int OptionsUnInit(void)
{
- FreeGlobalSettings();
DeleteObject(hListBkgBrush);
DeleteObject(hListSelectedBkgBrush);
- DeleteObject(g_Settings.NameFont);
return 0;
}
diff --git a/plugins/Scriver/src/chat/services.cpp b/plugins/Scriver/src/chat/services.cpp index 6e09eb3039..5910841a66 100644 --- a/plugins/Scriver/src/chat/services.cpp +++ b/plugins/Scriver/src/chat/services.cpp @@ -21,79 +21,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../commonheaders.h"
-HANDLE hSendEvent;
-HANDLE hBuildMenuEvent ;
-HANDLE g_hHookContactDblClick, g_hHookPrebuildMenu;
-CRITICAL_SECTION cs;
-
-int Chat_SmileyOptionsChanged(WPARAM wParam,LPARAM lParam)
-{
- SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE);
- return 0;
-}
-
-int Chat_PreShutdown(WPARAM wParam,LPARAM lParam)
-{
- SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
-
- SM_RemoveAll();
- MM_RemoveAll();
- return 0;
-}
-
-int Chat_FontsChanged(WPARAM wParam,LPARAM lParam)
-{
- LoadLogFonts();
- LoadMsgLogBitmaps();
- MM_FontsChanged();
- MM_FixColors();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
- return 0;
-}
-
-int Chat_IconsChanged(WPARAM wParam,LPARAM lParam)
-{
- FreeMsgLogBitmaps();
- LoadMsgLogBitmaps();
- MM_IconsChanged();
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, FALSE);
- return 0;
-}
-
-static INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam)
-{
- if (!lParam)
- return -1;
-
- mir_cslock lock(cs);
- return SM_GetCount((char*)lParam);
-}
-
-static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam)
+void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
{
- GC_INFO *gci = (GC_INFO *)lParam;
- if (!gci || !gci->pszModule)
- return 1;
-
- SESSION_INFO *si = NULL;
-
- mir_cslock lock(cs);
- if (gci->Flags & BYINDEX)
- si = SM_FindSessionByIndex( gci->pszModule, gci->iItem );
- else
- si = SM_FindSession( gci->pszID, gci->pszModule );
-
- if (si == NULL)
- return 1;
+ HWND hParent = NULL;
+ if (!si)
+ return;
- if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
- if (gci->Flags & HCONTACT) gci->hContact = si->windowData.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;
+ //Do we need to create a window?
+ if (si->hWnd == NULL) {
+ hParent = GetParentWindow(si->windowData.hContact, TRUE);
+ si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), hParent, RoomWndProc, (LPARAM)si);
+ }
+ SendMessage(si->hWnd, DM_UPDATETABCONTROL, -1, (LPARAM)si);
+ SendMessage(GetParent(si->hWnd), CM_ACTIVATECHILD, 0, (LPARAM)si->hWnd);
+ SendMessage(GetParent(si->hWnd), CM_POPUPWINDOW, 0, (LPARAM)si->hWnd);
+ SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
+ SetFocus(GetDlgItem(si->hWnd, IDC_CHAT_MESSAGE));
}
void LoadModuleIcons(MODULEINFO *mi)
@@ -115,438 +58,3 @@ void LoadModuleIcons(MODULEINFO *mi) ImageList_Destroy(hList);
}
-
-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 lock(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->bFontSize = gcr->dwFlags & GC_FONTSIZE;
- mi->bAckMsg = gcr->dwFlags & GC_ACKMSG ;
- mi->bChanMgr = gcr->dwFlags & GC_CHANMGR ;
- mi->bSingleFormat = gcr->dwFlags & GC_SINGLEFORMAT;
- 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);
- }
-
- 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 lock(cs);
- MODULEINFO *mi = MM_FindModule(gcw->pszModule);
- if (mi == NULL)
- return GC_NEWSESSION_ERROR;
-
- SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule);
- if (mi->hOfflineIcon == NULL)
- LoadModuleIcons(mi);
-
- // 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), LPGENT("Server: %s"), si->ptszName);
- else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
- si->windowData.hContact = CList_AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
- si->windowData.codePage = db_get_w(si->windowData.hContact, si->pszModule, "CodePage", (WORD)CP_ACP);
- si->pszHeader = Log_CreateRtfHeader(mi, si);
- db_set_s(si->windowData.hContact, si->pszModule, "Topic", "");
- db_unset(si->windowData.hContact, "CList", "StatusMsg");
- if (si->ptszStatusbarText)
- db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
- }
- else {
- SESSION_INFO *si2 = SM_FindSession(gcw->ptszID, gcw->pszModule);
- if (si2) {
- UM_RemoveAll(&si2->pUsers);
- TM_RemoveAll(&si2->pStatuses);
-
- si2->iStatusCount = 0;
- si2->nUsersInNicklist = 0;
-
- if (si2->hWnd )
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
- }
- }
-
- return 0;
-}
-
-static INT_PTR 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);
- 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, DM_UPDATETITLEBAR, 0, 0);
- }
- }
- 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->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
- if (si->hWnd)
- SendMessage(si->hWnd, DM_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(si, 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)
- SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
-}
-
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
-{
- HWND hParent = NULL;
- if (!si)
- return;
-
- //Do we need to create a window?
- if (si->hWnd == NULL)
- {
- hParent = GetParentWindow(si->windowData.hContact, TRUE);
- si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), hParent, RoomWndProc, (LPARAM)si);
- }
- SendMessage(si->hWnd, DM_UPDATETABCONTROL, -1, (LPARAM)si);
- SendMessage(GetParent(si->hWnd), CM_ACTIVATECHILD, 0, (LPARAM)si->hWnd);
- SendMessage(GetParent(si->hWnd), CM_POPUPWINDOW, 0, (LPARAM)si->hWnd);
- SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(si->hWnd, IDC_CHAT_MESSAGE));
-}
-
-static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
-{
- GCEVENT *gce = (GCEVENT*)lParam;
- SESSION_INFO *si;
- BOOL bIsHighlighted = FALSE;
- BOOL bRemoveFlag = FALSE;
-
- if (gce == NULL)
- return GC_EVENT_ERROR;
-
- GCDEST *gcd = gce->pDest;
- if (gcd == NULL)
- return GC_EVENT_ERROR;
-
- if (gce->cbSize != sizeof(GCEVENT))
- return GC_EVENT_WRONGVER;
-
- if (!IsEventSupported(gcd->iType))
- return GC_EVENT_ERROR;
-
- 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:
- if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- if (gce->ptszText) {
- replaceStrT(si->ptszTopic, gce->ptszText);
- db_set_ts(si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting(si->ptszTopic));
- if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
- db_set_ts(si->windowData.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) {
- if (si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule))
- 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) {
- si = SM_FindSession(pWnd, pMod);
-
- // fix for IRC's old stuyle mode notifications. Should not affect any other protocol
- if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
- return 0;
-
- if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0)
- return 0;
-
- if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd)
- SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- else if (si->hWnd)
- SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
-
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.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;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Service creation
-
-void HookEvents(void)
-{
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu);
-}
-
-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_EventDoubleclickedSvc);
- 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);
-}
diff --git a/plugins/Scriver/src/chat/tools.cpp b/plugins/Scriver/src/chat/tools.cpp index 62679fbe0f..0745ad83c6 100644 --- a/plugins/Scriver/src/chat/tools.cpp +++ b/plugins/Scriver/src/chat/tools.cpp @@ -21,344 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../commonheaders.h"
-TCHAR* RemoveFormatting(const TCHAR* pszWord)
-{
- static TCHAR szTemp[10000];
- int i = 0;
- int j = 0;
-
- if (pszWord == 0 || lstrlen(pszWord) == 0)
- return NULL;
-
- while (j < 9999 && i <= lstrlen(pszWord)) {
- if (pszWord[i] == '%') {
- switch (pszWord[i + 1]) {
- case '%':
- szTemp[j] = '%';
- j++;
- i++; i++;
- break;
- case 'b':
- case 'u':
- case 'i':
- case 'B':
- case 'U':
- case 'I':
- case 'r':
- case 'C':
- case 'F':
- i++; i++;
- break;
-
- case 'c':
- case 'f':
- i += 4;
- break;
-
- default:
- szTemp[j] = pszWord[i];
- j++;
- i++;
- break;
- }
- }
- else {
- szTemp[j] = pszWord[i];
- j++;
- i++;
- }
- }
-
- return (TCHAR*)&szTemp;
-}
-
-static void __stdcall ShowRoomFromPopup(void * pi)
-{
- SESSION_INFO *si = (SESSION_INFO*) pi;
- ShowRoom(si, WINDOW_VISIBLE, TRUE);
-}
-
-static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message) {
- case WM_COMMAND:
- if (HIWORD(wParam) == STN_CLICKED) {
- SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
- CallFunctionAsync(ShowRoomFromPopup, si);
- PUDeletePopup(hWnd);
- return TRUE;
- }
- break;
- case WM_CONTEXTMENU:
- SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
- if (si->windowData.hContact)
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
-
- PUDeletePopup( hWnd );
- break;
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
-{
- static TCHAR szBuf[4*1024];
-
- if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
- return 0;
-
- va_list marker;
- va_start(marker, fmt);
- mir_vsntprintf(szBuf, 4096, fmt, marker);
- va_end(marker);
-
- POPUPDATAT pd = { 0 };
- pd.lchContact = hContact;
- pd.lchIcon = (hIcon) ? hIcon : GetCachedIcon("chat_window");
-
- PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
- (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
- pcli->pfnGetContactDisplayName(hContact, 0));
-
- lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
- pd.iSeconds = g_Settings.iPopupTimeout;
-
- if (g_Settings.iPopupStyle == 2) {
- pd.colorBack = 0;
- pd.colorText = 0;
- }
- else if (g_Settings.iPopupStyle == 3) {
- pd.colorBack = g_Settings.crPUBkgColour;
- pd.colorText = g_Settings.crPUTextColour;
- }
- else {
- pd.colorBack = g_Settings.crLogBackground;
- pd.colorText = crBkg;
- }
-
- pd.PluginWindowProc = PopupDlgProc;
- pd.PluginData = si;
- return PUAddPopupT(&pd);
-}
-
-static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
-{
- int iEvent = gce->pDest->iType;
-
- if (iEvent&g_Settings.dwTrayIconFlags) {
- switch (iEvent) {
- case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- CList_AddEvent(si->windowData.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->windowData.hContact, GetCachedIcon("chat_log_message_in"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_ACTION:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_action"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_JOIN:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_join"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_PART:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_part"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_QUIT:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_quit"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
- break;
- case GC_EVENT_NICK:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_nick"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
- break;
- case GC_EVENT_KICK:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_kick"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- case GC_EVENT_NOTICE:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_notice"), "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
- break;
- case GC_EVENT_TOPIC:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_topic"), "chaticon", CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
- break;
- case GC_EVENT_INFORMATION:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_info"), "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
- break;
- case GC_EVENT_ADDSTATUS:
- CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_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->windowData.hContact, GetCachedIcon("chat_log_removestatus"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
- break;
- }
- }
-
- return TRUE;
-}
-
-static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
-{
- int iEvent = gce->pDest->iType;
-
- if (iEvent & g_Settings.dwPopupFlags) {
- switch (iEvent) {
- case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->windowData.hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- ShowPopup(si->windowData.hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_MESSAGE:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_message_in"), si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ACTION:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_action"), si->pszModule, si->ptszName, aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_JOIN:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_join"), si->pszModule, si->ptszName, aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
- break;
- case GC_EVENT_PART:
- if (!gce->ptszText)
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_part"), si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
- else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_part"), si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_QUIT:
- if (!gce->ptszText)
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
- else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NICK:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_nick"), si->pszModule, si->ptszName, aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
- break;
- case GC_EVENT_KICK:
- if (!gce->ptszText)
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
- else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NOTICE:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_notice"), si->pszModule, si->ptszName, aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_TOPIC:
- if (!gce->ptszNick)
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_topic"), si->pszModule, si->ptszName, aFonts[11].color, TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
- else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_topic"), si->pszModule, si->ptszName, aFonts[11].color, TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
- break;
- case GC_EVENT_INFORMATION:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_info"), si->pszModule, si->ptszName, aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ADDSTATUS:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_addstatus"), si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_removestatus"), si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- }
- }
-
- return TRUE;
-}
-
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix)
-{
- if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
- return FALSE;
-
- BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != GetParent(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;
-
- if (bHighlight) {
- gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatHighlight");
- if (bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
- SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
- if (db_get_b(si->windowData.hContact, "CList", "Hidden", 0) != 0)
- db_unset(si->windowData.hContact, "CList", "Hidden");
- if (bInactive)
- DoTrayIcon(si, gce);
- if (bInactive || !g_Settings.PopupInactiveOnly)
- DoPopup(si, gce);
- if (bInactive && si->hWnd)
- SendMessage(si->hWnd, GC_SETMESSAGEHIGHLIGHT, 0, 0);
- return TRUE;
- }
-
- // do blinking icons in tray
- if (bInactive || !g_Settings.TrayIconInactiveOnly)
- DoTrayIcon(si, gce);
-
- // stupid thing to not create multiple popups for a QUIT event for instance
- if (bManyFix == 0) {
- // do popups
- if (bInactive || !g_Settings.PopupInactiveOnly)
- DoPopup(si, gce);
-
- // do sounds and flashing
- switch (iEvent) {
- case GC_EVENT_JOIN:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatJoin");
- break;
- case GC_EVENT_PART:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatPart");
- break;
- case GC_EVENT_QUIT:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatQuit");
- break;
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatMode");
- break;
- case GC_EVENT_KICK:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatKick");
- break;
- case GC_EVENT_MESSAGE:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatMessage");
- if (bInactive && g_Settings.FlashWindow && si->hWnd)
- SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
-
- if (bInactive && !(si->wState & STATE_TALK)) {
- si->wState |= STATE_TALK;
- db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071);
- }
- if (bInactive && si->hWnd)
- SendMessage(si->hWnd, GC_SETTABHIGHLIGHT, 0, 0);
- break;
- case GC_EVENT_ACTION:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatAction");
- break;
- case GC_EVENT_NICK:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatNick");
- break;
- case GC_EVENT_NOTICE:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatNotice");
- break;
- case GC_EVENT_TOPIC:
- if (bInactive || !g_Settings.SoundsFocus)
- SkinPlaySound("ChatTopic");
- break;
- }
- }
-
- return TRUE;
-}
-
int GetColorIndex(const char* pszModule, COLORREF cr)
{
- MODULEINFO *pMod = MM_FindModule(pszModule);
+ MODULEINFO *pMod = pci->MM_FindModule(pszModule);
if (!pMod || pMod->nColorCount == 0)
return -1;
@@ -369,32 +34,6 @@ int GetColorIndex(const char* pszModule, COLORREF cr) return -1;
}
-// obscure function that is used to make sure that any of the colors
-// passed by the protocol is used as fore- or background color
-// in the messagebox. THis is to vvercome limitations in the richedit
-// that I do not know currently how to fix
-
-void CheckColorsInModule(const char* pszModule)
-{
- MODULEINFO *pMod = MM_FindModule(pszModule);
- COLORREF crFG;
- COLORREF crBG = (COLORREF)db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
-
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &crFG, FALSE);
-
- if (!pMod)
- return;
-
- for (int i = 0; i < pMod->nColorCount; i++) {
- if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) {
- if (pMod->crColors[i] == RGB(255, 255, 255))
- pMod->crColors[i]--;
- else
- pMod->crColors[i]++;
- }
- }
-}
-
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2)
{
for (int i = 0; s1[i]; i++)
@@ -405,254 +44,6 @@ TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) return NULL;
}
-BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText)
-{
- if (g_Settings.HighlightEnabled && g_Settings.pszHighlightWords && pszText && si->pMe) {
- TCHAR* p1 = g_Settings.pszHighlightWords;
- TCHAR* p2 = NULL;
- const TCHAR* p3 = pszText;
- static TCHAR szWord1[1000];
- static TCHAR szWord2[1000];
- static TCHAR szTrimString[] = _T(":,.!?;\'>)");
-
- // compare word for word
- while (*p1 != '\0') {
- // find the next/first word in the highlight word string
- // skip 'spaces' be4 the word
- while (*p1 == ' ' && *p1 != '\0')
- p1 += 1;
-
- //find the end of the word
- p2 = _tcschr(p1, ' ');
- if (!p2)
- p2 = _tcschr(p1, '\0');
- if (p1 == p2)
- return FALSE;
-
- // copy the word into szWord1
- lstrcpyn(szWord1, p1, p2 - p1 > 998 ? 999 : p2 - p1 + 1);
- p1 = p2;
-
- // replace %m with the users nickname
- p2 = _tcschr(szWord1, '%');
- if (p2 && p2[1] == 'm') {
- TCHAR szTemp[50];
-
- p2[1] = 's';
- lstrcpyn(szTemp, szWord1, SIZEOF(szTemp));
- mir_sntprintf(szWord1, SIZEOF(szWord1), szTemp, si->pMe->pszNick);
- }
-
- // time to get the next/first word in the incoming text string
- while (*p3 != '\0') {
- // skip 'spaces' be4 the word
- while (*p3 == ' ' && *p3 != '\0')
- p3 += 1;
-
- //find the end of the word
- p2 = (TCHAR *)_tcschr(p3, ' ');
- if (!p2)
- p2 = (TCHAR *)_tcschr(p3, '\0');
-
-
- if (p3 != p2) {
- // eliminate ending character if needed
- if (p2 - p3 > 1 && _tcschr(szTrimString, p2[-1]))
- p2 -= 1;
-
- // copy the word into szWord2 and remove formatting
- lstrcpyn(szWord2, p3, p2 - p3 > 998 ? 999 : p2 - p3 + 1);
-
- // reset the pointer if it was touched because of an ending character
- if (*p2 != '\0' && *p2 != ' ')
- p2 += 1;
- p3 = p2;
-
- CharLower(szWord1);
- CharLower(szWord2);
-
- // compare the words, using wildcards
- if (WCCmp(szWord1, RemoveFormatting(szWord2)))
- return TRUE;
- }
- }
-
- p3 = pszText;
- }
- }
-
- return FALSE;
-}
-
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
-{
- TCHAR szBuffer[4096];
- TCHAR szLine[4096];
- TCHAR szTime[100];
- TCHAR tszFile[MAX_PATH];
- TCHAR tszFolder[MAX_PATH];
- TCHAR p = '\0';
-
- if (!si || !gce)
- return FALSE;
-
- MODULEINFO *mi = MM_FindModule(si->pszModule);
- if (!mi)
- return FALSE;
-
- szBuffer[0] = '\0';
-
- lstrcpyn(tszFile, GetChatLogsFilename(si->windowData.hContact, gce->time), MAX_PATH);
- BOOL bFileJustCreated = !PathFileExists(tszFile);
- _tcsncpy(tszFolder, tszFile, MAX_PATH);
- PathRemoveFileSpec(tszFolder);
- if (!PathIsDirectory(tszFolder))
- CreateDirectoryTreeT(tszFolder);
-
- lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99);
-
- FILE *hFile = _tfopen(tszFile, _T("ab+"));
- if (hFile) {
- TCHAR szTemp[512], szTemp2[512];
- TCHAR* pszNick = NULL;
- if (bFileJustCreated)
- fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE
- if (gce->ptszNick) {
- if (g_Settings.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"), pszNick);
- break;
- case GC_EVENT_PART:
- p = '<';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), pszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_QUIT:
- p = '<';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), pszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), pszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NICK:
- p = '^';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
- break;
- case GC_EVENT_KICK:
- p = '~';
- if (!gce->ptszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_NOTICE:
- p = 'o';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_TOPIC:
- p = '#';
- if (!gce->ptszNick)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText));
- else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
- break;
- case GC_EVENT_INFORMATION:
- p = '!';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), RemoveFormatting(gce->ptszText));
- break;
- case GC_EVENT_ADDSTATUS:
- p = '+';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- p = '-';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick);
- break;
- }
- if (p)
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %c %s\r\n"), szTime, p, szBuffer);
- else
- mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %s\r\n"), szTime, szBuffer);
-
- if (szLine[0]) {
- _fputts(szLine, hFile);
-
- if (g_Settings.LoggingLimit > 0) {
- long dwSize;
- long 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;
- size_t read = 0;
-
- pBuffer = (BYTE *)mir_alloc(g_Settings.LoggingLimit * 1024 + 2);
- pBuffer[g_Settings.LoggingLimit * 1024] = '\0';
- pBuffer[g_Settings.LoggingLimit * 1024 + 1] = '\0';
- fseek(hFile, -g_Settings.LoggingLimit * 1024, SEEK_END);
- read = 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*)_tcschr((TCHAR*)pBuffer, _T('\n'));
- if (pBufferTemp) {
- pBufferTemp += sizeof(TCHAR);
- read = read - (pBufferTemp - pBuffer);
- }
- else pBufferTemp = pBuffer;
-
- if (read > 0) {
- hFile = _tfopen(tszFile, _T("wb"));
- if (hFile) {
- fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE
- 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 hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
GCMENUITEMS gcmi = { 0 };
@@ -695,7 +86,7 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s gcmi.Type = MENU_ON_NICKLIST;
}
- NotifyEventHooks(hBuildMenuEvent, 0, (WPARAM)&gcmi);
+ NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi);
if (gcmi.nItems > 0)
AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
@@ -743,7 +134,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;
@@ -761,56 +152,6 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int return TRUE;
}
-BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCDEST gcd = { pszModule, pszID, iType };
- GCHOOK gch = { 0 };
- gch.ptszUID = (LPTSTR)pszUID;
- gch.ptszText = (LPTSTR)pszText;
- gch.dwData = dwItem;
- gch.pDest = &gcd;
- NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch);
- return TRUE;
-}
-
-BOOL IsEventSupported(int eventType)
-{
- // Supported events
- switch (eventType) {
- case GC_EVENT_JOIN:
- case GC_EVENT_PART:
- case GC_EVENT_QUIT:
- case GC_EVENT_KICK:
- case GC_EVENT_NICK:
- case GC_EVENT_NOTICE:
- case GC_EVENT_MESSAGE:
- case GC_EVENT_TOPIC:
- case GC_EVENT_INFORMATION:
- case GC_EVENT_ACTION:
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- case GC_EVENT_CHUID:
- case GC_EVENT_CHANGESESSIONAME:
- case GC_EVENT_ADDGROUP:
- case GC_EVENT_SETITEMDATA:
- case GC_EVENT_GETITEMDATA:
- case GC_EVENT_SETSBTEXT:
- case GC_EVENT_ACK:
- case GC_EVENT_SENDMESSAGE:
- case GC_EVENT_SETSTATUSEX:
- case GC_EVENT_CONTROL:
- case GC_EVENT_SETCONTACTSTATUS:
- return TRUE;
- }
-
- // Other events
- return FALSE;
-}
-
TCHAR* GetChatLogsFilename(HANDLE hContact, time_t tTime)
{
REPLACEVARSARRAY rva[11];
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 50930e362e..40ef202c6e 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -122,7 +122,7 @@ static void InitButtons(HWND hwndDlg, SESSION_INFO *si) SendDlgItemMessage(hwndDlg, IDC_CHAT_COLOR, BUTTONSETASPUSHBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_CHAT_BKGCOLOR, BUTTONSETASPUSHBTN, TRUE, 0);
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (pInfo) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_BOLD), pInfo->bBold);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_ITALICS), pInfo->bItalics);
@@ -167,7 +167,7 @@ static void MessageDialogResize(HWND hwndDlg, SESSION_INFO *si, int w, int h) EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_SHOWNICKLIST), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_FILTER), TRUE);
if (si->iType == GCW_CHATROOM)
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_CHANMGR), MM_FindModule(si->pszModule)->bChanMgr);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_CHANMGR), pci->MM_FindModule(si->pszModule)->bChanMgr);
}
hdwp = BeginDeferWindowPos(20);
@@ -270,7 +270,7 @@ LBL_SkipEnd: pszName = dat->lastSession->ptszName;
}
}
- else pszName = UM_FindUserAutoComplete(si->pUsers, dat->szSearchQuery, dat->szSearchResult);
+ else pszName = pci->UM_FindUserAutoComplete(si->pUsers, dat->szSearchQuery, dat->szSearchResult);
mir_free(pszText);
replaceStrT(dat->szSearchResult, NULL);
@@ -479,7 +479,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, 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_CHAT_COLOR);
@@ -494,7 +494,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_CHAT_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 = db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_BKGCOLOR);
@@ -509,7 +509,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_CHAT_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_CHAT_BOLD);
u2 = cf.dwEffects;
u2 &= CFE_BOLD;
@@ -519,7 +519,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_CHAT_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_CHAT_ITALICS);
u2 = cf.dwEffects;
u2 &= CFE_ITALIC;
@@ -529,7 +529,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, CheckDlgButton(GetParent(hwnd), IDC_CHAT_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_CHAT_UNDERLINE);
u2 = cf.dwEffects;
u2 &= CFE_UNDERLINE;
@@ -726,7 +726,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case IDM_CLEAR:
if (si) {
SetWindowText(hwnd, _T(""));
- LM_RemoveAll(&si->pLog, &si->pLogEnd);
+ pci->LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iEventCount = 0;
si->LastTime = 0;
PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0);
@@ -804,7 +804,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS ti.rect = clientRect;
TCHAR tszBuf[1024]; tszBuf[0] = 0;
- USERINFO *ui = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
+ USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
if (ui) {
if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
TCHAR *p = (TCHAR*)ProtoCallService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui->pszUID);
@@ -818,7 +818,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, POINT * pt, SESS mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"),
TranslateT("Nickname"), ui->pszNick,
TranslateT("Unique ID"), ui->pszUID,
- TranslateT("Status"), TM_WordToString(parentdat->pStatuses, ui->Status));
+ TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status));
ti.lpszText = tszBuf;
}
@@ -905,7 +905,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, item = (DWORD)(-1);
else
item &= 0xFFFF;
- USERINFO *ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, (int)item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, (int)item);
if (ui) {
HMENU hMenu = 0;
UINT uID;
@@ -953,7 +953,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (wParam == VK_RETURN) {
int index = SendMessage(hwnd, LB_GETCURSEL, 0, 0);
if (index != LB_ERR) {
- USERINFO *ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
}
break;
@@ -995,7 +995,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, */
int iItems = SendMessage(hwnd, LB_GETCOUNT, 0, 0);
for (int i = 0; i < iItems; i++) {
- USERINFO *ui = UM_FindUserFromIndex(si->pUsers, i);
+ USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, i);
if (ui) {
if (!_tcsnicmp(ui->pszNick, si->szSearch, lstrlen(si->szSearch))) {
SendMessage(hwnd, LB_SETCURSEL, i, 0);
@@ -1141,7 +1141,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break;
case GC_SETWNDPROPS:
- LoadGlobalSettings();
+ // LoadGlobalSettings();
InitButtons(hwndDlg, si);
SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
@@ -1185,7 +1185,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TitleBarData tbd = { 0 };
TCHAR szTemp[100];
if (g_dat.flags & SMF_STATUSICON) {
- MODULEINFO *mi = MM_FindModule(si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
tbd.hIcon = (si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon;
tbd.hIconBig = (si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIconBig : mi->hOfflineIconBig;
}
@@ -1219,7 +1219,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case DM_UPDATESTATUSBAR:
{
- MODULEINFO *mi = MM_FindModule(si->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
TCHAR szTemp[512];
HICON hIcon = si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s : %s"), mi->ptszModDispName, si->ptszStatusbarText ? si->ptszStatusbarText : _T(""));
@@ -1248,7 +1248,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case DM_SETCODEPAGE:
si->windowData.codePage = (int)lParam;
- si->pszHeader = Log_CreateRtfHeader(MM_FindModule(si->pszModule), si);
+ si->pszHeader = Log_CreateRtfHeader(pci->MM_FindModule(si->pszModule), si);
SendMessage(hwndDlg, GC_REDRAWLOG2, 0, 0);
break;
@@ -1333,9 +1333,9 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar HICON hIcon;
if (!(si->wState & GC_EVENT_HIGHLIGHT)) {
if (si->wState & STATE_TALK)
- hIcon = (si->wStatus == ID_STATUS_ONLINE) ? MM_FindModule(si->pszModule)->hOnlineTalkIcon : MM_FindModule(si->pszModule)->hOfflineTalkIcon;
+ hIcon = (si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(si->pszModule)->hOnlineTalkIcon : pci->MM_FindModule(si->pszModule)->hOfflineTalkIcon;
else
- 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;
}
else hIcon = g_dat.hMsgIcon;
@@ -1420,7 +1420,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar 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;
@@ -1432,7 +1432,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar offset = 0;
else
offset = height / 2 - 5;
- 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);
@@ -1469,7 +1469,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SendDlgItemMessage(hwndDlg, IDC_CHAT_LIST, WM_SETREDRAW, FALSE, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LIST), LB_RESETCONTENT, 0, 0);
for (int index = 0; index<si->nUsersInNicklist; index++) {
- USERINFO *ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
if (ui) {
char szIndicator = SM_GetStatusIndicator(si, ui);
if (szIndicator>'\0') {
@@ -1544,12 +1544,11 @@ LABEL_SHOWWINDOW: if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_CHAT_SPLITTERX)) {
POINT pt;
RECT rc;
- int oldSplitterX;
GetClientRect(hwndDlg, &rc);
pt.x = wParam; pt.y = 0;
ScreenToClient(hwndDlg, &pt);
- oldSplitterX = si->iSplitterX;
+ int oldSplitterX = si->iSplitterX;
si->iSplitterX = rc.right - pt.x + 1;
if (si->iSplitterX < 35)
si->iSplitterX = 35;
@@ -1560,11 +1559,10 @@ LABEL_SHOWWINDOW: else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_CHAT_SPLITTERY)) {
POINT pt;
RECT rc;
- int oldSplitterY;
GetClientRect(hwndDlg, &rc);
pt.x = 0; pt.y = wParam;
ScreenToClient(hwndDlg, &pt);
- oldSplitterY = si->iSplitterY;
+ int oldSplitterY = si->iSplitterY;
si->iSplitterY = rc.bottom - pt.y;
g_Settings.iSplitterY = si->iSplitterY;
}
@@ -1574,7 +1572,7 @@ LABEL_SHOWWINDOW: case GC_FIREHOOK:
if (lParam) {
GCHOOK *gch = (GCHOOK *)lParam;
- NotifyEventHooks(hSendEvent, 0, (WPARAM)gch);
+ NotifyEventHooks(pci->hSendEvent, 0, (WPARAM)gch);
if (gch->pDest) {
mir_free((void*)gch->pDest->ptszID);
mir_free((void*)gch->pDest->pszModule);
@@ -1607,7 +1605,7 @@ LABEL_SHOWWINDOW: COLORCHOOSER * pCC = (COLORCHOOSER *)mir_alloc(sizeof(COLORCHOOSER));
GetWindowRect(GetDlgItem(hwndDlg, bFG ? IDC_CHAT_COLOR : IDC_CHAT_BKGCOLOR), &rc);
pCC->hWndTarget = GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE);
- pCC->pModule = MM_FindModule(si->pszModule);
+ pCC->pModule = pci->MM_FindModule(si->pszModule);
pCC->xPosition = rc.left + 3;
pCC->yPosition = IsWindowVisible(GetDlgItem(hwndDlg, IDC_CHAT_COLOR)) ? rc.top - 1 : rc.top + 20;
pCC->bForeground = bFG;
@@ -1643,7 +1641,7 @@ LABEL_SHOWWINDOW: if (uMsg != WM_ACTIVATE)
SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
- SetActiveSession(si->ptszID, si->pszModule);
+ pci->SetActiveSession(si->ptszID, si->pszModule);
if (db_get_w(si->windowData.hContact, si->pszModule, "ApparentMode", 0) != 0)
db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", (LPARAM)0);
@@ -1701,13 +1699,13 @@ LABEL_SHOWWINDOW: GetCursorPos(&p);
ScreenToClient(GetDlgItem(hwndDlg, IDC_CHAT_LIST), &p);
int item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y)));
- USERINFO *ui = SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
+ 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"), TM_WordToString(parentdat->pStatuses, ui->Status));
+ TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status));
lpttd->lpszText = ptszBuf;
}
}
@@ -1729,7 +1727,7 @@ LABEL_SHOWWINDOW: ScreenToClient(GetDlgItem(hwndDlg, IDC_CHAT_LIST), &hti.pt);
int item = LOWORD(SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LIST), LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
- USERINFO *ui = SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
if (ui) {
if (GetKeyState(VK_SHIFT) & 0x8000) {
LRESULT lResult = (LRESULT)SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), EM_GETSEL, 0, 0);
@@ -1765,15 +1763,9 @@ LABEL_SHOWWINDOW: si->windowData.cmdList = tcmdlist_append(si->windowData.cmdList, pszRtf, 20, FALSE);
TCHAR *ptszText = DoRtfToTags(pszRtf, si);
- TCHAR *p1 = _tcschr(ptszText, '\0');
+ rtrimt(ptszText);
- //remove trailing linebreaks
- while (p1 > ptszText && (*p1 == '\0' || *p1 == '\r' || *p1 == '\n')) {
- *p1 = '\0';
- p1--;
- }
-
- if (MM_FindModule(si->pszModule)->bAckMsg) {
+ if (pci->MM_FindModule(si->pszModule)->bAckMsg) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, TRUE, 0);
}
@@ -1831,7 +1823,7 @@ LABEL_SHOWWINDOW: case IDC_CHAT_HISTORY:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHAT_HISTORY))) {
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (pInfo)
ShellExecute(hwndDlg, NULL, GetChatLogsFilename(si->windowData.hContact, 0), NULL, NULL, SW_SHOW);
}
@@ -1858,7 +1850,7 @@ LABEL_SHOWWINDOW: case IDC_CHAT_BKGCOLOR:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHAT_BKGCOLOR))) {
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwEffects = 0;
@@ -1888,7 +1880,7 @@ LABEL_SHOWWINDOW: case IDC_CHAT_COLOR:
{
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwEffects = 0;
@@ -1925,7 +1917,7 @@ LABEL_SHOWWINDOW: case IDC_CHAT_ITALICS:
case IDC_CHAT_UNDERLINE:
{
- MODULEINFO *pInfo = MM_FindModule(si->pszModule);
+ MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
@@ -2003,7 +1995,7 @@ LABEL_SHOWWINDOW: if (res > 0) {
g_dat.chatBbuttonVisibility ^= (1 << (res - 1));
db_set_dw(NULL, SRMMMOD, SRMSGSET_CHATBUTTONVISIBILITY, g_dat.chatBbuttonVisibility);
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
}
DestroyMenu(hToolbarMenu);
}
@@ -2035,7 +2027,6 @@ LABEL_SHOWWINDOW: break;
case WM_DESTROY:
-
NotifyLocalWinEvent(si->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_CLOSING);
si->hWnd = NULL;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
diff --git a/plugins/Scriver/src/cmdlist.cpp b/plugins/Scriver/src/cmdlist.cpp index bac33bd1b8..af591908db 100644 --- a/plugins/Scriver/src/cmdlist.cpp +++ b/plugins/Scriver/src/cmdlist.cpp @@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-TCmdList *tcmdlist_append(TCmdList *list, const char *data, int maxSize, BOOL temporary) {
- TCmdList *n;
+TCmdList *tcmdlist_append(TCmdList *list, const char *data, int maxSize, BOOL temporary)
+{
TCmdList *new_list = (TCmdList *)mir_alloc(sizeof(TCmdList));
TCmdList *attach_to = NULL;
@@ -35,23 +35,23 @@ TCmdList *tcmdlist_append(TCmdList *list, const char *data, int maxSize, BOOL te new_list->temporary = temporary;
new_list->next = NULL;
new_list->szCmd = mir_strdup(data);
- for (n=list; n!=NULL; n=n->next) {
+ for (TCmdList *n = list; n != NULL; n = n->next)
attach_to = n;
- }
- if (attach_to==NULL) {
+
+ if (attach_to == NULL) {
new_list->prev = NULL;
return new_list;
- } else {
- new_list->prev = attach_to;
- attach_to->next = new_list;
- if (tcmdlist_len(list)>maxSize) {
- list = tcmdlist_remove_first(list);
- }
- return list;
}
+
+ new_list->prev = attach_to;
+ attach_to->next = new_list;
+ if (tcmdlist_len(list) > maxSize)
+ list = tcmdlist_remove_first(list);
+ return list;
}
-TCmdList *tcmdlist_remove_first(TCmdList *list) {
+TCmdList *tcmdlist_remove_first(TCmdList *list)
+{
TCmdList *n = list;
if (n->next) n->next->prev = n->prev;
if (n->prev) n->prev->next = n->next;
@@ -61,17 +61,18 @@ TCmdList *tcmdlist_remove_first(TCmdList *list) { return list;
}
-TCmdList *tcmdlist_remove(TCmdList *list, TCmdList *n) {
+TCmdList *tcmdlist_remove(TCmdList *list, TCmdList *n)
+{
if (n->next) n->next->prev = n->prev;
if (n->prev) n->prev->next = n->next;
- if (n==list) list = n->next;
+ if (n == list) list = n->next;
mir_free(n->szCmd);
mir_free(n);
return list;
}
-TCmdList *tcmdlist_append2(TCmdList *list, HANDLE hContact, const char *data) {
- TCmdList *n;
+TCmdList *tcmdlist_append2(TCmdList *list, HANDLE hContact, const char *data)
+{
TCmdList *new_list = (TCmdList *)mir_alloc(sizeof(TCmdList));
TCmdList *attach_to = NULL;
@@ -84,27 +85,26 @@ TCmdList *tcmdlist_append2(TCmdList *list, HANDLE hContact, const char *data) { new_list->hContact = hContact;
new_list->szCmd = mir_strdup(data);
list = tcmdlist_remove2(list, hContact);
- for (n=list; n!=NULL; n=n->next) {
+ for (TCmdList *n = list; n != NULL; n = n->next)
attach_to = n;
- }
- if (attach_to==NULL) {
+
+ if (attach_to == NULL) {
new_list->prev = NULL;
return new_list;
}
- else {
- new_list->prev = attach_to;
- attach_to->next = new_list;
- return list;
- }
+
+ new_list->prev = attach_to;
+ attach_to->next = new_list;
+ return list;
}
-TCmdList *tcmdlist_remove2(TCmdList *list, HANDLE hContact) {
- TCmdList *n;
- for (n=list; n!=NULL; n=n->next) {
- if (n->hContact==hContact) {
+TCmdList *tcmdlist_remove2(TCmdList *list, HANDLE hContact)
+{
+ for (TCmdList *n = list; n != NULL; n = n->next) {
+ if (n->hContact == hContact) {
if (n->next) n->next->prev = n->prev;
if (n->prev) n->prev->next = n->next;
- if (n==list) list = n->next;
+ if (n == list) list = n->next;
mir_free(n->szCmd);
mir_free(n);
return list;
@@ -113,40 +113,38 @@ TCmdList *tcmdlist_remove2(TCmdList *list, HANDLE hContact) { return list;
}
-TCmdList *tcmdlist_get2(TCmdList *list, HANDLE hContact) {
- TCmdList *n;
- for (n=list; n!=NULL; n=n->next) {
- if (n->hContact==hContact) {
+TCmdList *tcmdlist_get2(TCmdList *list, HANDLE hContact)
+{
+ for (TCmdList *n = list; n != NULL; n = n->next)
+ if (n->hContact == hContact)
return n;
- }
- }
+
return NULL;
}
-int tcmdlist_len(TCmdList *list) {
- TCmdList *n;
+int tcmdlist_len(TCmdList *list)
+{
int i = 0;
-
- for (n=list; n!=NULL; n=n->next) {
+ for (TCmdList *n = list; n != NULL; n = n->next)
i++;
- }
+
return i;
}
-TCmdList *tcmdlist_last(TCmdList *list) {
- TCmdList *n;
-
- for (n=list; n!=NULL; n=n->next) {
+TCmdList *tcmdlist_last(TCmdList *list)
+{
+ for (TCmdList *n = list; n != NULL; n = n->next)
if (!n->next)
return n;
- }
+
return NULL;
}
-void tcmdlist_free(TCmdList *list) {
+void tcmdlist_free(TCmdList *list)
+{
TCmdList *n = list, *next;
- while (n!=NULL) {
+ while (n != NULL) {
next = n->next;
mir_free(n->szCmd);
mir_free(n);
diff --git a/plugins/Scriver/src/commonheaders.h b/plugins/Scriver/src/commonheaders.h index 61290a8782..7f8533210f 100644 --- a/plugins/Scriver/src/commonheaders.h +++ b/plugins/Scriver/src/commonheaders.h @@ -108,22 +108,14 @@ extern CREOleCallback reOleCallback; extern void ChangeStatusIcons();
extern void LoadInfobarFonts();
extern HCURSOR hDragCursor;
-extern ITaskbarList3 * pTaskbarInterface;
+extern ITaskbarList3 *pTaskbarInterface;
extern GlobalMessageData g_dat;
extern CRITICAL_SECTION cs;
-extern TCHAR* pszActiveWndID ;
-extern char* pszActiveWndModule ;
-extern struct MM_INTERFACE mmi ;
-extern HBRUSH hListBkgBrush;
-extern HBRUSH hListSelectedBkgBrush;
-extern FONTINFO aFonts[OPTIONS_FONTCOUNT];
-extern HICON hIcons[30];
-extern HMENU g_hMenu;
-extern HANDLE hBuildMenuEvent;
-extern HANDLE hSendEvent;
-extern TABLIST *g_TabList;
-extern HANDLE hHookWinPopup, hHookWinWrite;
-extern HCURSOR hCurSplitNS, hCurSplitWE;
+extern HBRUSH hListBkgBrush;
+extern HBRUSH hListSelectedBkgBrush;
+extern HMENU g_hMenu;
+extern HANDLE hHookWinPopup, hHookWinWrite;
+extern HCURSOR hCurSplitNS, hCurSplitWE;
extern CREOleCallback reOleCallback;
@@ -138,10 +130,6 @@ extern CREOleCallback reOleCallback; int Chat_Load();
int Chat_Unload();
int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam);
-int Chat_FontsChanged(WPARAM wParam,LPARAM lParam);
-int Chat_SmileyOptionsChanged(WPARAM wParam,LPARAM lParam);
-int Chat_PreShutdown(WPARAM wParam,LPARAM lParam);
-int Chat_IconsChanged(WPARAM wParam,LPARAM lParam);
int OptInitialise(WPARAM wParam, LPARAM lParam);
int FontServiceFontsChanged(WPARAM wParam, LPARAM lParam);
int StatusIconPressed(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index de9442118d..7486bd6744 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -28,7 +28,6 @@ GlobalMessageData g_dat; static int ackevent(WPARAM wParam, LPARAM lParam);
extern int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam);
-extern int Chat_PreShutdown(WPARAM wParam,LPARAM lParam);
static const char *buttonIcons[] = {"scriver_CLOSEX", "scriver_QUOTE", "scriver_SMILEY",
"scriver_ADD", NULL, "scriver_USERDETAILS", "scriver_HISTORY",
@@ -410,9 +409,8 @@ static int ackevent(WPARAM wParam, LPARAM lParam) ewd->queueItem = item;
SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0);
SendMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd);
- } else {
- RemoveSendQueueItem(item);
}
+ else RemoveSendQueueItem(item);
}
return 0;
}
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index c79f4e7b1b..e38356629c 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -31,16 +31,14 @@ enum KB_ACTIONS {KB_PREV_TAB = 1, KB_NEXT_TAB, KB_SWITCHTOOLBAR, void InputAreaContextMenu(HWND hwnd, WPARAM wParam, LPARAM lParam, HANDLE hContact)
{
- HMENU hMenu, hSubMenu;
POINT pt;
CHARRANGE sel, all = { 0, -1 };
- MessageWindowPopupData mwpd;
int selection;
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
- hSubMenu = GetSubMenu(hMenu, 2);
+ HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ HMENU hSubMenu = GetSubMenu(hMenu, 2);
TranslateMenu(hSubMenu);
- SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)& sel);
+ SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
@@ -58,15 +56,16 @@ void InputAreaContextMenu(HWND hwnd, WPARAM wParam, LPARAM lParam, HANDLE hConta EnableMenuItem(hSubMenu, IDM_PASTE, MF_BYCOMMAND | MF_GRAYED);
}
if (lParam == 0xFFFFFFFF) {
- SendMessage(hwnd, EM_POSFROMCHAR, (WPARAM) & pt, (LPARAM)sel.cpMax);
+ SendMessage(hwnd, EM_POSFROMCHAR, (WPARAM)& pt, (LPARAM)sel.cpMax);
ClientToScreen(hwnd, &pt);
}
else {
- pt.x = (short) LOWORD(lParam);
- pt.y = (short) HIWORD(lParam);
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
}
// First notification
+ MessageWindowPopupData mwpd;
mwpd.cbSize = sizeof(mwpd);
mwpd.uType = MSG_WINDOWPOPUP_SHOWING;
mwpd.uFlags = MSG_WINDOWPOPUP_INPUT;
@@ -111,11 +110,10 @@ void InputAreaContextMenu(HWND hwnd, WPARAM wParam, LPARAM lParam, HANDLE hConta SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)& all);
break;
case IDM_CLEAR:
- SetWindowText(hwnd, _T( "" ));
+ SetWindowText(hwnd, _T(""));
break;
}
DestroyMenu(hMenu);
- //PostMessage(hwnd, WM_KEYUP, 0, 0 );
}
int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CommonWindowData *windowData)
@@ -186,7 +184,7 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, Common switch (msg) {
case WM_KEYDOWN:
- if (wParam >= '1' && wParam <='9' && isCtrl) {
+ if (wParam >= '1' && wParam <= '9' && isCtrl) {
SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, wParam - '1');
return 0;
}
@@ -244,7 +242,7 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, Common else
iLen = SetRichTextEncoded(hwnd, cmdListNew->szCmd, windowData->codePage);
- SendMessage(hwnd, EM_SCROLLCARET, 0,0);
+ SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
SendMessage(hwnd, EM_SETSEL, iLen, iLen);
@@ -280,12 +278,12 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, Common void RegisterKeyBindings()
{
char strDesc[64], strName[64];
- HOTKEYDESC desc = {sizeof(desc) };
+ HOTKEYDESC desc = { sizeof(desc) };
desc.pszSection = LPGEN("Messaging");
desc.pszName = "Scriver/Nav/Previous Tab";
desc.pszDescription = LPGEN("Navigate: Previous Tab");
desc.lParam = KB_PREV_TAB;
- desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_TAB);
+ desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, VK_TAB);
Hotkey_Register(&desc);
desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_PRIOR);
Hotkey_Register(&desc);
@@ -315,25 +313,25 @@ void RegisterKeyBindings() desc.pszName = "Scriver/Wnd/Toggle Statusbar";
desc.pszDescription = LPGEN("Window: Toggle status bar");
desc.lParam = KB_SWITCHSTATUSBAR;
- desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'S');
+ desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'S');
Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Titlebar";
desc.pszDescription = LPGEN("Window: Toggle title bar");
desc.lParam = KB_SWITCHTITLEBAR;
- desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'M');
+ desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'M');
Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Toolbar";
desc.pszDescription = LPGEN("Window: Toggle toolbar");
desc.lParam = KB_SWITCHTOOLBAR;
- desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'T');
+ desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'T');
Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Toggle Infobar";
desc.pszDescription = LPGEN("Window: Toggle info bar");
desc.lParam = KB_SWITCHINFOBAR;
- desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'N');
+ desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'N');
Hotkey_Register(&desc);
desc.pszName = "Scriver/Wnd/Clear Log";
@@ -387,22 +385,21 @@ BOOL HandleLinkClick(HINSTANCE hInstance, HWND hwndDlg, HWND hwndFocus, ENLINK * tr.lpstrText = (LPWSTR)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
SendMessage(lParam->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (_tcschr(tr.lpstrText, _T('@')) != NULL && _tcschr(tr.lpstrText, _T(':')) == NULL && _tcschr(tr.lpstrText, _T('/')) == NULL) {
- MoveMemory(tr.lpstrText + sizeof(TCHAR) * 7, tr.lpstrText, sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
- CopyMemory(tr.lpstrText, _T("mailto:"), sizeof(TCHAR) * 7);
+ MoveMemory(tr.lpstrText + sizeof(TCHAR)* 7, tr.lpstrText, sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
+ CopyMemory(tr.lpstrText, _T("mailto:"), sizeof(TCHAR)* 7);
}
BOOL bOpenLink = TRUE;
if (((ENLINK*)lParam)->msg == WM_RBUTTONDOWN) {
- HMENU hMenu, hSubMenu;
POINT pt;
bOpenLink = FALSE;
- hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXT));
- hSubMenu = GetSubMenu(hMenu, 1);
+ HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXT));
+ HMENU hSubMenu = GetSubMenu(hMenu, 1);
TranslateMenu(hSubMenu);
- pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
- pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
- ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt);
+ pt.x = (short)LOWORD(((ENLINK*)lParam)->lParam);
+ pt.y = (short)HIWORD(((ENLINK*)lParam)->lParam);
+ ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt);
switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
case IDM_OPENLINK:
bOpenLink = TRUE;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 82b7cbc47d..8a43b212e7 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -23,12 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-#define TIMERID_MSGSEND 0
-#define TIMERID_FLASHWND 1
-#define TIMERID_TYPE 2
-#define TIMERID_UNREAD 3
-#define TIMEOUT_TYPEOFF 10000 //send type off after 10 seconds of inactivity
-#define TIMEOUT_UNREAD 800 //multiple-send bombproofing: send max 3 messages every 4 seconds
#define VALID_AVATAR(x) (x==PA_FORMAT_PNG||x==PA_FORMAT_JPEG||x==PA_FORMAT_ICON||x==PA_FORMAT_BMP||x==PA_FORMAT_GIF)
#define ENTERCLICKTIME 1000 //max time in ms during which a double-tap on enter will cause a send
@@ -79,58 +73,61 @@ static TCHAR *GetQuotedTextW(TCHAR * text) l = (int)wcslen(text);
newLine = 1;
wasCR = 0;
- for (i=j=0; i<l; i++) {
- if (text[i]=='\r') {
+ for (i = j = 0; i < l; i++) {
+ if (text[i] == '\r') {
wasCR = 1;
newLine = 1;
- j += text[i+1]!='\n' ? 2 : 1;
- } else if (text[i]=='\n') {
+ j += text[i + 1] != '\n' ? 2 : 1;
+ }
+ else if (text[i] == '\n') {
newLine = 1;
j += wasCR ? 1 : 2;
wasCR = 0;
- } else {
+ }
+ else {
j++;
if (newLine) {
//for (;i<l && text[i]=='>';i++) j--;
- j+=2;
+ j += 2;
}
newLine = 0;
wasCR = 0;
}
}
- j+=3;
- out = (TCHAR *)mir_alloc(sizeof(TCHAR) * j);
+ j += 3;
+ out = (TCHAR *)mir_alloc(sizeof(TCHAR)* j);
newLine = 1;
wasCR = 0;
- for (i=j=0; i<l; i++) {
- if (text[i]=='\r') {
+ for (i = j = 0; i < l; i++) {
+ if (text[i] == '\r') {
wasCR = 1;
newLine = 1;
out[j++] = '\r';
- if (text[i+1]!='\n') {
- out[j++]='\n';
- }
- } else if (text[i]=='\n') {
+ if (text[i + 1] != '\n')
+ out[j++] = '\n';
+ }
+ else if (text[i] == '\n') {
newLine = 1;
- if (!wasCR) {
- out[j++]='\r';
- }
- out[j++]='\n';
+ if (!wasCR)
+ out[j++] = '\r';
+
+ out[j++] = '\n';
wasCR = 0;
- } else {
+ }
+ else {
if (newLine) {
- out[j++]='>';
- out[j++]=' ';
+ out[j++] = '>';
+ out[j++] = ' ';
//for (;i<l && text[i]=='>';i++) j--;
}
newLine = 0;
wasCR = 0;
- out[j++]=text[i];
+ out[j++] = text[i];
}
}
- out[j++]='\r';
- out[j++]='\n';
- out[j++]='\0';
+ out[j++] = '\r';
+ out[j++] = '\n';
+ out[j++] = '\0';
return out;
}
@@ -539,15 +536,15 @@ static void MessageDialogResize(HWND hwndDlg, struct SrmmWindowData *dat, int w, if (hSplitterPos > ( h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1 ) / 2)
hSplitterPos = ( h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1 ) / 2;
- if (h - hSplitterPos - infobarHeight < hSplitterMinTop) {
+ if (h - hSplitterPos - infobarHeight < hSplitterMinTop)
hSplitterPos = h - hSplitterMinTop - infobarHeight;
- }
- if (hSplitterPos < avatarHeight) {
+
+ if (hSplitterPos < avatarHeight)
hSplitterPos = avatarHeight;
- }
- if (hSplitterPos < hSplitterMinBottom) {
+
+ if (hSplitterPos < hSplitterMinBottom)
hSplitterPos = hSplitterMinBottom;
- }
+
if (!(pdat->flags2 & SMF2_SHOWINFOBAR)) {
if (dat->avatarPic && (g_dat.flags&SMF_AVATAR)) {
avatarWidth = BOTTOM_RIGHT_AVATAR_HEIGHT;
@@ -555,16 +552,16 @@ static void MessageDialogResize(HWND hwndDlg, struct SrmmWindowData *dat, int w, if (avatarHeight < BOTTOM_RIGHT_AVATAR_HEIGHT) {
avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT;
hSplitterPos = avatarHeight - toolbarHeight + 2;
- } else {
- avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT;
}
+ else avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT;
+
avatarWidth = avatarHeight;
- if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w/4) {
+ if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w/4)
avatarWidth = w /4;
- }
- if ((toolbarWidth - avatarWidth - 2) < dat->toolbarSize.cx) {
+
+ if ((toolbarWidth - avatarWidth - 2) < dat->toolbarSize.cx)
avatarWidth = toolbarWidth - dat->toolbarSize.cx - 2;
- }
+
toolbarWidth -= avatarWidth + 2;
messageEditWidth -= avatarWidth + 1;
}
@@ -1850,14 +1847,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (!(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
dat->nLastTyping = GetTickCount();
if (len != 0) {
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_OFF) {
+ if (dat->nTypeMode == PROTOTYPE_SELFTYPING_OFF)
NotifyTyping(dat, PROTOTYPE_SELFTYPING_ON);
- }
- } else {
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON) {
- NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
- }
}
+ else if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
}
}
break;
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 84fa594a11..e14213c100 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -118,14 +118,11 @@ static const colourOptionsList[] = { { LPGENT("Info bar background"), SRMSGSET_INFOBARBKGCOLOUR, 0, COLOR_3DLIGHT},
};
-int Chat_FontsChanged(WPARAM wParam,LPARAM lParam);
-
int FontServiceFontsChanged(WPARAM wParam, LPARAM lParam)
{
LoadMsgLogIcons();
LoadInfobarFonts();
WindowList_Broadcast(g_dat.hMessageWindowList, DM_OPTIONSAPPLIED, 0, 0);
- Chat_FontsChanged(wParam, lParam);
return 0;
}
@@ -236,14 +233,12 @@ int IconsChanged(WPARAM wParam, LPARAM lParam) ChangeStatusIcons();
WindowList_Broadcast(g_dat.hMessageWindowList, DM_REMAKELOG, 0, 0);
WindowList_Broadcast(g_dat.hMessageWindowList, DM_CHANGEICONS, 0, 1);
- Chat_IconsChanged(wParam, lParam);
return 0;
}
int SmileySettingsChanged(WPARAM wParam, LPARAM lParam)
{
WindowList_Broadcast(g_dat.hMessageWindowList, DM_REMAKELOG, wParam, 0);
- Chat_SmileyOptionsChanged(wParam, lParam);
return 0;
}
@@ -347,7 +342,7 @@ static void ApplyChanges(int i) ReloadGlobals();
WindowList_Broadcast(g_dat.hParentWindowList, DM_OPTIONSAPPLIED, 0, 0);
WindowList_Broadcast(g_dat.hMessageWindowList, DM_OPTIONSAPPLIED, 0, 0);
- SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
}
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 3d75a9223c..dcd9e2c39b 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -482,7 +482,6 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) int OnSystemPreshutdown(WPARAM wParam, LPARAM lParam)
{
- Chat_PreShutdown(wParam, lParam);
WindowList_Broadcast(g_dat.hMessageWindowList, WM_CLOSE, 0, 0);
WindowList_Broadcast(g_dat.hParentWindowList, WM_CLOSE, 0, 0);
DeinitStatusIcons();
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp index 2837713e39..317d8b6ef4 100644 --- a/plugins/Scriver/src/msgtimedout.cpp +++ b/plugins/Scriver/src/msgtimedout.cpp @@ -37,11 +37,11 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar TranslateDialogDefault(hwndDlg);
if (ewd != NULL) {
ShowWindow(GetParent(ewd->hwndParent), SW_RESTORE);
- if (ewd->szDescription) {
+ if (ewd->szDescription)
SetDlgItemText(hwndDlg, IDC_ERRORTEXT, ewd->szDescription);
- } else {
+ else
SetDlgItemText(hwndDlg, IDC_ERRORTEXT, TranslateT("An unknown error has occurred."));
- }
+
if (ewd->szText) {
SETTEXTEX st = {0};
st.flags = ST_DEFAULT;
@@ -49,11 +49,11 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar SendDlgItemMessage(hwndDlg, IDC_MSGTEXT, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)ewd->szText);
}
- if (ewd->szName) {
+ if (ewd->szName)
mir_sntprintf(szText, SIZEOF(szText), _T("%s - %s"), TranslateT("Send Error"), ewd->szName);
- } else {
+ else
mir_sntprintf(szText, SIZEOF(szText), _T("%s"), TranslateT("Send Error"));
- }
+
SetWindowText(hwndDlg, szText);
GetWindowRect(hwndDlg, &rc);
GetWindowRect(GetParent(ewd->hwndParent), &rcParent);
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index f3d37b9670..b791a24541 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SB_SENDING_WIDTH 25
#define SB_UNICODE_WIDTH 18
-#define TIMERID_FLASHWND 1
#define TIMEOUT_FLASHWND 900
static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lParam);
@@ -61,25 +60,24 @@ TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto) if (hContact && szProto) {
tokens[0] = GetNickname(hContact, szProto);
tokenLen[0] = lstrlen(tokens[0]);
- tokens[1] = mir_tstrdup( pcli->pfnGetStatusModeDescription(szProto ? db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) : ID_STATUS_OFFLINE, 0));
+ tokens[1] = mir_tstrdup(pcli->pfnGetStatusModeDescription(szProto ? db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) : ID_STATUS_OFFLINE, 0));
tokenLen[1] = lstrlen(tokens[1]);
tokens[2] = db_get_tsa(hContact, "CList", "StatusMsg");
if (tokens[2] != NULL) {
tokenLen[2] = (int)lstrlen(tokens[2]);
for (i = j = 0; i < tokenLen[2]; i++) {
- if (tokens[2][i] == '\r') {
+ if (tokens[2][i] == '\r')
continue;
- } else if (tokens[2][i] == '\n') {
+ if (tokens[2][i] == '\n')
tokens[2][j++] = ' ';
- } else {
+ else
tokens[2][j++] = tokens[2][i];
- }
}
tokens[2][j] = '\0';
tokenLen[2] = j;
}
- accModule = (char*) CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM) hContact, 0);
+ accModule = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0);
if (accModule != NULL) {
PROTOACCOUNT* proto = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)accModule);
if (proto != NULL) {
@@ -88,21 +86,20 @@ TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto) }
}
tmplt = db_get_tsa(NULL, SRMMMOD, SRMSGSET_WINDOWTITLE);
- if (tmplt != NULL) {
+ if (tmplt != NULL)
isTemplate = 1;
- } else {
- if (g_dat.flags & SMF_STATUSICON) {
+ else {
+ if (g_dat.flags & SMF_STATUSICON)
tmplt = _T("%name% - ");
- } else {
+ else
tmplt = _T("%name% (%status%) : ");
- }
}
- } else {
- tmplt = _T("");
}
+ else tmplt = _T("");
+
for (len = 0, p = tmplt; *p; p++, len++) {
if (*p == '%') {
- for (i = 0; i < SIZEOF(titleTokenNames); i ++) {
+ for (i = 0; i < SIZEOF(titleTokenNames); i++) {
int tnlen = (int)_tcslen(titleTokenNames[i]);
if (!_tcsncmp(p, titleTokenNames[i], tnlen)) {
len += tokenLen[i] - 1;
@@ -112,9 +109,9 @@ TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto) }
}
}
- if (!isTemplate) {
+ if (!isTemplate)
len += lstrlen(pszNewTitleEnd);
- }
+
title = (TCHAR *)mir_alloc(sizeof(TCHAR) * (len + 1));
for (len = 0, p = tmplt; *p; p++) {
if (*p == '%') {
@@ -138,12 +135,12 @@ TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto) len += lstrlen(pszNewTitleEnd);
}
title[len] = '\0';
- if (isTemplate) {
+ if (isTemplate)
mir_free(tmplt);
- }
- for (i = 0; i < SIZEOF(titleTokenNames); i ++) {
+
+ for (i = 0; i < SIZEOF(titleTokenNames); i++)
mir_free(tokens[i]);
- }
+
mir_free(pszNewTitleEnd);
return title;
}
@@ -175,64 +172,55 @@ static void GetChildWindowRect(ParentWindowData *dat, RECT *rcChild) rcChild->right = rc.right;
if (dat->flags2 & SMF2_TABSATBOTTOM) {
rcChild->top = 2;
- if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1)) {
+ if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1))
rcChild->bottom = rcTabs.bottom + 4;
- } else {
+ else
rcChild->bottom = rc.bottom - rc.top - (rcStatus.bottom - rcStatus.top);
- }
- } else {
- if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1)) {
+ }
+ else {
+ if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1))
rcChild->top = rcTabs.top;
- } else {
- rcChild->top = 2;//rcTabs.top - 2;
- }
+ else
+ rcChild->top = 2;
+
rcChild->bottom = rc.bottom - rc.top - (rcStatus.bottom - rcStatus.top);
}
}
static int GetTabFromHWND(ParentWindowData *dat, HWND child)
{
- MessageWindowTabData * mwtd;
- TCITEM tci;
- int l, i;
- l = TabCtrl_GetItemCount(dat->hwndTabs);
- for (i = 0; i < l; i++) {
- ZeroMemory(&tci, sizeof(TCITEM));
+ int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ for (int i = 0; i < l; i++) {
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(dat->hwndTabs, i, &tci);
- mwtd = (MessageWindowTabData *) tci.lParam;
- if (mwtd->hwnd == child) {
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
+ if (mwtd->hwnd == child)
return i;
- }
}
return -1;
}
static MessageWindowTabData * GetChildFromTab(HWND hwndTabs, int tabId)
{
- TCITEM tci;
- ZeroMemory(&tci, sizeof(TCITEM));
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
- if (TabCtrl_GetItem(hwndTabs, tabId, &tci)) {
+ if (TabCtrl_GetItem(hwndTabs, tabId, &tci))
return (MessageWindowTabData *) tci.lParam;
- }
+
return NULL;
}
static MessageWindowTabData * GetChildFromHWND(ParentWindowData *dat, HWND hwnd)
{
- MessageWindowTabData * mwtd;
- TCITEM tci;
- int l, i;
- l = TabCtrl_GetItemCount(dat->hwndTabs);
- for (i = 0; i < l; i++) {
- ZeroMemory(&tci, sizeof(TCITEM));
+ int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ for (int i = 0; i < l; i++) {
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(dat->hwndTabs, i, &tci);
- mwtd = (MessageWindowTabData *) tci.lParam;
- if (mwtd->hwnd == hwnd) {
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
+ if (mwtd->hwnd == hwnd)
return mwtd;
- }
}
return NULL;
}
@@ -241,19 +229,20 @@ static void GetMinimunWindowSize(ParentWindowData *dat, SIZE *size) {
MINMAXINFO mmi;
RECT rc, rcWindow;
- int i, minW = 216, minH = 80;
+ int minW = 216, minH = 80;
GetWindowRect(dat->hwnd, &rcWindow);
GetChildWindowRect(dat, &rc);
- for (i=0;i<dat->childrenCount;i++) {
+ for (int i = 0; i<dat->childrenCount; i++) {
MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
SendMessage(mwtd->hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
- if (i==0 || mmi.ptMinTrackSize.x > minW) minW = mmi.ptMinTrackSize.x;
- if (i==0 || mmi.ptMinTrackSize.y > minH) minH = mmi.ptMinTrackSize.y;
+ if (i == 0 || mmi.ptMinTrackSize.x > minW) minW = mmi.ptMinTrackSize.x;
+ if (i == 0 || mmi.ptMinTrackSize.y > minH) minH = mmi.ptMinTrackSize.y;
}
if (dat->bMinimized) {
size->cx = minW;
size->cy = minH;
- } else {
+ }
+ else {
size->cx = minW + (rcWindow.right - rcWindow.left) - (rc.right - rc.left);
size->cy = minH + (rcWindow.bottom - rcWindow.top) - (rc.bottom - rc.top);
}
@@ -278,9 +267,9 @@ static int AddOrReplaceIcon(HIMAGELIST hList, int prevIndex, HICON hIcon) {
int usageIdx = -1;
for (int i = 0; i < g_dat.tabIconListUsageSize; i++) {
- if (!g_dat.tabIconListUsage[i].used && usageIdx == -1) {
+ if (!g_dat.tabIconListUsage[i].used && usageIdx == -1)
usageIdx = i;
- }
+
if (g_dat.tabIconListUsage[i].index == prevIndex) {
usageIdx = i;
break;
@@ -288,75 +277,73 @@ static int AddOrReplaceIcon(HIMAGELIST hList, int prevIndex, HICON hIcon) }
if (usageIdx == -1) {
usageIdx = g_dat.tabIconListUsageSize;
- g_dat.tabIconListUsage = (ImageListUsageEntry*) mir_realloc(g_dat.tabIconListUsage, sizeof(ImageListUsageEntry) * (g_dat.tabIconListUsageSize + 1));
+ g_dat.tabIconListUsage = (ImageListUsageEntry*)mir_realloc(g_dat.tabIconListUsage, sizeof(ImageListUsageEntry)* (g_dat.tabIconListUsageSize + 1));
g_dat.tabIconListUsageSize++;
- } else {
- prevIndex = g_dat.tabIconListUsage[usageIdx].index;
}
+ else prevIndex = g_dat.tabIconListUsage[usageIdx].index;
+
g_dat.tabIconListUsage[usageIdx].used = 1;
- g_dat.tabIconListUsage[usageIdx].index = (int) ImageList_ReplaceIcon(hList, prevIndex, hIcon);
+ g_dat.tabIconListUsage[usageIdx].index = (int)ImageList_ReplaceIcon(hList, prevIndex, hIcon);
return g_dat.tabIconListUsage[usageIdx].index;
}
static void ReleaseIcon(int index)
{
- for (int i = 0; i < g_dat.tabIconListUsageSize; i++) {
- if (g_dat.tabIconListUsage[i].index == index) {
+ for (int i = 0; i < g_dat.tabIconListUsageSize; i++)
+ if (g_dat.tabIconListUsage[i].index == index)
g_dat.tabIconListUsage[i].used = 0;
- }
- }
}
-static void ActivateChild(ParentWindowData *dat, HWND child) {
- int i;
+static void ActivateChild(ParentWindowData *dat, HWND child)
+{
RECT rcChild;
GetChildWindowRect(dat, &rcChild);
SetWindowPos(child, HWND_TOP, rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, SWP_NOSIZE);
- i = GetTabFromHWND(dat, child);
- if ( i == -1 )
+ int i = GetTabFromHWND(dat, child);
+ if (i == -1)
return;
- else {
- MessageWindowTabData *mwtd;
- if (( mwtd = GetChildFromTab(dat->hwndTabs, i)) == NULL )
- return;
-
- dat->hContact = mwtd->hContact;
- if (child != dat->hwndActive) {
- HWND prev = dat->hwndActive;
- dat->hwndActive = child;
- SetupStatusBar(dat);
- SendMessage(dat->hwndActive, DM_UPDATESTATUSBAR, 0, 0);
- SendMessage(dat->hwndActive, DM_UPDATETITLEBAR, 0, 0);
- SendMessage(dat->hwnd, WM_SIZE, 0, 0);
- ShowWindow(dat->hwndActive, SW_SHOWNOACTIVATE);
- SendMessage(dat->hwndActive, DM_SCROLLLOGTOBOTTOM, 0, 0);
- if (prev!=NULL) ShowWindow(prev, SW_HIDE);
- } else {
- SendMessage(dat->hwnd, WM_SIZE, 0, 0);
- }
- TabCtrl_SetCurSel(dat->hwndTabs, i);
- SendMessage(dat->hwndActive, DM_ACTIVATE, WA_ACTIVE, 0);
+
+ MessageWindowTabData *mwtd;
+ if ((mwtd = GetChildFromTab(dat->hwndTabs, i)) == NULL)
+ return;
+
+ dat->hContact = mwtd->hContact;
+ if (child != dat->hwndActive) {
+ HWND prev = dat->hwndActive;
+ dat->hwndActive = child;
+ SetupStatusBar(dat);
+ SendMessage(dat->hwndActive, DM_UPDATESTATUSBAR, 0, 0);
+ SendMessage(dat->hwndActive, DM_UPDATETITLEBAR, 0, 0);
+ SendMessage(dat->hwnd, WM_SIZE, 0, 0);
+ ShowWindow(dat->hwndActive, SW_SHOWNOACTIVATE);
+ SendMessage(dat->hwndActive, DM_SCROLLLOGTOBOTTOM, 0, 0);
+ if (prev != NULL)
+ ShowWindow(prev, SW_HIDE);
}
+ else SendMessage(dat->hwnd, WM_SIZE, 0, 0);
+
+ TabCtrl_SetCurSel(dat->hwndTabs, i);
+ SendMessage(dat->hwndActive, DM_ACTIVATE, WA_ACTIVE, 0);
}
static void AddChild(ParentWindowData *dat, HWND hwnd, HANDLE hContact)
{
- TCITEM tci;
- int tabId;
- MessageWindowTabData *mwtd = (MessageWindowTabData *) mir_alloc(sizeof(MessageWindowTabData));
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)mir_alloc(sizeof(MessageWindowTabData));
mwtd->hwnd = hwnd;
mwtd->hContact = hContact;
mwtd->szProto = GetContactProto(hContact);
mwtd->parent = dat;
+
dat->childrenCount++;
+
+ TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE | TCIF_TEXT;
tci.lParam = (LPARAM)mwtd;
tci.iImage = -1;
tci.pszText = _T("");
- tabId = TabCtrl_InsertItem(dat->hwndTabs, dat->childrenCount-1, &tci);
-// ActivateChild(dat, mdat->hwnd);
- SetWindowPos(mwtd->hwnd, HWND_TOP, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, SWP_HIDEWINDOW);
+ int tabId = TabCtrl_InsertItem(dat->hwndTabs, dat->childrenCount - 1, &tci);
+ SetWindowPos(mwtd->hwnd, HWND_TOP, dat->childRect.left, dat->childRect.top, dat->childRect.right - dat->childRect.left, dat->childRect.bottom - dat->childRect.top, SWP_HIDEWINDOW);
SendMessage(dat->hwnd, WM_SIZE, 0, 0);
EnableThemeDialogTexture(hwnd, ETDT_ENABLETAB);
@@ -370,13 +357,12 @@ static void RemoveChild(ParentWindowData *dat, HWND child) tci.mask = TCIF_PARAM | TCIF_IMAGE;
TabCtrl_GetItem(dat->hwndTabs, tab, &tci);
TabCtrl_DeleteItem(dat->hwndTabs, tab);
- mir_free((MessageWindowTabData *) tci.lParam);
+ mir_free((MessageWindowTabData *)tci.lParam);
dat->childrenCount--;
if (child == dat->hwndActive) {
if (tab == TabCtrl_GetItemCount(dat->hwndTabs)) tab--;
- if (tab >=0 ) {
+ if (tab >= 0)
ActivateChild(dat, GetChildFromTab(dat->hwndTabs, tab)->hwnd);
- }
else
dat->hwndActive = NULL;
}
@@ -386,13 +372,11 @@ static void RemoveChild(ParentWindowData *dat, HWND child) static void CloseOtherChilden(ParentWindowData *dat, HWND child)
{
- int i;
ActivateChild(dat, child);
- for (i=dat->childrenCount-1;i>=0;i--) {
+ for (int i = dat->childrenCount - 1; i >= 0; i--) {
MessageWindowTabData *mwtd = GetChildFromTab(dat->hwndTabs, i);
- if (mwtd != NULL && mwtd->hwnd != child) {
+ if (mwtd != NULL && mwtd->hwnd != child)
SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
- }
}
ActivateChild(dat, child);
}
@@ -418,9 +402,8 @@ static void ActivateChildByIndex(ParentWindowData *dat, int index) int l = TabCtrl_GetItemCount(dat->hwndTabs);
if (index < l) {
MessageWindowTabData *mwtd = GetChildFromTab(dat->hwndTabs, index);
- if (mwtd != NULL) {
+ if (mwtd != NULL)
ActivateChild(dat, mwtd->hwnd);
- }
}
}
@@ -436,9 +419,9 @@ static void SetContainerWindowStyle(ParentWindowData *dat) ws = GetWindowLongPtr(dat->hwnd, GWL_EXSTYLE)& ~WS_EX_LAYERED;
ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
- SetWindowLongPtr(dat->hwnd , GWL_EXSTYLE , ws);
+ SetWindowLongPtr(dat->hwnd, GWL_EXSTYLE, ws);
if (dat->flags2 & SMF2_USETRANSPARENCY)
- SetLayeredWindowAttributes(dat->hwnd, RGB(255,255,255), (BYTE)(255-g_dat.inactiveAlpha), LWA_ALPHA);
+ SetLayeredWindowAttributes(dat->hwnd, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
ws = GetWindowLongPtr(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM | 0x2000);
if (dat->flags2 & SMF2_TABSATBOTTOM)
@@ -455,7 +438,7 @@ static void SetContainerWindowStyle(ParentWindowData *dat) RECT rc;
GetWindowRect(dat->hwnd, &rc);
SetWindowPos(dat->hwnd, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
}
INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -489,20 +472,21 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS);
dat->hwndActive = NULL;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat);
- if (g_dat.hTabIconList != NULL) {
+ if (g_dat.hTabIconList != NULL)
TabCtrl_SetImageList(dat->hwndTabs, g_dat.hTabIconList);
- }
+
dat->next = NULL;
if (!newData->isChat) {
dat->prev = g_dat.lastParent;
g_dat.lastParent = dat;
- } else {
+ }
+ else {
dat->prev = g_dat.lastChatParent;
g_dat.lastChatParent = dat;
}
- if (dat->prev != NULL) {
+ if (dat->prev != NULL)
dat->prev->next = dat;
- }
+
WindowList_Add(g_dat.hParentWindowList, hwndDlg, hwndDlg);
SubclassTabCtrl(dat->hwndTabs);
@@ -528,8 +512,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_GETMINMAXINFO:
{
- MINMAXINFO *mmi = (MINMAXINFO *) lParam;
- SIZE size;
+ MINMAXINFO *mmi = (MINMAXINFO *)lParam;
if (dat->bVMaximized) {
MONITORINFO mi;
HMONITOR hMonitor;
@@ -541,20 +524,21 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
rcDesktop = mi.rcWork;
+
mmi->ptMaxSize.x = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
mmi->ptMaxSize.y = rcDesktop.bottom - rcDesktop.top;
mmi->ptMaxPosition.x = wp.rcNormalPosition.left;
- if (IsIconic(hwndDlg)) {
+ if (IsIconic(hwndDlg))
mmi->ptMaxPosition.y = rcDesktop.top;
- } else {
+ else
mmi->ptMaxPosition.y = 0;
- }
}
+ SIZE size;
GetMinimunWindowSize(dat, &size);
mmi->ptMinTrackSize.x = size.cx;
mmi->ptMinTrackSize.y = size.cy;
- return FALSE;
}
+ return FALSE;
case WM_SIZE:
if (wParam == SIZE_MINIMIZED)
@@ -614,23 +598,22 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
if (dat && dat->hwndActive && dis->hwndItem == dat->hwndStatus) {
MessageWindowTabData *mwtd = GetChildFromHWND(dat, dat->hwndActive);
- if (mwtd != NULL) {
+ if (mwtd != NULL)
DrawStatusIcons(mwtd->hContact, dis->hDC, dis->rcItem, 2);
- }
return TRUE;
}
if (dis->hwndItem == dat->hwndTabs) {
DrawTab(dat, dat->hwndTabs, wParam, lParam);
return TRUE;
}
- return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
}
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
case WM_COMMAND:
if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
break;
- if ( LOWORD(wParam) == IDCANCEL)
+ if (LOWORD(wParam) == IDCANCEL)
return TRUE;
break;
@@ -654,12 +637,12 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case NM_RCLICK:
{
TCHITTESTINFO thinfo;
- int tabId, x, y;
GetCursorPos(&thinfo.pt);
- x = thinfo.pt.x;
- y = thinfo.pt.y;
+
+ int x = thinfo.pt.x;
+ int y = thinfo.pt.y;
ScreenToClient(dat->hwndTabs, &thinfo.pt);
- tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
+ int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
if (tabId != -1) {
HMENU hMenu, hSubMenu, hUserMenu;
BOOL menuResult;
@@ -683,30 +666,27 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR default:
CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(menuResult), MPCF_CONTACTMENU), (LPARAM)mwtd->hContact);
}
- if (hUserMenu != NULL) {
+ if (hUserMenu != NULL)
DestroyMenu(hUserMenu);
- }
DestroyMenu(hMenu);
}
}
break;
}
- } else if (pNMHDR->hwndFrom == dat->hwndStatus) {
+ }
+ else if (pNMHDR->hwndFrom == dat->hwndStatus) {
switch (pNMHDR->code) {
case NM_CLICK:
- // case NM_RCLICK:
- {
- NMMOUSE *nm=(NMMOUSE*)lParam;
- RECT rc;
- SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
- if (nm->pt.x >= rc.left) {
- MessageWindowTabData *mwtd = GetChildFromHWND(dat, dat->hwndActive);
- if (mwtd != NULL) {
- CheckStatusIconClick(mwtd->hContact, dat->hwndStatus, nm->pt, rc, 2, (pNMHDR->code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0));
- }
+ NMMOUSE *nm = (NMMOUSE*)lParam;
+ RECT rc;
+ SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
+ if (nm->pt.x >= rc.left) {
+ MessageWindowTabData *mwtd = GetChildFromHWND(dat, dat->hwndActive);
+ if (mwtd != NULL) {
+ CheckStatusIconClick(mwtd->hContact, dat->hwndStatus, nm->pt, rc, 2, (pNMHDR->code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0));
}
- return TRUE;
}
+ return TRUE;
}
}
}
@@ -730,7 +710,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case WM_CONTEXTMENU:
- if (dat->hwndStatus && dat->hwndStatus == (HWND) wParam) {
+ if (dat->hwndStatus && dat->hwndStatus == (HWND)wParam) {
RECT rc;
POINT pt, pt2;
GetCursorPos(&pt);
@@ -752,11 +732,9 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (LOWORD(wParam) == WA_INACTIVE) {
ws = GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
- SetWindowLongPtr(hwndDlg , GWL_EXSTYLE , ws);
- if (dat->flags2 & SMF2_USETRANSPARENCY) {
- SetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat.inactiveAlpha), LWA_ALPHA);
- // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
- }
+ SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, ws);
+ if (dat->flags2 & SMF2_USETRANSPARENCY)
+ SetLayeredWindowAttributes(hwndDlg, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
break;
}
if (dat->hwndActive != NULL) {
@@ -795,7 +773,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
GetCursorPos(&pt);
- // SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0);
+
rcDesktop = mi.rcWork;
pRect->left = pt.x-dat->mouseLBDownPos.x;
pRect->top = pt.y-dat->mouseLBDownPos.y;
@@ -819,26 +797,28 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR }
}
break;
+
case WM_SYSCOMMAND:
if ((wParam & 0xFFF0) == SC_MAXIMIZE) {
- if (GetKeyState(VK_CONTROL) & 0x8000) {
+ if (GetKeyState(VK_CONTROL) & 0x8000)
dat->bVMaximized = 1;
- } else {
+ else
dat->bVMaximized = 0;
- }
}
else if ((wParam & 0xFFF0) == SC_MOVE) {
RECT rc;
GetWindowRect(hwndDlg, &rc);
dat->mouseLBDownPos.x = LOWORD(lParam) - rc.left;
dat->mouseLBDownPos.y = HIWORD(lParam) - rc.top;
- } else if (wParam == IDM_TOPMOST) {
+ }
+ else if (wParam == IDM_TOPMOST) {
HMENU hMenu = GetSystemMenu(hwndDlg, FALSE);
if (dat->bTopmost) {
CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_UNCHECKED);
SetWindowPos(hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
dat->bTopmost = FALSE;
- } else {
+ }
+ else {
CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_CHECKED);
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
dat->bTopmost = TRUE;
@@ -920,7 +900,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (dat->childrenCount == 1 || ((g_dat.flags2 & SMF2_SWITCHTOACTIVE) && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
SendMessage(hwndDlg, CM_ACTIVATECHILD, 0, (LPARAM)lParam);
- SetWindowPos(hwndDlg, HWND_TOP, 0,0,0,0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
}
else { /* outgoing message */
@@ -931,7 +911,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case CM_REMOVECHILD:
- RemoveChild(dat, (HWND) lParam);
+ RemoveChild(dat, (HWND)lParam);
if (dat->childrenCount != 0)
SetFocus(dat->hwndActive);
else
@@ -943,21 +923,21 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE;
case CM_ACTIVATECHILD:
- ActivateChild(dat, (HWND) lParam);
+ ActivateChild(dat, (HWND)lParam);
return TRUE;
case CM_ACTIVATEPREV:
- ActivatePrevChild(dat, (HWND) lParam);
+ ActivatePrevChild(dat, (HWND)lParam);
SetFocus(dat->hwndActive);
return TRUE;
case CM_ACTIVATENEXT:
- ActivateNextChild(dat, (HWND) lParam);
+ ActivateNextChild(dat, (HWND)lParam);
SetFocus(dat->hwndActive);
return TRUE;
case CM_ACTIVATEBYINDEX:
- ActivateChildByIndex(dat, (int) lParam);
+ ActivateChildByIndex(dat, (int)lParam);
SetFocus(dat->hwndActive);
return TRUE;
@@ -974,11 +954,9 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE;
case DM_SENDMESSAGE:
- {
- for (int i=0; i < dat->childrenCount; i++) {
- MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
- SendMessage(mwtd->hwnd, DM_SENDMESSAGE, wParam, lParam);
- }
+ for (int i = 0; i < dat->childrenCount; i++) {
+ MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
+ SendMessage(mwtd->hwnd, DM_SENDMESSAGE, wParam, lParam);
}
break;
@@ -990,39 +968,35 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case CM_UPDATETITLEBAR:
{
- HWND hwnd = (HWND) lParam;
- TitleBarData *tbd = (TitleBarData *) wParam;
+ HWND hwnd = (HWND)lParam;
+ TitleBarData *tbd = (TitleBarData *)wParam;
if (tbd != NULL && dat->hwndActive == hwnd) {
if (tbd->iFlags & TBDF_TEXT) {
TCHAR oldtitle[256];
GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle));
- if (lstrcmp(tbd->pszText, oldtitle)) { //swt() flickers even if the title hasn't actually changed
+ if (lstrcmp(tbd->pszText, oldtitle))
SetWindowText(hwndDlg, tbd->pszText);
- //SendMessage(hwndDlg, WM_SIZE, 0, 0);
- }
}
if (tbd->iFlags & TBDF_ICON) {
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)tbd->hIcon);
- if (tbd->hIconBig != NULL) {
+ if (tbd->hIconBig != NULL)
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)tbd->hIconBig);
- }
if (pTaskbarInterface)
pTaskbarInterface->SetOverlayIcon(hwndDlg, tbd->hIconNot, L"");
}
}
- break;
}
+ break;
+
case CM_UPDATESTATUSBAR:
{
- HWND hwnd = (HWND) lParam;
- StatusBarData *sbd = (StatusBarData *) wParam;
+ HWND hwnd = (HWND)lParam;
+ StatusBarData *sbd = (StatusBarData *)wParam;
if (sbd != NULL) {
- if ((sbd->iFlags & SBDF_TEXT) && dat->hwndActive == hwnd) {
+ if ((sbd->iFlags & SBDF_TEXT) && dat->hwndActive == hwnd)
SendMessage(dat->hwndStatus, SB_SETTEXT, sbd->iItem, (LPARAM)sbd->pszText);
- }
- if ((sbd->iFlags & SBDF_ICON) && dat->hwndActive == hwnd) {
+ if ((sbd->iFlags & SBDF_ICON) && dat->hwndActive == hwnd)
SendMessage(dat->hwndStatus, SB_SETICON, sbd->iItem, (LPARAM)sbd->hIcon);
- }
RedrawWindow(dat->hwndStatus, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
}
}
@@ -1092,8 +1066,8 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
SendMessage(mwtd->hwnd, DM_SWITCHTOOLBAR, 0, 0);
}
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
}
+ SendMessage(hwndDlg, WM_SIZE, 0, 0);
break;
case DM_SWITCHTITLEBAR:
@@ -1108,7 +1082,6 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR GetWindowRect(hwndDlg, &rc);
SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
- // SendMessage(hwndDlg, WM_SIZE, 0, 0);
RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
break;
@@ -1131,127 +1104,131 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lParam)
{
- TabCtrlData *tcdat;
- TCITEM tci;
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) lParam;
- int iTabIndex = lpDIS->itemID;
- tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (iTabIndex >= 0) {
- HANDLE hTheme = NULL;
- int tstate;
- TCHAR szLabel[1024];
- tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
- tci.pszText = szLabel;
- tci.cchTextMax = SIZEOF(szLabel);
- tci.dwStateMask = TCIS_HIGHLIGHTED;
- if (TabCtrl_GetItem(hwnd, iTabIndex, &tci)) {
- IMAGEINFO info;
- RECT rIcon = lpDIS->rcItem;
- RECT rect = lpDIS->rcItem;
- RECT rectTab = lpDIS->rcItem;
- int bSelected = lpDIS->itemState & ODS_SELECTED;
- int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
- UINT dwFormat;
- if (!IsAppThemed()) {
- FillRect(lpDIS->hDC, &rect, GetSysColorBrush(COLOR_BTNFACE));
- }
+ int iTabIndex = lpDIS->itemID;
+ if (iTabIndex < 0)
+ return;
+
+ TabCtrlData *tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ HANDLE hTheme = NULL;
+ int tstate;
+ TCHAR szLabel[1024];
+ TCITEM tci;
+ tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
+ tci.pszText = szLabel;
+ tci.cchTextMax = SIZEOF(szLabel);
+ tci.dwStateMask = TCIS_HIGHLIGHTED;
+ if (TabCtrl_GetItem(hwnd, iTabIndex, &tci)) {
+ IMAGEINFO info;
+ RECT rIcon = lpDIS->rcItem;
+ RECT rect = lpDIS->rcItem;
+ RECT rectTab = lpDIS->rcItem;
+ int bSelected = lpDIS->itemState & ODS_SELECTED;
+ int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
+ UINT dwFormat;
+ if (!IsAppThemed()) {
+ FillRect(lpDIS->hDC, &rect, GetSysColorBrush(COLOR_BTNFACE));
+ }
+ else {
+ if (lpDIS->itemState & ODS_SELECTED)
+ tstate = TTIS_SELECTED;
+ else if (lpDIS->itemState & ODS_FOCUS)
+ tstate = TTIS_FOCUSED;
+ else if (lpDIS->itemState & ODS_HOTLIGHT)
+ tstate = TTIS_HOT;
else
- {
- if (lpDIS->itemState & ODS_SELECTED)
- tstate = TTIS_SELECTED;
- else if (lpDIS->itemState & ODS_FOCUS)
- tstate = TTIS_FOCUSED;
- else if (lpDIS->itemState & ODS_HOTLIGHT)
- tstate = TTIS_HOT;
- else
- tstate = TTIS_NORMAL;
+ tstate = TTIS_NORMAL;
- if (!bSelected)
- InflateRect(&rectTab, 1, 1);
+ if (!bSelected)
+ InflateRect(&rectTab, 1, 1);
- hTheme = OpenThemeData(hwnd, L"TAB");
- if (IsThemeBackgroundPartiallyTransparent(hTheme, TABP_TABITEM, tstate))
- DrawThemeParentBackground(hwnd, lpDIS->hDC, &rectTab);
- DrawThemeBackground(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, &rectTab, NULL);
- }
- if (atTop) {
- dwFormat = DT_SINGLELINE|DT_TOP|DT_CENTER|DT_NOPREFIX|DT_NOCLIP;
- rIcon.top = rect.top + GetSystemMetrics(SM_CYEDGE);
- if (tci.iImage >= 0) {
- rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
- ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
- ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
- }
- if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.right = rIcon.left - 1;
- }
- rect.top += GetSystemMetrics(SM_CYEDGE) + 2;
- } else {
- dwFormat = DT_SINGLELINE|DT_BOTTOM|DT_CENTER|DT_NOPREFIX|DT_NOCLIP;
+ hTheme = OpenThemeData(hwnd, L"TAB");
+ if (IsThemeBackgroundPartiallyTransparent(hTheme, TABP_TABITEM, tstate))
+ DrawThemeParentBackground(hwnd, lpDIS->hDC, &rectTab);
+ DrawThemeBackground(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, &rectTab, NULL);
+ }
+ if (atTop) {
+ dwFormat = DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
+ rIcon.top = rect.top + GetSystemMetrics(SM_CYEDGE);
+ if (tci.iImage >= 0) {
rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
- if (tci.iImage >= 0) {
- ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
- rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 1;
- ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
- }
- if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 2;
- rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.right = rIcon.left - 1;
- }
- rect.bottom -= GetSystemMetrics(SM_CYEDGE) + 2;
+ ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
+ ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
}
- if (hTheme) {
-
- DrawThemeText(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, szLabel, -1, dwFormat, 0, &rect);
+ if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.right = rIcon.left - 1;
+ }
+ rect.top += GetSystemMetrics(SM_CYEDGE) + 2;
+ }
+ else {
+ dwFormat = DT_SINGLELINE | DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
+ rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
+ if (tci.iImage >= 0) {
+ ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
+ rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 1;
+ ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
+ }
+ if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 2;
+ rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.right = rIcon.left - 1;
+ }
+ rect.bottom -= GetSystemMetrics(SM_CYEDGE) + 2;
+ }
+ if (hTheme)
+ DrawThemeText(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, szLabel, -1, dwFormat, 0, &rect);
+ else
+ DrawText(lpDIS->hDC, szLabel, -1, &rect, dwFormat);
+
+ if (tcdat->bDragged && iTabIndex == tcdat->destTab && iTabIndex != tcdat->srcTab) {
+ RECT hlRect = lpDIS->rcItem;
+ if (bSelected) {
+ hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
+ hlRect.top += GetSystemMetrics(SM_CYEDGE);
+ hlRect.left += GetSystemMetrics(SM_CXEDGE);
+ hlRect.right -= GetSystemMetrics(SM_CXEDGE);
}
- else
- DrawText(lpDIS->hDC, szLabel, -1, &rect, dwFormat);
- if (tcdat->bDragged && iTabIndex == tcdat->destTab && iTabIndex != tcdat->srcTab) {
- RECT hlRect = lpDIS->rcItem;
- if (bSelected) {
- hlRect.bottom-=GetSystemMetrics(SM_CYEDGE);
- hlRect.top+=GetSystemMetrics(SM_CYEDGE);
- hlRect.left+=GetSystemMetrics(SM_CXEDGE);
- hlRect.right-=GetSystemMetrics(SM_CXEDGE);
- } else {
- if (atTop) {
- hlRect.top += GetSystemMetrics(SM_CYEDGE);
- hlRect.bottom += GetSystemMetrics(SM_CYEDGE);
- } else {
- hlRect.top -= GetSystemMetrics(SM_CYEDGE);
- hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
- }
+ else {
+ if (atTop) {
+ hlRect.top += GetSystemMetrics(SM_CYEDGE);
+ hlRect.bottom += GetSystemMetrics(SM_CYEDGE);
+ }
+ else {
+ hlRect.top -= GetSystemMetrics(SM_CYEDGE);
+ hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
}
- FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
- hlRect.left++;
- hlRect.top++;
- hlRect.right--;
- hlRect.bottom--;
- FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
}
- if (hTheme)
- CloseThemeData(hTheme);
+ FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
+ hlRect.left++;
+ hlRect.top++;
+ hlRect.right--;
+ hlRect.bottom--;
+ FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
}
+ if (hTheme)
+ CloseThemeData(hTheme);
}
}
LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
TabCtrlData *dat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ TCHITTESTINFO thinfo;
+ int tabId;
switch(msg) {
case EM_SUBCLASSED:
dat = (TabCtrlData*)mir_alloc(sizeof(TabCtrlData));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
dat->bDragging = FALSE;
dat->bDragged = FALSE;
dat->srcTab = -1;
@@ -1259,39 +1236,34 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0;
case WM_MBUTTONDOWN:
- {
- TCHITTESTINFO thinfo;
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- int tabId = TabCtrl_HitTest(hwnd, &thinfo);
- if (tabId >= 0) {
- TCITEM tci;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwnd, tabId, &tci);
- MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam;
- if (mwtd != NULL) {
- SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ if (tabId >= 0) {
+ TCITEM tci;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwnd, tabId, &tci);
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
+ if (mwtd != NULL) {
+ SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
}
- return 0;
}
+ return 0;
+
case WM_LBUTTONDBLCLK:
- {
- TCHITTESTINFO thinfo;
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- int tabId = TabCtrl_HitTest(hwnd, &thinfo);
- if (tabId >=0 && tabId == dat->srcTab) {
- SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
- dat->destTab = -1;
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ if (tabId >= 0 && tabId == dat->srcTab) {
+ SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
}
+ dat->destTab = -1;
break;
+
case WM_LBUTTONDOWN:
if (!dat->bDragging) {
- TCHITTESTINFO thinfo;
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo);
@@ -1311,10 +1283,10 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0;
}
break;
+
case WM_CAPTURECHANGED:
case WM_LBUTTONUP:
if (dat->bDragging) {
- TCHITTESTINFO thinfo;
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
if (dat->bDragged) {
@@ -1323,7 +1295,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ImageList_Destroy(dat->hDragImageList);
SetCursor(LoadCursor(NULL, IDC_ARROW));
dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
- if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
+ if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
NMHDR nmh;
TCHAR sBuffer[501];
TCITEM item;
@@ -1333,7 +1305,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) item.pszText = sBuffer;
item.cchTextMax = SIZEOF(sBuffer);
TabCtrl_GetItem(hwnd, dat->srcTab, &item);
- sBuffer[SIZEOF(sBuffer)-1] = '\0';
+ sBuffer[SIZEOF(sBuffer) - 1] = '\0';
if (curSel == dat->srcTab)
curSel = dat->destTab;
@@ -1343,7 +1315,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) curSel++;
TabCtrl_DeleteItem(hwnd, dat->srcTab);
- TabCtrl_InsertItem(hwnd, dat->destTab, &item );
+ TabCtrl_InsertItem(hwnd, dat->destTab, &item);
TabCtrl_SetCurSel(hwnd, curSel);
dat->destTab = -1;
nmh.hwndFrom = hwnd;
@@ -1359,7 +1331,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) dat->destTab = -1;
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
- MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam;
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
if (mwtd != NULL) {
HWND hChild = mwtd->hwnd;
HANDLE hContact = mwtd->hContact;
@@ -1369,7 +1341,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) hParent = GetParent(hParent);
hParent = WindowList_Find(g_dat.hParentWindowList, hParent);
- if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
if (hParent == NULL) {
RECT rc, rcDesktop;
newData.hContact = hContact;
@@ -1456,28 +1428,28 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ReleaseCapture();
}
break;
+
case WM_MOUSEMOVE:
if (wParam & MK_LBUTTON) {
if (dat->bDragging) {
FILETIME ft;
- TCHITTESTINFO thinfo;
GetSystemTimeAsFileTime(&ft);
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
if (!dat->bDragged) {
- if ((abs(thinfo.pt.x-dat->mouseLBDownPos.x)<3 && abs(thinfo.pt.y-dat->mouseLBDownPos.y)<3)
- || (ft.dwLowDateTime - dat->lastClickTime) < 10*1000*150)
+ if ((abs(thinfo.pt.x - dat->mouseLBDownPos.x) < 3 && abs(thinfo.pt.y - dat->mouseLBDownPos.y) < 3)
+ || (ft.dwLowDateTime - dat->lastClickTime) < 10 * 1000 * 150)
break;
}
if (!dat->bDragged) {
POINT pt;
RECT rect;
RECT rect2;
- HBRUSH hBrush = CreateSolidBrush(RGB(255,0,254));
+ HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 254));
GetCursorPos(&pt);
TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- rect.right -= rect.left-1;
- rect.bottom -= rect.top-1;
+ rect.right -= rect.left - 1;
+ rect.bottom -= rect.top - 1;
rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom;
dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1);
HDC hDC = GetDC(hwnd);
@@ -1485,10 +1457,10 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
FillRect(hMemDC, &rect2, hBrush);
- SetWindowOrgEx (hMemDC, rect.left, rect.top, NULL);
+ SetWindowOrgEx(hMemDC, rect.left, rect.top, NULL);
SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT);
SelectObject(hMemDC, hOldBitmap);
- ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255,0,254));
+ ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255, 0, 254));
DeleteObject(hBitmap);
DeleteObject(hBrush);
ReleaseDC(hwnd, hDC);
@@ -1500,7 +1472,6 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) dat->mouseLBDownPos.y = thinfo.pt.y;
}
else {
- TCHITTESTINFO thinfo;
POINT pt;
GetCursorPos(&pt);
thinfo.pt = pt;
@@ -1510,7 +1481,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) newDest = -1;
if (newDest != dat->destTab) {
- dat->destTab = newDest;
+ dat->destTab = newDest;
ImageList_DragLeave(GetDesktopWindow());
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
@@ -1532,7 +1503,6 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int ScriverRestoreWindowPosition(HWND hwnd, HANDLE hContact, const char *szModule,const char *szNamePrefix, int flags, int showCmd)
{
- RECT rcDesktop;
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
GetWindowPlacement(hwnd, &wp);
@@ -1562,14 +1532,15 @@ int ScriverRestoreWindowPosition(HWND hwnd, HANDLE hContact, const char *szModul MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
- rcDesktop = mi.rcWork;
+ RECT rcDesktop = mi.rcWork;
if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom
|| wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
SetWindowPlacement(hwnd,&wp);
return 0;
}
-HWND GetParentWindow(HANDLE hContact, BOOL bChat) {
+HWND GetParentWindow(HANDLE hContact, BOOL bChat)
+{
NewMessageWindowLParam newData = { 0 };
newData.hContact = hContact;
newData.isChat = bChat;
@@ -1590,7 +1561,7 @@ HWND GetParentWindow(HANDLE hContact, BOOL bChat) { }
}
}
- if ( !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS))
+ if (!(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS))
newData.isChat = FALSE;
return CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
|