summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/chat/chat.h52
-rw-r--r--plugins/Scriver/src/chat/manager.cpp42
-rw-r--r--plugins/Scriver/src/chat/services.cpp168
-rw-r--r--plugins/Scriver/src/chat/tools.cpp137
4 files changed, 140 insertions, 259 deletions
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];