diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
commit | 05cd7934d4bdb097e112efdda356946868f3f5d6 (patch) | |
tree | 0fa678b494af8b994abf7319298a1af06fc9218a /src | |
parent | 50a2ba5bf6827b8f010288021c1797c11bd1531e (diff) |
- 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
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdchat/src/chat.h | 66 | ||||
-rw-r--r-- | src/core/stdchat/src/manager.cpp | 643 | ||||
-rw-r--r-- | src/core/stdchat/src/options.cpp | 543 | ||||
-rw-r--r-- | src/core/stdchat/src/services.cpp | 586 | ||||
-rw-r--r-- | src/core/stdchat/src/tools.cpp | 415 |
5 files changed, 1018 insertions, 1235 deletions
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<nValues;i++) {
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = hParent;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_TEXT | TVIF_STATE;
+ for (int i = 0; i < nValues; i++) {
tvis.item.pszText = TranslateTS(branch[i].szDescr);
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
if (branch[i].iMode)
- iState = ((db_get_dw(NULL, "Chat", branch[i].szDBName, defaultval)&branch[i].iMode)&branch[i].iMode)!=0?2:1;
+ iState = ((db_get_dw(NULL, "Chat", branch[i].szDBName, defaultval)&branch[i].iMode)&branch[i].iMode) != 0 ? 2 : 1;
else
- iState = db_get_b(NULL, "Chat", branch[i].szDBName, branch[i].bDefault)!=0?2:1;
- tvis.item.state=INDEXTOSTATEIMAGEMASK(iState);
+ iState = db_get_b(NULL, "Chat", branch[i].szDBName, branch[i].bDefault) != 0 ? 2 : 1;
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(iState);
hItemB[i] = TreeView_InsertItem(hwndTree, &tvis);
-} }
+ }
+}
static void SaveBranch(HWND hwndTree, const struct branch_t *branch, HTREEITEM *hItemB, int nValues)
{
@@ -252,60 +250,61 @@ static void SaveBranch(HWND hwndTree, const struct branch_t *branch, HTREEITEM * static void CheckHeading(HWND hwndTree, HTREEITEM hHeading)
{
BOOL bChecked = TRUE;
- TVITEM tvi;
if (hHeading == 0)
return;
- 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))
+ 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; i<OPTIONS_FONTCOUNT; i++)
+ for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
LoadMsgDlgFont(i, &aFonts[i].lf, &aFonts[i].color);
}
@@ -331,7 +328,7 @@ void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour) }
if (lf) {
mir_snprintf(str, SIZEOF(str), "Font%dSize", i);
- lf->lfHeight = (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;
+ }
}
|