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 --- 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 - 6 files changed, 205 insertions(+), 367 deletions(-) (limited to 'plugins/TabSRMM/src') 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); } } -- cgit v1.2.3