From 05cd7934d4bdb097e112efdda356946868f3f5d6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 8 Jan 2014 19:39:48 +0000 Subject: - end of ANSI support in chats; - manual crit section control removed from chat engine; - bunch of memory-related clutches either removed or replaced with smart pointers git-svn-id: http://svn.miranda-ng.org/main/trunk@7549 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/delphi/m_chat.inc | 21 +- include/m_chat.h | 190 ++--- plugins/MirandaG15/src/CAppletManager.cpp | 5 +- plugins/PasteIt/src/PasteIt.cpp | 56 +- plugins/Scriver/src/chat/chat.h | 52 +- plugins/Scriver/src/chat/manager.cpp | 42 +- plugins/Scriver/src/chat/services.cpp | 168 ++--- plugins/Scriver/src/chat/tools.cpp | 137 ++-- plugins/SendScreenshotPlus/src/CSend.cpp | 12 +- plugins/TabSRMM/src/chat/chat.h | 2 - plugins/TabSRMM/src/chat/chatprototypes.h | 54 +- plugins/TabSRMM/src/chat/manager.cpp | 48 +- plugins/TabSRMM/src/chat/services.cpp | 329 ++++----- plugins/TabSRMM/src/chat/tools.cpp | 134 +--- plugins/TabSRMM/src/chat/window.cpp | 5 - plugins/Utils.pas/mirutils.pas | 2 +- protocols/AimOscar/src/chat.cpp | 38 +- protocols/FacebookRM/src/chat.cpp | 123 +--- protocols/FacebookRM/src/proto.cpp | 2 +- protocols/Gadu-Gadu/src/core.cpp | 73 +- protocols/Gadu-Gadu/src/groupchat.cpp | 121 ++-- protocols/IRCG/src/commandmonitor.cpp | 1064 ++++++++++++++-------------- protocols/IRCG/src/input.cpp | 32 +- protocols/IRCG/src/irc.h | 2 +- protocols/IRCG/src/ircproto.cpp | 20 +- protocols/IRCG/src/scripting.cpp | 22 +- protocols/IRCG/src/services.cpp | 67 +- protocols/IRCG/src/tools.cpp | 36 +- protocols/JabberG/src/jabber_chat.cpp | 39 +- protocols/JabberG/src/jabber_groupchat.cpp | 18 +- protocols/JabberG/src/jabber_iqid.cpp | 4 +- protocols/JabberG/src/jabber_proto.cpp | 8 +- protocols/JabberG/src/jabber_thread.cpp | 4 +- protocols/MRA/src/MraChat.cpp | 46 +- protocols/MRA/src/Mra_functions.cpp | 4 +- protocols/MSN/src/msn_chat.cpp | 43 +- protocols/MSN/src/msn_commands.cpp | 44 +- protocols/MSN/src/msn_proto.cpp | 4 +- protocols/Omegle/src/chat.cpp | 120 +--- protocols/Omegle/src/proto.cpp | 2 +- protocols/Skype/src/skype_chat.cpp | 62 +- protocols/SkypeClassic/src/gchat.cpp | 130 ++-- protocols/SkypeClassic/src/skype.cpp | 117 ++- protocols/SkypeClassic/src/skypeopt.cpp | 6 +- protocols/Twitter/src/chat.cpp | 86 +-- protocols/Twitter/src/proto.cpp | 4 +- protocols/WhatsApp/src/chat.cpp | 10 +- protocols/WhatsApp/src/proto.cpp | 10 +- protocols/Yahoo/src/chat.cpp | 41 +- src/core/stdchat/src/chat.h | 66 +- src/core/stdchat/src/manager.cpp | 643 ++++++++--------- src/core/stdchat/src/options.cpp | 543 +++++++------- src/core/stdchat/src/services.cpp | 586 +++++++-------- src/core/stdchat/src/tools.cpp | 415 +++++------ 54 files changed, 2397 insertions(+), 3515 deletions(-) diff --git a/include/delphi/m_chat.inc b/include/delphi/m_chat.inc index 050b4a706a..516899c368 100644 --- a/include/delphi/m_chat.inc +++ b/include/delphi/m_chat.inc @@ -46,8 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. NOTE. Chat keeps its own copies of strings passed. - - * * Example of implementing this rule * *: + + * * Example of implementing this rule * *: * * This is a code snippet that is common in protocols * *: @@ -131,11 +131,6 @@ const GC_SINGLEFORMAT = $0100; //the protocol supports only 1 formatting per message GC_FONTSIZE = $0200; //enable font size selection - GC_UNICODE = $1000; //NOT SUPPORTED YET! Enable unicode (if chat supports it), - //Pass UNICODE instead of ASCII. Note that - //registration will fail if the unicode version of chat is not installed - GC_TCHAR = GC_UNICODE; - // Error messages GC_REGISTER_WRONGVER = 1; //You appear to be using the wrong version of this API. Registration failed. GC_REGISTER_ERROR = 2; //An internal error occurred. Registration failed. @@ -195,8 +190,8 @@ type szName :TCHAR; //The name of the session as it will be displayed to the user szID :TCHAR; //The unique identifier for the session. szStatusbarText:TCHAR; //Optional text to set in the statusbar of the chat room window, or NULL. - dwFlags :dword; - dwItemData :dword; //Set user defined data for this session. Retrieve it by using the GC_EVENT_GETITEMDATA event + dwFlags :dword; + dwItemData :int_ptr; //Set user defined data for this session. Retrieve it by using the GC_EVENT_GETITEMDATA event end; const @@ -394,7 +389,7 @@ const // pszText - The text GC_EVENT_SENDMESSAGE = $1008; -// GC_EVENT_SETSTATUSEX - not shown in the log (Space or tab delimited list of pszUID's to indicate as away). +// GC_EVENT_SETSTATUSEX - not shown in the log (Space or tab delimited list of pszUID's to indicate as away). // Used by IRC to mark users as away in the nicklist. If UIDs can contain spaces, use tabs // pszText - Space or tab delimited list of pszUID's @@ -460,7 +455,7 @@ type dwFlags :dword; // event flags: GCEF_ADDTOLOG, GC_UNICODE // FALSE any other time than when initializing the window (before sending SESSION_INITDONE) - dwItemData:dword_ptr; // User specified data. + dwItemData:int_ptr; // User specified data. time :dword; // Timestamp of the event end; @@ -514,7 +509,7 @@ type pszModule :PAnsiChar; // the module name as registered in MS_GC_REGISTER pszID :TCHAR; // unique ID of the session pszName :TCHAR; // display name of the session - dwItemData:dword_ptr; // user specified data. + dwItemData:int_ptr; // user specified data. iCount :int; // count of users in the nicklist pszUsers :PAnsiChar; // space separated string containing the UID's of the users in the user list. // NOTE. Use Mirandas mmi_free() on the returned string. @@ -554,7 +549,7 @@ type pDest :PGCDEST; // pointer to a GCDEST structure which specifies from which session the hook was triggered szText:TCHAR; // usage depends on type of event szUID :TCHAR; // unique identifier, usage depends on type of event - dwData:dword_ptr; // user defined data, usage depends on type of event} + dwData:int_ptr; // user defined data, usage depends on type of event} end; { diff --git a/include/m_chat.h b/include/m_chat.h index 3affd8c811..dcbd6710e2 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -127,24 +127,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Flags -#define GC_BOLD 0x0001 //enable the 'bold' button -#define GC_ITALICS 0x0002 //enable the 'italics' button -#define GC_UNDERLINE 0x0004 //enable the 'underline' button -#define GC_COLOR 0x0008 //enable the 'foreground color' button -#define GC_BKGCOLOR 0x0010 //enable the 'background color' button -#define GC_ACKMSG 0x0020 //the protocol must acknowlege messages sent -#define GC_TYPNOTIF 0x0040 //enable typing notifications. -#define GC_CHANMGR 0x0080 //enable the 'channel settings' button -#define GC_SINGLEFORMAT 0x0100 //the protocol supports only 1 formatting per message -#define GC_FONTSIZE 0x0200 //enable font size selection - -#define GC_UNICODE 0x01000 //enable unicode (if chat supports it), - //Pass UNICODE instead of ASCII. -#if defined( _UNICODE ) - #define GC_TCHAR GC_UNICODE -#else - #define GC_TCHAR 0 -#endif +#define GC_BOLD 0x0001 // enable the 'bold' button +#define GC_ITALICS 0x0002 // enable the 'italics' button +#define GC_UNDERLINE 0x0004 // enable the 'underline' button +#define GC_COLOR 0x0008 // enable the 'foreground color' button +#define GC_BKGCOLOR 0x0010 // enable the 'background color' button +#define GC_ACKMSG 0x0020 // the protocol must acknowlege messages sent +#define GC_TYPNOTIF 0x0040 // enable typing notifications. +#define GC_CHANMGR 0x0080 // enable the 'channel settings' button +#define GC_SINGLEFORMAT 0x0100 // the protocol supports only 1 formatting per message +#define GC_FONTSIZE 0x0200 // enable font size selection // Error messages #define GC_REGISTER_WRONGVER 1 // You appear to be using the wrong version of this API. Registration failed. @@ -153,22 +145,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // is not installed and GC_UNICODE is set. Registration failed // GCREGISTER struct -typedef struct { +struct GCREGISTER +{ int cbSize; // Set to sizeof(GCREGISTER); DWORD dwFlags; // Use GC_* flags above to indicate features supported LPCSTR pszModule; // This MUST be the protocol name as registered with Miranda IM - union { - LPCSTR pszModuleDispName; //This is the protocol's real name as it will be displayed to the user - LPCTSTR ptszModuleDispName; // used if GC_TCHAR flag is passed - }; + LPCTSTR ptszDispName; // used if GC_TCHAR flag is passed int iMaxText; // Max message length the protocol supports. Will limit the typing area input. 0 = no limit int nColors; // Number of colors in the colorchooser menu for the color buttons. Max = 100 COLORREF* pColors; // pointer to the first item in a static COLORREF array containing the colors // that should be showed in the colorchooser menu. // ie: COLORREF crCols[nColors]; - // pColors = &crCols[0]; -} - GCREGISTER; + // pColors = &crCols[0]; +}; #define MS_GC_REGISTER "GChat/Register" @@ -193,33 +182,23 @@ typedef struct { #define GCW_PRIVMESS 3 // NOT SUPPORTED YET! the session is a 1 to 1 session, but with additional // support for adding more users etc. ex "MSN session". - // Error messages #define GC_NEWSESSION_WRONGVER 1 // You appear to be using the wrong version of this API. #define GC_NEWSESSION_ERROR 2 // An internal error occurred. - // GCSESSION structure -typedef struct { - int cbSize; // Set to sizeof(GCSESSION); - int iType; // Use one of the GCW_* flags above to set the type of session +struct GCSESSION +{ + int cbSize; // set to sizeof(GCSESSION); + int iType; // Use one of the GCW_* flags above to set the type of session LPCSTR pszModule; // The name of the protocol owning the session (the same as pszModule when you register) - union { - LPCSTR pszName; // The name of the session as it will be displayed to the user - LPCTSTR ptszName; - }; - union { - LPCSTR pszID; // The unique identifier for the session. - LPCTSTR ptszID; - }; - union { - LPCSTR pszStatusbarText; // Optional text to set in the statusbar of the chat room window, or NULL. - LPCTSTR ptszStatusbarText; - }; - DWORD dwFlags; - DWORD dwItemData; // Set user defined data for this session. Retrieve it by using the GC_EVENT_GETITEMDATA event - } - GCSESSION; + LPCTSTR ptszName; // The name of the session as it will be displayed to the user + LPCTSTR ptszID; // The unique identifier for the session. + LPCTSTR ptszStatusbarText; // Optional text to set in the statusbar of the chat room window, or NULL. + DWORD dwFlags; + INT_PTR dwItemData; // Set user defined data for this session. Retrieve it by using the GC_EVENT_GETITEMDATA event +}; + #define MS_GC_NEWSESSION "GChat/NewChat" /* @@ -440,64 +419,48 @@ typedef struct { // do that as it will override any settings the user has made in the Chat options // NOTE 3: If pszID (of GCDEST) = NULL then this message will be broadcasted to all sessions, which can be usefule for terminating // all sessions when the protocol was disconnected -#define SESSION_INITDONE 1 //send this when the session is fully set up (all users have ben added to the nicklist) -#define SESSION_TERMINATE 7 //send to terminate a session and close the window associated with it -#define SESSION_OFFLINE 8 //send to set the session as "online" (hContact is set to Online etc) -#define SESSION_ONLINE 9 //send to set the session as "offline" (hContact is set to Offline etc) -//------------ -#define WINDOW_VISIBLE 2 //make the room window visible -#define WINDOW_HIDDEN 3 //close the room window. Session is not terminated. -#define WINDOW_MAXIMIZE 4 //make the room window maximized -#define WINDOW_MINIMIZE 5 //make the room window minimized -#define WINDOW_CLEARLOG 6 //clear the log of the room window +#define SESSION_INITDONE 1 // send this when the session is fully set up (all users have ben added to the nicklist) +#define SESSION_TERMINATE 7 // send to terminate a session and close the window associated with it +#define SESSION_OFFLINE 8 // send to set the session as "online" (hContact is set to Online etc) +#define SESSION_ONLINE 9 // send to set the session as "offline" (hContact is set to Offline etc) + +#define WINDOW_VISIBLE 2 // make the room window visible +#define WINDOW_HIDDEN 3 // close the room window. Session is not terminated. +#define WINDOW_MAXIMIZE 4 // make the room window maximized +#define WINDOW_MINIMIZE 5 // make the room window minimized +#define WINDOW_CLEARLOG 6 // clear the log of the room window #define GC_EVENT_CONTROL 0x1005 // Error messages -#define GC_EVENT_WRONGVER 1 //You appear to be using the wrong version of this API. -#define GC_EVENT_ERROR 2 //An internal error occurred. +#define GC_EVENT_WRONGVER 1 // You appear to be using the wrong version of this API. +#define GC_EVENT_ERROR 2 // An internal error occurred. // The GCDEST structure. It is passed to Chat inside GCEVENT. -typedef struct { - LPSTR pszModule; // Name of the protocol (same as you registered with) - LPTSTR ptszID; // Unique identifier of the session, or NULL to broadcast to all sessions as specified above - int iType; // Use GC_EVENT_* as defined above. Only one event per service call. -} - GCDEST; +struct GCDEST +{ + LPSTR pszModule; // Name of the protocol (same as you registered with) + LPTSTR ptszID; // Unique identifier of the session, or NULL to broadcast to all sessions as specified above + int iType; // Use GC_EVENT_* as defined above. Only one event per service call. +}; // The GCEVENT structure -typedef struct { - int cbSize; // Set to sizeof(GCEVENT); +struct GCEVENT +{ + int cbSize; // set to sizeof(GCEVENT); GCDEST *pDest; // pointer to a GCDEST structure which specifies the session to receive the event - union { - const char *pszText; // usage depends on type of event, max 2048 characters - const TCHAR *ptszText; - }; - union { - LPCSTR pszNick; // usage depends on type of event - LPCTSTR ptszNick; - }; - union { - LPCSTR pszUID; // usage depends on type of event, Do NOT use spaces for unique user identifiers. - LPCTSTR ptszUID; - }; - union { - LPCSTR pszStatus; // usage depends on type of event - LPCTSTR ptszStatus; - }; - union { - LPCSTR pszUserInfo; // Additional user information that is displayed after the nickname. - LPCTSTR ptszUserInfo; - }; - // IRC use it to display a hostmask for JOIN, PART (and more) events. - BOOL bIsMe; // Is this event from the Miranda user? - DWORD dwFlags; // event flags: GCEF_ADDTOLOG, GCEF_NOTNOTIFY, GC_UNICODE - - // FALSE any other time than when initializing the window (before sending SESSION_INITDONE) - DWORD_PTR dwItemData; // User specified data. + LPCTSTR ptszText; // + LPCTSTR ptszNick; // + LPCTSTR ptszUID; // + LPCTSTR ptszStatus; // + LPCTSTR ptszUserInfo; // + + BOOL bIsMe; // Is this event from the Miranda user? + DWORD dwFlags; // event flags: GCEF_ADDTOLOG, GCEF_NOTNOTIFY + + INT_PTR dwItemData; // User specified data. DWORD time; // Timestamp of the event -} - GCEVENT; +}; #define MS_GC_EVENT "GChat/NewEvent" @@ -539,22 +502,21 @@ typedef struct { #define COUNT 0x0080 // iCount is valid #define USERS 0x0100 // pszUsers is valid - // The GC_INFO structure -typedef struct { +struct GC_INFO +{ DWORD Flags; // use a combination of the above flags int iItem; // session type (GCW_*) int iType; // session type (GCW_*) LPSTR pszModule; // the module name as registered in MS_GC_REGISTER LPTSTR pszID; // unique ID of the session - TCHAR* pszName; // display name of the session - DWORD_PTR dwItemData; // user specified data. + LPTSTR pszName; // display name of the session + INT_PTR dwItemData; // user specified data. int iCount; // count of users in the nicklist - char* pszUsers; // space separated string containing the UID's of the users in the user list. + LPSTR pszUsers; // space separated string containing the UID's of the users in the user list. // NOTE. Use Mirandas mmi_free() on the returned string. HANDLE hContact; // hContact for the session (can be NULL) -} - GC_INFO; +}; #define MS_GC_GETINFO "GChat/GetInfo" @@ -583,19 +545,13 @@ typedef struct { // should take action, but MSN may want to terminate the session here) #define ME_GC_EVENT "GChat/OutgoingEvent" -typedef struct { +struct GCHOOK +{ GCDEST *pDest; // pointer to a GCDEST structure which specifies from which session the hook was triggered - union { - char *pszText; // usage depends on type of event - TCHAR *ptszText; - }; - union { - char *pszUID; // unique identifier, usage depends on type of event - TCHAR *ptszUID; - }; - DWORD_PTR dwData; // user defined data, usage depends on type of event -} - GCHOOK; + TCHAR *ptszText; // usage depends on type of event + TCHAR *ptszUID; // unique identifier, usage depends on type of event + INT_PTR dwData; // user defined data, usage depends on type of event +}; /* -- Build the pop up menus -- @@ -636,9 +592,9 @@ struct gc_item { }; typedef struct { - char *pszModule; // Contains the protocol name, do NOT change. - TCHAR *pszID; // The unique identifier of the session that triggered the hook, do NOT change. - TCHAR *pszUID; // Contains the unique identifier if Type = MENU_ON_NICKLIST. do NOT change. + LPSTR pszModule; // Contains the protocol name, do NOT change. + LPTSTR pszID; // The unique identifier of the session that triggered the hook, do NOT change. + LPTSTR pszUID; // Contains the unique identifier if Type = MENU_ON_NICKLIST. do NOT change. int Type; // Type of menu. MENU_ON_* flags used. do NOT change. int nItems; // Set this to the number of menu items you want to add gc_item *Item; // pointer to the first in the array of gc_item's diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index d586923033..48f861b2c9 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -856,7 +856,7 @@ HANDLE CAppletManager::SendMessageToContact(HANDLE hContact,tstring strMessage) if(pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) { - GCDEST gcd = {0}; + GCDEST gcd = { szProto, 0, GC_EVENT_SENDMESSAGE }; DBVARIANT dbv; if (!db_get_ts((HANDLE)hContact, szProto, "Nick", &dbv)) @@ -866,11 +866,8 @@ HANDLE CAppletManager::SendMessageToContact(HANDLE hContact,tstring strMessage) tstring strID = tstring(gcd.ptszID) + _T(" - ") + tstring(_A2T(toNarrowString(pIRCCon->strNetwork).c_str())); gcd.ptszID = (LPTSTR)strID.c_str(); - gcd.pszModule = szProto; - gcd.iType = GC_EVENT_SENDMESSAGE; GCEVENT gce = { sizeof(gce), &gcd }; - gce.dwFlags = GC_TCHAR; gce.ptszStatus = _T(""); gce.ptszText = (LPTSTR)strAscii.c_str(); gce.time = time(NULL); diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index 40510ee3b1..d69a97f987 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -142,41 +142,11 @@ void PasteIt(HANDLE hContact, int mode) // PSS_MESSAGE is not compatible with chat rooms // there are no simple method to send text to all users // in chat room. - // First I check if protocol is unicode or ascii. - BOOL isUnicodePlugin = TRUE; - PROTOACCOUNT* protoAc = ProtoGetAccount(szProto); - if(protoAc != NULL) - { - // protoAc->ppro is abstract class, that contains - // methods implemented in protocol ddl`s segment. - // Method address in vptr table must be converted - // to hInstance of protocol dll. - PROTO_INTERFACE* protoInt = protoAc->ppro; - MEMORY_BASIC_INFORMATION mb; - INT_PTR *vptr = *(INT_PTR**)&protoAc->ppro; - INT_PTR *vtable = (INT_PTR *)*vptr; - if(VirtualQuery((void*)vtable[0], &mb, sizeof(MEMORY_BASIC_INFORMATION))) - { - typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_InfoEx) ( DWORD mirandaVersion ); - HINSTANCE hInst = (HINSTANCE)mb.AllocationBase; - // Now I can get PLUGININFOEX from protocol - Miranda_Plugin_InfoEx infoEx = (Miranda_Plugin_InfoEx) GetProcAddress(hInst, "MirandaPluginInfoEx"); - PLUGININFOEX* pi = NULL; - if(infoEx != NULL) - pi = infoEx(gMirandaVersion); - - // If PLUGININFOEX flags contains UNICODE_AWARE, - // this mean that protocol is unicode. - if(pi != NULL && pi->cbSize == sizeof(PLUGININFOEX)) - isUnicodePlugin = pi->flags & UNICODE_AWARE; - } - } - // Next step is to get all protocol sessions and find // one with correct hContact GC_INFO gci = {0}; - GCDEST gcd = {0}; - GCEVENT gce = {0}; + GCDEST gcd = { szProto, NULL, GC_EVENT_SENDMESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)szProto); for (int i = 0; i < cnt ; i++ ) { @@ -189,29 +159,13 @@ void PasteIt(HANDLE hContact, int mode) // In this place session was finded, gci.pszID contains // session ID, but it is in unicode or ascii format, // depends on protocol wersion - gcd.pszModule = szProto; - gcd.iType = GC_EVENT_SENDMESSAGE; gcd.ptszID = gci.pszID; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; gce.bIsMe = TRUE; - gce.dwFlags = isUnicodePlugin ? (GCEF_ADDTOLOG | GC_UNICODE) : GCEF_ADDTOLOG; - wchar_t* s = NULL; - if(isUnicodePlugin) - { - // If session ID is in unicode, text must be too in unicode - s = mir_a2u_cp(pasteToWeb->szFileLink, CP_ACP); - gce.ptszText = s; - } - else - { - // If session ID is in ascii, text must be too in ascii - gce.pszText = pasteToWeb->szFileLink; - } + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszText = mir_a2u_cp(pasteToWeb->szFileLink, CP_ACP); gce.time = time(NULL); CallService(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce); - if(s != NULL) - mir_free(s); + mir_free((void*)gce.ptszText); break; } } diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h index e88221baae..0532333508 100644 --- a/plugins/Scriver/src/chat/chat.h +++ b/plugins/Scriver/src/chat/chat.h @@ -334,37 +334,37 @@ int Chat_IconsChanged(WPARAM wParam,LPARAM lParam); void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground); //manager.c -void SetActiveSession(const TCHAR* pszID, const char* pszModule); +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); +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); 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); +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_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); +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); +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); @@ -373,7 +373,7 @@ 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_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); @@ -412,15 +412,15 @@ int WCCmp(TCHAR* wild, TCHAR*string); //tools.c TCHAR* RemoveFormatting(const TCHAR* pszText); -BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix); +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 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); @@ -429,7 +429,5 @@ TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si); ////////////////////////////////////////////////////////////////////////////////// -TCHAR* a2tf(const TCHAR *str, int flags); - #define DEFLOGFILENAME _T("%miranda_logpath%\\%proto%\\%userid%.log") #endif diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp index 02c6854f88..cf98e7412d 100644 --- a/plugins/Scriver/src/chat/manager.cpp +++ b/plugins/Scriver/src/chat/manager.cpp @@ -30,7 +30,7 @@ SESSION_INFO* m_WndList = 0; TABLIST * g_TabList = 0; MODULEINFO *m_ModList = 0; -void SetActiveSession(const TCHAR* pszID, const char* pszModule) +void SetActiveSession(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); if ( si ) @@ -60,7 +60,7 @@ SESSION_INFO* GetActiveSession( void ) // Keeps track of all sessions and its windows //--------------------------------------------------- -SESSION_INFO* SM_AddSession( const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_AddSession( const TCHAR *pszID, const char* pszModule) { if ( !pszID || !pszModule ) return NULL; @@ -84,7 +84,7 @@ SESSION_INFO* SM_AddSession( const TCHAR* pszID, const char* pszModule) return NULL; } -int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeContact) +int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL removeContact) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -154,7 +154,7 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta return FALSE; } -SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *pTemp = m_WndList; @@ -183,7 +183,7 @@ HWND SM_FindWindowByContact(HANDLE hContact) return NULL; } -BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) +BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -208,7 +208,7 @@ BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) return TRUE; } -BOOL SM_SetStatusEx( const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags ) +BOOL SM_SetStatusEx( const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags ) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -282,7 +282,7 @@ HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return GetCachedIcon("chat_status0"); } -BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce) +BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; int bManyFix = 0; @@ -311,7 +311,7 @@ BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce) return 0; } -BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT * gce, BOOL bIsHighlighted) +BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -353,7 +353,7 @@ USERINFO * SM_AddUser( SESSION_INFO * si, const TCHAR* pszUID, const TCHAR* pszN return p; } -BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID) { SESSION_INFO *pTemp = m_WndList; @@ -371,7 +371,7 @@ BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) return FALSE; } -BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -401,7 +401,7 @@ BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return 0; } -USERINFO * SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index) +USERINFO * SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index) { SESSION_INFO *pTemp = m_WndList; @@ -418,7 +418,7 @@ USERINFO * SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int in } -STATUSINFO * SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus) +STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -439,7 +439,7 @@ STATUSINFO * SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR return 0; } -BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -463,7 +463,7 @@ BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return FALSE; } -BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) +BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) { SESSION_INFO* pTemp = m_WndList, *pLast = NULL; @@ -487,7 +487,7 @@ BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* return FALSE; } -BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -510,7 +510,7 @@ BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return FALSE; } -LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -530,7 +530,7 @@ LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPAR return 0; } -BOOL SM_PostMessage(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) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -573,7 +573,7 @@ BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM return TRUE; } -BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) +BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -602,7 +602,7 @@ BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) return TRUE; } -BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText) +BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -623,7 +623,7 @@ BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* } -BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID) +BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; @@ -646,7 +646,7 @@ BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID } -BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce) +BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; diff --git a/plugins/Scriver/src/chat/services.cpp b/plugins/Scriver/src/chat/services.cpp index cf6b644971..7bdc353d4b 100644 --- a/plugins/Scriver/src/chat/services.cpp +++ b/plugins/Scriver/src/chat/services.cpp @@ -26,22 +26,6 @@ HANDLE hBuildMenuEvent ; HANDLE g_hHookContactDblClick, g_hHookPrebuildMenu; CRITICAL_SECTION cs; -#ifdef _WIN64 - -#define SIZEOF_STRUCT_GCREGISTER_V1 40 -#define SIZEOF_STRUCT_GCWINDOW_V1 48 -#define SIZEOF_STRUCT_GCEVENT_V1 76 -#define SIZEOF_STRUCT_GCEVENT_V2 80 - -#else - -#define SIZEOF_STRUCT_GCREGISTER_V1 28 -#define SIZEOF_STRUCT_GCWINDOW_V1 32 -#define SIZEOF_STRUCT_GCEVENT_V1 44 -#define SIZEOF_STRUCT_GCEVENT_V2 48 - -#endif - int Chat_SmileyOptionsChanged(WPARAM wParam,LPARAM lParam) { SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE); @@ -107,10 +91,8 @@ static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam) 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 (si->dwFlags & GC_UNICODE) { - if (gci->Flags & ID) gci->pszID = si->ptszID; - if (gci->Flags & NAME) gci->pszName = si->ptszName; - } + if (gci->Flags & ID) gci->pszID = si->ptszID; + if (gci->Flags & NAME) gci->pszName = si->ptszName; return 0; } @@ -140,24 +122,24 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) if (gcr == NULL) return GC_REGISTER_ERROR; - if (gcr->cbSize != SIZEOF_STRUCT_GCREGISTER_V1) + if (gcr->cbSize != sizeof(GCREGISTER)) return GC_REGISTER_WRONGVER; mir_cslock lock(cs); - MODULEINFO *mi = MM_AddModule( gcr->pszModule ); + MODULEINFO *mi = MM_AddModule(gcr->pszModule); if (mi == NULL) return GC_REGISTER_ERROR; - mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags ); - 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->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) { @@ -176,18 +158,15 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) if (gcw == NULL) return GC_NEWSESSION_ERROR; - if (gcw->cbSize != SIZEOF_STRUCT_GCWINDOW_V1) + 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; - TCHAR *ptszID = a2tf( gcw->ptszID, gcw->dwFlags ); - SESSION_INFO *si = SM_AddSession( ptszID, gcw->pszModule); - + SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule); if (mi->hOfflineIcon == NULL) LoadModuleIcons(mi); @@ -200,19 +179,14 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) si->wStatus = ID_STATUS_ONLINE; si->iType = gcw->iType; si->dwFlags = gcw->dwFlags; - si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags ); - si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, 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 ( !(gcw->dwFlags & GC_UNICODE)) { - si->pszID = mir_strdup( gcw->pszID ); - si->pszName = mir_strdup( gcw->pszName ); - } - if (mi->bColor) { si->iFG = 4; si->bFGSet = TRUE; @@ -225,10 +199,10 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) 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, ptszID, szTemp, si->iType); - si->windowData.codePage = db_get_w(si->windowData.hContact, si->pszModule, "CodePage", (WORD) CP_ACP); + 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_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); @@ -236,7 +210,7 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", ""); } else { - SESSION_INFO *si2 = SM_FindSession( ptszID, gcw->pszModule ); + SESSION_INFO *si2 = SM_FindSession(gcw->ptszID, gcw->pszModule); if (si2) { UM_RemoveAll(&si2->pUsers); TM_RemoveAll(&si2->pStatuses); @@ -249,7 +223,6 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) } } - mir_free( ptszID ); return 0; } @@ -301,11 +274,11 @@ static INT_PTR DoControl(GCEVENT *gce, WPARAM wp) } 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->pszText) + 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->pszText) + 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); @@ -340,7 +313,7 @@ static INT_PTR DoControl(GCEVENT *gce, WPARAM wp) { SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0); } - else if (gce->pDest->iType == GC_EVENT_SENDMESSAGE && gce->pszText) + else if (gce->pDest->iType == GC_EVENT_SENDMESSAGE && gce->ptszText) { SM_SendUserMessage( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText); } @@ -353,7 +326,7 @@ static INT_PTR DoControl(GCEVENT *gce, WPARAM wp) return 0; } -static void AddUser(GCEVENT * gce) +static void AddUser(GCEVENT *gce) { SESSION_INFO *si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule); if (si == NULL) return; @@ -392,14 +365,12 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) { - GCEVENT *gce = (GCEVENT*)lParam, save_gce; - GCDEST save_gcd; + GCEVENT *gce = (GCEVENT*)lParam; SESSION_INFO *si; TCHAR* pWnd = NULL; char* pMod = NULL; BOOL bIsHighlighted = FALSE; BOOL bRemoveFlag = FALSE; - int iRetVal = GC_EVENT_ERROR; if (gce == NULL) return GC_EVENT_ERROR; @@ -408,24 +379,13 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (gcd == NULL) return GC_EVENT_ERROR; - if (gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2) + if (gce->cbSize != sizeof(GCEVENT)) return GC_EVENT_WRONGVER; - if ( !IsEventSupported(gcd->iType)) + if (!IsEventSupported(gcd->iType)) return GC_EVENT_ERROR; - EnterCriticalSection(&cs); - - if ( !( gce->dwFlags & GC_UNICODE)) { - save_gce = *gce; - save_gcd = *gce->pDest; - gce->pDest->ptszID = a2tf(gce->pDest->ptszID, gce->dwFlags); - gce->ptszUID = a2tf(gce->ptszUID, gce->dwFlags); - gce->ptszNick = a2tf(gce->ptszNick, gce->dwFlags); - gce->ptszStatus = a2tf(gce->ptszStatus, gce->dwFlags); - gce->ptszText = a2tf(gce->ptszText, gce->dwFlags); - gce->ptszUserInfo = a2tf(gce->ptszUserInfo, gce->dwFlags); - } + mir_cslock lck(cs); // Do different things according to type of event switch(gcd->iType) { @@ -435,8 +395,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (si && gce->dwItemData) si->hIcon = CopyIcon((HICON)gce->dwItemData); } - iRetVal = 0; - goto LBL_Exit; + return 0; case GC_EVENT_CHUID: case GC_EVENT_CHANGESESSIONAME: @@ -447,19 +406,17 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_ACK: case GC_EVENT_SENDMESSAGE : case GC_EVENT_SETSTATUSEX : - iRetVal = DoControl(gce, wParam); - goto LBL_Exit; + return DoControl(gce, wParam); case GC_EVENT_SETCONTACTSTATUS: - iRetVal = SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData); - goto LBL_Exit; + 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->pszText) { + 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 )) + if (db_get_b(NULL, "Chat", "TopicOnClist", 0)) db_set_ts(si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting(si->ptszTopic)); } } @@ -475,7 +432,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_MESSAGE: case GC_EVENT_ACTION: - if (!gce->bIsMe && gce->pDest->ptszID && gce->pszText) { + 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; @@ -508,18 +465,13 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) pWnd = si->ptszID; pMod = si->pszModule; } - else { - iRetVal = 0; - goto LBL_Exit; - } + else return 0; } else { // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc SM_AddEventToAllMatchingUID(gce); - if (!bRemoveFlag) { - iRetVal = 0; - goto LBL_Exit; - } + if (!bRemoveFlag) + return 0; } // add to log @@ -527,15 +479,11 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) 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)) { - iRetVal = 0; - goto LBL_Exit; - } + 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) { - iRetVal = 0; - goto LBL_Exit; - } + 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) @@ -549,40 +497,22 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) LogToFile(si, gce); } - if (!bRemoveFlag) { - iRetVal = 0; - goto LBL_Exit; - } + if (!bRemoveFlag) + return 0; } if (bRemoveFlag) - iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0; - -LBL_Exit: - LeaveCriticalSection(&cs); - - if ( !( gce->dwFlags & GC_UNICODE )) { - mir_free((void*)gce->ptszText); - mir_free((void*)gce->ptszNick); - mir_free((void*)gce->ptszUID); - mir_free((void*)gce->ptszStatus); - mir_free((void*)gce->ptszUserInfo); - mir_free((void*)gce->pDest->ptszID); - *gce = save_gce; - *gce->pDest = save_gcd; - } + return SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0; - return iRetVal; + return GC_EVENT_ERROR; } static INT_PTR Service_GetAddEventPtr(WPARAM wParam, LPARAM lParam) { - GCPTRS * gp = (GCPTRS *) lParam; - - EnterCriticalSection(&cs); + GCPTRS *gp = (GCPTRS*)lParam; + mir_cslock lck(cs); gp->pfnAddEvent = Service_AddEvent; - LeaveCriticalSection(&cs); return 0; } diff --git a/plugins/Scriver/src/chat/tools.cpp b/plugins/Scriver/src/chat/tools.cpp index 90f9f447ad..7fe38bb5e5 100644 --- a/plugins/Scriver/src/chat/tools.cpp +++ b/plugins/Scriver/src/chat/tools.cpp @@ -143,7 +143,7 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP return PUAddPopupT(&pd); } -static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) +static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { int iEvent = gce->pDest->iType; @@ -169,10 +169,10 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) 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->pszText); + 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->pszStatus, gce->ptszNick, si->ptszName); + 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); @@ -184,10 +184,10 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) 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->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + 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->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + 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; } } @@ -195,7 +195,7 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) return TRUE; } -static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) +static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { int iEvent = gce->pDest->iType; @@ -217,13 +217,13 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) 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->pszText) + 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->pszText) + 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)); @@ -232,10 +232,10 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) 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->pszText) - ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), (char*)gce->pszStatus, gce->ptszNick); + 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)"), (char*)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + 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)); @@ -250,10 +250,10 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) 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, (char*)gce->pszStatus, gce->ptszNick); + 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, (char*)gce->pszStatus, gce->ptszNick); + 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; } } @@ -261,7 +261,7 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) return TRUE; } -BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix) +BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix) { if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER) return FALSE; @@ -484,7 +484,7 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) return FALSE; } -BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) +BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) { TCHAR szBuffer[4096]; TCHAR szLine[4096]; @@ -524,8 +524,8 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) } else lstrcpyn(szTemp2, gce->ptszNick, 511); - if (gce->pszUserInfo) - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->pszUserInfo); + 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; @@ -543,21 +543,21 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_JOIN: p = '>'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char*)pszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), pszNick); break; case GC_EVENT_PART: p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char*)pszNick); + if (!gce->ptszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), pszNick); else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char*)pszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), pszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_QUIT: p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char*)pszNick); + if (!gce->ptszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), pszNick); else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char*)pszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), pszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NICK: p = '^'; @@ -565,10 +565,10 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_KICK: p = '~'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char*)gce->pszStatus, gce->ptszNick); + 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)"), (char*)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NOTICE: p = 'o'; @@ -576,7 +576,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_TOPIC: p = '#'; - if (!gce->pszNick) + 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); @@ -587,11 +587,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_ADDSTATUS: p = '+'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; case GC_EVENT_REMOVESTATUS: p = '-'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; } if (p) @@ -701,8 +701,7 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); for (int i = 0; i < gcmi.nItems; i++) { - TCHAR *ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags); - TCHAR *ptszText = TranslateTS(ptszDescr); + TCHAR *ptszText = TranslateTS(gcmi.Item[i].pszDesc); DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0; if (gcmi.Item[i].uType == MENU_NEWPOPUP) { @@ -725,8 +724,6 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_CHECK) AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); - - mir_free(ptszDescr); } return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); } @@ -744,70 +741,46 @@ 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 DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem) { - GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK)); - GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST)); - - replaceStr(gcd->pszModule, pszModule); SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) return FALSE; - if (!(si->dwFlags & GC_UNICODE)) { - gcd->ptszID = (LPTSTR)mir_t2a(pszID); - gch->pszUID = mir_t2a(pszUID); - gch->pszText = mir_t2a(pszText); - } - else { - replaceStrT(gcd->ptszID, pszID); - replaceStrT(gch->ptszUID, pszUID); - replaceStrT(gch->ptszText, pszText); - } - + GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST)); + replaceStr(gcd->pszModule, pszModule); + replaceStrT(gcd->ptszID, pszID); gcd->iType = iType; + + GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK)); + replaceStrT(gch->ptszUID, pszUID); + replaceStrT(gch->ptszText, pszText); gch->dwData = dwItem; gch->pDest = gcd; PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch); return TRUE; } -BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem) +BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem) { - GCHOOK gch = { 0 }; - GCDEST gcd = { 0 }; - - gcd.pszModule = (char*)pszModule; SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) return FALSE; - if (!(si->dwFlags & GC_UNICODE)) { - gcd.ptszID = (LPTSTR)mir_t2a(pszID); - gch.pszUID = mir_t2a(pszUID); - gch.pszText = mir_t2a(pszText); - } - else { - gcd.ptszID = mir_tstrdup(pszID); - gch.ptszUID = mir_tstrdup(pszUID); - gch.ptszText = mir_tstrdup(pszText); - } - - gcd.iType = iType; + GCDEST gcd = { (char*)pszModule, (LPTSTR)pszID, iType }; + GCHOOK gch = { 0 }; + gch.ptszUID = (LPTSTR)pszUID; + gch.ptszText = (LPTSTR)pszText; gch.dwData = dwItem; gch.pDest = &gcd; NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch); - - mir_free(gcd.ptszID); - mir_free(gch.ptszUID); - mir_free(gch.ptszText); return TRUE; } BOOL IsEventSupported(int eventType) { + // Supported events switch (eventType) { - // Supported events case GC_EVENT_JOIN: case GC_EVENT_PART: case GC_EVENT_QUIT: @@ -838,26 +811,6 @@ BOOL IsEventSupported(int eventType) return FALSE; } -TCHAR* a2tf(const TCHAR* str, int flags) -{ - if (str == NULL) - return NULL; - - if (flags & GC_UNICODE) - return mir_tstrdup(str); - - int codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); - - int cbLen = MultiByteToWideChar(codepage, 0, (char*)str, -1, 0, 0); - TCHAR *result = (TCHAR*)mir_alloc(sizeof(TCHAR)*(cbLen + 1)); - if (result == NULL) - return NULL; - - MultiByteToWideChar(codepage, 0, (char*)str, -1, result, cbLen); - result[cbLen] = 0; - return result; -} - TCHAR* GetChatLogsFilename(HANDLE hContact, time_t tTime) { REPLACEVARSARRAY rva[11]; diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index 8661fa0776..90f7700622 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -148,16 +148,10 @@ void CSend::svcSendChat() { gci.Flags = BYINDEX | HCONTACT | ID; CallService(MS_GC_GETINFO, 0, (LPARAM) &gci); if (gci.hContact == m_hContact) { - GCDEST gcd = {0}; - gcd.pszModule = m_pszProto; - gcd.iType = GC_EVENT_SENDMESSAGE; - gcd.ptszID = gci.pszID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.bIsMe = TRUE; - gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszText = m_szEventMsgT; gce.time = time(NULL); diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index 5f93dd1d64..2bba66c842 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -308,8 +308,6 @@ struct COLORCHOOSER #include "chatprototypes.h" #include "chat_resource.h" -TCHAR* a2tf(const TCHAR* str, int flags, DWORD cp = 0); - extern char *szChatIconString; #define DEFLOGFILENAME _T("%miranda_logpath%\\%proto%\\%userid%.log") diff --git a/plugins/TabSRMM/src/chat/chatprototypes.h b/plugins/TabSRMM/src/chat/chatprototypes.h index e709e40fc5..ace57346bf 100644 --- a/plugins/TabSRMM/src/chat/chatprototypes.h +++ b/plugins/TabSRMM/src/chat/chatprototypes.h @@ -68,43 +68,43 @@ INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam); HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup); //manager.c -void SetActiveSession(const TCHAR* pszID, const char* pszModule); +void 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_AddSession(const TCHAR *pszID, const char* pszModule); +int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, bool removeContact); void SM_RemoveContainer(TContainerData *pData); -SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule); -USERINFO* SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus); +SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule); +USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus); SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent); -BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID); -BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT *gce); -BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID); -BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule); +BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID); +BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce); +BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID); +BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule); HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO* ui, char* szIndicator); -BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus); -BOOL SM_SetStatusEx(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags ); -BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText); -STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus); +BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus); +BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags ); +BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText); +STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus); BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bisHighLight = FALSE); -BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted); -LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); -BOOL SM_PostMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted); +LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL SM_PostMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync); BOOL SM_RemoveAll (void); -BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); -BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD pszStatus); -BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); -BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID); -void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewCommand); -char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule); -char* SM_GetNextCommand(const TCHAR* pszID, const char* pszModule); +BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); +BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD pszStatus); +BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); +BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID); +void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand); +char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule); +char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule); int SM_GetCount(const char* pszModule); SESSION_INFO* SM_FindSessionByHWND(HWND h); SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h); SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem); char* SM_GetUsers(SESSION_INFO *si); -USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index); +USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index); BOOL SM_ReconfigureFilters(); BOOL SM_InvalidateLogDirectories(); MODULEINFO* MM_AddModule(const char* pszModule); @@ -113,7 +113,7 @@ 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_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); @@ -160,8 +160,8 @@ int GetRichTextLength(HWND hwnd); BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText); UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText); void DestroyGCMenu(HMENU *hMenu, int iIndex); -BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem); -BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem); +BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem); +BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem); BOOL IsEventSupported(int eventType); BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce); void Chat_SetFilters(SESSION_INFO *si); diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index 1b78cfcc8b..928a821a2d 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static SESSION_INFO *s_WndList = NULL; static MODULEINFO *s_ModList = NULL; -void SetActiveSession(const TCHAR* pszID, const char* pszModule) +void SetActiveSession(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si) @@ -59,7 +59,7 @@ SESSION_INFO* GetActiveSession(void) // Keeps track of all sessions and its windows //--------------------------------------------------- -SESSION_INFO* SM_AddSession(const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule) { if (!pszID || !pszModule) return NULL; @@ -89,7 +89,7 @@ SESSION_INFO* SM_AddSession(const TCHAR* pszID, const char* pszModule) return node; } -int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, bool removeContact) +int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, bool removeContact) { if (!pszModule) return FALSE; @@ -165,7 +165,7 @@ void SM_RemoveContainer(TContainerData *pContainer) si->pContainer = NULL; } -SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule) { if (!pszID || !pszModule) return NULL; @@ -177,7 +177,7 @@ SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule) return NULL; } -BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) +BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule) { if (!pszModule) return FALSE; @@ -197,7 +197,7 @@ BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) return TRUE; } -BOOL SM_SetStatusEx(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags) +BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags) { if (!pszModule) return FALSE; @@ -284,7 +284,7 @@ BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bIsHighLight) return 0; } -BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted) +BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted) { if (!pszID || !pszModule) return TRUE; @@ -317,7 +317,7 @@ BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT *gce, BOOL b return TRUE; } -USERINFO* SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus) +USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus) { if (!pszID || !pszModule) return NULL; @@ -332,7 +332,7 @@ USERINFO* SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* psz return 0; } -BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID) { if (!pszID || !pszModule || !pszUID) return FALSE; @@ -345,7 +345,7 @@ BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) return TRUE; } -BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID) { if (!pszModule || !pszUID) return FALSE; @@ -370,7 +370,7 @@ BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return 0; } -USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index) +USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index) { if (!pszModule) return NULL; @@ -382,7 +382,7 @@ USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int ind return UM_FindUserFromIndex(si->pUsers, index); } -STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus) +STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus) { if (!pszID || !pszModule) return NULL; @@ -397,7 +397,7 @@ STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* return ti; } -BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) { if (!pszID || !pszModule) return FALSE; @@ -415,7 +415,7 @@ BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return TRUE; } -BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) +BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) { if (!pszID || !pszModule) return FALSE; @@ -433,7 +433,7 @@ BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* return TRUE; } -BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) { if (!pszID || !pszModule) return FALSE; @@ -451,7 +451,7 @@ BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return TRUE; } -LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam) { for (SESSION_INFO *si = s_WndList; si && pszModule; si = si->next) { if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) { @@ -468,7 +468,7 @@ LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPAR return 0; } -BOOL SM_PostMessage(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) { if (!pszID || !pszModule) return 0; @@ -514,7 +514,7 @@ BOOL SM_InvalidateLogDirectories() return TRUE; } -BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) +BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus) { if (!pszModule) return FALSE; @@ -538,7 +538,7 @@ BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) return TRUE; } -BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText) +BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText) { if (!pszModule || !pszText) return FALSE; @@ -555,7 +555,7 @@ BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* return TRUE; } -BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID) +BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID) { if (!pszModule) return FALSE; @@ -574,7 +574,7 @@ BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID return TRUE; } -BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT *gce) +BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce) { if (!pszModule) return FALSE; @@ -640,7 +640,7 @@ BOOL SM_RemoveAll(void) return TRUE; } -void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewCommand) +void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand) { for (SESSION_INFO *si = s_WndList; si; si = si->next) { if (lstrcmpi(si->ptszID, pszID) == 0 && lstrcmpiA(si->pszModule, pszModule) == 0) { // match @@ -677,7 +677,7 @@ void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewC } } -char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was. +char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was. { SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) @@ -696,7 +696,7 @@ char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule) // get previo return pPrevCmd ? pPrevCmd->lpCommand : NULL; } -char* SM_GetNextCommand(const TCHAR* pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command) +char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 7eba873a60..41c9c9d5be 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -85,101 +85,76 @@ int Chat_IconsChanged(WPARAM wParam, LPARAM lParam) INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam) { - int i; - if (!lParam) return -1; - EnterCriticalSection(&cs); - - i = SM_GetCount((char *)lParam); - - LeaveCriticalSection(&cs); - return i; + mir_cslock lck(cs); + return SM_GetCount((char *)lParam); } INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam) { - GC_INFO * gci = (GC_INFO *) lParam; - SESSION_INFO *si = NULL; - + GC_INFO *gci = (GC_INFO *) lParam; if (!gci || !gci->pszModule) return 1; - EnterCriticalSection(&cs); - - if (gci->Flags&BYINDEX) + mir_cslock lck(cs); + SESSION_INFO *si; + if (gci->Flags & BYINDEX) si = SM_FindSessionByIndex(gci->pszModule, gci->iItem); else si = SM_FindSession(gci->pszID, gci->pszModule); + if (si == NULL) + return 1; - if (si) { - if (gci->Flags & DATA) gci->dwItemData = si->dwItemData; - if (gci->Flags & HCONTACT) gci->hContact = si->hContact; - if (gci->Flags & TYPE) gci->iType = si->iType; - if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist; - if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si); - - if (si->dwFlags & GC_UNICODE) { - if (gci->Flags & ID) gci->pszID = si->ptszID; - if (gci->Flags & NAME) gci->pszName = si->ptszName; - } - else { - if (gci->Flags & ID) gci->pszID = (TCHAR*)si->pszID; - if (gci->Flags & NAME) gci->pszName = (TCHAR*)si->pszName; - } - LeaveCriticalSection(&cs); - return 0; - } + if (gci->Flags & DATA) gci->dwItemData = si->dwItemData; + if (gci->Flags & HCONTACT) gci->hContact = si->hContact; + if (gci->Flags & TYPE) gci->iType = si->iType; + if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist; + if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si); - LeaveCriticalSection(&cs); - return 1; + if (gci->Flags & ID) gci->pszID = si->ptszID; + if (gci->Flags & NAME) gci->pszName = si->ptszName; + return 0; } INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) { GCREGISTER *gcr = (GCREGISTER *)lParam; - MODULEINFO * mi = NULL; if (gcr == NULL) return GC_REGISTER_ERROR; if (gcr->cbSize != sizeof(GCREGISTER)) return GC_REGISTER_WRONGVER; - EnterCriticalSection(&cs); - - mi = MM_AddModule(gcr->pszModule); - if (mi) { - mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags); - mi->bBold = (gcr->dwFlags & GC_BOLD) != 0; - mi->bUnderline = (gcr->dwFlags & GC_UNDERLINE) != 0; - mi->bItalics = (gcr->dwFlags & GC_ITALICS) != 0; - mi->bColor = (gcr->dwFlags & GC_COLOR) != 0; - mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0; - mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0; - mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0 ; - mi->iMaxText = gcr->iMaxText; - mi->nColorCount = gcr->nColors; - if (gcr->nColors > 0) { - mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors); - memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors); - } - mi->pszHeader = 0; - - CheckColorsInModule((char*)gcr->pszModule); - CList_SetAllOffline(TRUE, gcr->pszModule); + mir_cslock lck(cs); + MODULEINFO *mi = MM_AddModule(gcr->pszModule); + if (mi == NULL) + return GC_REGISTER_ERROR; - LeaveCriticalSection(&cs); - return 0; + mi->ptszModDispName = mir_tstrdup(gcr->ptszDispName); + mi->bBold = (gcr->dwFlags & GC_BOLD) != 0; + mi->bUnderline = (gcr->dwFlags & GC_UNDERLINE) != 0; + mi->bItalics = (gcr->dwFlags & GC_ITALICS) != 0; + mi->bColor = (gcr->dwFlags & GC_COLOR) != 0; + mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0; + mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0; + mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0; + mi->iMaxText = gcr->iMaxText; + mi->nColorCount = gcr->nColors; + if (gcr->nColors > 0) { + mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF)* gcr->nColors); + memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors); } + mi->pszHeader = 0; - LeaveCriticalSection(&cs); - return GC_REGISTER_ERROR; + CheckColorsInModule((char*)gcr->pszModule); + CList_SetAllOffline(TRUE, gcr->pszModule); + return 0; } INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) { - MODULEINFO *mi; GCSESSION *gcw = (GCSESSION *)lParam; if (gcw == NULL) return GC_NEWSESSION_ERROR; @@ -187,77 +162,66 @@ INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) if (gcw->cbSize != sizeof(GCSESSION)) return GC_NEWSESSION_WRONGVER; - EnterCriticalSection(&cs); - - if ((mi = MM_FindModule(gcw->pszModule)) != NULL) { - TCHAR* ptszID = a2tf(gcw->ptszID, gcw->dwFlags); - SESSION_INFO *si = SM_AddSession(ptszID, gcw->pszModule); - - // create a new session and set the defaults - if (si != NULL) { - TCHAR szTemp[256]; - - si->dwItemData = gcw->dwItemData; - if (gcw->iType != GCW_SERVER) - si->wStatus = ID_STATUS_ONLINE; - si->iType = gcw->iType; - si->dwFlags = gcw->dwFlags; - si->ptszName = a2tf(gcw->ptszName, gcw->dwFlags); - si->ptszStatusbarText = a2tf(gcw->ptszStatusbarText, gcw->dwFlags); - si->iSplitterX = g_Settings.iSplitterX; - si->bFilterEnabled = db_get_b(si->hContact, "Chat", "FilterEnabled", M.GetByte("Chat", "FilterEnabled", 0)) != 0; - si->bNicklistEnabled = M.GetByte("Chat", "ShowNicklist", 1) != 0; - if (!(gcw->dwFlags & GC_UNICODE)) { - si->pszID = mir_strdup(gcw->pszID); - si->pszName = mir_strdup(gcw->pszName); - } - - if (mi->bColor) { - si->iFG = 4; - si->bFGSet = TRUE; - } - if (mi->bBkgColor) { - si->iBG = 2; - si->bBGSet = TRUE; - } - if (si->iType == GCW_SERVER) - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName); - else - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName); - si->hContact = CList_AddRoom(gcw->pszModule, ptszID, szTemp, si->iType); - db_set_s(si->hContact, si->pszModule , "Topic", ""); - db_unset(si->hContact, "CList", "StatusMsg"); - if (si->ptszStatusbarText) - db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); - else - db_set_s(si->hContact, si->pszModule, "StatusBar", ""); - if (si->hContact) - Chat_SetFilters(si); + mir_cslock lck(cs); + MODULEINFO *mi = MM_FindModule(gcw->pszModule); + if (mi == NULL) + return GC_NEWSESSION_ERROR; + + // create a new session and set the defaults + SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule); + if (si != NULL) { + TCHAR szTemp[256]; + + si->dwItemData = gcw->dwItemData; + if (gcw->iType != GCW_SERVER) + si->wStatus = ID_STATUS_ONLINE; + si->iType = gcw->iType; + si->dwFlags = gcw->dwFlags; + si->ptszName = mir_tstrdup(gcw->ptszName); + si->ptszStatusbarText = mir_tstrdup(gcw->ptszStatusbarText); + si->iSplitterX = g_Settings.iSplitterX; + si->bFilterEnabled = db_get_b(si->hContact, "Chat", "FilterEnabled", M.GetByte("Chat", "FilterEnabled", 0)) != 0; + si->bNicklistEnabled = M.GetByte("Chat", "ShowNicklist", 1) != 0; + + if (mi->bColor) { + si->iFG = 4; + si->bFGSet = TRUE; } - else { - SESSION_INFO* si2 = SM_FindSession(ptszID, gcw->pszModule); - if (si2) { - - UM_RemoveAll(&si2->pUsers); - TM_RemoveAll(&si2->pStatuses); - - si2->iStatusCount = 0; - si2->nUsersInNicklist = 0; - - if (si2->hContact) - Chat_SetFilters(si2); - if (si2->hWnd) - RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); - } + if (mi->bBkgColor) { + si->iBG = 2; + si->bBGSet = TRUE; + } + if (si->iType == GCW_SERVER) + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName); + else + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName); + si->hContact = CList_AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType); + db_set_s(si->hContact, si->pszModule , "Topic", ""); + db_unset(si->hContact, "CList", "StatusMsg"); + if (si->ptszStatusbarText) + db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); + else + db_set_s(si->hContact, si->pszModule, "StatusBar", ""); + if (si->hContact) + Chat_SetFilters(si); + } + else { + SESSION_INFO* si2 = SM_FindSession(gcw->ptszID, gcw->pszModule); + if (si2) { + UM_RemoveAll(&si2->pUsers); + TM_RemoveAll(&si2->pStatuses); + + si2->iStatusCount = 0; + si2->nUsersInNicklist = 0; + + if (si2->hContact) + Chat_SetFilters(si2); + if (si2->hWnd) + RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); } - - LeaveCriticalSection(&cs); - mir_free(ptszID); - return 0; } - LeaveCriticalSection(&cs); - return GC_NEWSESSION_ERROR; + return 0; } static int DoControl(GCEVENT *gce, WPARAM wp) @@ -314,12 +278,12 @@ static int DoControl(GCEVENT *gce, WPARAM wp) break; case GC_EVENT_CHUID: - if (gce->pszText) + if (gce->ptszText) SM_ChangeUID(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText); break; case GC_EVENT_CHANGESESSIONAME: - if (gce->pszText) { + if (gce->ptszText) { si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { replaceStrT(si->ptszName, gce->ptszText); @@ -361,7 +325,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp) break; case GC_EVENT_SENDMESSAGE: - if (gce->pszText) + if (gce->ptszText) SM_SendUserMessage(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText); break; @@ -576,29 +540,12 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (!IsEventSupported(gcd->iType)) return GC_EVENT_ERROR; - int iRetVal = GC_EVENT_ERROR; LPCSTR pMod = NULL; LPCTSTR pWnd = NULL; - GCDEST save_gcd; - GCEVENT save_gce; SESSION_INFO *si = NULL; - bool bIsHighlighted = false, bRemoveFlag = false, bFreeText = false; - - if (!(gce->dwFlags & GC_UNICODE)) { - save_gce = *gce; - save_gcd = *gce->pDest; - gce->ptszUID = a2tf(gce->ptszUID, gce->dwFlags); - gce->ptszNick = a2tf(gce->ptszNick, gce->dwFlags); - gce->ptszStatus = a2tf(gce->ptszStatus, gce->dwFlags); - gce->pDest->ptszID = a2tf(gce->pDest->ptszID, gce->dwFlags); - if (gcd->iType != GC_EVENT_MESSAGE && gcd->iType != GC_EVENT_ACTION) { - gce->ptszText = a2tf(gce->ptszText, gce->dwFlags); - bFreeText = true; - } - gce->ptszUserInfo = a2tf(gce->ptszUserInfo, gce->dwFlags); - } + bool bIsHighlighted = false, bRemoveFlag = false; - EnterCriticalSection(&cs); + mir_cslock lck(cs); // Do different things according to type of event switch (gcd->iType) { @@ -608,8 +555,7 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (si && gce->dwItemData) si->hIcon = CopyIcon((HICON)gce->dwItemData); } - iRetVal = 0; - goto LBL_Exit; + return 0; case GC_EVENT_CHUID: case GC_EVENT_CHANGESESSIONAME: @@ -620,17 +566,15 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_ACK: case GC_EVENT_SENDMESSAGE : case GC_EVENT_SETSTATUSEX : - iRetVal = DoControl(gce, wParam); - goto LBL_Exit; + return DoControl(gce, wParam); case GC_EVENT_SETCONTACTSTATUS: - iRetVal = SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData); - goto LBL_Exit; + return SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData); case GC_EVENT_TOPIC: si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { - if (gce->pszText) { + if (gce->ptszText) { replaceStrT(si->ptszTopic, RemoveFormatting(gce->ptszText)); db_set_ts(si->hContact, si->pszModule , "Topic", /*RemoveFormatting*/(si->ptszTopic)); if (M.GetByte("Chat", "TopicOnClist", 1)) @@ -656,14 +600,7 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_MESSAGE: case GC_EVENT_ACTION: si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (!(gce->dwFlags & GC_UNICODE)) { - bFreeText = TRUE; - if (si) - gce->ptszText = a2tf(gce->ptszText, gce->dwFlags, M.GetDword(si->hContact, "ANSIcodepage", 0)); - else - gce->ptszText = a2tf(gce->ptszText, gce->dwFlags); - } - if (!gce->bIsMe && gce->pDest->ptszID && gce->pszText && si) + if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText && si) bIsHighlighted = si->Highlight->match(gce, si, CMUCHighlight::MATCH_TEXT | CMUCHighlight::MATCH_NICKNAME) != 0; break; @@ -699,18 +636,13 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) pWnd = si->ptszID; pMod = si->pszModule; } - else { - iRetVal = 0; - goto LBL_Exit; - } + else return 0; } else { // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc SM_AddEventToAllMatchingUID(gce, bIsHighlighted); - if (!bRemoveFlag) { - iRetVal = 0; - goto LBL_Exit; - } + if (!bRemoveFlag) + return 0; } // add to log @@ -719,63 +651,40 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) 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)) { - iRetVal = 0; - goto LBL_Exit; - } + 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) { - iRetVal = 0; - goto LBL_Exit; - } + 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) { + if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - } - else if (si->hWnd) { + else if (si->hWnd) SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); - } + if (!(gce->dwFlags & GCEF_NOTNOTIFY)) DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0); if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.bLoggingEnabled) LogToFile(si, gce); } - if (!bRemoveFlag) { - iRetVal = 0; - goto LBL_Exit; - } + if (!bRemoveFlag) + return 0; } if (bRemoveFlag) - iRetVal = (SM_RemoveUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID) == 0) ? 1 : 0; - -LBL_Exit: - LeaveCriticalSection(&cs); - - if (!(gce->dwFlags & GC_UNICODE)) { - if (bFreeText) - mir_free((void*)gce->ptszText); - mir_free((void*)gce->ptszNick); - mir_free((void*)gce->ptszUID); - mir_free((void*)gce->ptszStatus); - mir_free((void*)gce->ptszUserInfo); - mir_free((void*)gce->pDest->ptszID); - *gce = save_gce; - *gce->pDest = save_gcd; - } - return iRetVal; + return (SM_RemoveUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID) == 0) ? 1 : 0; + + return GC_EVENT_ERROR; } static INT_PTR Service_GetAddEventPtr(WPARAM wParam, LPARAM lParam) { GCPTRS * gp = (GCPTRS *) lParam; - EnterCriticalSection(&cs); - + mir_cslock lck(cs); gp->pfnAddEvent = Service_AddEvent; - LeaveCriticalSection(&cs); return 0; } diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index bc1e8bd2d1..b22c898352 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -262,11 +262,11 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_NICK: CList_AddEvent(si->hContact, hIcons[ICON_NICK], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s is now known as %s"), gce->ptszNick, gce->pszText); + TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); break; case GC_EVENT_KICK: CList_AddEvent(si->hContact, hIcons[ICON_KICK], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s kicked %s from %s"), gce->pszStatus, gce->ptszNick, si->ptszName); + TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName); break; case GC_EVENT_NOTICE: CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW, @@ -282,11 +282,11 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_ADDSTATUS: CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s enables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName); break; case GC_EVENT_REMOVESTATUS: CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s disables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName); break; } } @@ -368,7 +368,7 @@ passed: TranslateT("%s has joined"), gce->ptszNick); break; case GC_EVENT_PART: - if (!gce->pszText) + if (!gce->ptszText) ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color, TranslateT("%s has left"), gce->ptszNick); else @@ -376,7 +376,7 @@ passed: TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_QUIT: - if (!gce->pszText) + if (!gce->ptszText) ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick); else @@ -388,12 +388,12 @@ passed: TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); break; case GC_EVENT_KICK: - if (!gce->pszText) + if (!gce->ptszText) ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, - TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick); else ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, - TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NOTICE: ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, clr ? clr : aFonts[8].color, @@ -412,11 +412,11 @@ passed: break; case GC_EVENT_ADDSTATUS: ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[13].color, - TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; case GC_EVENT_REMOVESTATUS: ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[14].color, - TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; } } @@ -782,8 +782,8 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) } else lstrcpyn(szTemp2, gce->ptszNick, 511); - if (gce->pszUserInfo) - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->pszUserInfo); + 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; @@ -802,21 +802,21 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_JOIN: p = '>'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char *)pszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), pszNick); break; case GC_EVENT_PART: p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick); + if (!gce->ptszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), pszNick); else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), pszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_QUIT: p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick); + if (!gce->ptszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), pszNick); else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), pszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NICK: p = '^'; @@ -824,10 +824,10 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_KICK: p = '~'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + 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)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NOTICE: p = 'o'; @@ -835,7 +835,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_TOPIC: p = '#'; - if (!gce->pszNick) + 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); @@ -846,11 +846,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) break; case GC_EVENT_ADDSTATUS: p = '+'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; case GC_EVENT_REMOVESTATUS: p = '-'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick); break; } @@ -962,8 +962,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); for (int i=0; i < gcmi.nItems; i++) { - TCHAR *ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags); - TCHAR *ptszText = TranslateTS(ptszDescr); + TCHAR *ptszText = TranslateTS(gcmi.Item[i].pszDesc); DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0; if (gcmi.Item[i].uType == MENU_NEWPOPUP) { @@ -986,8 +985,6 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_CHECK) AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); - - mir_free(ptszDescr); } #if !defined(__DELAYED_FOR_3_1) @@ -998,19 +995,6 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO InsertMenu(*hMenu, pos, MF_BYPOSITION, (UINT_PTR)20021, TranslateT("Edit Highlight List...")); } #endif - if (iIndex == 1 && si->iType != GCW_SERVER && !(si->dwFlags & GC_UNICODE)) { - AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); - InsertMenu(PluginConfig.g_hMenuEncoding, 1, MF_BYPOSITION | MF_STRING, (UINT_PTR)CP_UTF8, TranslateT("UTF-8")); - int pos = GetMenuItemCount(*hMenu); - InsertMenu(*hMenu, pos, MF_BYPOSITION | MF_POPUP, (UINT_PTR) PluginConfig.g_hMenuEncoding, TranslateT("Character Encoding")); - for (int i=0; i < GetMenuItemCount(PluginConfig.g_hMenuEncoding); i++) - CheckMenuItem(PluginConfig.g_hMenuEncoding, i, MF_BYPOSITION | MF_UNCHECKED); - if (codepage == CP_ACP) - CheckMenuItem(PluginConfig.g_hMenuEncoding, 0, MF_BYPOSITION | MF_CHECKED); - else - CheckMenuItem(PluginConfig.g_hMenuEncoding, codepage, MF_BYCOMMAND | MF_CHECKED); - - } return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); } @@ -1026,7 +1010,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) +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); if (si == NULL) @@ -1035,18 +1019,9 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK)); GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST)); replaceStr(gcd->pszModule, pszModule); - - if (!(si->dwFlags & GC_UNICODE)) { - DWORD dwCP = M.GetDword(si->hContact, "ANSIcodepage", 0); - gcd->ptszID = (LPTSTR)mir_t2a(pszID); - gch->pszUID = mir_t2a(pszUID); - gch->pszText = mir_t2a_cp(pszText, dwCP); - } - else { - replaceStrT(gcd->ptszID, pszID); - replaceStrT(gch->ptszUID, pszUID); - replaceStrT(gch->ptszText, pszText); - } + replaceStrT(gcd->ptszID, pszID); + replaceStrT(gch->ptszUID, pszUID); + replaceStrT(gch->ptszText, pszText); gcd->iType = iType; gch->dwData = dwItem; gch->pDest = gcd; @@ -1054,35 +1029,19 @@ 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) +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; GCHOOK gch = {0}; - GCDEST gcd = {0}; - gcd.pszModule = (char*)pszModule; - - if (!(si->dwFlags & GC_UNICODE)) { - DWORD dwCP = M.GetDword(si->hContact, "ANSIcodepage", 0); - gcd.ptszID = (LPTSTR)mir_t2a(pszID); - gch.pszUID = mir_t2a(pszUID); - gch.pszText = mir_t2a_cp(pszText, dwCP); - } - else { - gcd.ptszID = mir_tstrdup(pszID); - gch.ptszUID = mir_tstrdup(pszUID); - gch.ptszText = mir_tstrdup(pszText); - } - gcd.iType = iType; + GCDEST gcd = { (char*)pszModule, (LPTSTR)pszID, iType }; + gch.ptszUID = (LPTSTR)pszUID; + gch.ptszText = (LPTSTR)pszText; gch.dwData = dwItem; gch.pDest = &gcd; NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch); - - mir_free(gcd.ptszID); - mir_free(gch.ptszUID); - mir_free(gch.ptszText); return TRUE; } @@ -1120,29 +1079,6 @@ BOOL IsEventSupported(int eventType) return FALSE; } -TCHAR* a2tf(const TCHAR* str, int flags, DWORD cp) -{ - if (str == NULL) - return NULL; - - if (flags & GC_UNICODE) - return mir_tstrdup(str); - - if (cp == CP_UTF8) - return mir_utf8decodeW((char*)str); - - if (cp == 0) - cp = PluginConfig.m_LangPackCP; - int cbLen = MultiByteToWideChar(cp, 0, (char*)str, -1, 0, 0); - TCHAR *result = (TCHAR*)mir_alloc(sizeof(TCHAR) * (cbLen + 1)); - if (result == NULL) - return NULL; - - MultiByteToWideChar(cp, 0, (char*)str, -1, result, cbLen); - result[cbLen] = 0; - return result; -} - /* * set all filters and notification config for a session * uses per channel mask + filterbits, default config as backup diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 5cd0acf84e..61b1dcd604 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2722,11 +2722,6 @@ LABEL_SHOWWINDOW: break; } - if (si->iType != GCW_SERVER && !(si->dwFlags & GC_UNICODE)) { - int pos = GetMenuItemCount(hMenu); - RemoveMenu(hMenu, pos - 1, MF_BYPOSITION); - RemoveMenu(PluginConfig.g_hMenuEncoding, 1, MF_BYPOSITION); - } DestroyGCMenu(&hMenu, 5); } } diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index e5a08ced1d..120a827b17 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -599,7 +599,7 @@ begin gce.pDest :=@gcd; gce.bIsMe :=true; gce.szText.w:=pszText; - gce.dwFlags :=GCEF_ADDTOLOG+GC_UNICODE; + gce.dwFlags :=GCEF_ADDTOLOG; gce.time :=GetCurrentTime; CallServiceSync(MS_GC_EVENT,0,lparam(@gce)); diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index 1c9f329486..f58f824016 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -21,13 +21,11 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; void CAimProto::chat_register(void) { - GCREGISTER gcr = {0}; - gcr.cbSize = sizeof(gcr); - gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR; - gcr.iMaxText = 0; + GCREGISTER gcr = { sizeof(gcr) }; + gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; gcr.nColors = 16; gcr.pColors = (COLORREF*)crCols; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); @@ -39,22 +37,15 @@ void CAimProto::chat_start(const char* id, unsigned short exchange) { TCHAR* idt = mir_a2t(id); - GCSESSION gcw = {0}; - gcw.cbSize = sizeof(gcw); - gcw.dwFlags = GC_TCHAR; + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = idt; gcw.ptszID = idt; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(gce); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = TranslateT("Me"); CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -81,12 +72,9 @@ void CAimProto::chat_event(const char* id, const char* sn, int evt, const TCHAR* TCHAR* nick = hContact ? (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), GCDNF_TCHAR) : snt; - GCDEST gcd = { m_szModuleName, { NULL }, evt }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(gce); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + GCDEST gcd = { m_szModuleName, idt, evt }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.pDest = &gcd; gce.ptszNick = nick; gce.ptszUID = snt; @@ -104,12 +92,8 @@ void CAimProto::chat_leave(const char* id) { TCHAR* idt = mir_a2t(id); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, idt, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.pDest = &gcd; CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 9744cb89dc..5315294fe7 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -30,22 +30,15 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char ptrT tnick( mir_a2t_cp(name,CP_UTF8)); ptrT ttext( mir_a2t_cp(message,CP_UTF8)); - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = (TCHAR *)tchat_id; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)tchat_id, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszText = ttext; - gce.time = timestamp ? timestamp : ::time(NULL); - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_MESSAGE; + gce.time = timestamp ? timestamp : ::time(NULL); if (id != NULL) gce.bIsMe = !strcmp(id,facy.self_.user_id.c_str()); - gce.dwFlags |= GCEF_ADDTOLOG; - + gce.dwFlags |= GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; - CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); std::map::iterator chatroom = facy.chat_rooms.find(tchat_id); @@ -60,15 +53,9 @@ void FacebookProto::RenameChat(const char *chat_id, const char *name) ptrT tchat_id( mir_a2t(chat_id)); ptrT tname( mir_a2t_cp(name, CP_UTF8)); - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = tchat_id; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_CHANGESESSIONAME }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszText = tname; - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_CHANGESESSIONAME; - CallService(MS_GC_EVENT, 0, reinterpret_cast(&gce)); } @@ -159,17 +146,14 @@ void FacebookProto::AddChatContact(const TCHAR *tchat_id, const char *id, const ptrT tnick( mir_a2t_cp(name, CP_UTF8)); ptrT tid( mir_a2t(id)); - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = (TCHAR *)tchat_id; - gcd.iType = GC_EVENT_JOIN; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.ptszNick = tnick; - gce.ptszUID = tid; - gce.time = ::time(NULL); - gce.bIsMe = !strcmp(id, facy.self_.user_id.c_str()); + GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.pDest = &gcd; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = tnick; + gce.ptszUID = tid; + gce.time = ::time(NULL); + gce.bIsMe = !strcmp(id, facy.self_.user_id.c_str()); if (gce.bIsMe) gce.ptszStatus = _T("Admin"); @@ -192,18 +176,12 @@ void FacebookProto::RemoveChatContact(const TCHAR *tchat_id, const char *id) ptrT tid( mir_a2t(id)); - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = (TCHAR *)tchat_id; - gcd.iType = GC_EVENT_PART; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - //gce.ptszNick = mir_a2t_cp(name, CP_UTF8); - gce.ptszUID = tid; - gce.ptszNick = tid; - gce.time = ::time(NULL); - gce.bIsMe = false;//!strcmp(id, facy.self_.user_id.c_str()); + GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_PART }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszUID = gce.ptszNick = tid; + gce.time = ::time(NULL); + gce.bIsMe = false;//!strcmp(id, facy.self_.user_id.c_str()); std::map::iterator room = facy.chat_rooms.find(tchat_id); if (room != facy.chat_rooms.end()) @@ -235,26 +213,19 @@ bool FacebookProto::IsChatContact(const TCHAR *chat_id, const char *id) void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname) { - GCSESSION gcw = {sizeof(gcw)}; - // Create the group chat session - gcw.dwFlags = GC_TCHAR; - gcw.iType = GCW_CHATROOM; + GCSESSION gcw = { sizeof(gcw) }; + gcw.iType = GCW_CHATROOM; + gcw.ptszID = tid; gcw.pszModule = m_szModuleName; - gcw.ptszName = tname; - gcw.ptszID = tid; + gcw.ptszName = tname; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); // Send setting events - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = (TCHAR *)tid; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)tid, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; // Create a user statuses - gcd.iType = GC_EVENT_ADDGROUP; gce.ptszStatus = _T("Admin"); CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast(&gce)); gce.ptszStatus = _T("Normal"); @@ -275,23 +246,6 @@ void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname) CallServiceSync(MS_GC_EVENT,SESSION_ONLINE, reinterpret_cast(&gce)); } -/*void FacebookProto::SetTopic(const char *topic) -{ - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_TOPIC; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - gce.time = ::time(NULL); - - std::string top = Translate(topic); - gce.ptszText = mir_a2t(top.c_str()); - CallServiceSync(MS_GC_EVENT,0, reinterpret_cast(&gce)); -} -*/ - INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress) { HANDLE hContact = (HANDLE)wParam; @@ -317,15 +271,8 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress) return 0; // Create a group - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - - gcd.iType = GC_EVENT_ADDGROUP; - + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = _T("Admin"); CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast(&gce)); @@ -343,18 +290,12 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress) INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = NULL; - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast(&gce)); CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast(&gce)); - return 0; } @@ -365,10 +306,8 @@ void FacebookProto::SetChatStatus(int status) gcd.ptszID = const_cast(m_tszUserName); gcd.iType = GC_EVENT_CONTROL; - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; if(status == ID_STATUS_ONLINE) { diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 86ab425c2d..bbe948120d 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -385,7 +385,7 @@ int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) GCREGISTER gcr = {sizeof(gcr)}; gcr.dwFlags = 0; //GC_ACKMSG; gcr.pszModule = m_szModuleName; - gcr.pszModuleDispName = m_szModuleName; + gcr.ptszDispName = m_tszUserName; gcr.iMaxText = FACEBOOK_MESSAGE_LIMIT; gcr.nColors = 0; gcr.pColors = NULL; diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 26a0f6d477..938e1dead2 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -826,21 +826,19 @@ retry: if (chat) { TCHAR id[32]; - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = chat; - gcdest.iType = GC_EVENT_MESSAGE; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - time_t t = time(NULL); UIN2IDT(e->event.msg.sender, id); - gcevent.ptszUID = id; + + GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + time_t t = time(NULL); + gce.ptszUID = id; TCHAR* messageT = mir_utf8decodeT(e->event.msg.message); - gcevent.ptszText = messageT; - gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR); - gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + gce.ptszText = messageT; + gce.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR); + gce.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; + gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("mainthread() (%x): Conference message to room %s & id %s."), this, chat, id); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(messageT); } } @@ -893,29 +891,26 @@ retry: if (chat) { TCHAR id[32]; - DBVARIANT dbv; - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = chat; - gcdest.iType = GC_EVENT_MESSAGE; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; UIN2IDT(getDword(GG_KEY_UIN, 0), id); - gcevent.ptszUID = id; + + DBVARIANT dbv; + GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszUID = id; TCHAR* messageT = mir_utf8decodeT(e->event.multilogon_msg.message); - gcevent.ptszText = messageT; + gce.ptszText = messageT; TCHAR* nickT; if (!getTString(GG_KEY_NICK, &dbv)){ nickT = mir_tstrdup(dbv.ptszVal); db_free(&dbv); - } else { - nickT = mir_tstrdup(TranslateT("Me")); } - gcevent.ptszNick = nickT; - gcevent.time = e->event.multilogon_msg.time; - gcevent.bIsMe = 1; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + else nickT = mir_tstrdup(TranslateT("Me")); + gce.ptszNick = nickT; + gce.time = e->event.multilogon_msg.time; + gce.bIsMe = 1; + gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("mainthread() (%x): Sent conference message to room %s."), this, chat); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(messageT); mir_free(nickT); } @@ -1284,12 +1279,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; if ( isChatRoom(hContact) && !getTString(hContact, "ChatRoomID", &dbv) && gc_enabled) { - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = dbv.ptszVal; - gcdest.iType = GC_EVENT_CONTROL; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - gcevent.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; GGGC *chat = gc_lookup(dbv.ptszVal); debugLogA("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal); @@ -1299,8 +1290,8 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) free(chat->recipients); list_remove(&chats, chat, 1); // Terminate chat window / shouldn't cascade entry is deleted - CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gcevent); - CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); + CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } db_free(&dbv); @@ -1366,17 +1357,13 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) static int cascade = 0; if (!cascade && dbv.ptszVal) { - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = dbv.ptszVal; - gcdest.iType = GC_EVENT_CHANGESESSIONAME; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - gcevent.dwFlags = GC_TCHAR; - gcevent.ptszText = ptszVal; + GCDEST gcd = { m_szModuleName, dbv.ptszVal, GC_EVENT_CHANGESESSIONAME }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszText = ptszVal; debugLogA("dbsettingchanged(): Conference %s was renamed.", dbv.pszVal); // Mark cascading /* FIXME */ cascade = 1; - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); /* FIXME */ cascade = 0; } db_free(&dbv); diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 0845a550be..3ae8ecf309 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -30,28 +30,23 @@ int GGPROTO::gc_init() { - if (ServiceExists(MS_GC_REGISTER)) - { + if (ServiceExists(MS_GC_REGISTER)) { char service[64]; - GCREGISTER gcr = {0}; // Register Gadu-Gadu proto - gcr.cbSize = sizeof(GCREGISTER); - gcr.dwFlags = GC_TCHAR; - gcr.iMaxText = 0; - gcr.nColors = 0; - gcr.pColors = 0; - gcr.ptszModuleDispName = m_tszUserName; + GCREGISTER gcr = { sizeof(gcr) }; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); + HookProtoEvent(ME_GC_EVENT, &GGPROTO::gc_event); + gc_enabled = TRUE; // create & hook event mir_snprintf(service, 64, GG_GC_GETCHAT, m_szModuleName); debugLogA("gc_init(): Registered with groupchat plugin."); } - else - debugLogA("gc_init(): Cannot register with groupchat plugin !!!"); + else debugLogA("gc_init(): Cannot register with groupchat plugin !!!"); return 1; } @@ -160,36 +155,30 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText) { TCHAR id[32]; - DBVARIANT dbv; - GCDEST gcdest = {0}; - gcdest.pszModule = m_szModuleName; - gcdest.ptszID = gch->pDest->ptszID; - gcdest.iType = GC_EVENT_MESSAGE; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - int lc; - UIN2IDT(uin, id); + DBVARIANT dbv; - gcevent.ptszUID = id; - gcevent.ptszText = gch->ptszText; + GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszUID = id; + gce.ptszText = gch->ptszText; TCHAR* nickT; if (!getTString(GG_KEY_NICK, &dbv)){ nickT = mir_tstrdup(dbv.ptszVal); db_free(&dbv); - } else { - nickT = mir_tstrdup(TranslateT("Me")); } - gcevent.ptszNick = nickT; + else nickT = mir_tstrdup(TranslateT("Me")); + gce.ptszNick = nickT; // Get rid of CRLF at back - lc = (int)_tcslen(gch->ptszText) - 1; + int lc = (int)_tcslen(gch->ptszText) - 1; while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r')) gch->ptszText[lc --] = 0; - gcevent.time = time(NULL); - gcevent.bIsMe = 1; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; + gce.time = time(NULL); + gce.bIsMe = 1; + gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("gc_event(): Sending conference message to room %s, \"%s\"."), gch->pDest->ptszID, gch->ptszText); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(nickT); char* pszText_utf8 = mir_utf8encodeT(gch->ptszText); @@ -230,8 +219,8 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count GGGC *chat; TCHAR id[32]; uin_t uin; DBVARIANT dbv; - GCDEST gcdest = {m_szModuleName, 0, GC_EVENT_ADDGROUP}; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; + GCDEST gcd = {m_szModuleName, 0, GC_EVENT_ADDGROUP}; + GCEVENT gce = { sizeof(gce), &gcd }; debugLogA("gc_getchat(): Count %d.", recipients_count); if (!recipients) return NULL; @@ -317,14 +306,12 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count TCHAR status[256]; TCHAR *senderName = sender ? pcli->pfnGetContactDisplayName(getcontact(sender, 1, 0, NULL), 0) : NULL; mir_sntprintf(status, 255, (sender) ? TranslateT("%s initiated the conference.") : TranslateT("This is my own conference."), senderName); - GCSESSION gcwindow = { 0 }; - gcwindow.cbSize = sizeof(GCSESSION); + + GCSESSION gcwindow = { sizeof(gcwindow) }; gcwindow.iType = GCW_CHATROOM; - gcwindow.dwFlags = GC_TCHAR; gcwindow.pszModule = m_szModuleName; gcwindow.ptszName = sender ? senderName : TranslateT("Conference"); gcwindow.ptszID = chat->id; - gcwindow.dwFlags = GC_TCHAR; gcwindow.dwItemData = (DWORD)chat; gcwindow.ptszStatusbarText = status; @@ -332,9 +319,9 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count TCHAR *name = (TCHAR*)calloc(_tcslen(gcwindow.ptszName) + 2, sizeof(TCHAR)); *name = '#'; _tcscpy(name + 1, gcwindow.ptszName); gcwindow.ptszName = name; + // Create new room - if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow)) - { + if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow)) { debugLog(_T("gc_getchat(): Cannot create new chat window %s."), chat->id); free(name); free(chat); @@ -342,15 +329,15 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count } free(name); - gcdest.ptszID = chat->id; - gcevent.ptszUID = id; - gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gcevent.time = 0; + gcd.ptszID = chat->id; + gce.ptszUID = id; + gce.dwFlags = GCEF_ADDTOLOG; + gce.time = 0; // Add normal group - gcevent.ptszStatus = TranslateT("Participants"); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); - gcdest.iType = GC_EVENT_JOIN; + gce.ptszStatus = TranslateT("Participants"); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); + gcd.iType = GC_EVENT_JOIN; // Add myself if (uin = getDword(GG_KEY_UIN, 0)) @@ -364,12 +351,12 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count } else { nickT = mir_tstrdup(TranslateT("Me")); } - gcevent.ptszNick = nickT; + gce.ptszNick = nickT; - gcevent.bIsMe = 1; - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + gce.bIsMe = 1; + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(nickT); - debugLog(_T("gc_getchat(): Myself %s: %s (%s) to the list..."), gcevent.ptszUID, gcevent.ptszNick, gcevent.ptszStatus); + debugLog(_T("gc_getchat(): Myself %s: %s (%s) to the list..."), gce.ptszUID, gce.ptszNick, gce.ptszStatus); } else debugLogA("gc_getchat(): Myself adding failed with uin %d !!!", uin); @@ -385,17 +372,17 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count HANDLE hContact = getcontact(chat->recipients[i], 1, 0, NULL); UIN2IDT(chat->recipients[i], id); if (hContact && (name = pcli->pfnGetContactDisplayName(hContact, 0)) != NULL) - gcevent.ptszNick = name; + gce.ptszNick = name; else - gcevent.ptszNick = TranslateT("'Unknown'"); - gcevent.bIsMe = 0; - gcevent.dwFlags = GC_TCHAR; - debugLog(_T("gc_getchat(): Added %s: %s (%s) to the list..."), gcevent.ptszUID, gcevent.ptszNick, gcevent.pszStatus); - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent); + gce.ptszNick = TranslateT("'Unknown'"); + gce.bIsMe = 0; + gce.dwFlags = 0; + debugLog(_T("gc_getchat(): Added %s: %s (%s) to the list..."), gce.ptszUID, gce.ptszNick, gce.ptszStatus); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } - gcdest.iType = GC_EVENT_CONTROL; - CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gcevent); - CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gcevent); + gcd.iType = GC_EVENT_CONTROL; + CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce); + CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); debugLog(_T("gc_getchat(): Returning new chat window %s, count %d."), chat->id, chat->recipients_count); list_add(&chats, chat, 0); @@ -501,13 +488,9 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa chat = gg->gc_getchat(0, participants, count); if (chat) { - GCDEST gcdest = {0}; - gcdest.pszModule = gg->m_szModuleName; - gcdest.ptszID = chat; - gcdest.iType = GC_EVENT_CONTROL; - GCEVENT gcevent = {sizeof(GCEVENT), &gcdest}; - gcevent.dwFlags = GC_TCHAR; - CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gcevent); + GCDEST gcd = { gg->m_szModuleName, chat, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); } free(participants); } @@ -653,16 +636,12 @@ int GGPROTO::gc_changenick(HANDLE hContact, TCHAR *ptszNick) if (chat->recipients[i] == uin) { TCHAR id[32]; - GCEVENT gce = {sizeof(GCEVENT)}; - GCDEST gcd; - UIN2IDT(uin, id); - gcd.iType = GC_EVENT_NICK; - gcd.pszModule = m_szModuleName; + + GCDEST gcd = { m_szModuleName, chat->id, GC_EVENT_NICK }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.pDest = &gcd; - gcd.ptszID = chat->id; gce.ptszUID = id; - gce.dwFlags = GC_TCHAR; gce.ptszText = ptszNick; debugLog(_T("gc_changenick(): Found room %s with uin %d, sending nick change %s."), chat->id, uin, id); diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index fa9a38b2a4..ae19f64af2 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -368,15 +368,9 @@ bool CIrcProto::OnIrc_QUIT(const CIrcMessage* pmsg) struct CONTACT user = { (LPTSTR)pmsg->prefix.sNick.c_str(), (LPTSTR)pmsg->prefix.sUser.c_str(), (LPTSTR)pmsg->prefix.sHost.c_str(), false, false, false}; CList_SetOffline( &user ); if ( pmsg->prefix.sNick == m_info.sNick ) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - gce.cbSize = sizeof(GCEVENT); - gcd.ptszID = NULL; - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce); } } else ShowMessage( pmsg ); @@ -390,17 +384,10 @@ bool CIrcProto::OnIrc_PART(const CIrcMessage* pmsg) CMString host = pmsg->prefix.sUser + _T("@") + pmsg->prefix.sHost; DoEvent(GC_EVENT_PART, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount()>1?pmsg->parameters[1].c_str():NULL, NULL, host.c_str(), NULL, true, false); if ( pmsg->prefix.sNick == m_info.sNick ) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - CMString S = MakeWndID( pmsg->parameters[0].c_str()); - gce.cbSize = sizeof(GCEVENT); - gcd.ptszID = ( TCHAR* )S.c_str(); - gce.dwFlags = GC_TCHAR; - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce); + CMString S = MakeWndID(pmsg->parameters[0].c_str()); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce); } } else ShowMessage( pmsg ); @@ -416,17 +403,10 @@ bool CIrcProto::OnIrc_KICK(const CIrcMessage* pmsg) ShowMessage( pmsg ); if ( pmsg->parameters[1] == m_info.sNick ) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CMString S = MakeWndID( pmsg->parameters[0].c_str()); - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gcd.ptszID = ( TCHAR* )S.c_str(); - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce); if ( m_rejoinIfKicked ) { CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0); @@ -1267,34 +1247,22 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) sChanName++; // Add a new chat window - GCSESSION gcw = {0}; - CMString sID = MakeWndID( sChanName ); + CMString sID = MakeWndID(sChanName); BYTE btOwnMode = 0; - gcw.cbSize = sizeof(GCSESSION); + + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; - gcw.dwFlags = GC_TCHAR; gcw.ptszID = sID.c_str(); gcw.pszModule = m_szModuleName; gcw.ptszName = sChanName; - if ( !CallServiceSync( MS_GC_NEWSESSION, 0, ( LPARAM )&gcw )) { + if (!CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) { DBVARIANT dbv; - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CMString sTemp; - int i = 0; + GCDEST gcd = { m_szModuleName, (TCHAR*)sID.c_str(), GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; PostIrcMessage( _T("/MODE %s"), sChanName ); - gcd.ptszID = ( TCHAR* )sID.c_str(); - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_ADDGROUP; - gce.time = 0; - gce.dwFlags = GC_TCHAR; - //register the statuses - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.ptszStatus = _T("Owner"); CallChatEvent(0, (LPARAM)&gce); gce.ptszStatus = _T("Admin"); @@ -1308,11 +1276,11 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) gce.ptszStatus = _T("Normal"); CallChatEvent(0, (LPARAM)&gce); - i = 0; - sTemp = GetWord(sNamesList.c_str(), i); + int i = 0; + CMString sTemp = GetWord(sNamesList.c_str(), i); // Fill the nicklist - while ( !sTemp.IsEmpty()) { + while (!sTemp.IsEmpty()) { CMString sStat; CMString sTemp2 = sTemp; sStat = PrefixToStatus(sTemp[0]); @@ -1328,7 +1296,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) BOOL bIsMe = ( !lstrcmpi( gce.ptszNick, m_info.sNick.c_str())) ? TRUE : FALSE; if ( bIsMe ) { char BitNr = -1; - switch ( sTemp2[0] ) { + switch (sTemp2[0]) { case '+': BitNr = 0; break; case '%': BitNr = 1; break; case '@': BitNr = 2; break; @@ -1340,20 +1308,20 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) else btOwnMode = 0; } - gce.dwFlags = GC_TCHAR; gce.bIsMe = bIsMe; - gce.time = bIsMe?time(0):0; + gce.time = bIsMe ? time(0) : 0; CallChatEvent(0, (LPARAM)&gce); - DoEvent( GC_EVENT_SETCONTACTSTATUS, sChanName, sTemp.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE ); + DoEvent(GC_EVENT_SETCONTACTSTATUS, sChanName, sTemp.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE); // fix for networks like freshirc where they allow more than one prefix - if ( PrefixToStatus( sTemp2[0]) != _T("Normal")) { - sTemp2.Delete(0,1); + if (PrefixToStatus(sTemp2[0]) != _T("Normal")) { + sTemp2.Delete(0, 1); sStat = PrefixToStatus(sTemp2[0]); - while ( sStat != _T("Normal")) { - DoEvent( GC_EVENT_ADDSTATUS, sID.c_str(), sTemp.c_str(), _T("system"), sStat.c_str(), NULL, NULL, false, false, 0 ); - sTemp2.Delete(0,1); + while (sStat != _T("Normal")) { + DoEvent(GC_EVENT_ADDSTATUS, sID.c_str(), sTemp.c_str(), _T("system"), sStat.c_str(), NULL, NULL, false, false, 0); + sTemp2.Delete(0, 1); sStat = PrefixToStatus(sTemp2[0]); - } } + } + } i++; sTemp = GetWord(sNamesList.c_str(), i); @@ -1383,14 +1351,14 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) gcd.ptszID = (TCHAR*)sID.c_str(); gcd.iType = GC_EVENT_CONTROL; gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; + gce.dwFlags = 0; gce.bIsMe = false; gce.dwItemData = false; - gce.pszNick = NULL; - gce.pszStatus = NULL; - gce.pszText = NULL; - gce.pszUID = NULL; - gce.pszUserInfo = NULL; + gce.ptszNick = NULL; + gce.ptszStatus = NULL; + gce.ptszText = NULL; + gce.ptszUID = NULL; + gce.ptszUserInfo = NULL; gce.time = time(0); gce.pDest = &gcd; @@ -1426,7 +1394,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) } else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce); - if ( save.IsEmpty()) + if (save.IsEmpty()) db_unset(NULL, m_szModuleName, "JTemp"); else setTString("JTemp", save.c_str()); @@ -1434,10 +1402,10 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) } else CallChatEvent( SESSION_INITDONE, (LPARAM)&gce); - { gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_ONLINE, (LPARAM)&gce); - } } } } + gcd.iType = GC_EVENT_CONTROL; + gce.pDest = &gcd; + CallChatEvent( SESSION_ONLINE, (LPARAM)&gce); + } } } sNamesList = _T(""); ShowMessage( pmsg ); @@ -1446,263 +1414,264 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) bool CIrcProto::OnIrc_INITIALTOPIC(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 ) { - AddWindowItemData( pmsg->parameters[1].c_str(), 0, 0, 0, pmsg->parameters[2].c_str()); + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2) { + AddWindowItemData(pmsg->parameters[1].c_str(), 0, 0, 0, pmsg->parameters[2].c_str()); sTopic = pmsg->parameters[1] + _T(" ") + pmsg->parameters[2]; sTopicName = _T(""); sTopicTime = _T(""); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_INITIALTOPICNAME(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 3 ) { + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 3) { TCHAR tTimeBuf[128], *tStopStr; time_t ttTopicTime; sTopicName = pmsg->parameters[2]; - ttTopicTime = _tcstol( pmsg->parameters[3].c_str(), &tStopStr, 10); + ttTopicTime = _tcstol(pmsg->parameters[3].c_str(), &tStopStr, 10); _tcsftime(tTimeBuf, 128, _T("%#c"), localtime(&ttTopicTime)); sTopicTime = tTimeBuf; } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_TOPIC(const CIrcMessage* pmsg) { - if ( pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming ) { - DoEvent( GC_EVENT_TOPIC, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str(), NULL, sTopicTime.IsEmpty() ? NULL : sTopicTime.c_str(), NULL, true, false); + if (pmsg->parameters.getCount() > 1 && pmsg->m_bIncoming) { + DoEvent(GC_EVENT_TOPIC, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str(), NULL, sTopicTime.IsEmpty() ? NULL : sTopicTime.c_str(), NULL, true, false); AddWindowItemData(pmsg->parameters[0].c_str(), 0, 0, 0, pmsg->parameters[1].c_str()); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } -static void __stdcall sttShowDlgList( void* param ) +static void __stdcall sttShowDlgList(void* param) { - CIrcProto *ppro = ( CIrcProto* )param; - if ( ppro->m_listDlg == NULL ) { - ppro->m_listDlg = new CListDlg( ppro ); + CIrcProto *ppro = (CIrcProto*)param; + if (ppro->m_listDlg == NULL) { + ppro->m_listDlg = new CListDlg(ppro); ppro->m_listDlg->Show(); } - SetEvent( ppro->m_evWndCreate ); + SetEvent(ppro->m_evWndCreate); } bool CIrcProto::OnIrc_LISTSTART(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming ) { - CallFunctionAsync( sttShowDlgList, this ); - WaitForSingleObject( m_evWndCreate, INFINITE ); + if (pmsg->m_bIncoming) { + CallFunctionAsync(sttShowDlgList, this); + WaitForSingleObject(m_evWndCreate, INFINITE); m_channelNumber = 0; } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_LIST(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming == 1 && m_listDlg && pmsg->parameters.getCount() > 2 ) { + if (pmsg->m_bIncoming == 1 && m_listDlg && pmsg->parameters.getCount() > 2) { m_channelNumber++; LVITEM lvItem; - HWND hListView = GetDlgItem( m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW ); - lvItem.iItem = ListView_GetItemCount( hListView ); + HWND hListView = GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW); + lvItem.iItem = ListView_GetItemCount(hListView); lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iSubItem = 0; lvItem.pszText = (TCHAR*)pmsg->parameters[1].c_str(); lvItem.lParam = lvItem.iItem; - lvItem.iItem = ListView_InsertItem( hListView, &lvItem ); + lvItem.iItem = ListView_InsertItem(hListView, &lvItem); lvItem.mask = LVIF_TEXT; - lvItem.iSubItem =1; - lvItem.pszText = (TCHAR*)pmsg->parameters[pmsg->parameters.getCount()-2].c_str(); - ListView_SetItem( hListView, &lvItem ); + lvItem.iSubItem = 1; + lvItem.pszText = (TCHAR*)pmsg->parameters[pmsg->parameters.getCount() - 2].c_str(); + ListView_SetItem(hListView, &lvItem); - TCHAR* temp = mir_tstrdup( pmsg->parameters[pmsg->parameters.getCount()-1] ); - TCHAR* find = _tcsstr( temp , _T("[+")); - TCHAR* find2 = _tcsstr( temp , _T("]")); + TCHAR* temp = mir_tstrdup(pmsg->parameters[pmsg->parameters.getCount() - 1]); + TCHAR* find = _tcsstr(temp, _T("[+")); + TCHAR* find2 = _tcsstr(temp, _T("]")); TCHAR* save = temp; - if ( find == temp && find2 != NULL && find+8 >= find2 ) { - temp = _tcsstr( temp, _T("]")); - if ( lstrlen(temp) > 1 ) { + if (find == temp && find2 != NULL && find + 8 >= find2) { + temp = _tcsstr(temp, _T("]")); + if (lstrlen(temp) > 1) { temp++; temp[0] = '\0'; - lvItem.iSubItem =2; + lvItem.iSubItem = 2; lvItem.pszText = save; - ListView_SetItem(hListView,&lvItem); + ListView_SetItem(hListView, &lvItem); temp[0] = ' '; temp++; } - else temp =save; + else temp = save; } - - lvItem.iSubItem =3; + + lvItem.iSubItem = 3; CMString S = DoColorCodes(temp, TRUE, FALSE); - lvItem.pszText = ( TCHAR* )S.c_str(); - ListView_SetItem( hListView, &lvItem ); + lvItem.pszText = (TCHAR*)S.c_str(); + ListView_SetItem(hListView, &lvItem); temp = save; - mir_free( temp ); - + mir_free(temp); + int percent = 100; - if ( m_noOfChannels > 0 ) - percent = (int)(m_channelNumber*100) / m_noOfChannels; + if (m_noOfChannels > 0) + percent = (int)(m_channelNumber * 100) / m_noOfChannels; TCHAR text[100]; - if ( percent < 100) + if (percent < 100) mir_sntprintf(text, SIZEOF(text), TranslateT("Downloading list (%u%%) - %u channels"), percent, m_channelNumber); else mir_sntprintf(text, SIZEOF(text), TranslateT("Downloading list - %u channels"), m_channelNumber); - m_listDlg->m_status.SetText( text ); + m_listDlg->m_status.SetText(text); } - + return true; } bool CIrcProto::OnIrc_LISTEND(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_listDlg ) { + if (pmsg->m_bIncoming && m_listDlg) { EnableWindow(GetDlgItem(m_listDlg->GetHwnd(), IDC_JOIN), true); - ListView_SetSelectionMark(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 0); + ListView_SetSelectionMark(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 0); ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 1, LVSCW_AUTOSIZE); ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 2, LVSCW_AUTOSIZE); ListView_SetColumnWidth(GetDlgItem(m_listDlg->GetHwnd(), IDC_INFO_LISTVIEW), 3, LVSCW_AUTOSIZE); m_listDlg->UpdateList(); TCHAR text[100]; - mir_sntprintf( text, SIZEOF(text), TranslateT("Done: %u channels"), m_channelNumber ); + mir_sntprintf(text, SIZEOF(text), TranslateT("Done: %u channels"), m_channelNumber); int percent = 100; - if ( m_noOfChannels > 0 ) - percent = (int)(m_channelNumber*100) / m_noOfChannels; - if ( percent < 70 ) { - lstrcat( text, _T(" ")); - lstrcat( text, TranslateT("(probably truncated by server)")); + if (m_noOfChannels > 0) + percent = (int)(m_channelNumber * 100) / m_noOfChannels; + if (percent < 70) { + lstrcat(text, _T(" ")); + lstrcat(text, TranslateT("(probably truncated by server)")); } - SetDlgItemText( m_listDlg->GetHwnd(), IDC_TEXT, text ); + SetDlgItemText(m_listDlg->GetHwnd(), IDC_TEXT, text); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_BANLIST(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 ) { - if ( m_managerDlg->GetHwnd() && ( + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2) { + if (m_managerDlg->GetHwnd() && ( m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("367") || m_managerDlg->m_radio2.GetState() && pmsg->sCommand == _T("346") || - m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("348")) && - !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) - { + m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("348")) && + !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) { CMString S = pmsg->parameters[2]; - if ( pmsg->parameters.getCount() > 3 ) { + if (pmsg->parameters.getCount() > 3) { S += _T(" - "); S += pmsg->parameters[3]; - if ( pmsg->parameters.getCount() > 4 ) { + if (pmsg->parameters.getCount() > 4) { S += _T(" - ( "); - time_t time = StrToInt( pmsg->parameters[4].c_str()); - S += _tctime( &time ); - ReplaceString( S, _T("\n"), _T(" ")); + time_t time = StrToInt(pmsg->parameters[4].c_str()); + S += _tctime(&time); + ReplaceString(S, _T("\n"), _T(" ")); S += _T(")"); - } } + } + } SendDlgItemMessage(m_managerDlg->GetHwnd(), IDC_LIST, LB_ADDSTRING, 0, (LPARAM)S.c_str()); - } } + } + } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_BANLISTEND(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) { - if ( m_managerDlg->GetHwnd() && - ( m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("368") + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) { + if (m_managerDlg->GetHwnd() && + (m_managerDlg->m_radio1.GetState() && pmsg->sCommand == _T("368") || m_managerDlg->m_radio2.GetState() && pmsg->sCommand == _T("347") - || m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("349")) && - !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) - { - if ( strchr( sChannelModes.c_str(), 'b' )) + || m_managerDlg->m_radio3.GetState() && pmsg->sCommand == _T("349")) && + !m_managerDlg->m_radio1.Enabled() && !m_managerDlg->m_radio2.Enabled() && !m_managerDlg->m_radio3.Enabled()) { + if (strchr(sChannelModes.c_str(), 'b')) m_managerDlg->m_radio1.Enable(); - if ( strchr( sChannelModes.c_str(), 'I' )) + if (strchr(sChannelModes.c_str(), 'I')) m_managerDlg->m_radio2.Enable(); - if ( strchr( sChannelModes.c_str(), 'e' )) + if (strchr(sChannelModes.c_str(), 'e')) m_managerDlg->m_radio3.Enable(); - if ( !IsDlgButtonChecked(m_managerDlg->GetHwnd(), IDC_NOTOP)) + if (!IsDlgButtonChecked(m_managerDlg->GetHwnd(), IDC_NOTOP)) m_managerDlg->m_add.Enable(); - } } - - ShowMessage( pmsg ); + } + } + + ShowMessage(pmsg); return true; } -static void __stdcall sttShowWhoisWnd( void* param ) +static void __stdcall sttShowWhoisWnd(void* param) { - CIrcMessage* pmsg = ( CIrcMessage* )param; - CIrcProto *ppro = ( CIrcProto* )pmsg->m_proto; - if ( ppro->m_whoisDlg == NULL ) { - ppro->m_whoisDlg = new CWhoisDlg( ppro ); + CIrcMessage* pmsg = (CIrcMessage*)param; + CIrcProto *ppro = (CIrcProto*)pmsg->m_proto; + if (ppro->m_whoisDlg == NULL) { + ppro->m_whoisDlg = new CWhoisDlg(ppro); ppro->m_whoisDlg->Show(); } - SetEvent( ppro->m_evWndCreate ); + SetEvent(ppro->m_evWndCreate); - ppro->m_whoisDlg->ShowMessage( pmsg ); + ppro->m_whoisDlg->ShowMessage(pmsg); delete pmsg; } bool CIrcProto::OnIrc_WHOIS_NAME(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 5 && m_manualWhoisCount > 0 ) { - CallFunctionAsync( sttShowWhoisWnd, new CIrcMessage( *pmsg )); - WaitForSingleObject( m_evWndCreate, INFINITE ); + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 5 && m_manualWhoisCount > 0) { + CallFunctionAsync(sttShowWhoisWnd, new CIrcMessage(*pmsg)); + WaitForSingleObject(m_evWndCreate, INFINITE); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_CHANNELS(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) - m_whoisDlg->m_InfoChannels.SetText( pmsg->parameters[2].c_str()); - ShowMessage( pmsg ); + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) + m_whoisDlg->m_InfoChannels.SetText(pmsg->parameters[2].c_str()); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_AWAY(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) - m_whoisDlg->m_InfoAway2.SetText( pmsg->parameters[2].c_str()); - if ( m_manualWhoisCount < 1 && pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 ) + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) + m_whoisDlg->m_InfoAway2.SetText(pmsg->parameters[2].c_str()); + if (m_manualWhoisCount < 1 && pmsg->m_bIncoming && pmsg->parameters.getCount() > 2) WhoisAwayReply = pmsg->parameters[2]; - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_OTHER(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) { + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) { TCHAR temp[1024], temp2[1024]; - m_whoisDlg->m_InfoOther.GetText( temp, 1000 ); - lstrcat( temp, _T("%s\r\n")); - mir_sntprintf( temp2, 1020, temp, pmsg->parameters[2].c_str()); - m_whoisDlg->m_InfoOther.SetText( temp2 ); + m_whoisDlg->m_InfoOther.GetText(temp, 1000); + lstrcat(temp, _T("%s\r\n")); + mir_sntprintf(temp2, 1020, temp, pmsg->parameters[2].c_str()); + m_whoisDlg->m_InfoOther.SetText(temp2); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_END(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 && m_manualWhoisCount < 1 ) { - CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, true}; - HANDLE hContact = CList_FindContact( &user ); - if ( hContact ) - ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM)WhoisAwayReply.c_str()); + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 && m_manualWhoisCount < 1) { + CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, true }; + HANDLE hContact = CList_FindContact(&user); + if (hContact) + ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)WhoisAwayReply.c_str()); } m_manualWhoisCount--; if (m_manualWhoisCount < 0) m_manualWhoisCount = 0; - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } @@ -1712,17 +1681,17 @@ bool CIrcProto::OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg) int H = 0; int M = 0; int S = 0; - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) { + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) { S = StrToInt(pmsg->parameters[2].c_str()); - D = S/(60*60*24); - S -= (D * 60 * 60 *24); - H = S/(60*60); + D = S / (60 * 60 * 24); + S -= (D * 60 * 60 * 24); + H = S / (60 * 60); S -= (H * 60 * 60); - M = S/60; - S -= (M * 60 ); - + M = S / 60; + S -= (M * 60); + TCHAR temp[100]; - if ( D ) + if (D) mir_sntprintf(temp, 99, _T("%ud, %uh, %um, %us"), D, H, M, S); else if (H) mir_sntprintf(temp, 99, _T("%uh, %um, %us"), H, M, S); @@ -1735,260 +1704,263 @@ bool CIrcProto::OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg) TCHAR temp3[256]; TCHAR tTimeBuf[128], *tStopStr; - time_t ttTime = _tcstol( pmsg->parameters[3].c_str(), &tStopStr, 10); + time_t ttTime = _tcstol(pmsg->parameters[3].c_str(), &tStopStr, 10); _tcsftime(tTimeBuf, 128, _T("%c"), localtime(&ttTime)); - mir_sntprintf( temp3, SIZEOF(temp3), _T("online since %s, idle %s"), tTimeBuf, temp); - m_whoisDlg->m_AwayTime.SetText( temp3 ); + mir_sntprintf(temp3, SIZEOF(temp3), _T("online since %s, idle %s"), tTimeBuf, temp); + m_whoisDlg->m_AwayTime.SetText(temp3); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_SERVER(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) - m_whoisDlg->m_InfoServer.SetText( pmsg->parameters[2].c_str()); - ShowMessage( pmsg ); + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) + m_whoisDlg->m_InfoServer.SetText(pmsg->parameters[2].c_str()); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_AUTH(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0 ) { - if ( pmsg->sCommand == _T("330")) - m_whoisDlg->m_InfoAuth.SetText( pmsg->parameters[2].c_str()); - else if ( pmsg->parameters[2] == _T("is an identified user") || pmsg->parameters[2] == _T("is a registered nick")) - m_whoisDlg->m_InfoAuth.SetText( pmsg->parameters[2].c_str()); + if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) { + if (pmsg->sCommand == _T("330")) + m_whoisDlg->m_InfoAuth.SetText(pmsg->parameters[2].c_str()); + else if (pmsg->parameters[2] == _T("is an identified user") || pmsg->parameters[2] == _T("is a registered nick")) + m_whoisDlg->m_InfoAuth.SetText(pmsg->parameters[2].c_str()); else - OnIrc_WHOIS_OTHER( pmsg ); + OnIrc_WHOIS_OTHER(pmsg); } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHOIS_NO_USER(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 && !IsChannel( pmsg->parameters[1] )) { - if ( m_whoisDlg ) - m_whoisDlg->ShowMessageNoUser( pmsg ); - - CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, false}; - HANDLE hContact = CList_FindContact( &user ); - if ( hContact ) { - AddOutgoingMessageToDB( hContact, (TCHAR*)((CMString)_T("> ") + pmsg->parameters[2] + (CMString)_T(": ") + pmsg->parameters[1]).c_str()); + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 2 && !IsChannel(pmsg->parameters[1])) { + if (m_whoisDlg) + m_whoisDlg->ShowMessageNoUser(pmsg); + + CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, false }; + HANDLE hContact = CList_FindContact(&user); + if (hContact) { + AddOutgoingMessageToDB(hContact, (TCHAR*)((CMString)_T("> ") + pmsg->parameters[2] + (CMString)_T(": ") + pmsg->parameters[1]).c_str()); DBVARIANT dbv; - if ( !getTString( hContact, "Default", &dbv )) { - setTString( hContact, "Nick", dbv.ptszVal ); - + if (!getTString(hContact, "Default", &dbv)) { + setTString(hContact, "Nick", dbv.ptszVal); + DBVARIANT dbv2; - if ( getByte( hContact, "AdvancedMode", 0 ) == 0 ) - DoUserhostWithReason(1, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal ); + if (getByte(hContact, "AdvancedMode", 0) == 0) + DoUserhostWithReason(1, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal); else { - if ( !getTString( hContact, "UWildcard", &dbv2 )) { - DoUserhostWithReason(2, ((CMString)_T("S") + dbv2.ptszVal).c_str(), true, dbv2.ptszVal ); + if (!getTString(hContact, "UWildcard", &dbv2)) { + DoUserhostWithReason(2, ((CMString)_T("S") + dbv2.ptszVal).c_str(), true, dbv2.ptszVal); db_free(&dbv2); } - else DoUserhostWithReason(2, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal ); + else DoUserhostWithReason(2, ((CMString)_T("S") + dbv.ptszVal).c_str(), true, dbv.ptszVal); } setString(hContact, "User", ""); setString(hContact, "Host", ""); db_free(&dbv); - } } } + } + } + } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } -static void __stdcall sttShowNickWnd( void* param ) +static void __stdcall sttShowNickWnd(void* param) { - CIrcMessage* pmsg = ( CIrcMessage* )param; + CIrcMessage* pmsg = (CIrcMessage*)param; CIrcProto *ppro = pmsg->m_proto; - if ( ppro->m_nickDlg == NULL ) { - ppro->m_nickDlg = new CNickDlg( ppro ); + if (ppro->m_nickDlg == NULL) { + ppro->m_nickDlg = new CNickDlg(ppro); ppro->m_nickDlg->Show(); } - SetEvent( ppro->m_evWndCreate ); - SetWindowText( GetDlgItem( ppro->m_nickDlg->GetHwnd(), IDC_CAPTION ), TranslateT("Change nickname")); - SetWindowText( GetDlgItem( ppro->m_nickDlg->GetHwnd(), IDC_TEXT ), pmsg->parameters.getCount() > 2 ? pmsg->parameters[2].c_str() : _T("")); - ppro->m_nickDlg->m_Enick.SetText( pmsg->parameters[1].c_str()); - ppro->m_nickDlg->m_Enick.SendMsg( CB_SETEDITSEL, 0, MAKELPARAM(0,-1)); + SetEvent(ppro->m_evWndCreate); + SetWindowText(GetDlgItem(ppro->m_nickDlg->GetHwnd(), IDC_CAPTION), TranslateT("Change nickname")); + SetWindowText(GetDlgItem(ppro->m_nickDlg->GetHwnd(), IDC_TEXT), pmsg->parameters.getCount() > 2 ? pmsg->parameters[2].c_str() : _T("")); + ppro->m_nickDlg->m_Enick.SetText(pmsg->parameters[1].c_str()); + ppro->m_nickDlg->m_Enick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); delete pmsg; } bool CIrcProto::OnIrc_NICK_ERR(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming ) { - if ( nickflag && ((m_alternativeNick[0] != 0)) && (pmsg->parameters.getCount() > 2 && _tcscmp(pmsg->parameters[1].c_str(), m_alternativeNick))) { + if (pmsg->m_bIncoming) { + if (nickflag && ((m_alternativeNick[0] != 0)) && (pmsg->parameters.getCount() > 2 && _tcscmp(pmsg->parameters[1].c_str(), m_alternativeNick))) { TCHAR m[200]; - mir_sntprintf( m, SIZEOF(m), _T("NICK %s"), m_alternativeNick ); - if ( IsConnected()) - SendIrcMessage( m ); + mir_sntprintf(m, SIZEOF(m), _T("NICK %s"), m_alternativeNick); + if (IsConnected()) + SendIrcMessage(m); } else { - CallFunctionAsync( sttShowNickWnd, new CIrcMessage( *pmsg )); - WaitForSingleObject( m_evWndCreate, INFINITE ); - } } + CallFunctionAsync(sttShowNickWnd, new CIrcMessage(*pmsg)); + WaitForSingleObject(m_evWndCreate, INFINITE); + } + } - ShowMessage( pmsg ); - return true; + ShowMessage(pmsg); + return true; } bool CIrcProto::OnIrc_JOINERROR(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming ) { + if (pmsg->m_bIncoming) { DBVARIANT dbv; - if ( !getTString( "JTemp", &dbv )) { + if (!getTString("JTemp", &dbv)) { CMString command = _T("a"); CMString save = _T(""); int i = 0; - while ( !command.IsEmpty()) { - command = GetWord( dbv.ptszVal, i ); + while (!command.IsEmpty()) { + command = GetWord(dbv.ptszVal, i); i++; - if ( !command.IsEmpty() && pmsg->parameters[0] == command.Mid(1, command.GetLength())) + if (!command.IsEmpty() && pmsg->parameters[0] == command.Mid(1, command.GetLength())) save += command + _T(" "); } - + db_free(&dbv); - if ( save.IsEmpty()) - db_unset( NULL, m_szModuleName, "JTemp" ); + if (save.IsEmpty()) + db_unset(NULL, m_szModuleName, "JTemp"); else - setTString( "JTemp", save.c_str()); - } } + setTString("JTemp", save.c_str()); + } + } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_UNKNOWN(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 0 ) { - if ( pmsg->parameters[0] == _T("WHO") && GetNextUserhostReason(2) != _T("U")) + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 0) { + if (pmsg->parameters[0] == _T("WHO") && GetNextUserhostReason(2) != _T("U")) return true; - if ( pmsg->parameters[0] == _T("USERHOST") && GetNextUserhostReason(1) != _T("U")) + if (pmsg->parameters[0] == _T("USERHOST") && GetNextUserhostReason(1) != _T("U")) return true; } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_ENDMOTD(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && !bPerformDone ) - DoOnConnect( pmsg ); - ShowMessage( pmsg ); + if (pmsg->m_bIncoming && !bPerformDone) + DoOnConnect(pmsg); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_NOOFCHANNELS(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) - m_noOfChannels = StrToInt( pmsg->parameters[1].c_str()); + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) + m_noOfChannels = StrToInt(pmsg->parameters[1].c_str()); - if ( pmsg->m_bIncoming && !bPerformDone ) - DoOnConnect( pmsg ); + if (pmsg->m_bIncoming && !bPerformDone) + DoOnConnect(pmsg); - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_ERROR(const CIrcMessage* pmsg) { - if ( pmsg->m_bIncoming && !m_disableErrorPopups && m_iDesiredStatus != ID_STATUS_OFFLINE) { + if (pmsg->m_bIncoming && !m_disableErrorPopups && m_iDesiredStatus != ID_STATUS_OFFLINE) { MIRANDASYSTRAYNOTIFY msn; msn.cbSize = sizeof(MIRANDASYSTRAYNOTIFY); msn.szProto = m_szModuleName; msn.tszInfoTitle = TranslateT("IRC error"); - + CMString S; - if ( pmsg->parameters.getCount() > 0 ) - S = DoColorCodes( pmsg->parameters[0].c_str(), TRUE, FALSE ); + if (pmsg->parameters.getCount() > 0) + S = DoColorCodes(pmsg->parameters[0].c_str(), TRUE, FALSE); else - S = TranslateT( "Unknown" ); + S = TranslateT("Unknown"); - msn.tszInfo = ( TCHAR* )S.c_str(); + msn.tszInfo = (TCHAR*)S.c_str(); msn.dwInfoFlags = NIIF_ERROR | NIIF_INTERN_UNICODE; msn.uTimeout = 15000; CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&msn); } - ShowMessage( pmsg ); - return true; + ShowMessage(pmsg); + return true; } bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg) { CMString command = GetNextUserhostReason(2); - if ( command[0] == 'S' ) { - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) { + if (command[0] == 'S') { + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) { // is it a channel? - if ( IsChannel( pmsg->parameters[1] )) { + if (IsChannel(pmsg->parameters[1])) { CMString S; - CMString User = GetWord( m_whoReply.c_str(), 0 ); - while ( !User.IsEmpty()) { - if ( GetWord( m_whoReply.c_str(), 3)[0] == 'G' ) { + CMString User = GetWord(m_whoReply.c_str(), 0); + while (!User.IsEmpty()) { + if (GetWord(m_whoReply.c_str(), 3)[0] == 'G') { S += User; S += _T("\t"); - DoEvent( GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_AWAY, FALSE, FALSE); + DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_AWAY, FALSE, FALSE); } - else DoEvent( GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE); + else DoEvent(GC_EVENT_SETCONTACTSTATUS, pmsg->parameters[1].c_str(), User.c_str(), NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE); - CMString SS = GetWordAddress( m_whoReply.c_str(), 4 ); - if ( SS.IsEmpty()) + CMString SS = GetWordAddress(m_whoReply.c_str(), 4); + if (SS.IsEmpty()) break; m_whoReply = SS; User = GetWord(m_whoReply.c_str(), 0); } - - DoEvent( GC_EVENT_SETSTATUSEX, pmsg->parameters[1].c_str(), NULL, S.IsEmpty() ? NULL : S.c_str(), NULL, NULL, GC_SSE_TABDELIMITED, FALSE, FALSE); + + DoEvent(GC_EVENT_SETSTATUSEX, pmsg->parameters[1].c_str(), NULL, S.IsEmpty() ? NULL : S.c_str(), NULL, NULL, GC_SSE_TABDELIMITED, FALSE, FALSE); return true; } /// if it is not a channel - TCHAR* UserList = mir_tstrdup( m_whoReply.c_str()); - const TCHAR* p1= UserList; + TCHAR* UserList = mir_tstrdup(m_whoReply.c_str()); + const TCHAR* p1 = UserList; m_whoReply = _T(""); - CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, true, false}; - HANDLE hContact = CList_FindContact( &user ); + CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, true, false }; + HANDLE hContact = CList_FindContact(&user); - if ( hContact && getByte( hContact, "AdvancedMode", 0 ) == 1 ) { - DBVARIANT dbv1, dbv2, dbv3, dbv4, dbv5, dbv6, dbv7; + if (hContact && getByte(hContact, "AdvancedMode", 0) == 1) { + DBVARIANT dbv1, dbv2, dbv3, dbv4, dbv5, dbv6, dbv7; TCHAR *DBDefault = NULL, *DBNick = NULL, *DBWildcard = NULL; TCHAR *DBUser = NULL, *DBHost = NULL, *DBManUser = NULL, *DBManHost = NULL; - if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal; - if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal; - if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal; - if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal; - if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal; - if ( !getTString(hContact, "User", &dbv6)) DBManUser = dbv6.ptszVal; - if ( !getTString(hContact, "Host", &dbv7)) DBManHost = dbv7.ptszVal; - if ( DBWildcard ) - CharLower( DBWildcard ); + if (!getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal; + if (!getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal; + if (!getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal; + if (!getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal; + if (!getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal; + if (!getTString(hContact, "User", &dbv6)) DBManUser = dbv6.ptszVal; + if (!getTString(hContact, "Host", &dbv7)) DBManHost = dbv7.ptszVal; + if (DBWildcard) + CharLower(DBWildcard); CMString nick; CMString user; CMString host; CMString away = GetWord(p1, 3); - while ( !away.IsEmpty()) { + while (!away.IsEmpty()) { nick = GetWord(p1, 0); user = GetWord(p1, 1); host = GetWord(p1, 2); - if (( DBWildcard && WCCmp( DBWildcard, nick.c_str()) || DBNick && !lstrcmpi(DBNick, nick.c_str()) || DBDefault && !lstrcmpi(DBDefault, nick.c_str())) - && (WCCmp(DBUser, user.c_str()) && WCCmp(DBHost, host.c_str()))) - { - if (away[0] == 'G' && getWord( hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_AWAY) + if ((DBWildcard && WCCmp(DBWildcard, nick.c_str()) || DBNick && !lstrcmpi(DBNick, nick.c_str()) || DBDefault && !lstrcmpi(DBDefault, nick.c_str())) + && (WCCmp(DBUser, user.c_str()) && WCCmp(DBHost, host.c_str()))) { + if (away[0] == 'G' && getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_AWAY) setWord(hContact, "Status", ID_STATUS_AWAY); - else if (away[0] == 'H' && getWord( hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) + else if (away[0] == 'H' && getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) setWord(hContact, "Status", ID_STATUS_ONLINE); - if (( DBNick && lstrcmpi( nick.c_str(), DBNick)) || !DBNick ) - setTString( hContact, "Nick", nick.c_str()); - if (( DBManUser && lstrcmpi( user.c_str(), DBManUser)) || !DBManUser ) - setTString( hContact, "User", user.c_str()); - if (( DBManHost && lstrcmpi(host.c_str(), DBManHost)) || !DBManHost ) + if ((DBNick && lstrcmpi(nick.c_str(), DBNick)) || !DBNick) + setTString(hContact, "Nick", nick.c_str()); + if ((DBManUser && lstrcmpi(user.c_str(), DBManUser)) || !DBManUser) + setTString(hContact, "User", user.c_str()); + if ((DBManHost && lstrcmpi(host.c_str(), DBManHost)) || !DBManHost) setTString(hContact, "Host", host.c_str()); goto LBL_Exit; @@ -1996,77 +1968,78 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage* pmsg) p1 = GetWordAddress(p1, 4); away = GetWord(p1, 3); } - - if ( DBWildcard && DBNick && !WCCmp( CharLower( DBWildcard ), CharLower( DBNick ))) { + + if (DBWildcard && DBNick && !WCCmp(CharLower(DBWildcard), CharLower(DBNick))) { setTString(hContact, "Nick", DBDefault); - + DoUserhostWithReason(2, ((CMString)_T("S") + DBWildcard).c_str(), true, DBWildcard); - + setString(hContact, "User", ""); setString(hContact, "Host", ""); goto LBL_Exit; } - if ( getWord( hContact, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) { + if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { setWord(hContact, "Status", ID_STATUS_OFFLINE); setTString(hContact, "Nick", DBDefault); setString(hContact, "User", ""); setString(hContact, "Host", ""); } LBL_Exit: - if ( DBDefault ) db_free(&dbv1); - if ( DBNick ) db_free(&dbv2); - if ( DBWildcard ) db_free(&dbv3); - if ( DBUser ) db_free(&dbv4); - if ( DBHost ) db_free(&dbv5); - if ( DBManUser ) db_free(&dbv6); - if ( DBManHost ) db_free(&dbv7); + if (DBDefault) db_free(&dbv1); + if (DBNick) db_free(&dbv2); + if (DBWildcard) db_free(&dbv3); + if (DBUser) db_free(&dbv4); + if (DBHost) db_free(&dbv5); + if (DBManUser) db_free(&dbv6); + if (DBManHost) db_free(&dbv7); } - mir_free( UserList ); + mir_free(UserList); } } - else ShowMessage( pmsg ); + else ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_WHO_REPLY(const CIrcMessage* pmsg) { CMString command = PeekAtReasons(2); - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 6 && command[0] == 'S' ) { - m_whoReply.AppendFormat( _T("%s %s %s %s "), pmsg->parameters[5].c_str(), pmsg->parameters[2].c_str(), pmsg->parameters[3].c_str(), pmsg->parameters[6].c_str()); - if ( lstrcmpi( pmsg->parameters[5].c_str(), m_info.sNick.c_str()) == 0 ) { + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 6 && command[0] == 'S') { + m_whoReply.AppendFormat(_T("%s %s %s %s "), pmsg->parameters[5].c_str(), pmsg->parameters[2].c_str(), pmsg->parameters[3].c_str(), pmsg->parameters[6].c_str()); + if (lstrcmpi(pmsg->parameters[5].c_str(), m_info.sNick.c_str()) == 0) { TCHAR host[1024]; - lstrcpyn( host, pmsg->parameters[3].c_str(), 1024 ); - ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(host), IP_AUTO )); - } } + lstrcpyn(host, pmsg->parameters[3].c_str(), 1024); + ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(_T2A(host), IP_AUTO)); + } + } - if ( command[0] == 'U' ) - ShowMessage( pmsg ); + if (command[0] == 'U') + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_TRYAGAIN(const CIrcMessage* pmsg) { CMString command = _T(""); - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 1 ) { - if ( pmsg->parameters[1] == _T("WHO")) + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) { + if (pmsg->parameters[1] == _T("WHO")) command = GetNextUserhostReason(2); - if ( pmsg->parameters[1] == _T("USERHOST")) + if (pmsg->parameters[1] == _T("USERHOST")) command = GetNextUserhostReason(1); } if (command[0] == 'U') - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) { CMString command = _T(""); - if ( pmsg->m_bIncoming ) { + if (pmsg->m_bIncoming) { command = GetNextUserhostReason(1); - if ( !command.IsEmpty() && command != _T("U") && pmsg->parameters.getCount() > 1 ) { - CONTACT finduser = {NULL, NULL, NULL, false, false, false}; + if (!command.IsEmpty() && command != _T("U") && pmsg->parameters.getCount() > 1) { + CONTACT finduser = { NULL, NULL, NULL, false, false, false }; TCHAR* p1 = NULL; TCHAR* p2 = NULL; int awaystatus = 0; @@ -2081,35 +2054,36 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) int j; // Status-check pre-processing: Setup check-list - OBJLIST checklist( 10 ); - if ( command[0] == 'S' ) { + OBJLIST checklist(10); + if (command[0] == 'S') { j = 0; sTemp = GetWord(command.c_str(), 0); - sTemp.Delete(0,1); - while ( !sTemp.IsEmpty()) { - checklist.insert( new CMString( sTemp )); + sTemp.Delete(0, 1); + while (!sTemp.IsEmpty()) { + checklist.insert(new CMString(sTemp)); j++; sTemp = GetWord(command.c_str(), j); - } } + } + } // Cycle through results j = 0; - sTemp = GetWord( pmsg->parameters[1].c_str(), j ); - while ( !sTemp.IsEmpty()) { - p1 = mir_tstrdup( sTemp.c_str()); + sTemp = GetWord(pmsg->parameters[1].c_str(), j); + while (!sTemp.IsEmpty()) { + p1 = mir_tstrdup(sTemp.c_str()); p2 = p1; // Pull out host, user and nick p2 = _tcschr(p1, '@'); - if ( p2 ) { + if (p2) { *p2 = '\0'; p2++; host = p2; } p2 = _tcschr(p1, '='); - if ( p2 ) { - if (*(p2-1) == '*') - *(p2-1) = '\0'; // remove special char for IRCOps + if (p2) { + if (*(p2 - 1) == '*') + *(p2 - 1) = '\0'; // remove special char for IRCOps *p2 = '\0'; p2++; awaystatus = *p2; @@ -2119,38 +2093,38 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) } mess = _T(""); mask = nick + _T("!") + user + _T("@") + host; - if ( host.IsEmpty() || user.IsEmpty() || nick.IsEmpty()) { - mir_free( p1 ); + if (host.IsEmpty() || user.IsEmpty() || nick.IsEmpty()) { + mir_free(p1); continue; } // Do command - switch ( command[0] ) { + switch (command[0]) { case 'S': // Status check { - finduser.name = (TCHAR*)nick.c_str(); - finduser.host = (TCHAR*)host.c_str(); - finduser.user = (TCHAR*)user.c_str(); - - HANDLE hContact = CList_FindContact(&finduser); - if ( hContact && getByte( hContact, "AdvancedMode", 0 ) == 0 ) { - setWord(hContact, "Status", awaystatus == '-'? ID_STATUS_AWAY : ID_STATUS_ONLINE); - setTString(hContact, "User", user.c_str()); - setTString(hContact, "Host", host.c_str()); - setTString(hContact, "Nick", nick.c_str()); - - // If user found, remove from checklist - for ( i = 0; i < checklist.getCount(); i++ ) - if ( !lstrcmpi(checklist[i].c_str(), nick.c_str())) - checklist.remove( i ); - } - break; + finduser.name = (TCHAR*)nick.c_str(); + finduser.host = (TCHAR*)host.c_str(); + finduser.user = (TCHAR*)user.c_str(); + + HANDLE hContact = CList_FindContact(&finduser); + if (hContact && getByte(hContact, "AdvancedMode", 0) == 0) { + setWord(hContact, "Status", awaystatus == '-' ? ID_STATUS_AWAY : ID_STATUS_ONLINE); + setTString(hContact, "User", user.c_str()); + setTString(hContact, "Host", host.c_str()); + setTString(hContact, "Nick", nick.c_str()); + + // If user found, remove from checklist + for (i = 0; i < checklist.getCount(); i++) + if (!lstrcmpi(checklist[i].c_str(), nick.c_str())) + checklist.remove(i); + } + break; } case 'I': // m_ignore mess = _T("/IGNORE %question=\""); mess += TranslateT("Please enter the hostmask (nick!user@host)\nNOTE! Contacts on your contact list are never ignored"); mess += (CMString)_T("\",\"") + TranslateT("Ignore") + _T("\",\"*!*@") + host + _T("\""); - if ( m_ignoreChannelDefault ) + if (m_ignoreChannelDefault) mess += _T(" +qnidcm"); else mess += _T(" +qnidc"); @@ -2167,39 +2141,41 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) case 'K': // Ban & Kick channel = (command.c_str() + 1); - mess.Format( _T("/MODE %s +b *!*@%s%%newl/KICK %s %s"), channel.c_str(), host.c_str(), channel.c_str(), nick.c_str()); + mess.Format(_T("/MODE %s +b *!*@%s%%newl/KICK %s %s"), channel.c_str(), host.c_str(), channel.c_str(), nick.c_str()); break; case 'L': // Ban & Kick with reason channel = (command.c_str() + 1); - mess.Format( _T("/MODE %s +b *!*@%s%%newl/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""), + mess.Format(_T("/MODE %s +b *!*@%s%%newl/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""), channel.c_str(), host.c_str(), channel.c_str(), nick.c_str(), TranslateT("Please enter the reason"), TranslateT("Ban'n Kick"), TranslateT("Jerk")); break; } - - mir_free( p1 ); + + mir_free(p1); // Post message - if ( !mess.IsEmpty()) - PostIrcMessageWnd( NULL, NULL, mess.c_str()); + if (!mess.IsEmpty()) + PostIrcMessageWnd(NULL, NULL, mess.c_str()); j++; sTemp = GetWord(pmsg->parameters[1].c_str(), j); } - + // Status-check post-processing: make buddies in ckeck-list offline - if ( command[0] == 'S' ) { - for ( i = 0; i < checklist.getCount(); i++ ) { + if (command[0] == 'S') { + for (i = 0; i < checklist.getCount(); i++) { finduser.name = (TCHAR*)checklist[i].c_str(); finduser.ExactNick = true; - CList_SetOffline( &finduser ); - } } + CList_SetOffline(&finduser); + } + } return true; - } } - - if ( !pmsg->m_bIncoming || command == _T("U")) - ShowMessage( pmsg ); + } + } + + if (!pmsg->m_bIncoming || command == _T("U")) + ShowMessage(pmsg); return true; } @@ -2208,80 +2184,83 @@ bool CIrcProto::OnIrc_SUPPORT(const CIrcMessage* pmsg) static const TCHAR* lpszFmt = _T("Try server %99[^ ,], port %19s"); TCHAR szAltServer[100]; TCHAR szAltPort[20]; - if ( pmsg->parameters.getCount() > 1 && _stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szAltServer, &szAltPort) == 2 ) { - ShowMessage( pmsg ); - lstrcpynA( m_serverName, _T2A(szAltServer), 99 ); - lstrcpynA( m_portStart, _T2A(szAltPort), 9 ); + if (pmsg->parameters.getCount() > 1 && _stscanf(pmsg->parameters[1].c_str(), lpszFmt, &szAltServer, &szAltPort) == 2) { + ShowMessage(pmsg); + lstrcpynA(m_serverName, _T2A(szAltServer), 99); + lstrcpynA(m_portStart, _T2A(szAltPort), 9); m_noOfChannels = 0; ConnectToServer(); return true; } - if ( pmsg->m_bIncoming && !bPerformDone ) + if (pmsg->m_bIncoming && !bPerformDone) DoOnConnect(pmsg); - - if ( pmsg->m_bIncoming && pmsg->parameters.getCount() > 0 ) { + + if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 0) { CMString S; - for ( int i = 0; i < pmsg->parameters.getCount(); i++ ) { - TCHAR* temp = mir_tstrdup( pmsg->parameters[i].c_str()); - if ( _tcsstr( temp, _T("CHANTYPES="))) { - TCHAR* p1 = _tcschr( temp, '=' ); + for (int i = 0; i < pmsg->parameters.getCount(); i++) { + TCHAR* temp = mir_tstrdup(pmsg->parameters[i].c_str()); + if (_tcsstr(temp, _T("CHANTYPES="))) { + TCHAR* p1 = _tcschr(temp, '='); p1++; - if ( lstrlen( p1 ) > 0 ) + if (lstrlen(p1) > 0) sChannelPrefixes = p1; } - if ( _tcsstr(temp, _T("CHANMODES="))) { - TCHAR* p1 = _tcschr( temp, '=' ); + if (_tcsstr(temp, _T("CHANMODES="))) { + TCHAR* p1 = _tcschr(temp, '='); p1++; - if ( lstrlen( p1 ) > 0) - sChannelModes = ( char* )_T2A( p1 ); + if (lstrlen(p1) > 0) + sChannelModes = (char*)_T2A(p1); } - if ( _tcsstr( temp, _T("PREFIX="))) { - TCHAR* p1 = _tcschr( temp, '(' ); - TCHAR* p2 = _tcschr( temp, ')' ); - if ( p1 && p2 ) { + if (_tcsstr(temp, _T("PREFIX="))) { + TCHAR* p1 = _tcschr(temp, '('); + TCHAR* p2 = _tcschr(temp, ')'); + if (p1 && p2) { p1++; - if ( p1 != p2 ) - sUserModes = ( char* )_T2A( p1 ); - sUserModes = sUserModes.Mid(0, p2-p1); + if (p1 != p2) + sUserModes = (char*)_T2A(p1); + sUserModes = sUserModes.Mid(0, p2 - p1); p2++; - if ( *p2 != '\0' ) + if (*p2 != '\0') sUserModePrefixes = p2; } else { - p1 = _tcschr( temp, '=' ); + p1 = _tcschr(temp, '='); p1++; sUserModePrefixes = p1; - for ( int i =0; i < sUserModePrefixes.GetLength()+1; i++ ) { - if ( sUserModePrefixes[i] == '@' ) - sUserModes.SetAt( i, 'o' ); - else if ( sUserModePrefixes[i] == '+' ) - sUserModes.SetAt( i, 'v' ); - else if ( sUserModePrefixes[i] == '-' ) - sUserModes.SetAt( i, 'u' ); - else if ( sUserModePrefixes[i] == '%' ) - sUserModes.SetAt( i, 'h' ); - else if ( sUserModePrefixes[i] == '!' ) - sUserModes.SetAt( i, 'a' ); - else if ( sUserModePrefixes[i] == '*' ) - sUserModes.SetAt( i, 'q' ); - else if ( sUserModePrefixes[i] == '\0' ) - sUserModes.SetAt( i, '\0' ); - else - sUserModes.SetAt( i, '_' ); - } } } + for (int i = 0; i < sUserModePrefixes.GetLength() + 1; i++) { + if (sUserModePrefixes[i] == '@') + sUserModes.SetAt(i, 'o'); + else if (sUserModePrefixes[i] == '+') + sUserModes.SetAt(i, 'v'); + else if (sUserModePrefixes[i] == '-') + sUserModes.SetAt(i, 'u'); + else if (sUserModePrefixes[i] == '%') + sUserModes.SetAt(i, 'h'); + else if (sUserModePrefixes[i] == '!') + sUserModes.SetAt(i, 'a'); + else if (sUserModePrefixes[i] == '*') + sUserModes.SetAt(i, 'q'); + else if (sUserModePrefixes[i] == '\0') + sUserModes.SetAt(i, '\0'); + else + sUserModes.SetAt(i, '_'); + } + } + } - mir_free( temp ); - } } + mir_free(temp); + } + } - ShowMessage( pmsg ); + ShowMessage(pmsg); return true; } void CIrcProto::OnIrcDefault(const CIrcMessage* pmsg) { - ShowMessage( pmsg ); + ShowMessage(pmsg); } void CIrcProto::OnIrcDisconnected() @@ -2296,36 +2275,29 @@ void CIrcProto::OnIrcDisconnected() int Temp = m_iStatus; KillIdent(); - KillChatTimer( OnlineNotifTimer ); - KillChatTimer( OnlineNotifTimer3 ); - KillChatTimer( KeepAliveTimer ); - KillChatTimer( InitTimer ); - KillChatTimer( IdentTimer ); + KillChatTimer(OnlineNotifTimer); + KillChatTimer(OnlineNotifTimer3); + KillChatTimer(KeepAliveTimer); + KillChatTimer(InitTimer); + KillChatTimer(IdentTimer); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_OFFLINE); CMString sDisconn = _T("\0035\002"); sDisconn += TranslateT("*Disconnected*"); - DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, sDisconn.c_str(), NULL, NULL, NULL, true, false); + DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, sDisconn.c_str(), NULL, NULL, NULL, true, false); - { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - gce.cbSize = sizeof(GCEVENT); - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce); - } + GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce); + + if (!Miranda_Terminated()) + CList_SetAllOffline(m_disconnectDCCChats); - if ( !Miranda_Terminated()) - CList_SetAllOffline( m_disconnectDCCChats ); - // restore the original nick, cause it might be changed - memcpy( m_nick, m_pNick, sizeof( m_nick )); - setTString( "Nick", m_pNick ); - + memcpy(m_nick, m_pNick, sizeof(m_nick)); + setTString("Nick", m_pNick); + CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | CMIF_GRAYED; Menu_ModifyItem(hMenuJoin, &mi); @@ -2336,25 +2308,26 @@ void CIrcProto::OnIrcDisconnected() ///////////////////////////////////////////////////////////////////////////////////////// // OnConnect -static void __stdcall sttMainThrdOnConnect( void* param ) +static void __stdcall sttMainThrdOnConnect(void* param) { - CIrcProto *ppro = ( CIrcProto* )param; + CIrcProto *ppro = (CIrcProto*)param; - ppro->SetChatTimer( ppro->InitTimer, 1*1000, TimerProc ); - if ( ppro->m_identTimer ) - ppro->SetChatTimer( ppro->IdentTimer, 60*1000, IdentTimerProc ); - if ( ppro->m_sendKeepAlive ) - ppro->SetChatTimer( ppro->KeepAliveTimer, 60*1000, KeepAliveTimerProc ); - if ( ppro->m_autoOnlineNotification && !ppro->bTempDisableCheck || ppro->bTempForceCheck ) { - ppro->SetChatTimer( ppro->OnlineNotifTimer, 1000, OnlineNotifTimerProc ); - if ( ppro->m_channelAwayNotification ) - ppro->SetChatTimer( ppro->OnlineNotifTimer3, 3000, OnlineNotifTimerProc3); -} } + ppro->SetChatTimer(ppro->InitTimer, 1 * 1000, TimerProc); + if (ppro->m_identTimer) + ppro->SetChatTimer(ppro->IdentTimer, 60 * 1000, IdentTimerProc); + if (ppro->m_sendKeepAlive) + ppro->SetChatTimer(ppro->KeepAliveTimer, 60 * 1000, KeepAliveTimerProc); + if (ppro->m_autoOnlineNotification && !ppro->bTempDisableCheck || ppro->bTempForceCheck) { + ppro->SetChatTimer(ppro->OnlineNotifTimer, 1000, OnlineNotifTimerProc); + if (ppro->m_channelAwayNotification) + ppro->SetChatTimer(ppro->OnlineNotifTimer3, 3000, OnlineNotifTimerProc3); + } +} -bool CIrcProto::DoOnConnect( const CIrcMessage* ) +bool CIrcProto::DoOnConnect(const CIrcMessage*) { bPerformDone = true; - nickflag = true; + nickflag = true; CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS; @@ -2364,50 +2337,47 @@ bool CIrcProto::DoOnConnect( const CIrcMessage* ) int Temp = m_iStatus; m_iStatus = ID_STATUS_ONLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE )Temp, m_iStatus ); - - if ( m_iDesiredStatus == ID_STATUS_AWAY ) - PostIrcMessage( _T("/AWAY %s"), m_statusMessage.Mid(0,450).c_str()); - - if ( m_perform ) { - DoPerform( "ALL NETWORKS" ); - if ( IsConnected()) { - DoPerform( _T2A( m_info.sNetwork.c_str())); - switch( m_iStatus ) { - case ID_STATUS_FREECHAT: DoPerform( "Event: Free for chat" ); break; - case ID_STATUS_ONLINE: DoPerform( "Event: Available" ); break; - } } } + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, m_iStatus); + + if (m_iDesiredStatus == ID_STATUS_AWAY) + PostIrcMessage(_T("/AWAY %s"), m_statusMessage.Mid(0, 450).c_str()); + + if (m_perform) { + DoPerform("ALL NETWORKS"); + if (IsConnected()) { + DoPerform(_T2A(m_info.sNetwork.c_str())); + switch (m_iStatus) { + case ID_STATUS_FREECHAT: DoPerform("Event: Free for chat"); break; + case ID_STATUS_ONLINE: DoPerform("Event: Available"); break; + } + } + } - if ( m_rejoinChannels ) { - int count = CallServiceSync( MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName); - for ( int i = 0; i < count ; i++ ) { - GC_INFO gci = {0}; + if (m_rejoinChannels) { + int count = CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName); + for (int i = 0; i < count; i++) { + GC_INFO gci = { 0 }; gci.Flags = BYINDEX | DATA | NAME | TYPE; gci.iItem = i; gci.pszModule = m_szModuleName; - if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM ) { - CHANNELINFO *wi = ( CHANNELINFO* )gci.dwItemData; - if ( wi && wi->pszPassword ) - PostIrcMessage( _T("/JOIN %s %s"), gci.pszName, wi->pszPassword); + if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM) { + CHANNELINFO *wi = (CHANNELINFO*)gci.dwItemData; + if (wi && wi->pszPassword) + PostIrcMessage(_T("/JOIN %s %s"), gci.pszName, wi->pszPassword); else - PostIrcMessage( _T("/JOIN %s"), gci.pszName); - } } } + PostIrcMessage(_T("/JOIN %s"), gci.pszName); + } + } + } - DoEvent( GC_EVENT_ADDGROUP, SERVERWINDOW, NULL, NULL, _T("Normal"), NULL, NULL, FALSE, TRUE); + DoEvent(GC_EVENT_ADDGROUP, SERVERWINDOW, NULL, NULL, _T("Normal"), NULL, NULL, FALSE, TRUE); { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - gce.dwFlags = GC_TCHAR; - gce.cbSize = sizeof(GCEVENT); - gcd.ptszID = SERVERWINDOW; - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - CallChatEvent( SESSION_ONLINE, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_ONLINE, (LPARAM)&gce); } - CallFunctionAsync( sttMainThrdOnConnect, this ); + CallFunctionAsync(sttMainThrdOnConnect, this); nickflag = false; return 0; } @@ -2417,77 +2387,77 @@ static void __cdecl AwayWarningThread(LPVOID) MessageBox(NULL, TranslateT("The usage of /AWAY in your perform buffer is restricted\n as IRC sends this command automatically."), TranslateT("IRC Error"), MB_OK); } -int CIrcProto::DoPerform( const char* event ) +int CIrcProto::DoPerform(const char* event) { String sSetting = String("PERFORM:") + event; sSetting.MakeUpper(); DBVARIANT dbv; - if ( !getTString( sSetting.c_str(), &dbv )) { - if ( !my_strstri( dbv.ptszVal, _T("/away"))) - PostIrcMessageWnd( NULL, NULL, dbv.ptszVal ); + if (!getTString(sSetting.c_str(), &dbv)) { + if (!my_strstri(dbv.ptszVal, _T("/away"))) + PostIrcMessageWnd(NULL, NULL, dbv.ptszVal); else - mir_forkthread( AwayWarningThread, NULL ); - db_free( &dbv ); + mir_forkthread(AwayWarningThread, NULL); + db_free(&dbv); return 1; } return 0; } -int CIrcProto::IsIgnored( const CMString& nick, const CMString& address, const CMString& host, char type) -{ - return IsIgnored( nick + _T("!") + address + _T("@") + host, type ); +int CIrcProto::IsIgnored(const CMString& nick, const CMString& address, const CMString& host, char type) +{ + return IsIgnored(nick + _T("!") + address + _T("@") + host, type); } -int CIrcProto::IsIgnored( CMString user, char type ) +int CIrcProto::IsIgnored(CMString user, char type) { - for ( int i=0; i < m_ignoreItems.getCount(); i++ ) { + for (int i = 0; i < m_ignoreItems.getCount(); i++) { const CIrcIgnoreItem& C = m_ignoreItems[i]; - if ( type == '\0' ) - if ( !lstrcmpi( user.c_str(), C.mask.c_str())) - return i+1; - - bool bUserContainsWild = ( _tcschr( user.c_str(), '*') != NULL || _tcschr( user.c_str(), '?' ) != NULL ); - if ( !bUserContainsWild && WCCmp( C.mask.c_str(), user.c_str()) || - bUserContainsWild && !lstrcmpi( user.c_str(), C.mask.c_str())) - { - if ( C.flags.IsEmpty() || C.flags[0] != '+' ) + if (type == '\0') + if (!lstrcmpi(user.c_str(), C.mask.c_str())) + return i + 1; + + bool bUserContainsWild = (_tcschr(user.c_str(), '*') != NULL || _tcschr(user.c_str(), '?') != NULL); + if (!bUserContainsWild && WCCmp(C.mask.c_str(), user.c_str()) || + bUserContainsWild && !lstrcmpi(user.c_str(), C.mask.c_str())) { + if (C.flags.IsEmpty() || C.flags[0] != '+') continue; - if ( !_tcschr( C.flags.c_str(), type )) + if (!_tcschr(C.flags.c_str(), type)) continue; - if ( C.network.IsEmpty()) - return i+1; + if (C.network.IsEmpty()) + return i + 1; - if ( IsConnected() && !lstrcmpi( C.network.c_str(), m_info.sNetwork.c_str())) - return i+1; - } } + if (IsConnected() && !lstrcmpi(C.network.c_str(), m_info.sNetwork.c_str())) + return i + 1; + } + } - return 0; + return 0; } -bool CIrcProto::AddIgnore( const TCHAR* mask, const TCHAR* flags, const TCHAR* network ) -{ - RemoveIgnore( mask ); - m_ignoreItems.insert( new CIrcIgnoreItem( mask, (_T("+") + CMString(flags)).c_str(), network )); +bool CIrcProto::AddIgnore(const TCHAR* mask, const TCHAR* flags, const TCHAR* network) +{ + RemoveIgnore(mask); + m_ignoreItems.insert(new CIrcIgnoreItem(mask, (_T("+") + CMString(flags)).c_str(), network)); RewriteIgnoreSettings(); - if ( m_ignoreDlg ) + if (m_ignoreDlg) m_ignoreDlg->RebuildList(); return true; -} +} -bool CIrcProto::RemoveIgnore( const TCHAR* mask ) -{ +bool CIrcProto::RemoveIgnore(const TCHAR* mask) +{ int idx; - while (( idx = IsIgnored( mask, '\0')) != 0 ) - m_ignoreItems.remove( idx-1 ); + while ((idx = IsIgnored(mask, '\0')) != 0) + m_ignoreItems.remove(idx - 1); RewriteIgnoreSettings(); - if ( m_ignoreDlg ) + if (m_ignoreDlg) m_ignoreDlg->RebuildList(); - return true; -} + return true; +} diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp index eb8125a351..674f8e857c 100644 --- a/protocols/IRCG/src/input.cpp +++ b/protocols/IRCG/src/input.cpp @@ -224,14 +224,8 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac if ( command == _T("/servershow") || command == _T("/serverhide")) { if ( m_useServer ) { - GCEVENT gce = {0}; - GCDEST gcd = {0}; - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_CONTROL; - gcd.ptszID = SERVERWINDOW; - gcd.pszModule = m_szModuleName; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallChatEvent( command == _T("/servershow") ? WINDOW_VISIBLE : WINDOW_HIDDEN, (LPARAM)&gce); } return true; @@ -261,15 +255,9 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac else S = MakeWndID( window ); - GCEVENT gce = {0}; - GCDEST gcd = {0}; - gce.cbSize = sizeof(GCEVENT); - gcd.iType = GC_EVENT_CONTROL; - gcd.pszModule = m_szModuleName; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - gcd.ptszID = (TCHAR*)S.c_str(); - CallChatEvent( WINDOW_CLEARLOG, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(WINDOW_CLEARLOG, (LPARAM)&gce); return true; } @@ -488,15 +476,9 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac return true; } - GCEVENT gce = {0}; - GCDEST gcd = {0}; - gcd.iType = GC_EVENT_CONTROL; CMString S = MakeWndID(window); - gcd.ptszID = (TCHAR*)S.c_str(); - gcd.pszModule = m_szModuleName; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce); PostIrcMessage( _T("/JOIN %s"), GetWordAddress(text.c_str(), 1)); diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h index f6028219ee..367b92a905 100644 --- a/protocols/IRCG/src/irc.h +++ b/protocols/IRCG/src/irc.h @@ -464,7 +464,7 @@ struct CIrcProto : public PROTO INT_PTR __cdecl Scripting_GetIrcData(WPARAM wparam, LPARAM lparam); BOOL Scripting_TriggerMSPRawIn(char ** pszRaw); BOOL Scripting_TriggerMSPRawOut(char ** pszRaw); - BOOL Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT * gce); + BOOL Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce); BOOL Scripting_TriggerMSPGuiOut(GCHOOK * gch); // services.cpp diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index f50b074a4f..360d572843 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -214,10 +214,10 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM ) if ( ServiceExists( MS_GC_REGISTER )) { GCREGISTER gcr = { sizeof(GCREGISTER) }; - gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR | GC_TCHAR; + gcr.dwFlags = GC_CHANMGR | GC_BOLD | GC_ITALICS | GC_UNDERLINE | GC_COLOR | GC_BKGCOLOR; gcr.nColors = 16; gcr.pColors = colors; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr); @@ -225,26 +225,18 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM ) HookProtoEvent(ME_GC_BUILDMENU, &CIrcProto::GCMenuHook); GCSESSION gcw = { sizeof(GCSESSION) }; - gcw.dwFlags = GC_TCHAR; gcw.iType = GCW_SERVER; gcw.ptszID = SERVERWINDOW; gcw.pszModule = m_szModuleName; gcw.ptszName = NEWTSTR_ALLOCA(( TCHAR* )_A2T( m_network )); CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - GCDEST gcd = { 0 }; - gcd.ptszID = SERVERWINDOW; - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = { sizeof(GCEVENT) }; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - + GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; if ( m_useServer && !m_hideServerWindow ) - CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce); + CallChatEvent(WINDOW_VISIBLE, (LPARAM)&gce); else - CallChatEvent( WINDOW_HIDDEN, (LPARAM)&gce); + CallChatEvent(WINDOW_HIDDEN, (LPARAM)&gce); bChatInstalled = TRUE; } else { diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp index f03b58d252..ea63dc16a2 100644 --- a/protocols/IRCG/src/scripting.cpp +++ b/protocols/IRCG/src/scripting.cpp @@ -78,17 +78,10 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam) static void __stdcall OnHook(void * pi) { GCHOOK* gch = ( GCHOOK* )pi; - - //Service_GCEventHook(1, (LPARAM) gch); - - if(gch->pszUID) - free(gch->pszUID); - if(gch->pszText) - free(gch->pszText); - if(gch->pDest->ptszID) - free(gch->pDest->ptszID); - if(gch->pDest->pszModule) - free(gch->pDest->pszModule); + free(gch->ptszUID); + free(gch->ptszText); + free(gch->pDest->ptszID); + free(gch->pDest->pszModule); delete gch->pDest; delete gch; } @@ -111,11 +104,12 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut( WPARAM, LPARAM lParam ) gchook->pDest->iType = gch->pDest->iType; if ( gch->ptszText ) gchook->ptszText = _tcsdup( gch->ptszText ); - else gchook->pszText = NULL; + else gchook->ptszText = NULL; if ( gch->ptszUID ) gchook->ptszUID = _tcsdup( gch->ptszUID ); - else gchook->pszUID = NULL; + else + gchook->ptszUID = NULL; if ( gch->pDest->ptszID ) { CMString S = MakeWndID( gch->pDest->ptszID ); @@ -152,7 +146,7 @@ BOOL CIrcProto::Scripting_TriggerMSPRawOut(char ** pszRaw) return iVal > 0 ? FALSE : TRUE; } -BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT * gce) +BOOL CIrcProto::Scripting_TriggerMSPGuiIn(WPARAM * wparam, GCEVENT *gce) { WPARAM_GUI_IN wgi = {0}; diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 211e9e0dc1..c0f68e43b2 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -221,20 +221,13 @@ int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM) if ( !getTString( hContact, "Nick", &dbv )) { int type = getByte(hContact, "ChatRoom", 0); if ( type != 0 ) { - GCEVENT gce = {0}; - GCDEST gcd = {0}; CMString S = _T(""); if (type == GCW_CHATROOM) S = MakeWndID( dbv.ptszVal ); if (type == GCW_SERVER) S = SERVERWINDOW; - gce.cbSize = sizeof(GCEVENT); - gce.dwItemData = 0; - gcd.iType = GC_EVENT_CONTROL; - gcd.pszModule = m_szModuleName; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - gcd.ptszID = ( TCHAR* )S.c_str(); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; int i = CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce); if (i && type == GCW_CHATROOM) PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo); @@ -276,16 +269,10 @@ INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM) if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM) { PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo); - GCEVENT gce = {0}; - GCDEST gcd = {0}; CMString S = MakeWndID(dbv.ptszVal); - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_CONTROL; - gcd.pszModule = m_szModuleName; - gce.pDest = &gcd; - gcd.ptszID = ( TCHAR* )S.c_str(); - CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce); } db_free(&dbv); } @@ -399,14 +386,8 @@ INT_PTR __cdecl CIrcProto::OnShowListMenuCommand(WPARAM, LPARAM) INT_PTR __cdecl CIrcProto::OnShowServerMenuCommand(WPARAM, LPARAM) { - GCEVENT gce = {0}; - GCDEST gcd = {0}; - gcd.iType = GC_EVENT_CONTROL; - gcd.ptszID = SERVERWINDOW; - gce.dwFlags = GC_TCHAR; - gcd.pszModule = m_szModuleName; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce); return 0; } @@ -530,8 +511,8 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) // first see if the scripting module should modify or stop this event if (m_bMbotInstalled && m_scriptingEnabled && wParam == NULL) { - gchtemp = (GCHOOK *)mir_alloc(sizeof(GCHOOK)); - gchtemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST)); + gchtemp = (GCHOOK*)mir_alloc(sizeof(GCHOOK)); + gchtemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST)); gchtemp->pDest->iType = gchook->pDest->iType; gchtemp->dwData = gchook->dwData; @@ -567,7 +548,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) break; case GC_USER_MESSAGE: - if (gch && gch->pszText && lstrlen(gch->ptszText) > 0 ) { + if (gch && gch->ptszText && *gch->ptszText) { TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000]; lstrcpy(pszText, gch->ptszText); DoChatFormatting(pszText); @@ -599,16 +580,11 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) case 3: PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo ); - { GCEVENT gce = {0}; - GCDEST gcd = {0}; + { S = MakeWndID(p1); - gce.cbSize = sizeof(GCEVENT); - gcd.iType = GC_EVENT_CONTROL; - gcd.pszModule = m_szModuleName; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - gcd.ptszID = ( TCHAR* )S.c_str(); - CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce); + GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce); } break; case 4: // show server window @@ -836,8 +812,8 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam) } } } if ( gchtemp ) { - mir_free(gchtemp->pszUID); - mir_free(gchtemp->pszText); + mir_free(gchtemp->ptszUID); + mir_free(gchtemp->ptszText); mir_free(gchtemp->pDest->ptszID); mir_free(gchtemp->pDest->pszModule); mir_free(gchtemp->pDest); @@ -1149,18 +1125,11 @@ void CIrcProto::ConnectToServer(void) void CIrcProto::DisconnectFromServer(void) { - GCEVENT gce = {0}; - GCDEST gcd = {0}; - if ( m_perform && IsConnected()) DoPerform( "Event: Disconnect" ); - gcd.iType = GC_EVENT_CONTROL; - gcd.ptszID = NULL; // all windows - gcd.pszModule = m_szModuleName; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - + GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce); ForkThread( &CIrcProto::DisconnectServerThread, 0 ); } diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 8489a2557a..ee4fcbb51c 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -406,18 +406,17 @@ TCHAR* __stdcall DoColorCodes(const TCHAR* text, bool bStrip, bool bReplacePerce INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam) { - GCEVENT * gce = (GCEVENT *)lParam; + GCEVENT *gce = (GCEVENT *)lParam; INT_PTR iVal = 0; // first see if the scripting module should modify or stop this event - if (m_bMbotInstalled && m_scriptingEnabled && gce - && gce->time != 0 && (gce->pDest->ptszID == NULL - || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW))) { + if (m_bMbotInstalled && m_scriptingEnabled && gce && gce->time != 0 && + (gce->pDest->ptszID == NULL || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW))) + { GCEVENT *gcevent = (GCEVENT*)lParam; - GCEVENT *gcetemp = NULL; - WPARAM wp = wParam; - gcetemp = (GCEVENT *)mir_alloc(sizeof(GCEVENT)); - gcetemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST)); + WPARAM wp = wParam; + GCEVENT *gcetemp = (GCEVENT*)mir_alloc(sizeof(GCEVENT)); + gcetemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST)); gcetemp->pDest->iType = gcevent->pDest->iType; gcetemp->dwFlags = gcevent->dwFlags; gcetemp->bIsMe = gcevent->bIsMe; @@ -446,11 +445,11 @@ INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam) } if (gcetemp) { - mir_free((void*)gcetemp->pszNick); - mir_free((void*)gcetemp->pszUID); - mir_free((void*)gcetemp->pszStatus); - mir_free((void*)gcetemp->pszUserInfo); - mir_free((void*)gcetemp->pszText); + mir_free((void*)gcetemp->ptszNick); + mir_free((void*)gcetemp->ptszUID); + mir_free((void*)gcetemp->ptszStatus); + mir_free((void*)gcetemp->ptszUserInfo); + mir_free((void*)gcetemp->ptszText); mir_free((void*)gcetemp->pDest->ptszID); mir_free((void*)gcetemp->pDest->pszModule); mir_free((void*)gcetemp->pDest); @@ -467,8 +466,7 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo, DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp) { - GCDEST gcd = { 0 }; - GCEVENT gce = { 0 }; + GCDEST gcd = { m_szModuleName, NULL, iEvent }; CMString sID; CMString sText = _T(""); @@ -491,13 +489,9 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN } else gcd.ptszID = NULL; - gcd.pszModule = m_szModuleName; - gcd.iType = iEvent; - - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = pszStatus; - gce.dwFlags = GC_TCHAR + ((bAddToLog) ? GCEF_ADDTOLOG : 0); + gce.dwFlags = (bAddToLog) ? GCEF_ADDTOLOG : 0; gce.ptszNick = pszNick; gce.ptszUID = pszNick; if (iEvent == GC_EVENT_TOPIC) diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 16764bc529..32e77d3c0b 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -133,7 +133,6 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) gcw.pszModule = m_szModuleName; gcw.ptszName = szNick; gcw.ptszID = item->jid; - gcw.dwFlags = GC_TCHAR; CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw); HANDLE hContact = HContactFromJID(item->jid); @@ -166,19 +165,13 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) item->bChatActive = TRUE; - GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_ADDGROUP }; - gcd.ptszID = item->jid; - - GCEVENT gce = { sizeof(GCEVENT) }; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; for (i = SIZEOF(sttStatuses)-1; i >= 0; i--) { gce.ptszStatus = TranslateTS(sttStatuses[i]); CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); } - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; gcd.iType = GC_EVENT_CONTROL; CallServiceSync(MS_GC_EVENT, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); @@ -253,17 +246,13 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus } if (*buf) { - GCDEST gcd = { m_szModuleName, 0, 0 }; - gcd.ptszID = item->jid; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); + GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_INFORMATION }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszNick = user->m_tszResourceName; gce.ptszUID = user->m_tszResourceName; gce.ptszText = EscapeChatTags(buf); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = time(0); - gcd.iType = GC_EVENT_INFORMATION; CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); mir_free((void*)gce.ptszText); // Since we processed msgText and created a new string @@ -286,17 +275,13 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR * if (myNick == NULL) myNick = JabberNickFromJID(m_szJabberJID); - GCDEST gcd = { m_szModuleName, 0, 0 }; - gcd.ptszID = item->jid; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); + GCDEST gcd = { m_szModuleName, item->jid }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszNick = nick; gce.ptszUID = resource; if (jid != NULL) gce.ptszUserInfo = jid; gce.ptszText = szReason; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; if (item->bChatActive == 2) { gce.dwFlags |= GCEF_ADDTOLOG; gce.time = time(0); @@ -351,14 +336,10 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) { TCHAR *szMessage = NULL; - GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; - gcd.ptszID = item->jid; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); + GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszUID = item->jid; gce.ptszText = xmlGetText(reason); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; if (code != 307 && code != 301) { CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); @@ -1453,7 +1434,7 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam) switch (gch->pDest->iType) { case GC_USER_MESSAGE: - if (gch->pszText && lstrlen(gch->ptszText) > 0) { + if (gch->ptszText && lstrlen(gch->ptszText) > 0) { rtrimt(gch->ptszText); if (m_bJabberOnline) { diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index fc27e29e78..3a1c740926 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -820,18 +820,13 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const TCHAR *ol setTString(hContact, "MyNick", newNick); } - GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CHUID }; - gcd.ptszID = item->jid; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CHUID }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszNick = oldNick; gce.ptszText = newNick; if (jid != NULL) gce.ptszUserInfo = jid; gce.time = time(0); - gce.dwFlags = GC_TCHAR; CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); gcd.iType = GC_EVENT_NICK; @@ -1072,8 +1067,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) if ( !lstrcmp(type, _T("error"))) return; - GCDEST gcd = { m_szModuleName, NULL, 0 }; - gcd.ptszID = item->jid; + GCDEST gcd = { m_szModuleName, item->jid, 0 }; const TCHAR *msgText = NULL; @@ -1141,14 +1135,12 @@ void CJabberProto::GroupchatProcessMessage(HXML node) } else nick = NULL; - GCEVENT gce = { sizeof(GCEVENT) }; - gce.pDest = &gcd; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszUID = resource; gce.ptszNick = nick; gce.time = msgTime; gce.ptszText = EscapeChatTags((TCHAR*)msgText); gce.bIsMe = nick == NULL ? FALSE : (lstrcmp(resource, item->nick) == 0); - gce.dwFlags = GC_TCHAR; if (!isHistory) gce.dwFlags |= GCEF_ADDTOLOG; @@ -1166,7 +1158,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); } - mir_free((void*)gce.pszText); // Since we processed msgText and created a new string + mir_free((void*)gce.ptszText); // Since we processed msgText and created a new string } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 93469fe0a4..27ec3fcfbd 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -445,11 +445,9 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "MyHandle"); if ( isChatRoom(hContact)) { - GCSESSION gcw = {0}; - gcw.cbSize = sizeof(GCSESSION); + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; - gcw.dwFlags = GC_TCHAR; gcw.ptszID = jid; gcw.ptszName = NEWTSTR_ALLOCA(jid); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 174ebdb262..276777df2e 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -218,13 +218,11 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) m_pInfoFrame = new CJabberInfoFrame(this); - GCREGISTER gcr = {0}; - gcr.cbSize = sizeof(GCREGISTER); - gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR; - gcr.iMaxText = 0; + GCREGISTER gcr = { sizeof(gcr) }; + gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; gcr.nColors = 16; gcr.pColors = &crCols[0]; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr); diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 05217363e7..1d344ad783 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -125,9 +125,7 @@ static VOID CALLBACK JabberOfflineChatWindows(void* param) { CJabberProto *ppro = (CJabberProto*)param; GCDEST gcd = { ppro->m_szModuleName, NULL, GC_EVENT_CONTROL }; - GCEVENT gce = { 0 }; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCEVENT gce = { sizeof(gce), &gcd }; CallService(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index 86c83daff6..2622dfe4d5 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -16,12 +16,10 @@ bool CMraProto::MraChatRegister() if ( !ServiceExists(MS_GC_REGISTER)) return FALSE; - GCREGISTER gcr = {0}; - gcr.cbSize = sizeof(GCREGISTER); - gcr.dwFlags = GC_UNICODE; + GCREGISTER gcr = { sizeof(gcr) }; gcr.iMaxText = MRA_MAXLENOFMESSAGE; gcr.nColors = 0; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr); @@ -33,38 +31,25 @@ INT_PTR CMraProto::MraChatSessionNew(HANDLE hContact) { if (bChatExists) if (hContact) { - GCSESSION gcw = {0}; CMStringW wszEMail; mraGetStringW(hContact, "e-mail", wszEMail); - gcw.cbSize = sizeof(GCSESSION); + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = GetContactNameW(hContact); gcw.ptszID = wszEMail; gcw.ptszStatusbarText = _T("status bar"); - gcw.dwFlags = GC_TCHAR; gcw.dwItemData = (DWORD)hContact; if ( !CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw)) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - gcd.pszModule = m_szModuleName; - gcd.ptszID = (TCHAR*)wszEMail.c_str(); - gcd.iType = GC_EVENT_ADDGROUP; - - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GC_UNICODE; + GCDEST gcd = { m_szModuleName, (TCHAR*)wszEMail.c_str(), GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; for (int i = 0; i < SIZEOF(lpwszStatuses); i++) { gce.ptszStatus = TranslateTS(lpwszStatuses[i]); CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); } - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; gcd.iType = GC_EVENT_CONTROL; - CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); @@ -83,19 +68,14 @@ void CMraProto::MraChatSessionDestroy(HANDLE hContact) if ( !bChatExists) return; - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CMStringW wszEMail; + GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; - gcd.pszModule = m_szModuleName; - gcd.iType = GC_EVENT_CONTROL; + CMStringW wszEMail; if (hContact) { mraGetStringW(hContact, "e-mail", wszEMail); gcd.ptszID = (LPWSTR)wszEMail.c_str(); } - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GC_UNICODE; CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, (LPARAM)&gce); @@ -108,18 +88,14 @@ INT_PTR CMraProto::MraChatSessionEventSendByHandle(HANDLE hContactChatSession, D CMStringW wszID, wszUID, wszNick; - GCDEST gcd = {0}; - gcd.pszModule = m_szModuleName; + GCDEST gcd = { m_szModuleName, 0, dwType }; if (hContactChatSession) { mraGetStringW(hContactChatSession, "e-mail", wszID); gcd.ptszID = (LPWSTR)wszID.c_str(); } - gcd.iType = dwType; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GC_UNICODE|dwFlags; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = dwFlags; gce.ptszUID = wszUID; gce.ptszStatus = lpwszStatus; gce.ptszText = lpwszMessage; diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 83f0ccd79c..c1f65f4d5c 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -509,15 +509,13 @@ HANDLE CMraProto::MraHContactFromEmail(const CMStringA& szEmail, BOOL bAddIfNeed if (!bFound && bAddIfNeeded) { //not already there: add if (IsEMailChatAgent(szEmail)) { - GCSESSION gcw = {0}; CMStringW wszEMail = szEmail; - gcw.cbSize = sizeof(GCSESSION); + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = wszEMail; gcw.ptszID = (LPWSTR)wszEMail.c_str(); - gcw.dwFlags = GC_UNICODE; if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0) { BOOL bChatAdded = FALSE; diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index d7e2bc3f90..d5718bb34e 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -47,21 +47,15 @@ int CMsnProto::MSN_ChatInit(ThreadData *info) mir_sntprintf(szName, SIZEOF(szName), _T("%s %s%s"), m_tszUserName, TranslateT("Chat #"), info->mChatID); - GCSESSION gcw = {0}; - gcw.cbSize = sizeof(GCSESSION); - gcw.dwFlags = GC_TCHAR; + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = szName; gcw.ptszID = info->mChatID; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; - gcd.ptszID = info->mChatID; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = TranslateT("Me"); CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -95,13 +89,9 @@ void CMsnProto::MSN_ChatStart(ThreadData* info) MSN_ChatInit(info); // add all participants onto the list - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_JOIN }; - gcd.ptszID = info->mChatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszStatus = TranslateT("Others"); gce.time = time(NULL); gce.bIsMe = FALSE; @@ -121,12 +111,9 @@ void CMsnProto::MSN_ChatStart(ThreadData* info) void CMsnProto::MSN_KillChatSession(TCHAR* id) { - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = id; - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, id, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_REMOVECONTACT; CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } @@ -320,7 +307,7 @@ INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) { - GCHOOK *gch = (GCHOOK*) lParam; + GCHOOK *gch = (GCHOOK*)lParam; if (!gch) return 1; @@ -349,13 +336,9 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) DBVARIANT dbv; int bError = getTString("Nick", &dbv); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE }; - gcd.ptszID = gch->pDest->ptszID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = bError ? _T("") : dbv.ptszVal; gce.ptszUID = mir_a2t(MyOptions.szEmail); gce.time = time(NULL); diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index aa8fe39c21..63836bea6a 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -470,13 +470,9 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para if (info->mChatID[0]) { - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE }; - gcd.ptszID = info->mChatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = mir_a2t(email); gce.ptszNick = GetContactNameT(hContact); gce.time = time(NULL); @@ -487,7 +483,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para mir_free(p); CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); - mir_free((void*)gce.pszText); + mir_free((void*)gce.ptszText); mir_free((void*)gce.ptszUID); } else if (hContact) @@ -1181,19 +1177,15 @@ LBL_InvalidCommand: // modified for chat if (msnHaveChatDll) { - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_QUIT }; - gcd.ptszID = info->mChatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = GetContactNameT(hContact); gce.ptszUID = mir_a2t(data.userEmail); gce.time = time(NULL); gce.bIsMe = FALSE; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); - mir_free((void*)gce.pszUID); + mir_free((void*)gce.ptszUID); } int personleft = info->contactLeft(data.userEmail); @@ -1207,13 +1199,9 @@ LBL_InvalidCommand: { if (!strcmp(data.isIdle, "1")) { - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_INFORMATION }; - gcd.ptszID = info->mChatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.bIsMe = FALSE; gce.time = time(NULL); gce.ptszText = TranslateT("This conversation has been inactive, participants will be removed."); @@ -1565,13 +1553,9 @@ remove: { if (chatCreated) { - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_JOIN }; - gcd.ptszID = info->mChatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = GetContactNameT(hContact); gce.ptszUID = mir_a2t(data.userEmail); gce.ptszStatus = TranslateT("Others"); diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 0c492a34ae..63191ab22f 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -184,11 +184,11 @@ int CMsnProto::OnModulesLoaded(WPARAM, LPARAM) if (msnHaveChatDll) { GCREGISTER gcr = {0}; gcr.cbSize = sizeof(GCREGISTER); - gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR; + gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; gcr.iMaxText = 0; gcr.nColors = 16; gcr.pColors = (COLORREF*)crCols; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index 39ad7925e5..88f6874c71 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -23,30 +23,23 @@ along with this program. If not, see . void OmegleProto::UpdateChat(const TCHAR *name, const TCHAR *message, bool addtolog) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = ::time(NULL); gce.ptszText = message; - gce.time = ::time(NULL); - gce.dwFlags = GC_TCHAR; - gcd.iType = GC_EVENT_MESSAGE; if (name == NULL) { gcd.iType = GC_EVENT_INFORMATION; name = TranslateT("Server"); gce.bIsMe = false; - } else { - gce.bIsMe = !_tcscmp(name, this->facy.nick_); } + else gce.bIsMe = !_tcscmp(name, this->facy.nick_); if (addtolog) gce.dwFlags |= GCEF_ADDTOLOG; gce.ptszNick = name; gce.ptszUID = gce.ptszNick; - CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); } @@ -214,29 +207,19 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam) /*void OmegleProto::SendChatEvent(int type) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast(&gce)); }*/ void OmegleProto::AddChatContact(const TCHAR *name) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_JOIN; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.ptszNick = name; - gce.ptszUID = gce.ptszNick; - gce.time = static_cast(time(0)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = DWORD(time(0)); + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = name; + gce.ptszUID = gce.ptszNick; if (name == NULL) gce.bIsMe = false; @@ -253,16 +236,12 @@ void OmegleProto::AddChatContact(const TCHAR *name) void OmegleProto::DeleteChatContact(const TCHAR *name) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_PART; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.ptszNick = name; - gce.ptszUID = gce.ptszNick; - gce.time = static_cast(time(0)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = name; + gce.ptszUID = gce.ptszNick; + gce.time = DWORD(time(0)); if (name == NULL) gce.bIsMe = false; else @@ -273,29 +252,21 @@ void OmegleProto::DeleteChatContact(const TCHAR *name) INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress) { - GCSESSION gcw = {sizeof(gcw)}; - // Create the group chat session - gcw.dwFlags = GC_TCHAR; - gcw.iType = GCW_CHATROOM; + GCSESSION gcw = {sizeof(gcw)}; + gcw.iType = GCW_CHATROOM; + gcw.ptszID = m_tszUserName; + gcw.ptszName = m_tszUserName; gcw.pszModule = m_szModuleName; - gcw.ptszName = m_tszUserName; - gcw.ptszID = m_tszUserName; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); if(m_iStatus == ID_STATUS_OFFLINE) return 0; // Create a group - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - - gcd.iType = GC_EVENT_ADDGROUP; - + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszStatus = _T("Admin"); CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast(&gce)); @@ -313,15 +284,10 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress) void OmegleProto::SetTopic(const TCHAR *topic) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_TOPIC; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_TOPIC }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - + if (topic == NULL) gce.ptszText = TranslateT("Omegle is a great way of meeting new friends!"); else @@ -332,14 +298,9 @@ void OmegleProto::SetTopic(const TCHAR *topic) INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast(&gce)); CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast(&gce)); @@ -349,14 +310,9 @@ INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM) void OmegleProto::SetChatStatus(int status) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); - gce.pDest = &gcd; if(status == ID_STATUS_ONLINE) { @@ -391,15 +347,9 @@ void OmegleProto::ClearChat() if (getByte(OMEGLE_KEY_NO_CLEAR, 0)) return; - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - - CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast(&gce)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, reinterpret_cast(&gce)); } // TODO: Could this be done better? diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index f0ebd14717..245fa749ea 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -176,7 +176,7 @@ int OmegleProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam) GCREGISTER gcr = {sizeof(gcr)}; gcr.dwFlags = GC_TYPNOTIF; //GC_ACKMSG; gcr.pszModule = m_szModuleName; - gcr.pszModuleDispName = m_szModuleName; + gcr.ptszDispName = m_tszUserName; gcr.iMaxText = OMEGLE_MESSAGE_LIMIT; gcr.nColors = 0; gcr.pColors = NULL; diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 3bb2534bbf..6f42d44393 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -161,17 +161,10 @@ void ChatRoom::CreateChatSession(bool showWindow) gcw.dwItemData = (DWORD)this; ::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; - gcd.ptszID = this->cid; - // load chat roles - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - - for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 2; i++) - { + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; + for (int i = 1; i < SIZEOF(ChatRoom::Roles) - 2; i++) { gce.ptszStatus = ::TranslateTS(ChatRoom::Roles[i]); ::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } @@ -205,16 +198,9 @@ wchar_t *ChatRoom::GetUri() void ChatRoom::ShowWindow() { - GCDEST gcd = { this->ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = this->cid; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - // show window - gcd.iType = GC_EVENT_CONTROL; + GCDEST gcd = { this->ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; ::CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); } @@ -357,13 +343,8 @@ void ChatRoom::LeaveChat() if (this->conversation->RetireFrom()) this->ppro->debugLogW(L"Retired from conversation %s", this->cid); - GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = this->cid; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } @@ -378,28 +359,19 @@ void ChatRoom::LeaveChatAndDelete() if (this->conversation->Delete()) this->ppro->debugLogW(L"Delete conversation %s", this->cid); - GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = this->cid; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { ppro->m_szModuleName, this->cid, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } void ChatRoom::SendEvent(const ChatMember &item, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message) { - GCDEST gcd = { ppro->m_szModuleName, { NULL }, eventType }; - gcd.ptszID = this->cid; - bool isMe = this->IsMe(item); - GCEVENT gce = {0}; - gce.cbSize = sizeof(gce); - gce.dwFlags = GC_TCHAR | flags; - gce.pDest = &gcd; + GCDEST gcd = { ppro->m_szModuleName, this->cid, eventType }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = flags; gce.ptszUID = item.GetSid(); gce.ptszNick = !isMe ? item.GetNick() : ::TranslateT("me"); gce.bIsMe = isMe; @@ -1270,14 +1242,8 @@ void CSkypeProto::CloseAllChatSessions() gci.iItem = i; if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) { - GCDEST gcd = { this->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = gci.pszID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - + GCDEST gcd = { this->m_szModuleName, gci.pszID, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; ::CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); ::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); } diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp index c9f5e5e97f..815521e699 100644 --- a/protocols/SkypeClassic/src/gchat.cpp +++ b/protocols/SkypeClassic/src/gchat.cpp @@ -109,12 +109,11 @@ gchat_contact *GetChatContact(gchat_contacts *gc, const TCHAR *who) { -2 = On failure >=0 = Number of added item */ -static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) { +static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) +{ int i = -2; HANDLE hContact; - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; + CONTACTINFO ci = {0}; TCHAR *twho; LOG (("AddChatContact %s", who)); @@ -123,15 +122,11 @@ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) { if ((i=ExistsChatContact(gc, twho))>=0) return i; hContact=find_contact(who); - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = gc->szChatName; - gcd.iType = GC_EVENT_JOIN; - - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.ptszStatus = pszRole?pszRole:_T("USER"); + GCDEST gcd = { SKYPE_PROTONAME, gc->szChatName, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = (DWORD)time(NULL); - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszStatus = pszRole ? pszRole : _T("USER"); ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; @@ -279,17 +274,10 @@ int __cdecl AddMembers(char *szSkypeMsg) { } // Quit contacts which are no longer there if (iRet == 0 && contactmask) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = szChatId; - gcd.iType = GC_EVENT_QUIT; - - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_QUIT }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = (DWORD)time(NULL); - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + gce.dwFlags = GCEF_ADDTOLOG; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; @@ -373,22 +361,18 @@ INT_PTR CALLBACK InputBoxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l lParam = 1 - Create groupchat, but don't open it 0 - Default - open groupchat after init */ -int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) { - GCSESSION gcw = {0}; - GCEVENT gce = {0}; - GCDEST gcd = {0}; + +int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) +{ DBVARIANT dbv, dbv2; char *szChatName; int iRet = -1; - UNREFERENCED_PARAMETER(lParam); - if (!wParam) return -1; - gcw.cbSize = sizeof(GCSESSION); + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = SKYPE_PROTONAME; - gcw.dwFlags = GC_TCHAR; if (!(szChatName = SkypeGet ("CHAT", (char *)wParam, "FRIENDLYNAME")) || !*szChatName) gcw.ptszName=TranslateT("Unknown"); else { @@ -401,18 +385,14 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) { #endif } gcw.ptszID = make_nonutf_tchar_string((const unsigned char*)wParam); - gcw.pszStatusbarText = NULL; + gcw.ptszStatusbarText = NULL; EnterCriticalSection(&m_GCMutex); if (!CallService(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) { char *szChatRole; - gce.cbSize = sizeof(GCEVENT); - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = (TCHAR*)gcw.ptszID; - gcd.iType = GC_EVENT_ADDGROUP; - gce.pDest = &gcd; + GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gcw.ptszID, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = _T("CREATOR"); - gce.dwFlags = GC_TCHAR; // BUG: Groupchat returns nonzero on success here in earlier versions, so we don't check // it here CallService(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -450,15 +430,15 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) { gce.bIsMe = TRUE; gce.dwFlags |= GCEF_ADDTOLOG; if (!CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce)) { - gce.cbSize = sizeof(GCEVENT); gcd.iType = GC_EVENT_CONTROL; - gce.pDest = &gcd; - if (!lParam) CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce); + if (!lParam) + CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce); CallService(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); - CallService(MS_GC_EVENT, lParam?WINDOW_HIDDEN:WINDOW_VISIBLE, (LPARAM)&gce); + CallService(MS_GC_EVENT, lParam ? WINDOW_HIDDEN : WINDOW_VISIBLE, (LPARAM)&gce); SkypeSend ("GET CHAT %s MEMBERS", (char *)wParam); iRet = 0; - } else {LOG (("ChatInit: Joining 'me' failed."));} + } + else {LOG (("ChatInit: Joining 'me' failed."));} } db_free(&dbv2); } @@ -482,14 +462,11 @@ int __cdecl ChatStart(char *szChatId, BOOL bJustCreate) { } -void KillChatSession(GCDEST *gcd) { - GCEVENT gce = {0}; - +void KillChatSession(GCDEST *gcd) +{ + GCEVENT gce = { sizeof(gce), gcd }; EnterCriticalSection(&m_GCMutex); LOG(("KillChatSession: Groupchatsession terminated.")); - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = gcd; gcd->iType = GC_EVENT_CONTROL; if (SkypeSend ("ALTER CHAT "STR" LEAVE", gcd->ptszID) == 0) { @@ -499,7 +476,8 @@ void KillChatSession(GCDEST *gcd) { LeaveCriticalSection(&m_GCMutex); } -void InviteUser(TCHAR *szChatId) { +void InviteUser(TCHAR *szChatId) +{ HMENU tMenu = CreatePopupMenu(); HANDLE hContact = db_find_first(), hInvitedUser; DBVARIANT dbv; @@ -557,21 +535,13 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) { if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) { if (strncmp(ptr, "ERROR", 5)) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; - DBVARIANT dbv; - - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = (TCHAR*)gch->pDest->ptszID; - gcd.iType = GC_EVENT_KICK; - - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gch->pDest->ptszID, GC_EVENT_KICK }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.time = (DWORD)time(NULL); - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; - gce.ptszUID= gch->ptszUID; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszUID = gch->ptszUID; + CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; @@ -579,6 +549,7 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; else gce.ptszNick=gce.ptszUID; + DBVARIANT dbv; if (!db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) { gce.ptszStatus = dbv.ptszVal; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -595,21 +566,16 @@ static void KickUser (HANDLE hContact, GCHOOK *gch) void SetChatTopic (TCHAR *szChatId, TCHAR *szTopic, BOOL bSet) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; HANDLE hContact = find_chat (szChatId); char *szUTFTopic; - gce.cbSize = sizeof(GCEVENT); - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = szChatId; - gcd.iType = GC_EVENT_TOPIC; - gce.pDest = &gcd; + GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_TOPIC }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszText = szTopic; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = (DWORD)time (NULL); - gce.dwFlags = GC_TCHAR; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); + gcd.iType = GC_EVENT_SETSBTEXT; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -665,8 +631,6 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { if(gch && gch->ptszText && _tcslen(gch->ptszText) > 0) { DBVARIANT dbv, dbv2; CCSDATA ccs = {0}; - GCDEST gcd = {0}; - GCEVENT gce = {0}; TCHAR *pEnd; // remove the ending linebreak @@ -698,8 +662,8 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { } // Add our line to the chatlog - gcd.pszModule = gch->pDest->pszModule; - gcd.ptszID = gch->pDest->ptszID; + GCDEST gcd = { gch->pDest->pszModule, gch->pDest->ptszID, 0 }; + GCEVENT gce = { sizeof(gce), &gcd }; if ( _tcsncmp(gch->ptszText, _T("/me "), 4)==0 && _tcslen(gch->ptszText)>4) { gce.ptszText = gch->ptszText+4; gcd.iType = GC_EVENT_ACTION; @@ -709,14 +673,14 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { gcd.iType = GC_EVENT_MESSAGE; } - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) gce.ptszNick=TranslateT("Me"); - else gce.ptszNick = dbv.ptszVal; + if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) + gce.ptszNick = TranslateT("Me"); + else + gce.ptszNick = dbv.ptszVal; db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv2); gce.ptszUID = dbv2.ptszVal; gce.time = (DWORD)time(NULL); - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + gce.dwFlags = GCEF_ADDTOLOG; gce.bIsMe = TRUE; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); if (dbv.pszVal) db_free(&dbv); @@ -864,11 +828,7 @@ INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam) if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv) == 0) { - GCDEST gcd = {0}; - - gcd.pszModule = SKYPE_PROTONAME; - gcd.iType = GC_EVENT_CONTROL; - gcd.ptszID = dbv.ptszVal; + GCDEST gcd = { SKYPE_PROTONAME, dbv.ptszVal, GC_EVENT_CONTROL }; KillChatSession(&gcd); db_free(&dbv); } diff --git a/protocols/SkypeClassic/src/skype.cpp b/protocols/SkypeClassic/src/skype.cpp index 9803ef549f..2c2d6ef737 100644 --- a/protocols/SkypeClassic/src/skype.cpp +++ b/protocols/SkypeClassic/src/skype.cpp @@ -820,18 +820,16 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { add_contextmenu(NULL); if ( ServiceExists( MS_GC_REGISTER )) { - GCREGISTER gcr = {0}; static COLORREF crCols[1] = {0}; char szEvent[MAXMODULELABELLENGTH]; - gcr.cbSize = sizeof( GCREGISTER ); - gcr.dwFlags = GC_CHANMGR | GC_TCHAR; // |GC_ACKMSG; // TODO: Not implemented yet - gcr.ptszModuleDispName = _T("Skype protocol"); + GCREGISTER gcr = { sizeof(gcr) }; + gcr.dwFlags = GC_CHANMGR; // |GC_ACKMSG; // TODO: Not implemented yet + gcr.ptszDispName = _T("Skype protocol"); gcr.pszModule = SKYPE_PROTONAME; if (CallService(MS_GC_REGISTER, 0, (LPARAM)&gcr)) - { OUTPUT(_T("Unable to register with Groupchat module!")); - } + _snprintf (szEvent, sizeof(szEvent), "%s\\ChatInit", SKYPE_PROTONAME); hInitChat = CreateHookableEvent(szEvent); hEvInitChat = HookEvent(szEvent, ChatInit); @@ -925,20 +923,14 @@ void FetchMessageThread(fetchmsg_arg *pargs) { } if (!strcmp(type,"KICKED")) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; - if (!hChat) __leave; - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat); - gcd.iType = GC_EVENT_KICK; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_KICK }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = timestamp; if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) { + CONTACTINFO ci = {0}; ci.hContact = find_contact(users); gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)users); if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) { @@ -961,9 +953,6 @@ void FetchMessageThread(fetchmsg_arg *pargs) { } if (!strcmp(type,"SETROLE")) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; gchat_contact *gcContact; char *pszRole; @@ -971,17 +960,15 @@ void FetchMessageThread(fetchmsg_arg *pargs) { // USERS - Wessen Rolle wurde gesetzt // ROLE - Die neue Rolle if (!hChat) __leave; - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat); - gcd.iType = GC_EVENT_REMOVESTATUS; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_REMOVESTATUS }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = timestamp; if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) { gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)users); if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) { + CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; @@ -1019,19 +1006,13 @@ void FetchMessageThread(fetchmsg_arg *pargs) { } if (!strcmp(type,"SETTOPIC")) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; - LOG(("FetchMessageThread CHAT SETTOPIC")); - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat); - gcd.iType = GC_EVENT_TOPIC; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_TOPIC }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = timestamp; if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) { + CONTACTINFO ci = {0}; ci.hContact = find_contact(who); gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who); ci.cbSize = sizeof(ci); @@ -1059,19 +1040,13 @@ void FetchMessageThread(fetchmsg_arg *pargs) { } if (!strcmp(type,"LEFT") || (bAddedMembers = strcmp(type,"ADDEDMEMBERS")==0)) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - CONTACTINFO ci = {0}; char *pszInvited = Translate("invited "); LOG(("FetchMessageThread CHAT LEFT or ADDEDMEMBERS")); if (bAddedMembers) { - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat); - gcd.iType = GC_EVENT_ACTION; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), GC_EVENT_ACTION }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.time = timestamp; if (users=SkypeGetErr (cmdMessage, args.msgnum, "USERS")) { // We assume that users buffer has enough room for "invited" string @@ -1080,18 +1055,22 @@ void FetchMessageThread(fetchmsg_arg *pargs) { gce.ptszText= make_tchar_string((const unsigned char*)users); if (who=SkypeGetErr (cmdMessage, args.msgnum, szPartnerHandle)) { DBVARIANT dbv; - if (db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0) { gce.bIsMe = strcmp(who, dbv.pszVal)==0; db_free(&dbv); } - if (!gce.bIsMe) ci.hContact = find_contact(who); - gce.ptszUID= make_nonutf_tchar_string((const unsigned char*)who); + gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who); + + CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); + if (!gce.bIsMe) + ci.hContact = find_contact(who); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; - else gce.ptszNick=gce.ptszUID; + if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) + gce.ptszNick = ci.pszVal; + else + gce.ptszNick = gce.ptszUID; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); free_nonutf_tchar_string((void*)gce.ptszUID); @@ -1251,36 +1230,31 @@ void FetchMessageThread(fetchmsg_arg *pargs) { bHasPartList) || msgptr[0]==0) __leave; if (isGroupChat && bUseGroupChat) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; DBVARIANT dbv = {0}; - CONTACTINFO ci = {0}; LOG(("FetchMessageThread This is a group chat message")); if (!hChat) ChatStart(chat, FALSE); - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)chat); - gcd.iType = bEmoted?GC_EVENT_ACTION:GC_EVENT_MESSAGE; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; - if ((gce.bIsMe = (direction&DBEF_SENT)?TRUE:FALSE) && - db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0) + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)chat), bEmoted ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + if ((gce.bIsMe = (direction&DBEF_SENT)?TRUE:FALSE) && db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)==0) { free(who); who = _strdup(dbv.pszVal); db_free(&dbv); } gce.ptszUID = make_nonutf_tchar_string((const unsigned char*)who); + gce.ptszNick = gce.ptszUID; + + CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; - ci.hContact = !gce.bIsMe?hContact:NULL; - gce.ptszNick=gce.ptszUID; - if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; - gce.time = timestamp>0?timestamp:(DWORD)SkypeTime(NULL); - gce.pszText = msgptr; - if (pre.flags & PREF_UNICODE) gce.pszText += msglen; - gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR; + ci.hContact = !gce.bIsMe ? hContact : NULL; + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) + gce.ptszNick = ci.pszVal; + gce.time = timestamp > 0 ? timestamp : (DWORD)SkypeTime(NULL); + gce.ptszText = (TCHAR*)(msgptr+msglen); + gce.dwFlags = GCEF_ADDTOLOG; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); MsgList_Add (pre.lParam, INVALID_HANDLE_VALUE); // Mark as groupchat if (ci.pszVal) mir_free (ci.pszVal); @@ -2119,19 +2093,12 @@ LONG APIENTRY WndProc(HWND hWndDlg, UINT message, UINT wParam, LONG lParam) *ptr=0; if (hContact = find_chatA(szSkypeMsg+5)) { - GCDEST gcd = {0}; - GCEVENT gce = {0}; - if (db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { - gcd.pszModule = SKYPE_PROTONAME; - gcd.ptszID = make_nonutf_tchar_string((const unsigned char*)szSkypeMsg+5); - gcd.iType = GC_EVENT_CHANGESESSIONAME; - gce.cbSize = sizeof(GCEVENT); - gce.pDest = &gcd; + GCDEST gcd = { SKYPE_PROTONAME, make_nonutf_tchar_string((const unsigned char*)szSkypeMsg+5), GC_EVENT_CHANGESESSIONAME }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszText = make_tchar_string((const unsigned char*)ptr+14); - gce.dwFlags = GC_TCHAR; if (gce.ptszText) { CallService(MS_GC_EVENT, 0, (LPARAM)&gce); db_set_ts (hContact, SKYPE_PROTONAME, "Nick", gce.ptszText); diff --git a/protocols/SkypeClassic/src/skypeopt.cpp b/protocols/SkypeClassic/src/skypeopt.cpp index db077b8b74..75b90967f2 100644 --- a/protocols/SkypeClassic/src/skypeopt.cpp +++ b/protocols/SkypeClassic/src/skypeopt.cpp @@ -416,8 +416,10 @@ INT_PTR CALLBACK OptionsProxyDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_USES2S: - for (i=0; i. void TwitterProto::UpdateChat(const twitter_user &update) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_MESSAGE; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG; - gce.pDest = &gcd; - gce.ptszUID = mir_a2t(update.username.c_str()); - gce.bIsMe = (update.username == twit_.get_username()); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.pDest = &gcd; + gce.bIsMe = (update.username == twit_.get_username()); + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszUID = mir_a2t(update.username.c_str()); //TODO: write code here to replace % with %% in update.status.text (which is a std::string) std::string chatText = update.status.text; @@ -93,18 +89,12 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) // TODO: remove nick? void TwitterProto::AddChatContact(const char *name,const char *nick) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_JOIN; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - gce.ptszNick = mir_a2t(nick ? nick:name); - gce.ptszUID = mir_a2t(name); - gce.bIsMe = false; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = DWORD(time(0)); + gce.ptszNick = mir_a2t(nick ? nick:name); + gce.ptszUID = mir_a2t(name); gce.ptszStatus = _T("Normal"); - gce.time = static_cast(time(0)); CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); mir_free(const_cast(gce.ptszNick)); @@ -113,16 +103,11 @@ void TwitterProto::AddChatContact(const char *name,const char *nick) void TwitterProto::DeleteChatContact(const char *name) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_PART; - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - gce.ptszNick = mir_a2t(name); - gce.ptszUID = gce.ptszNick; - gce.time = static_cast(time(0)); + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = DWORD(time(0)); + gce.ptszNick = mir_a2t(name); + gce.ptszUID = gce.ptszNick; CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); mir_free(const_cast(gce.ptszNick)); @@ -130,28 +115,20 @@ void TwitterProto::DeleteChatContact(const char *name) INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress) { - GCSESSION gcw = {sizeof(gcw)}; - // ***** Create the group chat session - gcw.dwFlags = GC_TCHAR; - gcw.iType = GCW_CHATROOM; + GCSESSION gcw = { sizeof(gcw) }; + gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; - gcw.ptszName = m_tszUserName; - gcw.ptszID = m_tszUserName; + gcw.ptszName = m_tszUserName; + gcw.ptszID = m_tszUserName; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); if(m_iStatus != ID_STATUS_ONLINE) return 0; // ***** Create a group - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - - GCEVENT gce = {sizeof(gce)}; - gce.pDest = &gcd; - gce.dwFlags = GC_TCHAR; - - gcd.iType = GC_EVENT_ADDGROUP; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = _T("Normal"); CallServiceSync(MS_GC_EVENT,0,reinterpret_cast(&gce)); @@ -170,29 +147,18 @@ INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM) { in_chat_ = false; - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast(&gce)); CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast(&gce)); - return 0; } void TwitterProto::SetChatStatus(int status) { - GCDEST gcd = { m_szModuleName }; - gcd.ptszID = const_cast(m_tszUserName); - gcd.iType = GC_EVENT_CONTROL; - - GCEVENT gce = {sizeof(gce)}; - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; if(status == ID_STATUS_ONLINE) { diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index d90c67b6e1..35ca3af92f 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -374,9 +374,9 @@ int TwitterProto::OnModulesLoaded(WPARAM,LPARAM) twit_.set_handle(this, m_hNetlibUser); - GCREGISTER gcr = {sizeof(gcr)}; + GCREGISTER gcr = { sizeof(gcr) }; gcr.pszModule = m_szModuleName; - gcr.pszModuleDispName = m_szModuleName; + gcr.ptszDispName = m_tszUserName; gcr.iMaxText = 159; CallService(MS_GC_REGISTER,0,reinterpret_cast(&gcr)); diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index e978c9f0ee..63551a953f 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -43,13 +43,9 @@ int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam) // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE }; - gcd.ptszID = hook->pDest->ptszID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, hook->pDest->ptszID, GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = mir_a2t(this->nick.c_str()); gce.ptszUID = mir_a2t(this->jid.c_str()); gce.time = time(NULL); diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 69f5931026..892ad9e373 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -38,13 +38,9 @@ WhatsAppProto::WhatsAppProto(const char* proto_name, const TCHAR* username) : def_avatar_folder_ = std::tstring( VARST( _T("%miranda_avatarcache%"))) + _T("\\") + m_tszUserName; // Register group chat - GCREGISTER gcr = {0}; - gcr.cbSize = sizeof(GCREGISTER); - gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR; - gcr.iMaxText = 0; - gcr.nColors = 0; - gcr.pColors = NULL; //(COLORREF*)crCols; - gcr.ptszModuleDispName = m_tszUserName; + GCREGISTER gcr = { sizeof(gcr) }; + gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index e4edd7cc3d..0b22d5e23f 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -180,13 +180,11 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; void CYahooProto::ChatRegister(void) { - GCREGISTER gcr = {0}; - gcr.cbSize = sizeof(gcr); - gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR; - gcr.iMaxText = 0; + GCREGISTER gcr = { sizeof(gcr) }; + gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; gcr.nColors = 16; gcr.pColors = (COLORREF*)crCols; - gcr.ptszModuleDispName = m_tszUserName; + gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); @@ -198,22 +196,15 @@ void CYahooProto::ChatStart(const char* room) { TCHAR* idt = mir_a2t(room); - GCSESSION gcw = {0}; - gcw.cbSize = sizeof(gcw); - gcw.dwFlags = GC_TCHAR; + GCSESSION gcw = { sizeof(gcw) }; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = idt; gcw.ptszID = idt; CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(gce); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP }; + GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszStatus = TranslateT("Me"); CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); @@ -233,13 +224,9 @@ void CYahooProto::ChatLeave(const char* room) { TCHAR* idt = mir_a2t(room); - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, idt, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_REMOVECONTACT; CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce); @@ -260,13 +247,9 @@ void CYahooProto::ChatEvent(const char* room, const char* who, int evt, const TC HANDLE hContact = getbuddyH(who); TCHAR* nick = hContact ? (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), GCDNF_TCHAR) : snt; - GCDEST gcd = { m_szModuleName, { NULL }, evt }; - gcd.ptszID = idt; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(gce); - gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; - gce.pDest = &gcd; + GCDEST gcd = { m_szModuleName, idt, evt }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = nick; gce.ptszUID = snt; gce.bIsMe = _stricmp(who, m_yahoo_id) == 0; diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h index b6c2bc1488..2bb2bd3384 100644 --- a/src/core/stdchat/src/chat.h +++ b/src/core/stdchat/src/chat.h @@ -442,49 +442,49 @@ void TabsInit(void); void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground); //manager.c -void SetActiveSession(const TCHAR* pszID, const char* pszModule); +void SetActiveSession(const TCHAR *pszID, const char* pszModule); void SetActiveSessionEx(SESSION_INFO *si); SESSION_INFO* GetActiveSession(void); -SESSION_INFO* SM_AddSession(const TCHAR* pszID, const char* pszModule); -int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeContact); -SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule); -USERINFO* SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus); -BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID); -BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce); -BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID); -BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule); +SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule); +int SM_RemoveSession(const TCHAR *pszID, const char* pszModule, BOOL removeContact); +SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule); +USERINFO* SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus); +BOOL SM_ChangeUID(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID); +BOOL SM_ChangeNick(const TCHAR *pszID, const char* pszModule, GCEVENT *gce); +BOOL SM_RemoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID); +BOOL SM_SetOffline(const TCHAR *pszID, const char* pszModule); BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd); HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui); -BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus); -BOOL SM_SetStatusEx(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags ); -BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText); -STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus); +BOOL SM_SetStatus(const TCHAR *pszID, const char* pszModule, int wStatus); +BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags ); +BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText); +STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus); SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si); SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si); -BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce); -BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT * gce, BOOL bIsHighlighted); -LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); -BOOL SM_PostMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce); +BOOL SM_AddEvent(const TCHAR *pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted); +LRESULT SM_SendMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL SM_PostMessage(const TCHAR *pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam); BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync); BOOL SM_RemoveAll (void); -BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); -BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD pszStatus); -BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); -BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID); -void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewCommand); -char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule); -char* SM_GetNextCommand(const TCHAR* pszID, const char* pszModule); +BOOL SM_GiveStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); +BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD pszStatus); +BOOL SM_TakeStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus); +BOOL SM_MoveUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID); +void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand); +char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule); +char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule); int SM_GetCount(const char* pszModule); SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem); char* SM_GetUsers(SESSION_INFO *si); -USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index); +USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char* pszModule, int index); MODULEINFO* MM_AddModule(const char* pszModule); MODULEINFO* MM_FindModule(const char* pszModule); void MM_FixColors(); void MM_FontsChanged(void); void MM_IconsChanged(void); BOOL MM_RemoveAll (void); -BOOL TabM_AddTab(const TCHAR* pszID, const char* pszModule); +BOOL TabM_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); @@ -522,7 +522,7 @@ int WCCmp(TCHAR* wild, TCHAR*string); //tools.c TCHAR* RemoveFormatting(const TCHAR* pszText); -BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix); +BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix); int GetColorIndex(const char* pszModule, COLORREF cr); void CheckColorsInModule(const char* pszModule); const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ; @@ -530,10 +530,10 @@ int GetRichTextLength(HWND hwnd); BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText); UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText); void DestroyGCMenu(HMENU *hMenu, int iIndex); -BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem); -BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem); +BOOL 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); +BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce); // message.c char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si); @@ -541,10 +541,4 @@ TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si); #pragma comment(lib,"comctl32.lib") -////////////////////////////////////////////////////////////////////////////////// - -TCHAR* a2tf( const TCHAR* str, int flags ); -TCHAR* replaceStr( TCHAR** dest, const TCHAR* src ); -char* replaceStrA( char** dest, const char* src ); - #endif diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp index af7f6b6944..1f63a0839e 100644 --- a/src/core/stdchat/src/manager.cpp +++ b/src/core/stdchat/src/manager.cpp @@ -35,24 +35,25 @@ SESSION_INFO* m_WndList = 0; TABLIST * g_TabList = 0; MODULEINFO *m_ModList = 0; -void SetActiveSession(const TCHAR* pszID, const char* pszModule) +void SetActiveSession(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if ( si ) + if (si) SetActiveSessionEx(si); } void SetActiveSessionEx(SESSION_INFO *si) { - if ( si ) { - replaceStr( &pszActiveWndID, si->ptszID ); - replaceStrA( &pszActiveWndModule, si->pszModule ); -} } + if (si) { + replaceStrT(pszActiveWndID, si->ptszID); + replaceStr(pszActiveWndModule, si->pszModule); + } +} -SESSION_INFO* GetActiveSession( void ) +SESSION_INFO* GetActiveSession(void) { - SESSION_INFO *si = SM_FindSession( pszActiveWndID, pszActiveWndModule ); - if ( si ) + SESSION_INFO *si = SM_FindSession(pszActiveWndID, pszActiveWndModule); + if (si) return si; return m_WndList; @@ -64,16 +65,16 @@ SESSION_INFO* GetActiveSession( void ) // Keeps track of all sessions and its windows //--------------------------------------------------- -SESSION_INFO* SM_AddSession( const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char* pszModule) { - if ( !pszID || !pszModule ) + if (!pszID || !pszModule) return NULL; - if ( !SM_FindSession(pszID, pszModule)) { - SESSION_INFO*node = (SESSION_INFO*) mir_alloc(sizeof(SESSION_INFO)); + if (!SM_FindSession(pszID, pszModule)) { + SESSION_INFO*node = (SESSION_INFO*)mir_alloc(sizeof(SESSION_INFO)); ZeroMemory(node, sizeof(SESSION_INFO)); - node->ptszID = mir_tstrdup( pszID ); - node->pszModule = mir_strdup( pszModule ); + node->ptszID = mir_tstrdup(pszID); + node->pszModule = mir_strdup(pszModule); if (m_WndList == NULL) { // list is empty m_WndList = node; @@ -88,30 +89,25 @@ SESSION_INFO* SM_AddSession( const TCHAR* pszID, const char* pszModule) return NULL; } -int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeContact) +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 + while (pTemp != NULL) { + if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) // match { COMMAND_INFO *pCurComm; DWORD dw = pTemp->dwItemData; - if (!g_Settings.TabsEnable) - { - if (pTemp->hWnd ) - SendMessage(pTemp->hWnd, GC_EVENT_CONTROL+WM_USER+500, SESSION_TERMINATE, 0); - } - else - { - if (g_TabSession.hWnd) - SendMessage(g_TabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)pTemp); + if (!g_Settings.TabsEnable) { + if (pTemp->hWnd) + SendMessage(pTemp->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0); } + else if (g_TabSession.hWnd) + SendMessage(g_TabSession.hWnd, GC_REMOVETAB, 1, (LPARAM)pTemp); if (pTemp->hWnd) g_TabSession.nUsersInNicklist = 0; @@ -131,9 +127,8 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta // contact may have been deleted here already, since function may be called after deleting // contact so the handle may be invalid, therefore db_get_b shall return 0 - if (pTemp->hContact && db_get_b( pTemp->hContact, pTemp->pszModule, "ChatRoom", 0 ) != 0) - { - CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM?TRUE:FALSE); + if (pTemp->hContact && db_get_b(pTemp->hContact, pTemp->pszModule, "ChatRoom", 0) != 0) { + CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM ? TRUE : FALSE); db_set_s(pTemp->hContact, pTemp->pszModule, "Topic", ""); db_set_s(pTemp->hContact, pTemp->pszModule, "StatusBar", ""); db_unset(pTemp->hContact, "CList", "StatusMsg"); @@ -142,18 +137,17 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->hContact, 0); } - mir_free( pTemp->pszModule ); - mir_free( pTemp->ptszID ); - mir_free( pTemp->ptszName ); - mir_free( pTemp->ptszStatusbarText ); - mir_free( pTemp->ptszTopic ); - mir_free( pTemp->pszID ); - mir_free( pTemp->pszName ); + mir_free(pTemp->pszModule); + mir_free(pTemp->ptszID); + mir_free(pTemp->ptszName); + mir_free(pTemp->ptszStatusbarText); + mir_free(pTemp->ptszTopic); + mir_free(pTemp->pszID); + mir_free(pTemp->pszName); // delete commands pCurComm = pTemp->lpCommands; - while (pCurComm != NULL) - { + while (pCurComm != NULL) { COMMAND_INFO *pNext = pCurComm->next; mir_free(pCurComm->lpCommand); mir_free(pCurComm); @@ -168,8 +162,7 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta else pTemp = m_WndList; } - else - { + else { pLast = pTemp; pTemp = pTemp->next; } @@ -177,15 +170,15 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta return FALSE; } -SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule) +SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char* pszModule) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; - if ( !pszID || !pszModule ) + if (!pszID || !pszModule) return NULL; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA(pTemp->pszModule,pszModule)) + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) return pTemp; pLast = pTemp; @@ -194,17 +187,15 @@ SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule) return NULL; } -BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) +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)) - { + while (pTemp != NULL) { + if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { UM_RemoveAll(&pTemp->pUsers); pTemp->nUsersInNicklist = 0; if (pTemp->hWnd) @@ -223,15 +214,15 @@ BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule) return TRUE; } -BOOL SM_SetStatusEx( const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags ) +BOOL SM_SetStatusEx(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText, int flags) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; if (!pszModule) return FALSE; - while ( pTemp != NULL ) { - if (( !pszID || !lstrcmpi( pTemp->ptszID, pszID )) && !lstrcmpiA(pTemp->pszModule,pszModule)) { + while (pTemp != NULL) { + if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { UM_SetStatusEx(pTemp->pUsers, pszText, flags); if (pTemp->hWnd) RedrawWindow(GetDlgItem(pTemp->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); @@ -251,10 +242,8 @@ HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return NULL; ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status)); - if (ti) - { - if ((int)ti->hIcon < STATUSICONCOUNT) - { + if (ti) { + if ((int)ti->hIcon < STATUSICONCOUNT) { int id = si->iStatusCount - (int)ti->hIcon - 1; if (id == 0) return hIcons[ICON_STATUS0]; @@ -275,16 +264,16 @@ HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return hIcons[ICON_STATUS0]; } -BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce) +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) { + if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) { + if (UM_FindUser(pTemp->pUsers, gce->ptszUID)) { + if (pTemp->bInitDone) { + if (SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE) && pTemp->hWnd && pTemp->bInitDone) { g_TabSession.pLog = pTemp->pLog; g_TabSession.pLogEnd = pTemp->pLogEnd; SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0); @@ -296,10 +285,12 @@ BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce) } if (!(gce->dwFlags & GCEF_NOTNOTIFY)) DoSoundsFlashPopupTrayStuff(pTemp, gce, FALSE, bManyFix); - bManyFix ++; + bManyFix++; if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled) LogToFile(pTemp, gce); - } } } + } + } + } pLast = pTemp; pTemp = pTemp->next; @@ -308,23 +299,23 @@ BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce) return 0; } -BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT * gce, BOOL bIsHighlighted) +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)) { + 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->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; @@ -343,19 +334,19 @@ BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT * gce, BOOL return TRUE; } -USERINFO * SM_AddUser( const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus) +USERINFO * SM_AddUser(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; if (!pszID || !pszModule) return NULL; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA( pTemp->pszModule, pszModule )) { - USERINFO * p = UM_AddUser( pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus); + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) { + USERINFO * p = UM_AddUser(pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus); pTemp->nUsersInNicklist++; if (pTemp->hWnd) - g_TabSession.nUsersInNicklist ++; + g_TabSession.nUsersInNicklist++; return p; } pLast = pTemp; @@ -365,16 +356,16 @@ USERINFO * SM_AddUser( const TCHAR* pszID, const char* pszModule, const TCHAR* p return 0; } -BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +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 ); + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) { + UM_SortUser(&pTemp->pUsers, pszUID); return TRUE; } pTemp = pTemp->next; @@ -383,22 +374,22 @@ BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) return FALSE; } -BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID) +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 )) { + while (pTemp != NULL) { + if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { DWORD dw; USERINFO * ui = UM_FindUser(pTemp->pUsers, pszUID); - if ( ui ) { + if (ui) { pTemp->nUsersInNicklist--; if (pTemp->hWnd) { g_TabSession.pUsers = pTemp->pUsers; - g_TabSession.nUsersInNicklist --; + g_TabSession.nUsersInNicklist--; } dw = UM_RemoveUser(&pTemp->pUsers, pszUID); @@ -408,7 +399,8 @@ BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI if (pszID) return TRUE; - } } + } + } pLast = pTemp; pTemp = pTemp->next; @@ -417,16 +409,16 @@ BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return 0; } -USERINFO * SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index) +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 ); + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) + return UM_FindUserFromIndex(pTemp->pUsers, index); pTemp = pTemp->next; } @@ -434,19 +426,19 @@ USERINFO * SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int in } -STATUSINFO * SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus) +STATUSINFO * SM_AddStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszStatus) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; - if (!pszID || !pszModule ) + 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 ) + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) { + STATUSINFO* ti = TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount); + if (ti) pTemp->iStatusCount++; - if ( g_Settings.TabsEnable && pTemp->hWnd ) + if (g_Settings.TabsEnable && pTemp->hWnd) g_TabSession.pStatuses = pTemp->pStatuses; return ti; } @@ -457,19 +449,19 @@ STATUSINFO * SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR return 0; } -BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +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 ) + if (!pszID || !pszModule) return FALSE; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA( pTemp->pszModule, pszModule )) { + 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 ) + SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID); + if (pTemp->hWnd) SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0); } return TRUE; @@ -481,19 +473,19 @@ BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return FALSE; } -BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) +BOOL SM_SetContactStatus(const TCHAR *pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus) { SESSION_INFO* pTemp = m_WndList, *pLast = NULL; - if ( !pszID || !pszModule ) + if (!pszID || !pszModule) return FALSE; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA( pTemp->pszModule, pszModule )) { + 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 ) + SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID); + if (pTemp->hWnd) SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0); } return TRUE; @@ -505,19 +497,19 @@ BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* return FALSE; } -BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus) +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 ) + if (!pszID || !pszModule) return FALSE; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->ptszID, pszID ) && !lstrcmpiA( pTemp->pszModule, pszModule )) { + 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 ) { + if (ui) { SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID); - if ( pTemp->hWnd ) + if (pTemp->hWnd) SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0); } return TRUE; @@ -528,18 +520,18 @@ BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUI return FALSE; } -LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam) +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 ) { + 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 ) + if (pszID) return i; } - if ( pszID ) + if (pszID) return 0; } pLast = pTemp; @@ -548,16 +540,16 @@ LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPAR return 0; } -BOOL SM_PostMessage(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) { 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 ) + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) { + if (pTemp->hWnd) return PostMessage(pTemp->hWnd, msg, wParam, lParam); return FALSE; @@ -572,12 +564,9 @@ BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; - while (pTemp != NULL) - { - if (!pszModule || !lstrcmpiA(pTemp->pszModule, pszModule)) - { - if (pTemp->hWnd) - { + while (pTemp != NULL) { + if (!pszModule || !lstrcmpiA(pTemp->pszModule, pszModule)) { + if (pTemp->hWnd) { if (bAsync) PostMessage(pTemp->hWnd, msg, wParam, lParam); else @@ -591,28 +580,28 @@ BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM return TRUE; } -BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) +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 )) { + while (pTemp != NULL) { + if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { pTemp->wStatus = wStatus; if (pTemp->hWnd && g_Settings.TabsEnable) g_TabSession.wStatus = wStatus; - if ( pTemp->hContact ) { - if ( pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE ) - db_unset(pTemp->hContact, "CList", "Hidden"); + if (pTemp->hContact) { + if (pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE) + db_unset(pTemp->hContact, "CList", "Hidden"); db_set_w(pTemp->hContact, pTemp->pszModule, "Status", (WORD)wStatus); } - if ( g_Settings.TabsEnable && g_TabSession.hWnd ) - PostMessage( g_TabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM) pTemp ); + if (g_Settings.TabsEnable && g_TabSession.hWnd) + PostMessage(g_TabSession.hWnd, GC_FIXTABICONS, 0, (LPARAM)pTemp); if (pszID) return TRUE; @@ -623,17 +612,17 @@ BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus) return TRUE; } -BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText) +BOOL SM_SendUserMessage(const TCHAR *pszID, const char* pszModule, const TCHAR* pszText) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; - if ( !pszModule || !pszText ) + 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); + 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; } @@ -648,13 +637,11 @@ SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si) BOOL bFound = FALSE; SESSION_INFO* pTemp = m_WndList; - if ( !si ) + if (!si) return NULL; - while (pTemp != NULL) - { - if (si == pTemp) - { + while (pTemp != NULL) { + if (si == pTemp) { if (bFound) return NULL; else @@ -676,12 +663,9 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si) if (!si) return NULL; - while (pTemp != NULL) - { - if (si == pTemp) - { - if (pLast) - { + while (pTemp != NULL) { + if (si == pTemp) { + if (pLast) { if (pLast != pTemp) return pLast; else @@ -697,20 +681,20 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si) return NULL; } -BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID) +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 ) - replaceStr( &ui->pszUID, pszNewUID ); + 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 ) + if (pszID) return TRUE; } pLast = pTemp; @@ -724,10 +708,8 @@ BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd) { SESSION_INFO *pTemp = m_WndList, *pLast = NULL; - while (pTemp != NULL) - { - if (si && si == pTemp) - { + while (pTemp != NULL) { + if (si && si == pTemp) { pTemp->hWnd = hwnd; } else @@ -737,21 +719,21 @@ BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd) } return TRUE; } -BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce) +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 ) { - replaceStr( &ui->pszNick, gce->ptszText); - SM_MoveUser( pTemp->ptszID, pTemp->pszModule, ui->pszUID ); - if ( pTemp->hWnd ) - SendMessage( pTemp->hWnd, GC_UPDATENICKLIST, 0, 0 ); + 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) @@ -762,18 +744,17 @@ BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce) } return TRUE; } -BOOL SM_RemoveAll (void) +BOOL SM_RemoveAll(void) { - while (m_WndList) - { + 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); + SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0); DoEventHook(m_WndList->ptszID, m_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)m_WndList->dwItemData); if (m_WndList->hContact) - CList_SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM?TRUE:FALSE); - db_set_s(m_WndList->hContact, m_WndList->pszModule , "Topic", ""); + CList_SetOffline(m_WndList->hContact, m_WndList->iType == GCW_CHATROOM ? TRUE : FALSE); + db_set_s(m_WndList->hContact, m_WndList->pszModule, "Topic", ""); db_unset(m_WndList->hContact, "CList", "StatusMsg"); db_set_s(m_WndList->hContact, m_WndList->pszModule, "StatusBar", ""); @@ -783,13 +764,13 @@ BOOL SM_RemoveAll (void) m_WndList->iStatusCount = 0; m_WndList->nUsersInNicklist = 0; - mir_free( m_WndList->pszModule ); - mir_free( m_WndList->ptszID ); - mir_free( m_WndList->ptszName ); - mir_free( m_WndList->ptszStatusbarText ); - mir_free( m_WndList->ptszTopic ); - mir_free( m_WndList->pszID ); - mir_free( m_WndList->pszName ); + mir_free(m_WndList->pszModule); + mir_free(m_WndList->ptszID); + mir_free(m_WndList->ptszName); + mir_free(m_WndList->ptszStatusbarText); + mir_free(m_WndList->ptszTopic); + mir_free(m_WndList->pszID); + mir_free(m_WndList->pszName); while (m_WndList->lpCommands != NULL) { COMMAND_INFO *pNext = m_WndList->lpCommands->next; @@ -805,13 +786,13 @@ BOOL SM_RemoveAll (void) return TRUE; } -void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewCommand) +void SM_AddCommand(const TCHAR *pszID, const char* pszModule, const char* lpNewCommand) { SESSION_INFO* pTemp = m_WndList; - while ( pTemp != NULL ) { - if ( lstrcmpi( pTemp->ptszID, pszID ) == 0 && lstrcmpiA( pTemp->pszModule, pszModule ) == 0) { // match + while (pTemp != NULL) { + if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match COMMAND_INFO *node = (COMMAND_INFO *)mir_alloc(sizeof(COMMAND_INFO)); - node->lpCommand = mir_strdup( lpNewCommand ); + node->lpCommand = mir_strdup(lpNewCommand); node->last = NULL; // always added at beginning! // new commands are added at start @@ -837,15 +818,17 @@ void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewC pLast->next = NULL; // done pTemp->wCommandsNum--; - } } + } + } pTemp = pTemp->next; -} } + } +} -char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was. +char* SM_GetPrevCommand(const TCHAR *pszID, const char* pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was. { SESSION_INFO* pTemp = m_WndList; - while ( pTemp != NULL ) { - if ( lstrcmpi( pTemp->ptszID, pszID ) == 0 && lstrcmpiA( pTemp->pszModule, pszModule ) == 0) { // match + while (pTemp != NULL) { + if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match COMMAND_INFO *pPrevCmd = NULL; if (pTemp->lpCurrentCommand != NULL) { if (pTemp->lpCurrentCommand->next != NULL) // not NULL @@ -863,11 +846,11 @@ char* SM_GetPrevCommand(const TCHAR* pszID, const char* pszModule) // get previo return(NULL); } -char* SM_GetNextCommand(const TCHAR* pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command) +char* SM_GetNextCommand(const TCHAR *pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command) { SESSION_INFO* pTemp = m_WndList; - while ( pTemp != NULL ) { - if ( lstrcmpi( pTemp->ptszID, pszID ) == 0 && lstrcmpiA( pTemp->pszModule, pszModule ) == 0) { // match + while (pTemp != NULL) { + if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match COMMAND_INFO *pNextCmd = NULL; if (pTemp->lpCurrentCommand != NULL) pNextCmd = pTemp->lpCurrentCommand->last; // last command (newest at beginning) @@ -885,8 +868,7 @@ int SM_GetCount(const char* pszModule) SESSION_INFO* pTemp = m_WndList; int count = 0; - while (pTemp != NULL) - { + while (pTemp != NULL) { if (!lstrcmpiA(pszModule, pTemp->pszModule)) count++; @@ -899,11 +881,9 @@ 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) + while (pTemp != NULL) { + if (!lstrcmpiA(pszModule, pTemp->pszModule)) { + if (iItem == count) return pTemp; else count++; @@ -922,12 +902,12 @@ char* SM_GetUsers(SESSION_INFO *si) char* p = NULL; int alloced = 0; - if ( si == NULL ) + if (si == NULL) return NULL; while (pTemp != NULL) { - if ( si == pTemp ) { - if (( utemp = pTemp->pUsers ) == NULL ) + if (si == pTemp) { + if ((utemp = pTemp->pUsers) == NULL) return NULL; break; @@ -937,14 +917,14 @@ char* SM_GetUsers(SESSION_INFO *si) do { int pLen = lstrlenA(p), nameLen = lstrlen(utemp->pszUID); - if ( pLen + nameLen + 2 > alloced ) - p = (char *)mir_realloc( p, alloced += 4096 ); + 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, " " ); + WideCharToMultiByte(CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen + 1, 0, 0); + lstrcpyA(p + pLen + nameLen, " "); utemp = utemp->next; } - while ( utemp != NULL ); + while (utemp != NULL); return p; } @@ -964,9 +944,8 @@ MODULEINFO* MM_AddModule(const char* pszModule) { if (!pszModule) return NULL; - if (!MM_FindModule(pszModule)) - { - MODULEINFO *node = (MODULEINFO*) mir_alloc(sizeof(MODULEINFO)); + if (!MM_FindModule(pszModule)) { + MODULEINFO *node = (MODULEINFO*)mir_alloc(sizeof(MODULEINFO)); ZeroMemory(node, sizeof(MODULEINFO)); node->pszModule = (char*)mir_alloc(lstrlenA(pszModule) + 1); @@ -977,8 +956,7 @@ MODULEINFO* MM_AddModule(const char* pszModule) m_ModList = node; node->next = NULL; } - else - { + else { node->next = m_ModList; m_ModList = node; } @@ -991,9 +969,8 @@ void MM_IconsChanged(void) { MODULEINFO *pTemp = m_ModList, *pLast = NULL; ImageList_ReplaceIcon(hIconsList, 0, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); - ImageList_ReplaceIcon(hIconsList, 1, LoadIconEx( "overlay", FALSE )); - while (pTemp != NULL) - { + ImageList_ReplaceIcon(hIconsList, 1, LoadIconEx("overlay", FALSE)); + while (pTemp != NULL) { pTemp->OnlineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_ONLINE)); pTemp->OfflineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_OFFLINE)); @@ -1008,11 +985,11 @@ void MM_IconsChanged(void) pTemp->hOfflineIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT); pTemp->hOnlineIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT); - pTemp->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); - ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex+1, pTemp->hOnlineTalkIcon); + pTemp->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); + ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex + 1, pTemp->hOnlineTalkIcon); - pTemp->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); - ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex+1, pTemp->hOfflineTalkIcon); + pTemp->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); + ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex + 1, pTemp->hOfflineTalkIcon); pLast = pTemp; pTemp = pTemp->next; @@ -1022,8 +999,7 @@ void MM_IconsChanged(void) void MM_FontsChanged(void) { MODULEINFO *pTemp = m_ModList; - while (pTemp != NULL) - { + while (pTemp != NULL) { pTemp->pszHeader = Log_CreateRtfHeader(pTemp); pTemp = pTemp->next; } @@ -1037,7 +1013,7 @@ MODULEINFO* MM_FindModule(const char* pszModule) return NULL; while (pTemp != NULL) { - if (lstrcmpiA(pTemp->pszModule,pszModule) == 0) + if (lstrcmpiA(pTemp->pszModule, pszModule) == 0) return pTemp; pLast = pTemp; @@ -1051,18 +1027,16 @@ void MM_FixColors() { MODULEINFO *pTemp = m_ModList; - while (pTemp != NULL) - { + while (pTemp != NULL) { CheckColorsInModule(pTemp->pszModule); pTemp = pTemp->next; } return; } -BOOL MM_RemoveAll (void) +BOOL MM_RemoveAll(void) { - while (m_ModList != NULL) - { + while (m_ModList != NULL) { MODULEINFO *pLast = m_ModList->next; mir_free(m_ModList->pszModule); mir_free(m_ModList->ptszModDispName); @@ -1094,18 +1068,18 @@ BOOL MM_RemoveAll (void) // be restored //--------------------------------------------------- -BOOL TabM_AddTab(const TCHAR* pszID, const char* pszModule) +BOOL TabM_AddTab(const TCHAR *pszID, const char* pszModule) { TABLIST *node = NULL; if (!pszID || !pszModule) return FALSE; - node = (TABLIST*) mir_alloc(sizeof(TABLIST)); - ZeroMemory( node, sizeof( TABLIST )); - node->pszID = mir_tstrdup( pszID ); - node->pszModule = mir_strdup( pszModule ); + node = (TABLIST*)mir_alloc(sizeof(TABLIST)); + ZeroMemory(node, sizeof(TABLIST)); + node->pszID = mir_tstrdup(pszID); + node->pszModule = mir_strdup(pszModule); - if ( g_TabList == NULL ) { // list is empty + if (g_TabList == NULL) { // list is empty g_TabList = node; node->next = NULL; } @@ -1116,10 +1090,9 @@ BOOL TabM_AddTab(const TCHAR* pszID, const char* pszModule) return TRUE; } -BOOL TabM_RemoveAll (void) +BOOL TabM_RemoveAll(void) { - while (g_TabList != NULL) - { + while (g_TabList != NULL) { TABLIST * pLast = g_TabList->next; mir_free(g_TabList->pszModule); mir_free(g_TabList->pszID); @@ -1142,10 +1115,10 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int if (!ppStatusList || !pszStatus) return NULL; - if ( !TM_FindStatus(*ppStatusList, pszStatus)) { - STATUSINFO *node = (STATUSINFO*) mir_alloc(sizeof(STATUSINFO)); + if (!TM_FindStatus(*ppStatusList, pszStatus)) { + STATUSINFO *node = (STATUSINFO*)mir_alloc(sizeof(STATUSINFO)); ZeroMemory(node, sizeof(STATUSINFO)); - replaceStr( &node->pszGroup, pszStatus ); + replaceStrT(node->pszGroup, pszStatus); node->hIcon = (HICON)(*iCount); while ((int)node->hIcon > STATUSICONCOUNT - 1) node->hIcon--; @@ -1156,9 +1129,8 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int *ppStatusList = node; node->next = NULL; } - else - { - node->Status = ppStatusList[0]->Status*2; + else { + node->Status = ppStatusList[0]->Status * 2; node->next = *ppStatusList; *ppStatusList = node; } @@ -1175,8 +1147,8 @@ STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus) if (!pStatusList || !pszStatus) return NULL; - while ( pTemp != NULL ) { - if ( lstrcmpi(pTemp->pszGroup, pszStatus) == 0 ) + while (pTemp != NULL) { + if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0) return pTemp; pLast = pTemp; @@ -1193,10 +1165,10 @@ WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus) return 0; while (pTemp != NULL) { - if ( lstrcmpi( pTemp->pszGroup, pszStatus ) == 0 ) + if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0) return pTemp->Status; - if ( pTemp->next == NULL ) + if (pTemp->next == NULL) return pStatusList->Status; pLast = pTemp; @@ -1224,14 +1196,13 @@ TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status) return 0; } -BOOL TM_RemoveAll (STATUSINFO** ppStatusList) +BOOL TM_RemoveAll(STATUSINFO** ppStatusList) { if (!ppStatusList) return FALSE; - while (*ppStatusList != NULL) - { + while (*ppStatusList != NULL) { STATUSINFO *pLast = ppStatusList[0]->next; mir_free(ppStatusList[0]->pszGroup); if ((int)ppStatusList[0]->hIcon > 10) @@ -1258,19 +1229,18 @@ static int UM_CompareItem(USERINFO * u1, const TCHAR* pszNick, WORD wStatus) WORD dw1 = u1->Status; WORD dw2 = wStatus; - for (i=0; i<8; i++ ) - { - if (( dw1 & 1 ) && !( dw2 & 1 )) + for (i = 0; i < 8; i++) { + if ((dw1 & 1) && !(dw2 & 1)) return -1; - if (( dw2 & 1 ) && !( dw1 & 1 )) + if ((dw2 & 1) && !(dw1 & 1)) return 1; - if (( dw1 & 1 ) && ( dw2 & 1 )) - return lstrcmp( u1->pszNick, pszNick ); + if ((dw1 & 1) && (dw2 & 1)) + return lstrcmp(u1->pszNick, pszNick); dw1 = dw1 >> 1; dw2 = dw2 >> 1; } - return lstrcmp( u1->pszNick, pszNick ); + return lstrcmp(u1->pszNick, pszNick); } @@ -1282,12 +1252,12 @@ USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID) if (!pTemp || !pszUID) return NULL; - while(pTemp && lstrcmpi( pTemp->pszUID, pszUID)) { + while (pTemp && lstrcmpi(pTemp->pszUID, pszUID)) { pLast = pTemp; pTemp = pTemp->next; } - if ( pTemp ) { + if (pTemp) { node = pTemp; if (pLast) pLast->next = pTemp->next; @@ -1297,7 +1267,7 @@ USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID) pLast = NULL; - while ( pTemp && UM_CompareItem(pTemp, node->pszNick, node->Status ) <= 0) { + while (pTemp && UM_CompareItem(pTemp, node->pszNick, node->Status) <= 0) { pLast = pTemp; pTemp = pTemp->next; } @@ -1307,14 +1277,15 @@ USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID) node->next = NULL; } else { - if ( pLast ) { + if (pLast) { node->next = pTemp; pLast->next = node; } else { node->next = *ppUserList; *ppUserList = node; - } } + } + } return node; } @@ -1328,31 +1299,31 @@ USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR if (!pStatusList || !ppUserList) return NULL; - while(pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0) - { + while (pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0) { pLast = pTemp; pTemp = pTemp->next; } // if (!UM_FindUser(*ppUserList, pszUI, wStatus) { - USERINFO *node = (USERINFO*) mir_alloc(sizeof(USERINFO)); + USERINFO *node = (USERINFO*)mir_alloc(sizeof(USERINFO)); ZeroMemory(node, sizeof(USERINFO)); - replaceStr( &node->pszUID, pszUID ); + replaceStrT(node->pszUID, pszUID); if (*ppUserList == NULL) { // list is empty *ppUserList = node; node->next = NULL; } else { - if ( pLast ) { + if (pLast) { node->next = pTemp; pLast->next = node; } else { node->next = *ppUserList; *ppUserList = node; - } } + } + } return node; } @@ -1366,8 +1337,8 @@ USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID) if (!pUserList || !pszUID) return NULL; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->pszUID, pszUID )) + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->pszUID, pszUID)) return pTemp; pLast = pTemp; @@ -1378,18 +1349,15 @@ USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID) USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index) { - int i = 0; - USERINFO *pTemp = pUserList; - if (!pUserList) return NULL; - while (pTemp != NULL) - { + int i = 0; + USERINFO *pTemp = pUserList; + while (pTemp != NULL) { if (i == index) - { return pTemp; - } + pTemp = pTemp->next; i++; } @@ -1398,13 +1366,12 @@ USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index) 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 )) { + USERINFO *pTemp = pUserList, *pLast = NULL; + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->pszUID, pszUID)) { pTemp->Status |= status; return pTemp; } @@ -1421,8 +1388,8 @@ USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD sta if (!pUserList || !pszUID) return NULL; - while ( pTemp != NULL ) { - if ( !lstrcmpi( pTemp->pszUID, pszUID )) { + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->pszUID, pszUID)) { pTemp->ContactStatus = status; return pTemp; } @@ -1432,26 +1399,27 @@ USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD sta return 0; } -BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags ) +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' : ' '; + 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 ) + while (pTemp != NULL) { + if (!bOnlyMe) pTemp->iStatusEx = 0; - if ( pszText != NULL ) { + if (pszText != NULL) { TCHAR* s = (TCHAR *)_tcsstr(pszText, pTemp->pszUID); - if ( s ) { + 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; - } } } + 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; @@ -1461,13 +1429,12 @@ BOOL UM_SetStatusEx(USERINFO* pUserList, const TCHAR* pszText, int flags ) 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 )) { + USERINFO *pTemp = pUserList, *pLast = NULL; + while (pTemp != NULL) { + if (!lstrcmpi(pTemp->pszUID, pszUID)) { pTemp->Status &= ~status; return pTemp; } @@ -1479,16 +1446,15 @@ USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status) 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 ( pTemp->pszNick && my_strstri( pTemp->pszNick, pszOriginal) == pTemp->pszNick ) - if ( lstrcmpi( pTemp->pszNick, pszCurrent ) > 0 && ( !pszName || lstrcmpi( pTemp->pszNick, pszName ) < 0)) - pszName = pTemp->pszNick; + TCHAR* pszName = NULL; + USERINFO *pTemp = pUserList; + while (pTemp != NULL) { + if (pTemp->pszNick && my_strstri(pTemp->pszNick, pszOriginal) == pTemp->pszNick) + if (lstrcmpi(pTemp->pszNick, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->pszNick, pszName) < 0)) + pszName = pTemp->pszNick; pTemp = pTemp->next; } @@ -1503,7 +1469,7 @@ BOOL UM_RemoveUser(USERINFO** ppUserList, const TCHAR* pszUID) return FALSE; while (pTemp != NULL) { - if (!lstrcmpi( pTemp->pszUID, pszUID )) { + if (!lstrcmpi(pTemp->pszUID, pszUID)) { if (pLast == NULL) *ppUserList = pTemp->next; else @@ -1519,17 +1485,16 @@ BOOL UM_RemoveUser(USERINFO** ppUserList, const TCHAR* pszUID) return FALSE; } -BOOL UM_RemoveAll (USERINFO** ppUserList) +BOOL UM_RemoveAll(USERINFO** ppUserList) { if (!ppUserList) return FALSE; - while (*ppUserList != NULL) - { + while (*ppUserList != NULL) { USERINFO *pLast = ppUserList[0]->next; - mir_free( ppUserList[0]->pszUID ); - mir_free( ppUserList[0]->pszNick ); - mir_free( *ppUserList ); + mir_free(ppUserList[0]->pszUID); + mir_free(ppUserList[0]->pszNick); + mir_free(*ppUserList); *ppUserList = pLast; } *ppUserList = NULL; @@ -1543,31 +1508,23 @@ BOOL UM_RemoveAll (USERINFO** ppUserList) // in a window log //--------------------------------------------------- -LOGINFO * LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd) +LOGINFO* LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd) { - - LOGINFO *node = NULL; - if (!ppLogListStart || !ppLogListEnd) return NULL; - node = (LOGINFO*) mir_alloc(sizeof(LOGINFO)); - ZeroMemory(node, sizeof(LOGINFO)); - - - if (*ppLogListStart == NULL) // list is empty - { + LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO)); + if (*ppLogListStart == NULL) { // list is empty *ppLogListStart = node; *ppLogListEnd = node; node->next = NULL; node->prev = NULL; } - else - { + else { ppLogListStart[0]->prev = node; node->next = *ppLogListStart; *ppLogListStart = node; - ppLogListStart[0]->prev=NULL; + ppLogListStart[0]->prev = NULL; } return node; @@ -1594,15 +1551,15 @@ BOOL LM_TrimLog(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd, int iCount) return TRUE; } -BOOL LM_RemoveAll (LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd) +BOOL LM_RemoveAll(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd) { - while ( *ppLogListStart != NULL ) { + 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 ); + 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; diff --git a/src/core/stdchat/src/options.cpp b/src/core/stdchat/src/options.cpp index 2875ed7785..67a37eac84 100644 --- a/src/core/stdchat/src/options.cpp +++ b/src/core/stdchat/src/options.cpp @@ -191,41 +191,39 @@ HTREEITEM hItemB6[SIZEOF(branch6)]; static HTREEITEM InsertBranch(HWND hwndTree, char* pszDescr, BOOL bExpanded) { - HTREEITEM res; - TVINSERTSTRUCT tvis = {0}; - - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT|TVIF_STATE; - tvis.item.pszText = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)pszDescr); + TVINSERTSTRUCT tvis = { 0 }; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_TEXT | TVIF_STATE; + tvis.item.pszText = (TCHAR*)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)pszDescr); tvis.item.stateMask = bExpanded ? TVIS_STATEIMAGEMASK | TVIS_EXPANDED : TVIS_STATEIMAGEMASK; - tvis.item.state = bExpanded ? INDEXTOSTATEIMAGEMASK(1) | TVIS_EXPANDED : INDEXTOSTATEIMAGEMASK(1); - res = TreeView_InsertItem(hwndTree, &tvis); + tvis.item.state = bExpanded ? INDEXTOSTATEIMAGEMASK(1) | TVIS_EXPANDED : INDEXTOSTATEIMAGEMASK(1); + HTREEITEM res = TreeView_InsertItem(hwndTree, &tvis); mir_free(tvis.item.pszText); return res; } static void FillBranch(HWND hwndTree, HTREEITEM hParent, const struct branch_t *branch, HTREEITEM *hItemB, int nValues, DWORD defaultval) { - TVINSERTSTRUCT tvis; - int i; int iState; if (hParent == 0) return; - tvis.hParent=hParent; - tvis.hInsertAfter=TVI_LAST; - tvis.item.mask=TVIF_TEXT|TVIF_STATE; - for (i=0;i>12 == 1)) + TVITEM tvi; + tvi.mask = TVIF_HANDLE | TVIF_STATE; + tvi.hItem = TreeView_GetNextItem(hwndTree, hHeading, TVGN_CHILD); + while (tvi.hItem && bChecked) { + if (tvi.hItem != hItemB1[0] && tvi.hItem != hItemB1[1]) { + TreeView_GetItem(hwndTree, &tvi); + if (((tvi.state & TVIS_STATEIMAGEMASK) >> 12 == 1)) bChecked = FALSE; } - tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); + tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem); } tvi.stateMask = TVIS_STATEIMAGEMASK; - tvi.state = INDEXTOSTATEIMAGEMASK(bChecked?2:1); + tvi.state = INDEXTOSTATEIMAGEMASK(bChecked ? 2 : 1); tvi.hItem = hHeading; - TreeView_SetItem(hwndTree,&tvi); + TreeView_SetItem(hwndTree, &tvi); } static void CheckBranches(HWND hwndTree, HTREEITEM hHeading) { BOOL bChecked = TRUE; - TVITEM tvi; if (hHeading == 0) return; - tvi.mask=TVIF_HANDLE|TVIF_STATE; + TVITEM tvi; + tvi.mask = TVIF_HANDLE | TVIF_STATE; tvi.hItem = hHeading; - TreeView_GetItem(hwndTree,&tvi); - if (((tvi.state&TVIS_STATEIMAGEMASK)>>12==2)) + TreeView_GetItem(hwndTree, &tvi); + if (((tvi.state & TVIS_STATEIMAGEMASK) >> 12 == 2)) bChecked = FALSE; - tvi.hItem=TreeView_GetNextItem(hwndTree, hHeading, TVGN_CHILD); + tvi.hItem = TreeView_GetNextItem(hwndTree, hHeading, TVGN_CHILD); tvi.stateMask = TVIS_STATEIMAGEMASK; - while(tvi.hItem) { - tvi.state=INDEXTOSTATEIMAGEMASK(bChecked?2:1); - if (tvi.hItem !=hItemB1[0] && tvi.hItem != hItemB1[1] ) - TreeView_SetItem(hwndTree,&tvi); - tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); -} } + while (tvi.hItem) { + tvi.state = INDEXTOSTATEIMAGEMASK(bChecked ? 2 : 1); + if (tvi.hItem != hItemB1[0] && tvi.hItem != hItemB1[1]) + TreeView_SetItem(hwndTree, &tvi); + tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem); + } +} static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { TCHAR szDir[MAX_PATH]; - switch(uMsg) { + switch (uMsg) { case BFFM_INITIALIZED: SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); break; case BFFM_SELCHANGED: - if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) - SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); + if (SHGetPathFromIDList((LPITEMIDLIST)lp, szDir)) + SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir); break; } return 0; @@ -313,9 +312,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p void LoadLogFonts(void) { - int i; - - for ( i = 0; ilfHeight = (char) db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defSize); + lf->lfHeight = (char)db_get_b(NULL, "ChatFonts", str, fontOptionsList[i].defSize); lf->lfWidth = 0; lf->lfEscapement = 0; lf->lfOrientation = 0; @@ -353,11 +350,13 @@ void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour) else { lstrcpyn(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); db_free(&dbv); -} } } + } + } +} -void RegisterFonts( void ) +void RegisterFonts(void) { - FontIDT fontid = {0}; + FontIDT fontid = { 0 }; ColourIDT colourid; char idstr[10]; int index = 0, i; @@ -460,7 +459,7 @@ static IconItem iconList[] = { LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART, 10 }, { LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT, 10 }, { LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK, 10 }, - { LPGEN("Nick change (10x10)"), "chat_log_nick", IDI_NICK, 10 }, + { LPGEN("Nick change (10x10)"), "chat_log_nick", IDI_NICK, 10 }, { LPGEN("Notice (10x10)"), "chat_log_notice", IDI_NOTICE, 10 }, { LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC, 10 }, { LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_HIGHLIGHT, 10 }, @@ -474,7 +473,7 @@ void AddIcons(void) } // load icons from the skinning module if available -HICON LoadIconEx( char* pszIcoLibName, BOOL big ) +HICON LoadIconEx(char* pszIcoLibName, BOOL big) { char szTemp[256]; mir_snprintf(szTemp, SIZEOF(szTemp), "chat_%s", pszIcoLibName); @@ -484,11 +483,11 @@ HICON LoadIconEx( char* pszIcoLibName, BOOL big ) static void InitSetting(TCHAR** ppPointer, char* pszSetting, TCHAR* pszDefault) { DBVARIANT dbv; - if ( !db_get_ts(NULL, "Chat", pszSetting, &dbv )) { - replaceStr( ppPointer, dbv.ptszVal ); + if (!db_get_ts(NULL, "Chat", pszSetting, &dbv)) { + replaceStrT(*ppPointer, dbv.ptszVal); db_free(&dbv); } - else replaceStr( ppPointer, pszDefault ); + else replaceStrT(*ppPointer, pszDefault); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -496,15 +495,10 @@ static void InitSetting(TCHAR** ppPointer, char* pszSetting, TCHAR* pszDefault) #define OPT_FIXHEADINGS (WM_USER+1) +static HTREEITEM hListHeading0, hListHeading1, hListHeading2, hListHeading3, hListHeading4, hListHeading5, hListHeading6; + static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { - static HTREEITEM hListHeading1 = 0; - static HTREEITEM hListHeading2= 0; - static HTREEITEM hListHeading3= 0; - static HTREEITEM hListHeading4= 0; - static HTREEITEM hListHeading5= 0; - static HTREEITEM hListHeading6= 0; - static HTREEITEM hListHeading0= 0; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); @@ -542,94 +536,94 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA break; case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) { - case IDC_CHECKBOXES: - if (((LPNMHDR)lParam)->code==NM_CLICK) { - TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { - if (hti.flags&TVHT_ONITEMSTATEICON) { - TVITEM tvi = {0}; - tvi.mask=TVIF_HANDLE|TVIF_STATE; - tvi.hItem=hti.hItem; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - if (tvi.hItem == hItemB1[0] && INDEXTOSTATEIMAGEMASK(1)==tvi.state) - TreeView_SetItemState(((LPNMHDR)lParam)->hwndFrom, hItemB1[1], INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - if (tvi.hItem == hItemB1[1] && INDEXTOSTATEIMAGEMASK(1)==tvi.state) - TreeView_SetItemState(((LPNMHDR)lParam)->hwndFrom, hItemB1[0], INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - - if (tvi.hItem == hListHeading0) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0); - else if (tvi.hItem == hListHeading1) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1); - else if (tvi.hItem == hListHeading2) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2); - else if (tvi.hItem == hListHeading3) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3); - else if (tvi.hItem == hListHeading4) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4); - else if (tvi.hItem == hListHeading5) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5); - else if (tvi.hItem == hListHeading6) - CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6); - else - PostMessage(hwndDlg, OPT_FIXHEADINGS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } } } - break; - - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - { - BYTE b = db_get_b(NULL, "Chat", "Tabs", 1); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch0, hItemB0, SIZEOF(branch0)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, hItemB1, SIZEOF(branch1)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, hItemB2, SIZEOF(branch2)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch3, hItemB3, SIZEOF(branch3)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch4, hItemB4, SIZEOF(branch4)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch5, hItemB5, SIZEOF(branch5)); - if (PopupInstalled) - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch6, hItemB6, SIZEOF(branch6)); - 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.StripFormat = (BOOL)db_get_b(NULL, "Chat", "TrimFormatting", 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.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0)?TRUE:FALSE; - - if (b != db_get_b(NULL, "Chat", "Tabs", 1)) { - SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE); - g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1); - } - else SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + switch(((LPNMHDR)lParam)->idFrom) { + case IDC_CHECKBOXES: + if (((LPNMHDR)lParam)->code == NM_CLICK) { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { + if (hti.flags & TVHT_ONITEMSTATEICON) { + TVITEM tvi = { 0 }; + tvi.mask = TVIF_HANDLE | TVIF_STATE; + tvi.hItem = hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); + if (tvi.hItem == hItemB1[0] && INDEXTOSTATEIMAGEMASK(1) == tvi.state) + TreeView_SetItemState(((LPNMHDR)lParam)->hwndFrom, hItemB1[1], INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); + if (tvi.hItem == hItemB1[1] && INDEXTOSTATEIMAGEMASK(1) == tvi.state) + TreeView_SetItemState(((LPNMHDR)lParam)->hwndFrom, hItemB1[0], INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); + + if (tvi.hItem == hListHeading0) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0); + else if (tvi.hItem == hListHeading1) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1); + else if (tvi.hItem == hListHeading2) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2); + else if (tvi.hItem == hListHeading3) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3); + else if (tvi.hItem == hListHeading4) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4); + else if (tvi.hItem == hListHeading5) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5); + else if (tvi.hItem == hListHeading6) + CheckBranches(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6); + else + PostMessage(hwndDlg, OPT_FIXHEADINGS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - return TRUE; - } } } + } + } + break; + + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + BYTE b = db_get_b(NULL, "Chat", "Tabs", 1); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch0, hItemB0, SIZEOF(branch0)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, hItemB1, SIZEOF(branch1)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, hItemB2, SIZEOF(branch2)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch3, hItemB3, SIZEOF(branch3)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch4, hItemB4, SIZEOF(branch4)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch5, hItemB5, SIZEOF(branch5)); + if (PopupInstalled) + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch6, hItemB6, SIZEOF(branch6)); + 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.StripFormat = (BOOL)db_get_b(NULL, "Chat", "TrimFormatting", 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.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; + + if (b != db_get_b(NULL, "Chat", "Tabs", 1)) { + SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE); + g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1); + } + else SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + + return TRUE; + } + } break; case WM_DESTROY: - { - BYTE b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch1Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch2Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch3Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch4Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch5Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch0Exp", b); - if (PopupInstalled) { - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6, TVIS_EXPANDED)&TVIS_EXPANDED?1:0; - db_set_b(NULL, "Chat", "Branch6Exp", b); - } } + BYTE b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch1Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch2Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch3Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch4Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch5Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch0Exp", b); + if (PopupInstalled) { + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6, TVIS_EXPANDED)&TVIS_EXPANDED ? 1 : 0; + db_set_b(NULL, "Chat", "Branch6Exp", b); + } break; } return FALSE; @@ -643,12 +637,12 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - SendDlgItemMessage(hwndDlg,IDC_SPIN2,UDM_SETRANGE,0,MAKELONG(5000,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN2,UDM_SETPOS,0,MAKELONG(db_get_w(NULL,"Chat","LogLimit",100),0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN3,UDM_SETRANGE,0,MAKELONG(10000,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN3,UDM_SETPOS,0,MAKELONG(db_get_w(NULL,"Chat","LoggingLimit",100),0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN4,UDM_SETRANGE,0,MAKELONG(255,10)); - SendDlgItemMessage(hwndDlg,IDC_SPIN4,UDM_SETPOS,0,MAKELONG(db_get_b(NULL,"Chat","NicklistRowDist",12),0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_SETRANGE, 0, MAKELONG(5000, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LogLimit", 100), 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN3, UDM_SETRANGE, 0, MAKELONG(10000, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN3, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LoggingLimit", 100), 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN4, UDM_SETRANGE, 0, MAKELONG(255, 10)); + SendDlgItemMessage(hwndDlg, IDC_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_b(NULL, "Chat", "NicklistRowDist", 12), 0)); { TCHAR* pszGroup = NULL; InitSetting(&pszGroup, "AddToGroup", _T("Chat rooms")); @@ -666,11 +660,11 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA SetDlgItemText(hwndDlg, IDC_OUTSTAMP, g_Settings.pszOutgoingNick); SetDlgItemText(hwndDlg, IDC_INSTAMP, g_Settings.pszIncomingNick); CheckDlgButton(hwndDlg, IDC_HIGHLIGHT, g_Settings.HighlightEnabled); - EnableWindow(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS), g_Settings.HighlightEnabled?TRUE:FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS), g_Settings.HighlightEnabled ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_LOGGING, g_Settings.LoggingEnabled); - EnableWindow(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), g_Settings.LoggingEnabled?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_FONTCHOOSE), g_Settings.LoggingEnabled?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT), g_Settings.LoggingEnabled?TRUE:FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), g_Settings.LoggingEnabled ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_FONTCHOOSE), g_Settings.LoggingEnabled ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT), g_Settings.LoggingEnabled ? TRUE : FALSE); break; case WM_COMMAND: @@ -688,34 +682,35 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA switch (LOWORD(wParam)) { case IDC_LOGGING: - EnableWindow(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_FONTCHOOSE), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED?TRUE:FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_FONTCHOOSE), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT), IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); break; case IDC_FONTCHOOSE: - { - LPITEMIDLIST idList; - BROWSEINFO bi = {0}; - TCHAR szDirectory[MAX_PATH]; - TCHAR szTemp[MAX_PATH]; - - bi.hwndOwner=hwndDlg; - bi.pszDisplayName=szDirectory; - bi.lpszTitle=TranslateT("Select folder"); - bi.ulFlags=BIF_NEWDIALOGSTYLE|BIF_EDITBOX|BIF_RETURNONLYFSDIRS; - bi.lpfn=BrowseCallbackProc; - bi.lParam=(LPARAM)szDirectory; - idList = SHBrowseForFolder(&bi); - if ( idList ) { - SHGetPathFromIDList(idList,szDirectory); - lstrcat(szDirectory, _T("\\")); - PathToRelativeT(szDirectory, szTemp); - SetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, lstrlen(szTemp) > 1 ? szTemp : _T("Logs\\")); - CoTaskMemFree(idList); + { + LPITEMIDLIST idList; + BROWSEINFO bi = { 0 }; + TCHAR szDirectory[MAX_PATH]; + TCHAR szTemp[MAX_PATH]; + + bi.hwndOwner = hwndDlg; + bi.pszDisplayName = szDirectory; + bi.lpszTitle = TranslateT("Select folder"); + bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)szDirectory; + idList = SHBrowseForFolder(&bi); + if (idList) { + SHGetPathFromIDList(idList, szDirectory); + lstrcat(szDirectory, _T("\\")); + PathToRelativeT(szDirectory, szTemp); + SetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, lstrlen(szTemp) > 1 ? szTemp : _T("Logs\\")); + CoTaskMemFree(idList); + } } break; - } + case IDC_HIGHLIGHT: EnableWindow(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS), IsDlgButtonChecked(hwndDlg, IDC_HIGHLIGHT) == BST_CHECKED?TRUE:FALSE); break; @@ -726,32 +721,30 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY ) { - int iLen; + if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) { TCHAR * pszText = NULL; - - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS)); - if ( iLen > 0 ) { - TCHAR *ptszText = (TCHAR *)mir_alloc((iLen+2) * sizeof(TCHAR)); + int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_HIGHLIGHTWORDS)); + if (iLen > 0) { + TCHAR *ptszText = (TCHAR *)mir_alloc((iLen + 2) * sizeof(TCHAR)); TCHAR *p2 = NULL; - - if(ptszText) { - GetDlgItemText(hwndDlg, IDC_HIGHLIGHTWORDS, ptszText, iLen + 1); - p2 = _tcschr(ptszText, ','); - while ( p2 ) { - *p2 = ' '; - p2 = _tcschr(ptszText, ','); - } - db_set_ts(NULL, "Chat", "HighlightWords", ptszText); - mir_free(ptszText); + + if (ptszText) { + GetDlgItemText(hwndDlg, IDC_HIGHLIGHTWORDS, ptszText, iLen + 1); + p2 = _tcschr(ptszText, ','); + while (p2) { + *p2 = ' '; + p2 = _tcschr(ptszText, ','); + } + db_set_ts(NULL, "Chat", "HighlightWords", ptszText); + mir_free(ptszText); } } else db_unset(NULL, "Chat", "HighlightWords"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY)); - if ( iLen > 0 ) { + if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText,iLen + 1); + GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText, iLen + 1); db_set_ts(NULL, "Chat", "LogDirectory", pszText); } else db_unset(NULL, "Chat", "LogDirectory"); @@ -759,60 +752,60 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA PathToAbsoluteT(pszText, g_Settings.pszLogDir); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGTIMESTAMP)); - if ( iLen > 0 ) { + if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen+1); + GetDlgItemText(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "LogTimestamp", pszText); } else db_unset(NULL, "Chat", "LogTimestamp"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP)); - if ( iLen > 0 ) { + if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_TIMESTAMP, pszText, iLen+1); + GetDlgItemText(hwndDlg, IDC_TIMESTAMP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "HeaderTime", pszText); } else db_unset(NULL, "Chat", "HeaderTime"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP)); - if ( iLen > 0 ) { + if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_INSTAMP, pszText,iLen+1); + GetDlgItemText(hwndDlg, IDC_INSTAMP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "HeaderIncoming", pszText); } else db_unset(NULL, "Chat", "HeaderIncoming"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP)); - if ( iLen > 0 ) { + if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_OUTSTAMP, pszText,iLen+1); + GetDlgItemText(hwndDlg, IDC_OUTSTAMP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "HeaderOutgoing", pszText); } else db_unset(NULL, "Chat", "HeaderOutgoing"); - g_Settings.HighlightEnabled = IsDlgButtonChecked(hwndDlg, IDC_HIGHLIGHT) == BST_CHECKED?TRUE:FALSE; + g_Settings.HighlightEnabled = IsDlgButtonChecked(hwndDlg, IDC_HIGHLIGHT) == BST_CHECKED ? TRUE : FALSE; db_set_b(NULL, "Chat", "HighlightEnabled", (BYTE)g_Settings.HighlightEnabled); - g_Settings.LoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED?TRUE:FALSE; + g_Settings.LoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE; db_set_b(NULL, "Chat", "LoggingEnabled", (BYTE)g_Settings.LoggingEnabled); - if ( g_Settings.LoggingEnabled ) + if (g_Settings.LoggingEnabled) CreateDirectoryTreeT(g_Settings.pszLogDir); - iLen = SendDlgItemMessage(hwndDlg,IDC_SPIN2,UDM_GETPOS,0,0); + iLen = SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_GETPOS, 0, 0); db_set_w(NULL, "Chat", "LogLimit", (WORD)iLen); - iLen = SendDlgItemMessage(hwndDlg,IDC_SPIN3,UDM_GETPOS,0,0); + iLen = SendDlgItemMessage(hwndDlg, IDC_SPIN3, UDM_GETPOS, 0, 0); db_set_w(NULL, "Chat", "LoggingLimit", (WORD)iLen); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)); if (iLen > 0) { pszText = (TCHAR *)mir_realloc(pszText, (iLen + 1) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen+1); + GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1); db_set_ts(NULL, "Chat", "AddToGroup", pszText); } else db_set_s(NULL, "Chat", "AddToGroup", ""); mir_free(pszText); - iLen = SendDlgItemMessage(hwndDlg,IDC_SPIN4,UDM_GETPOS,0,0); + iLen = SendDlgItemMessage(hwndDlg, IDC_SPIN4, UDM_GETPOS, 0, 0); if (iLen > 0) db_set_b(NULL, "Chat", "NicklistRowDist", (BYTE)iLen); else @@ -831,31 +824,31 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPA ///////////////////////////////////////////////////////////////////////////////////////// // Popup options -static INT_PTR CALLBACK DlgProcOptionsPopup(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) +static INT_PTR CALLBACK DlgProcOptionsPopup(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - SendDlgItemMessage(hwndDlg, IDC_BKG, CPM_SETCOLOUR,0,g_Settings.crPUBkgColour); - SendDlgItemMessage(hwndDlg, IDC_TEXT, CPM_SETCOLOUR,0,g_Settings.crPUTextColour); + SendDlgItemMessage(hwndDlg, IDC_BKG, CPM_SETCOLOUR, 0, g_Settings.crPUBkgColour); + SendDlgItemMessage(hwndDlg, IDC_TEXT, CPM_SETCOLOUR, 0, g_Settings.crPUTextColour); - if (g_Settings.iPopupStyle ==2) + if (g_Settings.iPopupStyle == 2) CheckDlgButton(hwndDlg, IDC_RADIO2, BST_CHECKED); - else if (g_Settings.iPopupStyle ==3) + else if (g_Settings.iPopupStyle == 3) CheckDlgButton(hwndDlg, IDC_RADIO3, BST_CHECKED); else CheckDlgButton(hwndDlg, IDC_RADIO1, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) ==BST_CHECKED?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) ==BST_CHECKED?TRUE:FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BKG), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) == BST_CHECKED ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) == BST_CHECKED ? TRUE : FALSE); - SendDlgItemMessage(hwndDlg,IDC_SPIN1,UDM_SETRANGE,0,MAKELONG(100,-1)); - SendDlgItemMessage(hwndDlg,IDC_SPIN1,UDM_SETPOS,0,MAKELONG(g_Settings.iPopupTimeout,0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(100, -1)); + SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(g_Settings.iPopupTimeout, 0)); break; case WM_COMMAND: - if ((LOWORD(wParam) == IDC_TIMEOUT) && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam != GetFocus())) + if ((LOWORD(wParam) == IDC_TIMEOUT) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; if (lParam != 0) @@ -866,14 +859,14 @@ static INT_PTR CALLBACK DlgProcOptionsPopup(HWND hwndDlg,UINT uMsg,WPARAM wParam case IDC_RADIO1: case IDC_RADIO2: case IDC_RADIO3: - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) ==BST_CHECKED?TRUE:FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) ==BST_CHECKED?TRUE:FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BKG), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) == BST_CHECKED ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT), IsDlgButtonChecked(hwndDlg, IDC_RADIO3) == BST_CHECKED ? TRUE : FALSE); break; } break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY ) { + if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) { int iLen; if (IsDlgButtonChecked(hwndDlg, IDC_RADIO2) == BST_CHECKED) @@ -886,14 +879,14 @@ static INT_PTR CALLBACK DlgProcOptionsPopup(HWND hwndDlg,UINT uMsg,WPARAM wParam g_Settings.iPopupStyle = iLen; db_set_b(NULL, "Chat", "PopupStyle", (BYTE)iLen); - iLen = SendDlgItemMessage(hwndDlg,IDC_SPIN1,UDM_GETPOS,0,0); + iLen = SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_GETPOS, 0, 0); g_Settings.iPopupTimeout = iLen; db_set_w(NULL, "Chat", "PopupTimeout", (WORD)iLen); - g_Settings.crPUBkgColour = SendDlgItemMessage(hwndDlg,IDC_BKG,CPM_GETCOLOUR,0,0); - db_set_dw(NULL, "Chat", "PopupColorBG", (DWORD)SendDlgItemMessage(hwndDlg,IDC_BKG,CPM_GETCOLOUR,0,0)); - g_Settings.crPUTextColour = SendDlgItemMessage(hwndDlg,IDC_TEXT,CPM_GETCOLOUR,0,0); - db_set_dw(NULL, "Chat", "PopupColorText", (DWORD)SendDlgItemMessage(hwndDlg,IDC_TEXT,CPM_GETCOLOUR,0,0)); + g_Settings.crPUBkgColour = SendDlgItemMessage(hwndDlg, IDC_BKG, CPM_GETCOLOUR, 0, 0); + db_set_dw(NULL, "Chat", "PopupColorBG", (DWORD)SendDlgItemMessage(hwndDlg, IDC_BKG, CPM_GETCOLOUR, 0, 0)); + g_Settings.crPUTextColour = SendDlgItemMessage(hwndDlg, IDC_TEXT, CPM_GETCOLOUR, 0, 0); + db_set_dw(NULL, "Chat", "PopupColorText", (DWORD)SendDlgItemMessage(hwndDlg, IDC_TEXT, CPM_GETCOLOUR, 0, 0)); return TRUE; } break; @@ -953,10 +946,10 @@ void LoadGlobalSettings(void) 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.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.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); @@ -967,13 +960,13 @@ void LoadGlobalSettings(void) 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); + 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")); + InitSetting(&g_Settings.pszTimeStamp, "HeaderTime", _T("[%H:%M]")); + InitSetting(&g_Settings.pszTimeStampLog, "LogTimestamp", _T("[%d %b %y %H:%M]")); + InitSetting(&g_Settings.pszIncomingNick, "HeaderIncoming", _T("%n:")); + InitSetting(&g_Settings.pszOutgoingNick, "HeaderOutgoing", _T("%n:")); + InitSetting(&g_Settings.pszHighlightWords, "HighlightWords", _T("%m")); { TCHAR pszTemp[MAX_PATH]; @@ -984,22 +977,22 @@ void LoadGlobalSettings(void) db_free(&dbv); } else { - TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat")); - lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp)-1); - mir_free(tmpPath); - } + TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_logpath%\\Chat")); + lstrcpyn(pszTemp, tmpPath, SIZEOF(pszTemp) - 1); + mir_free(tmpPath); + } PathToAbsoluteT(pszTemp, g_Settings.pszLogDir); } - g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0)?TRUE:FALSE; + g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; - if ( g_Settings.MessageBoxFont ) - DeleteObject( g_Settings.MessageBoxFont ); - LoadMsgDlgFont( 17, &lf, NULL ); + if (g_Settings.MessageBoxFont) + DeleteObject(g_Settings.MessageBoxFont); + LoadMsgDlgFont(17, &lf, NULL); g_Settings.MessageBoxFont = CreateFontIndirect(&lf); - if ( g_Settings.UserListFont ) + if (g_Settings.UserListFont) DeleteObject(g_Settings.UserListFont); LoadMsgDlgFont(18, &lf, NULL); g_Settings.UserListFont = CreateFontIndirect(&lf); @@ -1026,21 +1019,20 @@ static void FreeGlobalSettings(void) 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 ); + if (g_Settings.MessageBoxFont) + DeleteObject(g_Settings.MessageBoxFont); + if (g_Settings.UserListFont) + DeleteObject(g_Settings.UserListFont); + if (g_Settings.UserListHeadingsFont) + DeleteObject(g_Settings.UserListHeadingsFont); } int OptionsInit(void) { - LOGFONT lf; - g_hOptions = HookEvent(ME_OPT_INITIALISE, OptionsInitialize); LoadLogFonts(); + LOGFONT lf; LoadMsgDlgFont(18, &lf, NULL); lstrcpy(lf.lfFaceName, _T("MS Shell Dlg")); lf.lfUnderline = lf.lfItalic = lf.lfStrikeOut = 0; @@ -1058,33 +1050,28 @@ int OptionsInit(void) g_Settings.iHeight = db_get_dw(NULL, "Chat", "roomheight", -1); LoadGlobalSettings(); - SkinAddNewSoundEx("ChatMessage", LPGEN("Group chats"), LPGEN("Incoming message")); + SkinAddNewSoundEx("ChatMessage", LPGEN("Group chats"), LPGEN("Incoming message")); SkinAddNewSoundEx("ChatHighlight", LPGEN("Group chats"), LPGEN("Message is highlighted")); - SkinAddNewSoundEx("ChatAction", LPGEN("Group chats"), LPGEN("User has performed an action")); - SkinAddNewSoundEx("ChatJoin", LPGEN("Group chats"), LPGEN("User has joined")); - SkinAddNewSoundEx("ChatPart", LPGEN("Group chats"), LPGEN("User has left")); - SkinAddNewSoundEx("ChatKick", LPGEN("Group chats"), LPGEN("User has kicked some other user")); - SkinAddNewSoundEx("ChatMode", LPGEN("Group chats"), LPGEN("User's status was changed")); - SkinAddNewSoundEx("ChatNick", LPGEN("Group chats"), LPGEN("User has changed name")); - SkinAddNewSoundEx("ChatNotice", LPGEN("Group chats"), LPGEN("User has sent a notice")); - SkinAddNewSoundEx("ChatQuit", LPGEN("Group chats"), LPGEN("User has disconnected")); - SkinAddNewSoundEx("ChatTopic", LPGEN("Group chats"), LPGEN("The topic has been changed")); - - if ( g_Settings.LoggingEnabled ) + SkinAddNewSoundEx("ChatAction", LPGEN("Group chats"), LPGEN("User has performed an action")); + SkinAddNewSoundEx("ChatJoin", LPGEN("Group chats"), LPGEN("User has joined")); + SkinAddNewSoundEx("ChatPart", LPGEN("Group chats"), LPGEN("User has left")); + SkinAddNewSoundEx("ChatKick", LPGEN("Group chats"), LPGEN("User has kicked some other user")); + SkinAddNewSoundEx("ChatMode", LPGEN("Group chats"), LPGEN("User's status was changed")); + SkinAddNewSoundEx("ChatNick", LPGEN("Group chats"), LPGEN("User has changed name")); + SkinAddNewSoundEx("ChatNotice", LPGEN("Group chats"), LPGEN("User has sent a notice")); + SkinAddNewSoundEx("ChatQuit", LPGEN("Group chats"), LPGEN("User has disconnected")); + SkinAddNewSoundEx("ChatTopic", LPGEN("Group chats"), LPGEN("The topic has been changed")); + + if (g_Settings.LoggingEnabled) CreateDirectoryTreeT(g_Settings.pszLogDir); - { - LOGFONT lf; - HFONT hFont; - int iText; - - LoadMsgDlgFont(0, &lf, NULL); - hFont = CreateFontIndirect(&lf); - iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)),hFont, TRUE); - DeleteObject(hFont); - g_Settings.LogTextIndent = iText; - g_Settings.LogTextIndent = g_Settings.LogTextIndent*12/10; - } + LOGFONT lf2; + LoadMsgDlgFont(0, &lf2, NULL); + HFONT hFont = CreateFontIndirect(&lf2); + int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE); + DeleteObject(hFont); + g_Settings.LogTextIndent = iText; + g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10; return 0; } diff --git a/src/core/stdchat/src/services.cpp b/src/core/stdchat/src/services.cpp index 9c57522cae..0e146a2903 100644 --- a/src/core/stdchat/src/services.cpp +++ b/src/core/stdchat/src/services.cpp @@ -50,28 +50,12 @@ static HANDLE hEventJoinChat = NULL, hEventLeaveChat = NULL; -#ifdef _WIN64 - -#define SIZEOF_STRUCT_GCREGISTER_V1 40 -#define SIZEOF_STRUCT_GCWINDOW_V1 48 -#define SIZEOF_STRUCT_GCEVENT_V1 76 -#define SIZEOF_STRUCT_GCEVENT_V2 80 - -#else - -#define SIZEOF_STRUCT_GCREGISTER_V1 28 -#define SIZEOF_STRUCT_GCWINDOW_V1 32 -#define SIZEOF_STRUCT_GCEVENT_V1 44 -#define SIZEOF_STRUCT_GCEVENT_V2 48 - -#endif - void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) { if (!si) return; - if ( g_Settings.TabsEnable) { + if (g_Settings.TabsEnable) { // the session is not the current tab, so we copy the necessary // details into the SESSION_INFO for the tabbed window if (!si->hWnd) { @@ -155,7 +139,7 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) ///////////////////////////////////////////////////////////////////////////////////////// // Post-load event hooks -static int FontsChanged(WPARAM wParam,LPARAM lParam) +static int FontsChanged(WPARAM wParam, LPARAM lParam) { LoadLogFonts(); { @@ -165,11 +149,11 @@ static int FontsChanged(WPARAM wParam,LPARAM lParam) LoadMsgDlgFont(0, &lf, NULL); hFont = CreateFontIndirect(&lf); - iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)),hFont, TRUE); + iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE); DeleteObject(hFont); g_Settings.LogTextIndent = iText; - g_Settings.LogTextIndent = g_Settings.LogTextIndent*12/10; - g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0)?TRUE:FALSE; + g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10; + g_Settings.LogIndentEnabled = (db_get_b(NULL, "Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; } MM_FontsChanged(); MM_FixColors(); @@ -177,7 +161,7 @@ static int FontsChanged(WPARAM wParam,LPARAM lParam) return 0; } -static int IconsChanged(WPARAM wParam,LPARAM lParam) +static int IconsChanged(WPARAM wParam, LPARAM lParam) { FreeMsgLogBitmaps(); @@ -188,7 +172,7 @@ static int IconsChanged(WPARAM wParam,LPARAM lParam) return 0; } -static int PreShutdown(WPARAM wParam,LPARAM lParam) +static int PreShutdown(WPARAM wParam, LPARAM lParam) { SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE); @@ -198,220 +182,187 @@ static int PreShutdown(WPARAM wParam,LPARAM lParam) return 0; } -static int SmileyOptionsChanged(WPARAM wParam,LPARAM lParam) +static int SmileyOptionsChanged(WPARAM wParam, LPARAM lParam) { SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE); return 0; } -static INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam) +static INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam) { - int i; - if (!lParam) return -1; - EnterCriticalSection(&cs); - - i = SM_GetCount((char *)lParam); - - LeaveCriticalSection(&cs); - return i; + mir_cslock lck(cs); + return SM_GetCount((char *)lParam); } -static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam) +static INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam) { - GC_INFO * gci = (GC_INFO *) lParam; + GC_INFO *gci = (GC_INFO *)lParam; SESSION_INFO *si = NULL; if (!gci || !gci->pszModule) return 1; - EnterCriticalSection(&cs); + mir_cslock lck(cs); - if ( gci->Flags&BYINDEX) - si = SM_FindSessionByIndex( gci->pszModule, gci->iItem ); + if (gci->Flags&BYINDEX) + si = SM_FindSessionByIndex(gci->pszModule, gci->iItem); else - si = SM_FindSession( gci->pszID, gci->pszModule ); - - if ( si ) { - if ( gci->Flags & DATA ) gci->dwItemData = si->dwItemData; - if ( gci->Flags & HCONTACT ) gci->hContact = si->hContact; - if ( gci->Flags & TYPE ) gci->iType = si->iType; - if ( gci->Flags & COUNT ) gci->iCount = si->nUsersInNicklist; - if ( gci->Flags & USERS ) gci->pszUsers = SM_GetUsers(si); - - if ( si->dwFlags & GC_UNICODE ) { - if ( gci->Flags & ID ) gci->pszID = si->ptszID; - if ( gci->Flags & NAME ) gci->pszName = si->ptszName; - } - else { - if ( gci->Flags & ID ) gci->pszID = ( TCHAR* )si->pszID; - if ( gci->Flags & NAME ) gci->pszName = ( TCHAR* )si->pszName; - } - - LeaveCriticalSection(&cs); + si = SM_FindSession(gci->pszID, gci->pszModule); + + if (si) { + if (gci->Flags & DATA) gci->dwItemData = si->dwItemData; + if (gci->Flags & HCONTACT) gci->hContact = si->hContact; + if (gci->Flags & TYPE) gci->iType = si->iType; + if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist; + if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si); + if (gci->Flags & ID) gci->pszID = si->ptszID; + if (gci->Flags & NAME) gci->pszName = si->ptszName; return 0; } - LeaveCriticalSection(&cs); return 1; } static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) { - GCREGISTER *gcr = (GCREGISTER *)lParam; - MODULEINFO * mi = NULL; - if ( gcr == NULL) + if (gcr == NULL) return GC_REGISTER_ERROR; - if (gcr->cbSize != SIZEOF_STRUCT_GCREGISTER_V1) + if (gcr->cbSize != sizeof(GCREGISTER)) return GC_REGISTER_WRONGVER; - EnterCriticalSection(&cs); - - mi = MM_AddModule( gcr->pszModule ); - if ( mi ) { - mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags ); - mi->bBold = gcr->dwFlags&GC_BOLD; - mi->bUnderline = gcr->dwFlags&GC_UNDERLINE ; - mi->bItalics = gcr->dwFlags&GC_ITALICS ; - mi->bColor = gcr->dwFlags&GC_COLOR ; - mi->bBkgColor = gcr->dwFlags&GC_BKGCOLOR ; - mi->bAckMsg = gcr->dwFlags&GC_ACKMSG ; - mi->bChanMgr = gcr->dwFlags&GC_CHANMGR ; - mi->iMaxText= gcr->iMaxText; - mi->nColorCount = gcr->nColors; - if ( gcr->nColors > 0) { - mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors); - memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors); - } + mir_cslock lck(cs); + MODULEINFO *mi = MM_AddModule(gcr->pszModule); + if (mi == NULL) + return GC_REGISTER_ERROR; - mi->OnlineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_ONLINE)); - mi->hOnlineIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT); + mi->ptszModDispName = mir_tstrdup(gcr->ptszDispName); + mi->bBold = gcr->dwFlags & GC_BOLD; + mi->bUnderline = gcr->dwFlags & GC_UNDERLINE; + mi->bItalics = gcr->dwFlags & GC_ITALICS; + mi->bColor = gcr->dwFlags & GC_COLOR; + mi->bBkgColor = gcr->dwFlags & GC_BKGCOLOR; + mi->bAckMsg = gcr->dwFlags & GC_ACKMSG; + mi->bChanMgr = gcr->dwFlags & GC_CHANMGR; + mi->iMaxText = gcr->iMaxText; + mi->nColorCount = gcr->nColors; + if (gcr->nColors > 0) { + mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF)* gcr->nColors); + memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors); + } - mi->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); - ImageList_AddIcon(hIconsList, mi->hOnlineTalkIcon); + mi->OnlineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_ONLINE)); + mi->hOnlineIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT); - mi->OfflineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_OFFLINE)); - mi->hOfflineIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT); + mi->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); + ImageList_AddIcon(hIconsList, mi->hOnlineTalkIcon); - mi->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); - ImageList_AddIcon(hIconsList, mi->hOfflineTalkIcon); + mi->OfflineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_OFFLINE)); + mi->hOfflineIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT); - mi->pszHeader = Log_CreateRtfHeader(mi); + mi->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); + ImageList_AddIcon(hIconsList, mi->hOfflineTalkIcon); - CheckColorsInModule((char*)gcr->pszModule); - CList_SetAllOffline(TRUE, gcr->pszModule); + mi->pszHeader = Log_CreateRtfHeader(mi); - LeaveCriticalSection(&cs); - return 0; - } - - LeaveCriticalSection(&cs); - return GC_REGISTER_ERROR; + CheckColorsInModule((char*)gcr->pszModule); + CList_SetAllOffline(TRUE, gcr->pszModule); + return 0; } static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) { - MODULEINFO* mi; - GCSESSION *gcw =(GCSESSION *)lParam; - if (gcw== NULL) + GCSESSION *gcw = (GCSESSION *)lParam; + if (gcw == NULL) return GC_NEWSESSION_ERROR; - if (gcw->cbSize != SIZEOF_STRUCT_GCWINDOW_V1) + if (gcw->cbSize != sizeof(GCSESSION)) return GC_NEWSESSION_WRONGVER; - EnterCriticalSection(&cs); - - if (( mi = MM_FindModule( gcw->pszModule )) != NULL ) { - TCHAR* ptszID = a2tf( gcw->ptszID, gcw->dwFlags ); - SESSION_INFO *si = SM_AddSession( ptszID, gcw->pszModule); - - // create a new session and set the defaults - if ( si != NULL ) { - TCHAR szTemp[256]; - - si->dwItemData = gcw->dwItemData; - if ( gcw->iType != GCW_SERVER ) - si->wStatus = ID_STATUS_ONLINE; - si->iType = gcw->iType; - si->dwFlags = gcw->dwFlags; - si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags ); - si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, gcw->dwFlags ); - 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 ( !( gcw->dwFlags & GC_UNICODE )) { - si->pszID = mir_strdup( gcw->pszID ); - si->pszName = mir_strdup( gcw->pszName ); - } + mir_cslock lck(cs); + MODULEINFO* mi = MM_FindModule(gcw->pszModule); + if (mi == NULL) + return GC_NEWSESSION_ERROR; - if ( mi->bColor ) { - si->iFG = 4; - si->bFGSet = TRUE; - } - if ( mi->bBkgColor ) { - si->iBG = 2; - si->bBGSet = TRUE; - } - if (si->iType == GCW_SERVER) - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName); - else - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName); - si->hContact = CList_AddRoom( gcw->pszModule, ptszID, szTemp, si->iType); - db_set_s(si->hContact, si->pszModule , "Topic", ""); - db_unset(si->hContact, "CList", "StatusMsg"); - if (si->ptszStatusbarText) - db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); - else - db_set_s(si->hContact, si->pszModule, "StatusBar", ""); + SESSION_INFO *si = SM_AddSession(gcw->ptszID, gcw->pszModule); + + // create a new session and set the defaults + if (si != NULL) { + TCHAR szTemp[256]; + + si->dwItemData = gcw->dwItemData; + if (gcw->iType != GCW_SERVER) + si->wStatus = ID_STATUS_ONLINE; + si->iType = gcw->iType; + si->dwFlags = gcw->dwFlags; + si->ptszName = mir_tstrdup(gcw->ptszName); + si->ptszStatusbarText = mir_tstrdup(gcw->ptszStatusbarText); + si->iSplitterX = g_Settings.iSplitterX; + si->iSplitterY = g_Settings.iSplitterY; + si->iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0); + si->bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0); + si->bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1); + + if (mi->bColor) { + si->iFG = 4; + si->bFGSet = TRUE; } - else { - SESSION_INFO* si2 = SM_FindSession( ptszID, gcw->pszModule ); - if ( si2 ) { - if (si2->hWnd) - g_TabSession.nUsersInNicklist = 0; - - UM_RemoveAll(&si2->pUsers); - TM_RemoveAll(&si2->pStatuses); + if (mi->bBkgColor) { + si->iBG = 2; + si->bBGSet = TRUE; + } + if (si->iType == GCW_SERVER) + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName); + else + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName); + si->hContact = CList_AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType); + db_set_s(si->hContact, si->pszModule, "Topic", ""); + db_unset(si->hContact, "CList", "StatusMsg"); + if (si->ptszStatusbarText) + db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); + else + db_set_s(si->hContact, si->pszModule, "StatusBar", ""); + } + else { + SESSION_INFO* si2 = SM_FindSession(gcw->ptszID, gcw->pszModule); + if (si2) { + if (si2->hWnd) + g_TabSession.nUsersInNicklist = 0; - si2->iStatusCount = 0; - si2->nUsersInNicklist = 0; + UM_RemoveAll(&si2->pUsers); + TM_RemoveAll(&si2->pStatuses); - if ( !g_Settings.TabsEnable ) { - if (si2->hWnd ) - RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); - } - else if (g_TabSession.hWnd) - RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); - } } + si2->iStatusCount = 0; + si2->nUsersInNicklist = 0; - LeaveCriticalSection(&cs); - mir_free( ptszID ); - return 0; + if (!g_Settings.TabsEnable) { + if (si2->hWnd) + RedrawWindow(GetDlgItem(si2->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); + } + else if (g_TabSession.hWnd) + RedrawWindow(GetDlgItem(g_TabSession.hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); + } } - LeaveCriticalSection(&cs); - return GC_NEWSESSION_ERROR; + return 0; } -static int DoControl(GCEVENT * gce, WPARAM wp) +static int DoControl(GCEVENT *gce, WPARAM wp) { - if ( gce->pDest->iType == GC_EVENT_CONTROL ) { + SESSION_INFO *si; + + if (gce->pDest->iType == GC_EVENT_CONTROL) { switch (wp) { case WINDOW_HIDDEN: - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) { - si->bInitDone = TRUE; - SetActiveSession(si->ptszID, si->pszModule); - if (si->hWnd) - ShowRoom(si, wp, FALSE); - } + 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; @@ -419,14 +370,12 @@ static int DoControl(GCEVENT * gce, WPARAM wp) case WINDOW_MAXIMIZE: case WINDOW_VISIBLE: case SESSION_INITDONE: - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) { - si->bInitDone = TRUE; - if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0) - ShowRoom(si, wp, TRUE); - return 0; - } } + 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: @@ -434,15 +383,13 @@ static int DoControl(GCEVENT * gce, WPARAM wp) // fall through case SESSION_ONLINE: - SM_SetStatus( gce->pDest->ptszID, gce->pDest->pszModule, wp==SESSION_ONLINE?ID_STATUS_ONLINE:ID_STATUS_OFFLINE); + SM_SetStatus(gce->pDest->ptszID, gce->pDest->pszModule, wp == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE); break; case WINDOW_CLEARLOG: - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if ( si ) { + if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) { LM_RemoveAll(&si->pLog, &si->pLogEnd); - if ( si->hWnd ) { + if (si->hWnd) { g_TabSession.pLog = si->pLog; g_TabSession.pLogEnd = si->pLogEnd; } @@ -450,77 +397,70 @@ static int DoControl(GCEVENT * gce, WPARAM wp) 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->pszText) - { - SM_ChangeUID( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText); + 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->pszText) - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if ( si ) { - replaceStr( &si->ptszName, gce->ptszText ); - if ( si->hWnd ) + else if (gce->pDest->iType == GC_EVENT_CHANGESESSIONAME && gce->ptszText) { + if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) { + replaceStrT(si->ptszName, gce->ptszText); + if (si->hWnd) SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0); - if ( g_TabSession.hWnd && g_Settings.TabsEnable ) { + if (g_TabSession.hWnd && g_Settings.TabsEnable) { g_TabSession.ptszName = si->ptszName; SendMessage(g_TabSession.hWnd, GC_SESSIONNAMECHANGE, 0, (LPARAM)si); - } } } + } + } + } else if (gce->pDest->iType == GC_EVENT_SETITEMDATA) { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) + if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) si->dwItemData = gce->dwItemData; } - else if (gce->pDest->iType ==GC_EVENT_GETITEMDATA) { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) { + 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) - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) { - replaceStr( &si->ptszStatusbarText, gce->ptszText ); - if ( si->ptszStatusbarText ) + else if (gce->pDest->iType == GC_EVENT_SETSBTEXT) { + if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) { + replaceStrT(si->ptszStatusbarText, gce->ptszText); + if (si->ptszStatusbarText) db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); else db_set_s(si->hContact, si->pszModule, "StatusBar", ""); - if ( si->hWnd ) { + if (si->hWnd) { g_TabSession.ptszStatusbarText = si->ptszStatusbarText; SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0); - } } + } + } } - else if (gce->pDest->iType == GC_EVENT_ACK) - { + 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->pszText) - { - SM_SendUserMessage( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText); + 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 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) +static void AddUser(GCEVENT *gce) { SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si == NULL) return; @@ -545,50 +485,37 @@ static void AddUser(GCEVENT * gce) static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) { - GCEVENT *gce = (GCEVENT*)lParam, save_gce; - GCDEST *gcd = NULL, save_gcd; + GCEVENT *gce = (GCEVENT*)lParam; + GCDEST *gcd = NULL; TCHAR* pWnd = NULL; char* pMod = NULL; BOOL bIsHighlighted = FALSE; BOOL bRemoveFlag = FALSE; - int iRetVal = GC_EVENT_ERROR; - if ( gce == NULL ) + if (gce == NULL) return GC_EVENT_ERROR; gcd = gce->pDest; - if ( gcd == NULL ) + if (gcd == NULL) return GC_EVENT_ERROR; - if ( gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2 ) + if (gce->cbSize != sizeof(GCEVENT)) return GC_EVENT_WRONGVER; - if ( !IsEventSupported( gcd->iType )) + if (!IsEventSupported(gcd->iType)) return GC_EVENT_ERROR; - EnterCriticalSection(&cs); - - if (!(gce->dwFlags & GC_UNICODE)) { - save_gce = *gce; - save_gcd = *gce->pDest; - gce->pDest->ptszID = a2tf(gce->pDest->ptszID, gce->dwFlags); - gce->ptszUID = a2tf(gce->ptszUID, gce->dwFlags); - gce->ptszNick = a2tf(gce->ptszNick, gce->dwFlags); - gce->ptszStatus = a2tf(gce->ptszStatus, gce->dwFlags); - gce->ptszText = a2tf(gce->ptszText, gce->dwFlags); - gce->ptszUserInfo = a2tf(gce->ptszUserInfo, gce->dwFlags); - } + mir_cslock lck(cs); // Do different things according to type of event - switch(gcd->iType) { + switch (gcd->iType) { case GC_EVENT_ADDGROUP: { - STATUSINFO* si = SM_AddStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus); - if ( si && gce->dwItemData) + STATUSINFO* si = SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus); + if (si && gce->dwItemData) si->hIcon = CopyIcon((HICON)gce->dwItemData); } - iRetVal = 0; - goto LBL_Exit; + return 0; case GC_EVENT_CHUID: case GC_EVENT_CHANGESESSIONAME: @@ -597,30 +524,29 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_CONTROL: case GC_EVENT_SETSBTEXT: case GC_EVENT_ACK: - case GC_EVENT_SENDMESSAGE : - case GC_EVENT_SETSTATUSEX : - iRetVal = DoControl(gce, wParam); - goto LBL_Exit; + case GC_EVENT_SENDMESSAGE: + case GC_EVENT_SETSTATUSEX: + return DoControl(gce, wParam); case GC_EVENT_SETCONTACTSTATUS: - iRetVal = SM_SetContactStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData ); - goto LBL_Exit; + return SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData); case GC_EVENT_TOPIC: - { - SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si) { - if (gce->pszText) { - replaceStr(&si->ptszTopic, gce->ptszText); - if (si->hWnd) - g_TabSession.ptszTopic = si->ptszTopic; - db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic)); - if (db_get_b(NULL, "Chat", "TopicOnClist", 0)) - db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic)); + { + SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); + if (si) { + if (gce->ptszText) { + replaceStrT(si->ptszTopic, gce->ptszText); + if (si->hWnd) + g_TabSession.ptszTopic = si->ptszTopic; + db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic)); + if (db_get_b(NULL, "Chat", "TopicOnClist", 0)) + db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic)); + } } } break; - } + case GC_EVENT_ADDSTATUS: SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus); break; @@ -631,11 +557,11 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_MESSAGE: case GC_EVENT_ACTION: - if (!gce->bIsMe && gce->pDest->ptszID && gce->pszText) { + if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText) { SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) - if (IsHighlighted(si, gce->ptszText)) - bIsHighlighted = TRUE; + if (IsHighlighted(si, gce->ptszText)) + bIsHighlighted = TRUE; } break; @@ -659,39 +585,31 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) pWnd = gcd->ptszID; pMod = gcd->pszModule; } - else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) { + else if (gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION) { SESSION_INFO *si = GetActiveSession(); - if ( si && !lstrcmpA( si->pszModule, gcd->pszModule )) { + if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) { pWnd = si->ptszID; pMod = si->pszModule; } - else { - iRetVal = 0; - goto LBL_Exit; - } + else return 0; } else { // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc - SM_AddEventToAllMatchingUID( gce ); - if ( !bRemoveFlag ) { - iRetVal = 0; - goto LBL_Exit; - } } + SM_AddEventToAllMatchingUID(gce); + if (!bRemoveFlag) + return 0; + } // add to log - if ( pWnd ) { + if (pWnd) { SESSION_INFO *si = SM_FindSession(pWnd, pMod); // fix for IRC's old stuyle mode notifications. Should not affect any other protocol - if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !( gce->dwFlags & GCEF_ADDTOLOG )) { - iRetVal = 0; - goto LBL_Exit; - } + 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) { - iRetVal = 0; - goto LBL_Exit; - } + 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) { @@ -710,39 +628,22 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) LogToFile(si, gce); } - if ( !bRemoveFlag ) { - iRetVal = 0; - goto LBL_Exit; - } } - - if ( bRemoveFlag ) - iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0; - -LBL_Exit: - LeaveCriticalSection(&cs); - - if ( !( gce->dwFlags & GC_UNICODE )) { - mir_free((void*)gce->ptszText ); - mir_free((void*)gce->ptszNick ); - mir_free((void*)gce->ptszUID ); - mir_free((void*)gce->ptszStatus ); - mir_free((void*)gce->ptszUserInfo ); - mir_free((void*)gce->pDest->ptszID ); - *gce = save_gce; - *gce->pDest = save_gcd; + if (!bRemoveFlag) + return 0; } - return iRetVal; + 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; - - EnterCriticalSection(&cs); + GCPTRS *gp = (GCPTRS *)lParam; + mir_cslock lck(cs); gp->pfnAddEvent = Service_AddEvent; - LeaveCriticalSection(&cs); return 0; } @@ -755,42 +656,41 @@ static int ModuleLoad(WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// // Service creation -static int ModulesLoaded(WPARAM wParam,LPARAM lParam) +static int ModulesLoaded(WPARAM wParam, LPARAM lParam) { char* mods[3] = { "Chat", "ChatFonts" }; - CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2 ); + CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2); RegisterFonts(); AddIcons(); LoadIcons(); - { - CLISTMENUITEM mi = { sizeof(mi) }; - mi.position = -2000090001; - mi.flags = CMIF_DEFAULT; - mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_JOIN ); - mi.pszName = LPGEN("&Join"); - mi.pszService = "GChat/JoinChat"; - hJoinMenuItem = Menu_AddContactMenuItem(&mi); - - mi.position = -2000090000; - mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_LEAVE ); - mi.flags = CMIF_NOTOFFLINE; - mi.pszName = LPGEN("&Leave"); - mi.pszService = "GChat/LeaveChat"; - hLeaveMenuItem = Menu_AddContactMenuItem(&mi); - } + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.position = -2000090001; + mi.flags = CMIF_DEFAULT; + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN); + mi.pszName = LPGEN("&Join"); + mi.pszService = "GChat/JoinChat"; + hJoinMenuItem = Menu_AddContactMenuItem(&mi); + + mi.position = -2000090000; + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_LEAVE); + mi.flags = CMIF_NOTOFFLINE; + mi.pszName = LPGEN("&Leave"); + mi.pszService = "GChat/LeaveChat"; + hLeaveMenuItem = Menu_AddContactMenuItem(&mi); HookEvent(ME_FONT_RELOAD, FontsChanged); HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged); - if ( ServiceExists( MS_SMILEYADD_SHOWSELECTION )) { + if (ServiceExists(MS_SMILEYADD_SHOWSELECTION)) { SmileyAddInstalled = TRUE; HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileyOptionsChanged); } ModuleLoad(0, 0); - if ( ServiceExists( MS_IEVIEW_WINDOW )) + if (ServiceExists(MS_IEVIEW_WINDOW)) IEviewInstalled = TRUE; CList_SetAllOffline(TRUE, NULL); @@ -800,7 +700,7 @@ static int ModulesLoaded(WPARAM wParam,LPARAM lParam) void HookEvents(void) { InitializeCriticalSection(&cs); - + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu); HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); @@ -816,17 +716,17 @@ void UnhookEvents(void) 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_REGISTER, Service_Register); + CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat); + CreateServiceFunction(MS_GC_EVENT, Service_AddEvent); + CreateServiceFunction(MS_GC_GETEVENTPTR, Service_GetAddEventPtr); + CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo); CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount); - CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclicked); + CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclicked); CreateServiceFunction("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc); - CreateServiceFunction("GChat/JoinChat", CList_JoinChat); - CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat); + CreateServiceFunction("GChat/JoinChat", CList_JoinChat); + CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat); } void CreateHookableEvents(void) diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp index e2babc70e9..3ccd7f710c 100644 --- a/src/core/stdchat/src/tools.cpp +++ b/src/core/stdchat/src/tools.cpp @@ -32,10 +32,9 @@ extern SESSION_INFO g_TabSession; int GetRichTextLength(HWND hwnd) { GETTEXTLENGTHEX gtl; - gtl.flags = GTL_PRECISE; - gtl.codepage = CP_ACP ; - return (int) SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + gtl.codepage = CP_ACP; + return (int)SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); } TCHAR* RemoveFormatting(const TCHAR* pszWord) @@ -44,12 +43,12 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) int i = 0; int j = 0; - if ( pszWord == 0 || lstrlen(pszWord) == 0 ) + if (pszWord == 0 || lstrlen(pszWord) == 0) return NULL; - while(j < 9999 && i <= lstrlen( pszWord )) { + while (j < 9999 && i <= lstrlen(pszWord)) { if (pszWord[i] == '%') { - switch ( pszWord[i+1] ) { + switch (pszWord[i + 1]) { case '%': szTemp[j] = '%'; j++; @@ -77,29 +76,30 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) j++; i++; break; - } } + } + } else { szTemp[j] = pszWord[i]; j++; i++; - } } + } + } - return (TCHAR*) &szTemp; + return (TCHAR*)&szTemp; } static void __stdcall ShowRoomFromPopup(void * pi) { - SESSION_INFO *si = (SESSION_INFO*) 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) { + switch (message) { case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { - SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd); - + SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd); CallFunctionAsync(ShowRoomFromPopup, si); PUDeletePopup(hWnd); @@ -107,48 +107,46 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA } break; case WM_CONTEXTMENU: - { - SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd); - if (si->hContact) - if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0)) - CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)"chaticon"); + SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd); + if (si->hContact) + if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0)) + CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)"chaticon"); - if (si->hWnd && KillTimer(si->hWnd, TIMERID_FLASHWND)) - FlashWindow(si->hWnd, FALSE); + if (si->hWnd && KillTimer(si->hWnd, TIMERID_FLASHWND)) + FlashWindow(si->hWnd, FALSE); - PUDeletePopup(hWnd); - } + 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 int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...) { - POPUPDATAT pd = {0}; - va_list marker; - static TCHAR szBuf[4*1024]; + 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; - if ( hIcon ) + if (hIcon) pd.lchIcon = hIcon; else - pd.lchIcon = LoadIconEx( "window", FALSE ); + pd.lchIcon = LoadIconEx("window", FALSE); PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName); - mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%s - %s"), + 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); + lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE); pd.iSeconds = g_Settings.iPopupTimeout; if (g_Settings.iPopupStyle == 2) { @@ -169,17 +167,17 @@ static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP return PUAddPopupT(&pd); } -static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) +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 : + if (iEvent&g_Settings.dwTrayIconFlags) { + switch (iEvent) { + case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: + case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT: CList_AddEvent(si->hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName); break; - case GC_EVENT_MESSAGE : + case GC_EVENT_MESSAGE: CList_AddEvent(si->hContact, hIcons[ICON_MESSAGE], "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName); break; case GC_EVENT_ACTION: @@ -195,10 +193,10 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) CList_AddEvent(si->hContact, hIcons[ICON_QUIT], "chaticon", CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick); break; case GC_EVENT_NICK: - CList_AddEvent(si->hContact, hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->pszText); + CList_AddEvent(si->hContact, hIcons[ICON_NICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); break; case GC_EVENT_KICK: - CList_AddEvent(si->hContact, hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->pszStatus, gce->ptszNick, si->ptszName); + CList_AddEvent(si->hContact, hIcons[ICON_KICK], "chaticon", CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName); break; case GC_EVENT_NOTICE: CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], "chaticon", CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick); @@ -210,30 +208,31 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) CList_AddEvent(si->hContact, hIcons[ICON_INFO], "chaticon", CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName); break; case GC_EVENT_ADDSTATUS: - CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s enables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName); break; case GC_EVENT_REMOVESTATUS: - CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName); break; - } } + } + } return TRUE; } -static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) +static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { int iEvent = gce->pDest->iType; - if ( iEvent & g_Settings.dwPopupFlags ) { + if (iEvent & g_Settings.dwPopupFlags) { switch (iEvent) { - case GC_EVENT_MESSAGE|GC_EVENT_HIGHLIGHT : - ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting( gce->ptszText )); + case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: + ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); break; - case GC_EVENT_ACTION|GC_EVENT_HIGHLIGHT : + case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT: ShowPopup(si->hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); break; - case GC_EVENT_MESSAGE : - ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting( gce->ptszText)); + case GC_EVENT_MESSAGE: + ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_ACTION: ShowPopup(si->hContact, si, hIcons[ICON_ACTION], si->pszModule, si->ptszName, aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); @@ -242,25 +241,25 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) ShowPopup(si->hContact, si, hIcons[ICON_JOIN], si->pszModule, si->ptszName, aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick); break; case GC_EVENT_PART: - if (!gce->pszText) + if (!gce->ptszText) ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left"), gce->ptszNick); else ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; + break; case GC_EVENT_QUIT: - if (!gce->pszText) + if (!gce->ptszText) ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick); else - ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick,RemoveFormatting(gce->ptszText)); - break; + ShowPopup(si->hContact, si, hIcons[ICON_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->hContact, si, hIcons[ICON_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->pszText) - ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + if (!gce->ptszText) + ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick); else - ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NOTICE: ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); @@ -275,19 +274,20 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) ShowPopup(si->hContact, si, hIcons[ICON_INFO], si->pszModule, si->ptszName, aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText)); break; case GC_EVENT_ADDSTATUS: - ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick); break; case GC_EVENT_REMOVESTATUS: - ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick); break; - } } + } + } return TRUE; } -BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix) +BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix) { - if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER) + if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER) return FALSE; BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != si->hWnd; @@ -295,7 +295,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh int iEvent = gce->pDest->iType; - if ( bHighlight ) { + if (bHighlight) { gce->pDest->iType |= GC_EVENT_HIGHLIGHT; if (bInactive || !g_Settings.SoundsFocus) SkinPlaySound("ChatHighlight"); @@ -308,7 +308,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh if (bInactive || !g_Settings.PopupInactiveOnly) DoPopup(si, gce); if (g_Settings.TabsEnable && bInactive && g_TabSession.hWnd) - SendMessage(g_TabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM) si); + SendMessage(g_TabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si); return TRUE; } @@ -351,12 +351,12 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh if (!g_Settings.TabsEnable && bInactive && g_Settings.FlashWindow && si->hWnd) SetTimer(si->hWnd, TIMERID_FLASHWND, 900, NULL); - if (bInactive && !( si->wState & STATE_TALK )) { + if (bInactive && !(si->wState & STATE_TALK)) { si->wState |= STATE_TALK; - db_set_w(si->hContact, si->pszModule,"ApparentMode",(LPARAM)(WORD) 40071); + db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071); } if (g_Settings.TabsEnable && bInactive && g_TabSession.hWnd) - SendMessage(g_TabSession.hWnd, GC_SETTABHIGHLIGHT, 0, (LPARAM) si); + SendMessage(g_TabSession.hWnd, GC_SETTABHIGHLIGHT, 0, (LPARAM)si); break; case GC_EVENT_ACTION: if (bInactive || !g_Settings.SoundsFocus) @@ -374,7 +374,8 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh if (bInactive || !g_Settings.SoundsFocus) SkinPlaySound("ChatTopic"); break; - } } + } + } return TRUE; } @@ -388,8 +389,8 @@ int GetColorIndex(const char* pszModule, COLORREF cr) return -1; for (i = 0; i < pMod->nColorCount; i++) - if (pMod->crColors[i] == cr) - return i; + if (pMod->crColors[i] == cr) + return i; return -1; } @@ -401,38 +402,40 @@ int GetColorIndex(const char* pszModule, COLORREF cr) void CheckColorsInModule(const char* pszModule) { - MODULEINFO * pMod = MM_FindModule( pszModule ); + MODULEINFO * pMod = MM_FindModule(pszModule); int i = 0; COLORREF crFG; COLORREF crBG = (COLORREF)db_get_dw(NULL, "Chat", "ColorMessageBG", GetSysColor(COLOR_WINDOW)); LoadMsgDlgFont(17, NULL, &crFG); - if ( !pMod ) + if (!pMod) return; for (i = 0; i < pMod->nColorCount; i++) { if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) { - if (pMod->crColors[i] == RGB(255,255,255)) + if (pMod->crColors[i] == RGB(255, 255, 255)) pMod->crColors[i]--; else pMod->crColors[i]++; -} } } + } + } +} const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) { - int i,j,k; - for(i=0; s1[i]; i++) - for(j=i, k=0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++) - if (!s2[k+1]) - return s1 + i; + int i, j, k; + for (i = 0; s1[i]; i++) + for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++) + if (!s2[k + 1]) + return s1 + i; return NULL; } BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) { - if ( g_Settings.HighlightEnabled && g_Settings.pszHighlightWords && pszText && si->pMe ) { + if (g_Settings.HighlightEnabled && g_Settings.pszHighlightWords && pszText && si->pMe) { TCHAR* p1 = g_Settings.pszHighlightWords; TCHAR* p2 = NULL; const TCHAR* p3 = pszText; @@ -444,7 +447,7 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) while (*p1 != '\0') { // find the next/first word in the highlight word string // skip 'spaces' be4 the word - while(*p1 == ' ' && *p1 != '\0') + while (*p1 == ' ' && *p1 != '\0') p1 += 1; //find the end of the word @@ -469,10 +472,9 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) } // time to get the next/first word in the incoming text string - while(*p3 != '\0') - { + while (*p3 != '\0') { // skip 'spaces' be4 the word - while(*p3 == ' ' && *p3 != '\0') + while (*p3 == ' ' && *p3 != '\0') p3 += 1; //find the end of the word @@ -483,11 +485,11 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) if (p3 != p2) { // eliminate ending character if needed - if (p2-p3 > 1 && _tcschr(szTrimString, p2[-1])) + 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); + 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 != ' ') @@ -500,36 +502,35 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) // compare the words, using wildcards if (WCCmp(szWord1, RemoveFormatting(szWord2))) return TRUE; - } } + } + } p3 = pszText; - } } + } + } return FALSE; } -BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) +BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) { - MODULEINFO * mi = NULL; TCHAR szBuffer[4096]; TCHAR szLine[4096]; TCHAR szTime[100]; - FILE *hFile = NULL; TCHAR szFile[MAX_PATH]; TCHAR szName[MAX_PATH]; TCHAR szFolder[MAX_PATH]; char p = '\0'; - TCHAR *szModName = NULL; szBuffer[0] = '\0'; if (!si || !gce) return FALSE; - mi = MM_FindModule(si->pszModule); - if ( !mi ) + MODULEINFO *mi = MM_FindModule(si->pszModule); + if (!mi) return FALSE; - szModName = mir_a2t(si->pszModule); + TCHAR *szModName = mir_a2t(si->pszModule); mir_sntprintf(szName, MAX_PATH, _T("%s"), mi->ptszModDispName ? mi->ptszModDispName : (szModName = mir_a2t(si->pszModule))); mir_free(szModName); ValidateFilename(szName); @@ -543,9 +544,8 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) mir_sntprintf(szFile, MAX_PATH, _T("%s\\%s"), szFolder, szName ); lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99); - hFile = _tfopen(szFile, _T("at+")); - if (hFile) - { + FILE *hFile = _tfopen(szFile, _T("at+")); + if (hFile) { TCHAR szTemp[512], szTemp2[512]; TCHAR* pszNick = NULL; if ( gce->ptszNick ) { @@ -555,8 +555,8 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) } else lstrcpyn(szTemp2, gce->ptszNick, 511); - if (gce->pszUserInfo) - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->pszUserInfo); + 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; @@ -578,14 +578,14 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_PART: p = '<'; - if (!gce->pszText) + if (!gce->ptszText) mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick); else mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_QUIT: p = '<'; - if (!gce->pszText) + if (!gce->ptszText) mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick); else mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick,RemoveFormatting(gce->ptszText)); @@ -596,10 +596,10 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_KICK: p = '~'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + if (!gce->ptszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick); else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); break; case GC_EVENT_NOTICE: p = '¤'; @@ -607,7 +607,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_TOPIC: p = '#'; - if (!gce->pszNick) + 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); @@ -618,11 +618,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) break; case GC_EVENT_ADDSTATUS: p = '+'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick); break; case GC_EVENT_REMOVESTATUS: p = '-'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick); break; } if (p) @@ -630,34 +630,34 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) else mir_sntprintf(szLine, SIZEOF(szLine), TranslateT("%s %s\n"), szTime, szBuffer); - if ( szLine[0] ) { - char* p = mir_t2a( szLine ); + if (szLine[0]) { + char *p = mir_t2a(szLine); fputs(p, hFile); - mir_free( p ); + mir_free(p); - if ( g_Settings.LoggingLimit > 0 ) { + if (g_Settings.LoggingLimit > 0) { DWORD dwSize; DWORD trimlimit; - fseek(hFile,0,SEEK_END); + fseek(hFile, 0, SEEK_END); dwSize = ftell(hFile); - rewind (hFile); - trimlimit = g_Settings.LoggingLimit*1024+ 1024*10; + rewind(hFile); + trimlimit = g_Settings.LoggingLimit * 1024 + 1024 * 10; if (dwSize > trimlimit) { BYTE * pBuffer = 0; BYTE * pBufferTemp = 0; int read = 0; - pBuffer = (BYTE *)mir_alloc(g_Settings.LoggingLimit*1024+1); - pBuffer[g_Settings.LoggingLimit*1024] = '\0'; - fseek(hFile,-g_Settings.LoggingLimit*1024,SEEK_END); - read = (int)fread(pBuffer, 1, g_Settings.LoggingLimit*1024, hFile); + pBuffer = (BYTE *)mir_alloc(g_Settings.LoggingLimit * 1024 + 1); + pBuffer[g_Settings.LoggingLimit * 1024] = '\0'; + fseek(hFile, -g_Settings.LoggingLimit * 1024, SEEK_END); + read = (int)fread(pBuffer, 1, g_Settings.LoggingLimit * 1024, hFile); fclose(hFile); hFile = NULL; // trim to whole lines, should help with broken log files I hope. pBufferTemp = (BYTE *)strchr((char *)pBuffer, '\n'); - if ( pBufferTemp ) { + if (pBufferTemp) { pBufferTemp++; read -= pBufferTemp - pBuffer; } @@ -665,13 +665,16 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) if (read > 0) { hFile = _tfopen(szFile, _T("wt")); - if (hFile ) { + if (hFile) { fwrite(pBufferTemp, 1, read, hFile); fclose(hFile); hFile = NULL; - } } + } + } mir_free(pBuffer); - } } } + } + } + } if (hFile) fclose(hFile); hFile = NULL; @@ -683,8 +686,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText) { - GCMENUITEMS gcmi = {0}; - int i; + GCMENUITEMS gcmi = { 0 }; HMENU hSubMenu = 0; *hMenu = GetSubMenu(g_hMenu, iIndex); @@ -698,24 +700,23 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO EnableMenuItem(*hMenu, ID_CLEARLOG, MF_ENABLED); EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED); - ModifyMenu(*hMenu, 4, MF_GRAYED|MF_BYPOSITION, 4, NULL); + ModifyMenu(*hMenu, 4, MF_GRAYED | MF_BYPOSITION, 4, NULL); if (!i) { EnableMenuItem(*hMenu, ID_COPYALL, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_BYCOMMAND | MF_GRAYED); if (pszWordText && pszWordText[0]) - ModifyMenu(*hMenu, 4, MF_ENABLED|MF_BYPOSITION, 4, NULL); + ModifyMenu(*hMenu, 4, MF_ENABLED | MF_BYPOSITION, 4, NULL); } - if ( pszWordText && pszWordText[0] ) { + if (pszWordText && pszWordText[0]) { TCHAR szMenuText[4096]; - mir_sntprintf( szMenuText, 4096, TranslateT("Look up \'%s\':"), pszWordText ); - ModifyMenu( *hMenu, 4, MF_STRING|MF_BYPOSITION, 4, szMenuText ); + mir_sntprintf(szMenuText, 4096, TranslateT("Look up \'%s\':"), pszWordText); + ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText); } - else ModifyMenu( *hMenu, 4, MF_STRING|MF_GRAYED|MF_BYPOSITION, 4, TranslateT( "No word to look up" )); + else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up")); gcmi.Type = MENU_ON_LOG; } - else if (iIndex == 0) - { + else if (iIndex == 0) { TCHAR szTemp[50]; if (pszWordText) mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("&Message %s"), pszWordText); @@ -724,7 +725,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (lstrlen(szTemp) > 40) lstrcpy(szTemp + 40, _T("...")); - ModifyMenu(*hMenu, ID_MESS, MF_STRING|MF_BYCOMMAND, ID_MESS, szTemp); + ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp); gcmi.Type = MENU_ON_NICKLIST; } @@ -733,9 +734,8 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (gcmi.nItems > 0) AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); - for (i = 0; i < gcmi.nItems; i++) { - TCHAR* ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags); - TCHAR* ptszText = TranslateTS(ptszDescr); + for (int i = 0; i < gcmi.nItems; i++) { + TCHAR* ptszText = TranslateTS(gcmi.Item[i].pszDesc); DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0; if (gcmi.Item[i].uType == MENU_NEWPOPUP) { @@ -758,8 +758,6 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_CHECK) AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); - - mir_free( ptszDescr ); } return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); } @@ -769,143 +767,90 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex) MENUITEMINFO mi; mi.cbSize = sizeof(mi); mi.fMask = MIIM_SUBMENU; - while(GetMenuItemInfo(*hMenu, iIndex, TRUE, &mi)) - { + while (GetMenuItemInfo(*hMenu, iIndex, TRUE, &mi)) { if (mi.hSubMenu != NULL) DestroyMenu(mi.hSubMenu); RemoveMenu(*hMenu, iIndex, MF_BYPOSITION); } } -BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem) +BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem) { - GCHOOK* gch = (GCHOOK*)mir_calloc( sizeof( GCHOOK )); - GCDEST* gcd = (GCDEST*)mir_calloc( sizeof( GCDEST )); - - gcd->pszModule = mir_strdup( pszModule ); - SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) return FALSE; - if (!(si->dwFlags & GC_UNICODE)) { - gcd->ptszID = (LPTSTR)mir_t2a(pszID); - gch->pszUID = mir_t2a(pszUID); - gch->pszText = mir_t2a(pszText); - } - else { - gcd->ptszID = mir_tstrdup(pszID); - gch->ptszUID = mir_tstrdup(pszUID); - gch->ptszText = mir_tstrdup(pszText); - } - + GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST)); + gcd->pszModule = mir_strdup(pszModule); + gcd->ptszID = mir_tstrdup(pszID); gcd->iType = iType; + + GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK)); + gch->ptszUID = mir_tstrdup(pszUID); + gch->ptszText = mir_tstrdup(pszText); gch->dwData = dwItem; gch->pDest = gcd; PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch); return TRUE; } -BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem) +BOOL DoEventHook(const TCHAR *pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem) { - GCHOOK gch = {0}; - GCDEST gcd = {0}; - - gcd.pszModule = (char*)pszModule; - SESSION_INFO *si = SM_FindSession(pszID, pszModule); if (si == NULL) return FALSE; - if (!(si->dwFlags & GC_UNICODE)) { - gcd.ptszID = (LPTSTR)mir_t2a(pszID); - gch.pszUID = mir_t2a(pszUID); - gch.pszText = mir_t2a(pszText); - } - else { - gcd.ptszID = mir_tstrdup(pszID); - gch.ptszUID = mir_tstrdup(pszUID); - gch.ptszText = mir_tstrdup(pszText); - } - - gcd.iType = iType; + GCDEST gcd = { (char*)pszModule, (LPTSTR)pszID, iType }; + GCHOOK gch = { 0 }; + gch.ptszUID = (LPTSTR)pszUID; + gch.ptszText = (LPTSTR)pszText; gch.dwData = dwItem; gch.pDest = &gcd; NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch); - - mir_free(gcd.ptszID); - mir_free(gch.ptszUID); - mir_free(gch.ptszText); return TRUE; } BOOL IsEventSupported(int eventType) { - switch (eventType) - { - // Supported events - 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; + // 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; } -void ValidateFilename (TCHAR * filename) +void ValidateFilename(TCHAR *filename) { TCHAR *p1 = filename; TCHAR szForbidden[] = _T("\\/:*?\"<>|"); - while(*p1 != '\0') - { + while (*p1 != '\0') { if (_tcschr(szForbidden, *p1)) *p1 = '_'; - p1 +=1; -} } - -TCHAR* a2tf( const TCHAR* str, int flags ) -{ - if ( str == NULL ) - return NULL; - - if ( flags & GC_UNICODE ) - return mir_tstrdup( str ); - else - return mir_a2u((char*)str); -} - -TCHAR* replaceStr( TCHAR** dest, const TCHAR* src ) -{ - mir_free( *dest ); - *dest = mir_tstrdup( src ); - return *dest; -} - -char* replaceStrA( char** dest, const char* src ) -{ - mir_free( *dest ); - *dest = mir_strdup( src ); - return *dest; + p1 += 1; + } } -- cgit v1.2.3