diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-07 13:20:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-07 13:20:17 +0000 |
commit | 7cb44a3c4447a149004189b046a67def1b65a356 (patch) | |
tree | 2d7e0b08597167d5d9e24a99602a49c83492b631 /plugins/TabSRMM/src/chat | |
parent | 5801a85ed970b55b2041c588914f982039dc8031 (diff) |
- SM cleaning;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@5256 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/chatprototypes.h | 32 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/clist.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/manager.cpp | 894 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/message.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/options.cpp | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/services.cpp | 69 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 24 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 12 |
11 files changed, 433 insertions, 618 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index 316ca997e6..ff7d5577ea 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -233,7 +233,7 @@ struct LOGSTREAMDATA HWND hwnd;
LOGINFO* lin;
bool bStripFormat, bRedraw;
- SESSION_INFO* si;
+ SESSION_INFO *si;
int crCount;
TWindowData* dat;
};
@@ -244,7 +244,7 @@ struct TMUCSettings bool bShowTime, bShowTimeIfChanged, bLoggingEnabled;
bool bFlashWindow, bFlashWindowHightlight;
bool bOpenInDefault;
- bool bHighlightEnabled, bLogIndentEnabled;
+ bool bLogIndentEnabled;
bool bStripFormat;
bool bBBCodeInPopups;
bool bTrayIconInactiveOnly;
@@ -305,7 +305,7 @@ struct COLORCHOOSER int yPosition;
HWND hWndTarget;
bool bForeground;
- SESSION_INFO* si;
+ SESSION_INFO *si;
};
#pragma comment(lib,"comctl32.lib")
diff --git a/plugins/TabSRMM/src/chat/chatprototypes.h b/plugins/TabSRMM/src/chat/chatprototypes.h index 863fe3e0c1..e70361c10e 100644 --- a/plugins/TabSRMM/src/chat/chatprototypes.h +++ b/plugins/TabSRMM/src/chat/chatprototypes.h @@ -27,7 +27,7 @@ void UpgradeCheck(void); INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
//log.c
-void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO* si, bool bRedraw, bool bPhaseTwo);
+void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
void LoadMsgLogBitmaps(void);
void FreeMsgLogBitmaps(void);
TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
@@ -51,15 +51,14 @@ HICON LoadIconEx(int iIndex, char * pszIcoLibName, int iX, int iY); void HookEvents(void);
void UnhookEvents(void);
int CreateServiceFunctions(void);
-void DestroyServiceFunctions(void);
-void DestroyHookableEvents(void);
void CreateHookableEvents(void);
+void DestroyHookableEvents(void);
void TabsInit(void);
int ModulesLoaded(WPARAM wParam,LPARAM lParam);
int SmileyOptionsChanged(WPARAM wParam,LPARAM lParam);
int PreShutdown(WPARAM wParam,LPARAM lParam);
int IconsChanged(WPARAM wParam,LPARAM lParam);
-void ShowRoom(SESSION_INFO* si, WPARAM wp, BOOL bSetForeground);
+void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground);
INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam);
int Service_ItemData(WPARAM wParam, LPARAM lParam);
int Service_SetSBText(WPARAM wParam, LPARAM lParam);
@@ -70,24 +69,25 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT //manager.c
void SetActiveSession(const TCHAR* pszID, const char* pszModule);
-void SetActiveSessionEx(SESSION_INFO* si);
+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);
+void SM_RemoveContainer(TContainerData *pData);
SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule);
USERINFO* SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus);
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID);
-BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce);
+BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT *gce);
BOOL SM_RemoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID);
BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule);
-HICON SM_GetStatusIcon(SESSION_INFO* si, USERINFO* ui, char* szIndicator);
+HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO* ui, char* szIndicator);
BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus);
BOOL SM_SetStatusEx(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags );
BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText);
STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus);
-BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce, BOOL bisHighLight = FALSE);
-BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT * gce, BOOL bIsHighlighted);
+BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bisHighLight = FALSE);
+BOOL SM_AddEvent(const TCHAR* pszID, const char* pszModule, GCEVENT *gce, BOOL bIsHighlighted);
LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL SM_PostMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync);
@@ -103,7 +103,7 @@ int SM_GetCount(const char* pszModule); SESSION_INFO* SM_FindSessionByHWND(HWND h);
SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h);
SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem);
-char* SM_GetUsers(SESSION_INFO* si);
+char* SM_GetUsers(SESSION_INFO *si);
USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index);
BOOL SM_ReconfigureFilters();
BOOL SM_InvalidateLogDirectories();
@@ -152,20 +152,20 @@ int WCCmp(TCHAR* wild, TCHAR*string); //tools.c
TCHAR* RemoveFormatting(const TCHAR* pszText, bool fLower = false, bool fStripCR = false, TCHAR* buf = 0, const size_t len = 0);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO* si, GCEVENT * gce, BOOL bHighlight, int bManyFix);
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
int Chat_GetColorIndex(const char* pszModule, COLORREF cr);
void CheckColorsInModule(const char* pszModule);
TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) ;
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);
+BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText);
+UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
void Chat_SetFilters(SESSION_INFO *si);
void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p);
// message.c
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO* si);
-TCHAR* Chat_DoRtfToTags( char* pszRtfText, SESSION_INFO* si);
+char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
+TCHAR* Chat_DoRtfToTags( char* pszRtfText, SESSION_INFO *si);
diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index 0d3efc5358..fcdf0730b7 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -147,7 +147,7 @@ int CList_RoomDoubleclicked(WPARAM wParam, LPARAM lParam) return 0;
if (!db_get_ts(hContact, szProto, "ChatRoomID", &dbv)) {
- SESSION_INFO* si = SM_FindSession(dbv.ptszVal, szProto);
+ SESSION_INFO *si = SM_FindSession(dbv.ptszVal, szProto);
if (si) {
// is the "toggle visibility option set, so we need to close the window?
if (si->hWnd != NULL
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index d5d6e8e8f5..551bacb1ca 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -954,7 +954,7 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG return 0;
}
-void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO* si, bool bRedraw, bool bPhaseTwo)
+void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo)
{
EDITSTREAM stream;
LOGSTREAMDATA streamData;
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 8fbcdf565d..2891cb5b90 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -85,7 +85,6 @@ int Chat_Unload(void) mir_free(pszActiveWndModule);
DestroyMenu(g_hMenu);
- DestroyServiceFunctions();
DestroyHookableEvents();
FreeIcons();
OptionsUnInit();
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index 344f186c50..e5ea48094f 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -26,17 +26,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WINDOWS_COMMANDS_MAX 30
#define STATUSICONCOUNT 6
-SESSION_INFO *m_WndList = 0;
-MODULEINFO *m_ModList = 0;
+static SESSION_INFO *s_WndList = NULL;
+static MODULEINFO *s_ModList = NULL;
void SetActiveSession(const TCHAR* pszID, const char* pszModule)
{
- SESSION_INFO* si = SM_FindSession(pszID, pszModule);
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si)
SetActiveSessionEx(si);
}
-void SetActiveSessionEx(SESSION_INFO* si)
+void SetActiveSessionEx(SESSION_INFO *si)
{
if (si) {
replaceStr(&pszActiveWndID, si->ptszID);
@@ -46,11 +46,11 @@ void SetActiveSessionEx(SESSION_INFO* si) SESSION_INFO* GetActiveSession(void)
{
- SESSION_INFO* si = SM_FindSession(pszActiveWndID, pszActiveWndModule);
+ SESSION_INFO *si = SM_FindSession(pszActiveWndID, pszActiveWndModule);
if (si)
return si;
- return m_WndList;
+ return s_WndList;
}
//---------------------------------------------------
@@ -64,39 +64,37 @@ SESSION_INFO* SM_AddSession(const TCHAR* pszID, const char* pszModule) if (!pszID || !pszModule)
return NULL;
- if (!SM_FindSession(pszID, pszModule)) {
- SESSION_INFO*node = (SESSION_INFO*) mir_alloc(sizeof(SESSION_INFO));
- ZeroMemory(node, sizeof(SESSION_INFO));
- node->ptszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
+ if (SM_FindSession(pszID, pszModule))
+ return NULL;
- MODULEINFO *mi = MM_FindModule(pszModule);
+ SESSION_INFO *node = (SESSION_INFO*)mir_calloc(sizeof(SESSION_INFO));
+ node->ptszID = mir_tstrdup(pszID);
+ node->pszModule = mir_strdup(pszModule);
- if (mi) {
- mi->idleTimeStamp = time(0);
- SM_BroadcastMessage(pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
- }
+ MODULEINFO *mi = MM_FindModule(pszModule);
+ if (mi) {
+ mi->idleTimeStamp = time(0);
+ SM_BroadcastMessage(pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
+ }
- if (m_WndList == NULL) { // list is empty
- m_WndList = node;
- node->next = NULL;
- } else {
- node->next = m_WndList;
- m_WndList = node;
- }
- node->Highlight = g_Settings.Highlight;
- return node;
+ if (s_WndList == NULL) { // list is empty
+ s_WndList = node;
+ node->next = NULL;
}
- return NULL;
+ else {
+ node->next = s_WndList;
+ s_WndList = node;
+ }
+ node->Highlight = g_Settings.Highlight;
+ return node;
}
int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, bool removeContact)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
+ SESSION_INFO* pTemp = s_WndList, *pLast = NULL;
while (pTemp != NULL) {
if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) { // match
COMMAND_INFO *pCurComm;
@@ -108,7 +106,7 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, bool removeConta DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
if (pLast == NULL)
- m_WndList = pTemp->next;
+ s_WndList = pTemp->next;
else
pLast->next = pTemp->next;
@@ -153,8 +151,9 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, bool removeConta if (pLast)
pTemp = pLast->next;
else
- pTemp = m_WndList;
- } else {
+ pTemp = s_WndList;
+ }
+ else {
pLast = pTemp;
pTemp = pTemp->next;
}
@@ -162,189 +161,175 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, bool removeConta return FALSE;
}
-SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule)
+void SM_RemoveContainer(TContainerData *pContainer)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (si->pContainer == pContainer)
+ si->pContainer = NULL;
+}
+SESSION_INFO* SM_FindSession(const TCHAR* pszID, const char* pszModule)
+{
if (!pszID || !pszModule)
return NULL;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
- return pTemp;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (!lstrcmpi(si->ptszID, pszID) && !lstrcmpiA(si->pszModule, pszModule))
+ return si;
- pLast = pTemp;
- pTemp = pTemp->next;
- }
return NULL;
}
BOOL SM_SetOffline(const TCHAR* pszID, const char* pszModule)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_RemoveAll(&pTemp->pUsers);
- pTemp->nUsersInNicklist = 0;
- if (pTemp->iType != GCW_SERVER)
- pTemp->bInitDone = FALSE;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ UM_RemoveAll(&si->pUsers);
+ si->nUsersInNicklist = 0;
+ if (si->iType != GCW_SERVER)
+ si->bInitDone = FALSE;
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
BOOL SM_SetStatusEx(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText, int flags)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_SetStatusEx(pTemp->pUsers, pszText, flags);
- if (pTemp->hWnd)
- RedrawWindow(GetDlgItem(pTemp->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ UM_SetStatusEx(si->pUsers, pszText, flags);
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
-HICON SM_GetStatusIcon(SESSION_INFO* si, USERINFO* ui, char *szIndicator)
+HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO* ui, char *szIndicator)
{
- STATUSINFO * ti;
if (!ui || !si)
return NULL;
*szIndicator = 0;
- ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status));
- if (ti) {
- if ((INT_PTR)ti->hIcon < STATUSICONCOUNT) {
- int id = si->iStatusCount - (int)ti->hIcon - 1;
- if (id == 0) {
- *szIndicator = 0;
- return hIcons[ICON_STATUS0];
- }
- if (id == 1) {
- *szIndicator = '+';
- return hIcons[ICON_STATUS1];
- }
- if (id == 2) {
- *szIndicator = '%';
- return hIcons[ICON_STATUS2];
- }
- if (id == 3) {
- *szIndicator = '@';
- return hIcons[ICON_STATUS3];
- }
- if (id == 4) {
- *szIndicator = '!';
- return hIcons[ICON_STATUS4];
- }
- if (id == 5) {
- *szIndicator = '*';
- return hIcons[ICON_STATUS5];
- }
- } else
- return ti->hIcon;
+ STATUSINFO *ti = TM_FindStatus(si->pStatuses, TM_WordToString(si->pStatuses, ui->Status));
+ if (ti == NULL)
+ return hIcons[ICON_STATUS0];
+
+ if ((INT_PTR)ti->hIcon >= STATUSICONCOUNT)
+ return ti->hIcon;
+
+ int id = si->iStatusCount - (int)ti->hIcon - 1;
+ if (id == 0) {
+ *szIndicator = 0;
+ return hIcons[ICON_STATUS0];
+ }
+ if (id == 1) {
+ *szIndicator = '+';
+ return hIcons[ICON_STATUS1];
}
+ if (id == 2) {
+ *szIndicator = '%';
+ return hIcons[ICON_STATUS2];
+ }
+ if (id == 3) {
+ *szIndicator = '@';
+ return hIcons[ICON_STATUS3];
+ }
+ if (id == 4) {
+ *szIndicator = '!';
+ return hIcons[ICON_STATUS4];
+ }
+ if (id == 5) {
+ *szIndicator = '*';
+ return hIcons[ICON_STATUS5];
+ }
+
return hIcons[ICON_STATUS0];
}
-BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce, BOOL bIsHighLight)
+BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce, BOOL bIsHighLight)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
int bManyFix = 0;
- while (pTemp != NULL) {
- if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) {
- if (UM_FindUser(pTemp->pUsers, gce->ptszUID)) {
- if (pTemp->bInitDone) {
- if (SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE) && pTemp->hWnd && pTemp->bInitDone) {
- SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
- } else if (pTemp->hWnd && pTemp->bInitDone) {
- SendMessage(pTemp->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if (!lstrcmpiA(si->pszModule, gce->pDest->pszModule)) {
+ if (UM_FindUser(si->pUsers, gce->ptszUID)) {
+ if (si->bInitDone) {
+ if (SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- DoSoundsFlashPopupTrayStuff(pTemp, gce, bIsHighLight, bManyFix);
+ DoSoundsFlashPopupTrayStuff(si, gce, bIsHighLight, bManyFix);
bManyFix ++;
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.bLoggingEnabled)
- LogToFile(pTemp, gce);
+ LogToFile(si, gce);
}
}
}
-
- pLast = pTemp;
- pTemp = pTemp->next;
}
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)) {
- LOGINFO * li = LM_AddEvent(&pTemp->pLog, &pTemp->pLogEnd);
- pTemp->iEventCount += 1;
-
- li->iType = gce->pDest->iType;
- li->ptszNick = mir_tstrdup(gce->ptszNick);
- li->ptszText = mir_tstrdup(gce->ptszText);
- li->ptszStatus = mir_tstrdup(gce->ptszStatus);
- li->ptszUserInfo = mir_tstrdup(gce->ptszUserInfo);
-
- li->bIsMe = gce->bIsMe != 0;
- li->bIsHighlighted = bIsHighlighted != 0;
- li->time = gce->time;
-
- if (g_Settings.iEventLimit > 0 && pTemp->iEventCount > g_Settings.iEventLimit + g_Settings.iEventLimitThreshold) {
- LM_TrimLog(&pTemp->pLog, &pTemp->pLogEnd, pTemp->iEventCount - g_Settings.iEventLimit);
- pTemp->wasTrimmed = TRUE;
- pTemp->iEventCount = g_Settings.iEventLimit;
- }
- return TRUE;
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return TRUE;
+
+ if (!lstrcmpi(si->ptszID, pszID) && !lstrcmpiA(si->pszModule, pszModule)) {
+ LOGINFO *li = LM_AddEvent(&si->pLog, &si->pLogEnd);
+ si->iEventCount += 1;
+
+ li->iType = gce->pDest->iType;
+ li->ptszNick = mir_tstrdup(gce->ptszNick);
+ li->ptszText = mir_tstrdup(gce->ptszText);
+ li->ptszStatus = mir_tstrdup(gce->ptszStatus);
+ li->ptszUserInfo = mir_tstrdup(gce->ptszUserInfo);
+
+ li->bIsMe = gce->bIsMe != 0;
+ li->bIsHighlighted = bIsHighlighted != 0;
+ li->time = gce->time;
+
+ if (g_Settings.iEventLimit > 0 && si->iEventCount > g_Settings.iEventLimit + g_Settings.iEventLimitThreshold) {
+ LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings.iEventLimit);
+ si->wasTrimmed = TRUE;
+ si->iEventCount = g_Settings.iEventLimit;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
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);
- pTemp->nUsersInNicklist++;
- return p;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si) {
+ USERINFO *p = UM_AddUser(si->pStatuses, &si->pUsers, pszUID, pszNick, wStatus);
+ si->nUsersInNicklist++;
+ return p;
}
return 0;
@@ -352,245 +337,183 @@ USERINFO * SM_AddUser(const TCHAR* pszID, const char* pszModule, const TCHAR* ps BOOL SM_MoveUser(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID)
{
- SESSION_INFO* pTemp = m_WndList;
-
if (!pszID || !pszModule || !pszUID)
return FALSE;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- UM_SortUser(&pTemp->pUsers, pszUID);
- return TRUE;
- }
- pTemp = pTemp->next;
- }
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return FALSE;
- return FALSE;
+ UM_SortUser(&si->pUsers, pszUID);
+ return TRUE;
}
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)) {
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
DWORD dw;
- USERINFO * ui = UM_FindUser(pTemp->pUsers, pszUID);
+ USERINFO *ui = UM_FindUser(si->pUsers, pszUID);
if (ui) {
- pTemp->nUsersInNicklist--;
+ si->nUsersInNicklist--;
- dw = UM_RemoveUser(&pTemp->pUsers, pszUID);
+ dw = UM_RemoveUser(&si->pUsers, pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
if (pszID)
return TRUE;
}
}
-
- pLast = pTemp;
- pTemp = pTemp->next;
}
return 0;
}
-USERINFO * SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index)
+USERINFO* SM_GetUserFromIndex(const TCHAR* pszID, const char* pszModule, int index)
{
- SESSION_INFO* pTemp = m_WndList;
-
if (!pszModule)
- return FALSE;
+ return NULL;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
- return UM_FindUserFromIndex(pTemp->pUsers, index);
- pTemp = pTemp->next;
- }
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return NULL;
- return NULL;
+ return UM_FindUserFromIndex(si->pUsers, index);
}
-
-STATUSINFO * SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus)
+STATUSINFO* SM_AddStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszStatus)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return NULL;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- STATUSINFO* ti = TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount);
- if (ti)
- pTemp->iStatusCount++;
- return ti;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return NULL;
- return 0;
+ STATUSINFO *ti = TM_AddStatus(&si->pStatuses, pszStatus, &si->iStatusCount);
+ if (ti)
+ si->iStatusCount++;
+ return ti;
}
BOOL SM_GiveStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return FALSE;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO * ui = UM_GiveStatus(pTemp->pUsers, pszUID, TM_StringToWord(pTemp->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return FALSE;
+
+ USERINFO *ui = UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ if (ui) {
+ SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
}
-
- return FALSE;
+ return TRUE;
}
BOOL SM_SetContactStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, WORD wStatus)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return FALSE;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO * ui = UM_SetContactStatus(pTemp->pUsers, pszUID, wStatus);
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return FALSE;
- return FALSE;
+ USERINFO *ui = UM_SetContactStatus(si->pUsers, pszUID, wStatus);
+ if (ui) {
+ SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ }
+ return TRUE;
}
BOOL SM_TakeStatus(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszStatus)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return FALSE;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO* ui = UM_TakeStatus(pTemp->pUsers, pszUID, TM_StringToWord(pTemp->pStatuses, pszStatus));
- if (ui) {
- SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
- if (pTemp->hWnd)
- SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
- }
- return TRUE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return FALSE;
- return FALSE;
+ USERINFO* ui = UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ if (ui) {
+ SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ }
+ return TRUE;
}
+
LRESULT SM_SendMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
- while (pTemp && pszModule) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd) {
- LRESULT i = SendMessage(pTemp->hWnd, msg, wParam, lParam);
+ for (SESSION_INFO *si = s_WndList; si && pszModule; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ if (si->hWnd) {
+ LRESULT i = SendMessage(si->hWnd, msg, wParam, lParam);
if (pszID)
return i;
}
if (pszID)
return 0;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return 0;
}
BOOL SM_PostMessage(const TCHAR* pszID, const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszID || !pszModule)
return 0;
- while (pTemp != NULL) {
- if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd)
- return PostMessage(pTemp->hWnd, msg, wParam, lParam);
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si && si->hWnd)
+ return PostMessage(si->hWnd, msg, wParam, lParam);
- return FALSE;
- }
- pLast = pTemp;
- pTemp = pTemp->next;
- }
return FALSE;
}
BOOL SM_BroadcastMessage(const char* pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
- while (pTemp != NULL) {
- if (!pszModule || !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->hWnd) {
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if (!pszModule || !lstrcmpiA(si->pszModule, pszModule)) {
+ if (si->hWnd) {
if (bAsync)
- PostMessage(pTemp->hWnd, msg, wParam, lParam);
+ PostMessage(si->hWnd, msg, wParam, lParam);
else
- SendMessage(pTemp->hWnd, msg, wParam, lParam);
+ SendMessage(si->hWnd, msg, wParam, lParam);
}
-
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
BOOL SM_ReconfigureFilters()
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ Chat_SetFilters(si);
- while (pTemp != NULL) {
- Chat_SetFilters(pTemp);
- pLast = pTemp;
- pTemp = pTemp->next;
- }
return TRUE;
}
BOOL SM_InvalidateLogDirectories()
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
EnterCriticalSection(&cs);
- while (pTemp != NULL) {
- pTemp->pszLogFileName[0] = 0;
- pLast = pTemp;
- pTemp = pTemp->next;
- }
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ si->pszLogFileName[0] = 0;
LeaveCriticalSection(&cs);
return TRUE;
@@ -598,163 +521,151 @@ BOOL SM_InvalidateLogDirectories() BOOL SM_SetStatus(const TCHAR* pszID, const char* pszModule, int wStatus)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- pTemp->wStatus = wStatus;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ si->wStatus = wStatus;
- if (pTemp->hContact) {
- if (pTemp->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
- db_unset(pTemp->hContact, "CList", "Hidden");
+ if (si->hContact) {
+ if (si->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
+ db_unset(si->hContact, "CList", "Hidden");
- db_set_w(pTemp->hContact, pTemp->pszModule, "Status", (WORD)wStatus);
+ db_set_w(si->hContact, si->pszModule, "Status", (WORD)wStatus);
}
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
BOOL SM_SendUserMessage(const TCHAR* pszID, const char* pszModule, const TCHAR* pszText)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule || !pszText)
return FALSE;
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- if (pTemp->iType == GCW_CHATROOM)
- DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_USER_MESSAGE, NULL, pszText, 0);
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ if (si->iType == GCW_CHATROOM)
+ DoEventHook(si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, pszText, 0);
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID, const TCHAR* pszNewUID)
{
- SESSION_INFO* pTemp = m_WndList, *pLast = NULL;
-
if (!pszModule)
return FALSE;
- while (pTemp != NULL) {
- if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
- USERINFO* ui = UM_FindUser(pTemp->pUsers, pszUID);
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ USERINFO* ui = UM_FindUser(si->pUsers, pszUID);
if (ui)
replaceStr(&ui->pszUID, pszNewUID);
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
-BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce)
+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);
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if ((!pszID || !lstrcmpi(si->ptszID, pszID)) && !lstrcmpiA(si->pszModule, pszModule)) {
+ USERINFO* ui = UM_FindUser(si->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);
- if (pTemp->dat)
- GetMyNick(pTemp->dat);
- SendMessage(pTemp->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+ SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ if (si->hWnd) {
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ if (si->dat)
+ GetMyNick(si->dat);
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
}
}
if (pszID)
return TRUE;
}
- pLast = pTemp;
- pTemp = pTemp->next;
}
+
return TRUE;
}
+
BOOL SM_RemoveAll(void)
{
- while (m_WndList) {
- SESSION_INFO*pLast = m_WndList->next;
-
- if (m_WndList->hWnd)
- SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
- DoEventHook(m_WndList->ptszID, m_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)m_WndList->dwItemData);
- if (m_WndList->hContact)
- 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", "");
-
- UM_RemoveAll(&m_WndList->pUsers);
- TM_RemoveAll(&m_WndList->pStatuses);
- LM_RemoveAll(&m_WndList->pLog, &m_WndList->pLogEnd);
- m_WndList->iStatusCount = 0;
- m_WndList->nUsersInNicklist = 0;
-
- mir_free(m_WndList->pszModule);
- mir_free(m_WndList->ptszID);
- mir_free(m_WndList->ptszName);
- mir_free(m_WndList->ptszStatusbarText);
- mir_free(m_WndList->ptszTopic);
-
- while (m_WndList->lpCommands != NULL) {
- COMMAND_INFO *pNext = m_WndList->lpCommands->next;
- mir_free(m_WndList->lpCommands->lpCommand);
- mir_free(m_WndList->lpCommands);
- m_WndList->lpCommands = pNext;
+ while (s_WndList) {
+ SESSION_INFO *pLast = s_WndList->next;
+
+ if (s_WndList->hWnd)
+ SendMessage(s_WndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+ DoEventHook(s_WndList->ptszID, s_WndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)s_WndList->dwItemData);
+ if (s_WndList->hContact)
+ CList_SetOffline(s_WndList->hContact, s_WndList->iType == GCW_CHATROOM ? TRUE : FALSE);
+ db_set_s(s_WndList->hContact, s_WndList->pszModule , "Topic", "");
+ db_unset(s_WndList->hContact, "CList", "StatusMsg");
+ db_set_s(s_WndList->hContact, s_WndList->pszModule, "StatusBar", "");
+
+ UM_RemoveAll(&s_WndList->pUsers);
+ TM_RemoveAll(&s_WndList->pStatuses);
+ LM_RemoveAll(&s_WndList->pLog, &s_WndList->pLogEnd);
+ s_WndList->iStatusCount = 0;
+ s_WndList->nUsersInNicklist = 0;
+
+ mir_free(s_WndList->pszModule);
+ mir_free(s_WndList->ptszID);
+ mir_free(s_WndList->ptszName);
+ mir_free(s_WndList->ptszStatusbarText);
+ mir_free(s_WndList->ptszTopic);
+
+ while (s_WndList->lpCommands != NULL) {
+ COMMAND_INFO *pNext = s_WndList->lpCommands->next;
+ mir_free(s_WndList->lpCommands->lpCommand);
+ mir_free(s_WndList->lpCommands);
+ s_WndList->lpCommands = pNext;
}
- mir_free(m_WndList);
- m_WndList = pLast;
+ mir_free(s_WndList);
+ s_WndList = pLast;
}
- m_WndList = NULL;
+ s_WndList = NULL;
return TRUE;
}
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
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if (lstrcmpi(si->ptszID, pszID) == 0 && lstrcmpiA(si->pszModule, pszModule) == 0) { // match
COMMAND_INFO *node = (COMMAND_INFO *)mir_alloc(sizeof(COMMAND_INFO));
node->lpCommand = mir_strdup(lpNewCommand);
node->last = NULL; // always added at beginning!
// new commands are added at start
- if (pTemp->lpCommands == NULL) {
+ if (si->lpCommands == NULL) {
node->next = NULL;
- pTemp->lpCommands = node;
+ si->lpCommands = node;
} else {
- node->next = pTemp->lpCommands;
- pTemp->lpCommands->last = node; // hmm, weird
- pTemp->lpCommands = node;
+ node->next = si->lpCommands;
+ si->lpCommands->last = node; // hmm, weird
+ si->lpCommands = node;
}
- pTemp->lpCurrentCommand = NULL; // current command
- pTemp->wCommandsNum++;
+ si->lpCurrentCommand = NULL; // current command
+ si->wCommandsNum++;
- if (pTemp->wCommandsNum > WINDOWS_COMMANDS_MAX) {
- COMMAND_INFO *pCurComm = pTemp->lpCommands;
+ if (si->wCommandsNum > WINDOWS_COMMANDS_MAX) {
+ COMMAND_INFO *pCurComm = si->lpCommands;
COMMAND_INFO *pLast;
while (pCurComm->next != NULL) {
pCurComm = pCurComm->next;
@@ -764,171 +675,141 @@ void SM_AddCommand(const TCHAR* pszID, const char* pszModule, const char* lpNewC mir_free(pCurComm);
pLast->next = NULL;
// done
- pTemp->wCommandsNum--;
+ si->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.
{
- SESSION_INFO* pTemp = m_WndList;
- 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
- pPrevCmd = pTemp->lpCurrentCommand->next; // next command (newest at beginning)
- else
- pPrevCmd = pTemp->lpCurrentCommand;
- } else pPrevCmd = pTemp->lpCommands;
-
- pTemp->lpCurrentCommand = pPrevCmd; // make it the new command
- return(((pPrevCmd) ? (pPrevCmd->lpCommand) : (NULL)));
- }
- pTemp = pTemp->next;
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return NULL;
+
+ COMMAND_INFO *pPrevCmd = NULL;
+ if (si->lpCurrentCommand != NULL) {
+ if (si->lpCurrentCommand->next != NULL) // not NULL
+ pPrevCmd = si->lpCurrentCommand->next; // next command (newest at beginning)
+ else
+ pPrevCmd = si->lpCurrentCommand;
}
- return(NULL);
+ else pPrevCmd = si->lpCommands;
+
+ si->lpCurrentCommand = pPrevCmd; // make it the new command
+ return pPrevCmd ? pPrevCmd->lpCommand : NULL;
}
char* SM_GetNextCommand(const TCHAR* pszID, const char* pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command)
{
- SESSION_INFO* pTemp = m_WndList;
- 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)
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
+ return NULL;
- pTemp->lpCurrentCommand = pNextCmd; // make it the new command
- return(((pNextCmd) ? (pNextCmd->lpCommand) : (NULL)));
- }
- pTemp = pTemp->next;
- }
- return(NULL);
+ COMMAND_INFO *pNextCmd = NULL;
+ if (si->lpCurrentCommand != NULL)
+ pNextCmd = si->lpCurrentCommand->last; // last command (newest at beginning)
+
+ si->lpCurrentCommand = pNextCmd; // make it the new command
+ return pNextCmd ? pNextCmd->lpCommand : NULL;
}
int SM_GetCount(const char* pszModule)
{
- SESSION_INFO* pTemp = m_WndList;
int count = 0;
- while (pTemp != NULL) {
- if (!lstrcmpiA(pszModule, pTemp->pszModule))
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (!lstrcmpiA(pszModule, si->pszModule))
count++;
- pTemp = pTemp->next;
- }
return count;
}
SESSION_INFO* SM_FindSessionByHWND(HWND hWnd)
{
- SESSION_INFO *pTemp = m_WndList;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (si->hWnd == hWnd)
+ return si;
- while (pTemp) {
- if (pTemp->hWnd == hWnd)
- return pTemp;
- pTemp = pTemp->next;
- }
return NULL;
}
-SESSION_INFO * SM_FindSessionByHCONTACT(HANDLE h)
+SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h)
{
- SESSION_INFO *pTemp = m_WndList;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (si->hContact == h)
+ return si;
- while (pTemp) {
- if (pTemp->hContact == h)
- return pTemp;
- pTemp = pTemp->next;
- }
return NULL;
}
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)) {
+ for (SESSION_INFO *si = s_WndList; si; si = si->next) {
+ if (!lstrcmpiA(pszModule, si->pszModule)) {
if (iItem == count)
- return pTemp;
- else
- count++;
- }
+ return si;
- pTemp = pTemp->next;
+ count++;
+ }
}
+
return NULL;
}
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
- SESSION_INFO* pResult = NULL;
- if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName) {
- pResult = currSession;
- } else {
- TCHAR* pszName = NULL;
- SESSION_INFO* pTemp = m_WndList;
- if (currSession == prevSession) {
- pszCurrent = pszOriginal;
- }
- while (pTemp != NULL) {
- if (pTemp != currSession && !lstrcmpiA(pszModule, pTemp->pszModule)) {
- if (my_strstri(pTemp->ptszName, pszOriginal) == pTemp->ptszName) {
- if (prevSession != pTemp && lstrcmpi(pTemp->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(pTemp->ptszName, pszName) < 0)) {
- pResult = pTemp;
- pszName = pTemp->ptszName;
- }
+ if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
+ return currSession;
+
+ TCHAR* pszName = NULL;
+ if (currSession == prevSession)
+ pszCurrent = pszOriginal;
+
+ SESSION_INFO *pResult = NULL;
+ for (SESSION_INFO *si = s_WndList; si; si = si->next)
+ if (si != currSession && !lstrcmpiA(pszModule, si->pszModule))
+ if (my_strstri(si->ptszName, pszOriginal) == si->ptszName)
+ if (prevSession != si && lstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(si->ptszName, pszName) < 0)) {
+ pResult = si;
+ pszName = si->ptszName;
}
- }
- pTemp = pTemp->next;
- }
- }
- return pResult;
+ return pResult;
}
-char* SM_GetUsers(SESSION_INFO* si)
+char* SM_GetUsers(SESSION_INFO *si)
{
- SESSION_INFO* pTemp = m_WndList;
- USERINFO* utemp;
- int count = 0;
- char* p = NULL;
- int alloced = 0;
-
if (si == NULL)
return NULL;
- while (pTemp != NULL) {
- if (si == pTemp) {
- if ((utemp = pTemp->pUsers) == NULL)
- return NULL;
+ for (SESSION_INFO *psi = s_WndList; psi; psi = psi->next)
+ if (psi == si)
+ goto LBL_Found;
+ return NULL;
- break;
- }
- pTemp = pTemp->next;
- }
+LBL_Found:
+ USERINFO *utemp = si->pUsers;
+ if (utemp == NULL)
+ return NULL;
- do {
+ char* p = NULL;
+ int alloced = 0;
+
+ while (utemp != NULL) {
int pLen = lstrlenA(p), nameLen = lstrlen(utemp->pszUID);
if (pLen + nameLen + 2 > alloced)
p = (char *)mir_realloc(p, alloced += 4096);
WideCharToMultiByte(CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen + 1, 0, 0);
lstrcpyA(p + pLen + nameLen, " ");
utemp = utemp->next;
- } while (utemp != NULL);
+ }
+
return p;
}
-
-
-
-
-
//---------------------------------------------------
// Module Manager functions
//
@@ -947,60 +828,31 @@ MODULEINFO* MM_AddModule(const char* pszModule) node->pszModule = (char*)mir_alloc(lstrlenA(pszModule) + 1);
lstrcpyA(node->pszModule, pszModule);
node->idleTimeStamp = time(0);
- if (m_ModList == NULL) { // list is empty
- m_ModList = node;
+ if (s_ModList == NULL) { // list is empty
+ s_ModList = node;
node->next = NULL;
} else {
- node->next = m_ModList;
- m_ModList = node;
+ node->next = s_ModList;
+ s_ModList = node;
}
return node;
}
return FALSE;
}
-/*
-void MM_IconsChanged(void)
-{
- MODULEINFO *pTemp = m_ModList, *pLast = NULL;
- while (pTemp != NULL) {
- if (pTemp->hOfflineIcon)
- DestroyIcon(pTemp->hOfflineIcon);
- if (pTemp->hOnlineIcon)
- DestroyIcon(pTemp->hOnlineIcon);
- if (pTemp->hOnlineTalkIcon)
- DestroyIcon(pTemp->hOnlineTalkIcon);
- if (pTemp->hOfflineTalkIcon)
- DestroyIcon(pTemp->hOfflineTalkIcon);
-
- 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->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1));
- ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex+1, pTemp->hOfflineTalkIcon);
-
- pLast = pTemp;
- pTemp = pTemp->next;
- }
- return;
-}
-*/
-
void MM_FontsChanged(void)
{
- MODULEINFO *pTemp = m_ModList;
+ MODULEINFO *pTemp = s_ModList;
while (pTemp != NULL) {
pTemp->pszHeader = Log_CreateRtfHeader(pTemp);
pTemp = pTemp->next;
}
return;
}
+
MODULEINFO* MM_FindModule(const char* pszModule)
{
- MODULEINFO *pTemp = m_ModList, *pLast = NULL;
+ MODULEINFO *pTemp = s_ModList;
if (!pszModule)
return NULL;
@@ -1009,7 +861,6 @@ MODULEINFO* MM_FindModule(const char* pszModule) if (lstrcmpiA(pTemp->pszModule, pszModule) == 0)
return pTemp;
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1018,7 +869,7 @@ MODULEINFO* MM_FindModule(const char* pszModule) // stupid thing..
void MM_FixColors()
{
- MODULEINFO *pTemp = m_ModList;
+ MODULEINFO *pTemp = s_ModList;
while (pTemp != NULL) {
CheckColorsInModule(pTemp->pszModule);
@@ -1029,18 +880,18 @@ void MM_FixColors() BOOL MM_RemoveAll(void)
{
- while (m_ModList != NULL) {
- MODULEINFO *pLast = m_ModList->next;
- mir_free(m_ModList->pszModule);
- mir_free(m_ModList->ptszModDispName);
- if (m_ModList->pszHeader)
- mir_free(m_ModList->pszHeader);
- mir_free(m_ModList->crColors);
+ while (s_ModList != NULL) {
+ MODULEINFO *pLast = s_ModList->next;
+ mir_free(s_ModList->pszModule);
+ mir_free(s_ModList->ptszModDispName);
+ if (s_ModList->pszHeader)
+ mir_free(s_ModList->pszHeader);
+ mir_free(s_ModList->crColors);
- mir_free(m_ModList);
- m_ModList = pLast;
+ mir_free(s_ModList);
+ s_ModList = pLast;
}
- m_ModList = NULL;
+ s_ModList = NULL;
return TRUE;
}
@@ -1081,7 +932,7 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus)
{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
+ STATUSINFO *pTemp = pStatusList;
if (!pStatusList || !pszStatus)
return NULL;
@@ -1090,7 +941,6 @@ STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus) if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0)
return pTemp;
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1098,7 +948,7 @@ STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus) WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus)
{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
+ STATUSINFO *pTemp = pStatusList;
if (!pStatusList || !pszStatus)
return 0;
@@ -1110,7 +960,6 @@ WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus) if (pTemp->next == NULL)
return pStatusList->Status;
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1118,7 +967,7 @@ WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus) TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status)
{
- STATUSINFO *pTemp = pStatusList, *pLast = NULL;
+ STATUSINFO *pTemp = pStatusList;
if (!pStatusList)
return NULL;
@@ -1129,7 +978,6 @@ TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status) if (Status == 0)
return pTemp->pszGroup;
}
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1292,7 +1140,7 @@ USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID)
{
- USERINFO *pTemp = pUserList, *pLast = NULL;
+ USERINFO *pTemp = pUserList;
if (!pUserList || !pszUID)
return NULL;
@@ -1301,7 +1149,6 @@ USERINFO* UM_FindUser(USERINFO* pUserList, const TCHAR* pszUID) if (!lstrcmpi(pTemp->pszUID, pszUID))
return pTemp;
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1327,7 +1174,7 @@ USERINFO* UM_FindUserFromIndex(USERINFO* pUserList, int index) USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
{
- USERINFO *pTemp = pUserList, *pLast = NULL;
+ USERINFO *pTemp = pUserList;
if (!pUserList || !pszUID)
return NULL;
@@ -1337,7 +1184,6 @@ USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status) pTemp->Status |= status;
return pTemp;
}
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1345,7 +1191,7 @@ USERINFO* UM_GiveStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status) USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status)
{
- USERINFO *pTemp = pUserList, *pLast = NULL;
+ USERINFO *pTemp = pUserList;
if (!pUserList || !pszUID)
return NULL;
@@ -1355,7 +1201,6 @@ USERINFO* UM_SetContactStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD sta pTemp->ContactStatus = status;
return pTemp;
}
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
@@ -1393,7 +1238,7 @@ 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;
+ USERINFO *pTemp = pUserList;
if (!pUserList || !pszUID)
return NULL;
@@ -1403,7 +1248,6 @@ USERINFO* UM_TakeStatus(USERINFO* pUserList, const TCHAR* pszUID, WORD status) pTemp->Status &= ~status;
return pTemp;
}
- pLast = pTemp;
pTemp = pTemp->next;
}
return 0;
diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp index c42710c406..7195c26567 100644 --- a/plugins/TabSRMM/src/chat/message.cpp +++ b/plugins/TabSRMM/src/chat/message.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\commonheaders.h"
-static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO* si)
+static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO *si)
{
int i;
MODULEINFO * pMod = MM_FindModule(si->pszModule);
@@ -35,7 +35,7 @@ static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO* si) return -1;
}
-static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO* si)
+static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO *si)
{
char *p1, *p2, *pEnd;
int iIndex = 1;
@@ -79,7 +79,7 @@ static int ReadInteger(const char* p, int* result) return i;
}
-TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si)
+TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
{
int i, iRemoveChars, cp = CP_ACP;
char InsertThis[50];
@@ -314,7 +314,7 @@ static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbB return 0;
}
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO* si)
+char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si)
{
EDITSTREAM stream;
char* pszText = NULL;
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index b1e88ead66..e905eef4a0 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -1257,7 +1257,6 @@ void LoadGlobalSettings(void) g_Settings.bOpenInDefault = M.GetBool("Chat", "DefaultContainer", true);
g_Settings.bFlashWindow = M.GetBool("Chat", "FlashWindow", false);
g_Settings.bFlashWindowHightlight = M.GetBool("Chat", "FlashWindowHighlight", false);
- g_Settings.bHighlightEnabled = M.GetBool("Chat", "HighlightEnabled", true);
g_Settings.UserListColors[CHAT_STATUS_NORMAL] = M.GetDword(CHAT_FONTMODULE, "Font18Col", RGB(0, 0, 0));
g_Settings.UserListColors[CHAT_STATUS_AWAY] = M.GetDword(CHAT_FONTMODULE, "Font19Col", RGB(170, 170, 170));
g_Settings.UserListColors[CHAT_STATUS_OFFLINE] = M.GetDword(CHAT_FONTMODULE, "Font5Col", RGB(160, 90, 90));
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 56a63831f1..e421518e24 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -38,23 +38,10 @@ CRITICAL_SECTION cs;
-HANDLE hSendEvent;
-HANDLE hBuildMenuEvent;
+HANDLE hSendEvent, hBuildMenuEvent;
HGENMENU hJoinMenuItem, hLeaveMenuItem;
-static HANDLE
- hServiceRegister = NULL,
- hServiceNewChat = NULL,
- hServiceAddEvent = NULL,
- hServiceGetAddEventPtr = NULL,
- hServiceGetInfo = NULL,
- hServiceGetCount = NULL,
- hEventPrebuildMenu = NULL,
- hEventDoubleclicked = NULL,
- hEventJoinChat = NULL,
- hEventLeaveChat = NULL;
-
int Chat_ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
if (!PluginConfig.m_chat_enabled)
@@ -122,7 +109,7 @@ INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam) INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam)
{
GC_INFO * gci = (GC_INFO *) lParam;
- SESSION_INFO* si = NULL;
+ SESSION_INFO *si = NULL;
if (!gci || !gci->pszModule)
return 1;
@@ -212,7 +199,7 @@ INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) if ((mi = MM_FindModule(gcw->pszModule)) != NULL) {
TCHAR* ptszID = a2tf(gcw->ptszID, gcw->dwFlags);
- SESSION_INFO* si = SM_AddSession(ptszID, gcw->pszModule);
+ SESSION_INFO *si = SM_AddSession(ptszID, gcw->pszModule);
// create a new session and set the defaults
if (si != NULL) {
@@ -281,9 +268,9 @@ INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) return GC_NEWSESSION_ERROR;
}
-static int DoControl(GCEVENT * gce, WPARAM wp)
+static int DoControl(GCEVENT *gce, WPARAM wp)
{
- SESSION_INFO* si;
+ SESSION_INFO *si;
switch(gce->pDest->iType) {
case GC_EVENT_CONTROL:
@@ -396,12 +383,12 @@ static int DoControl(GCEVENT * gce, WPARAM wp) return 0;
}
-static void AddUser(GCEVENT * gce)
+static void AddUser(GCEVENT *gce)
{
- SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
+ SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
if (si) {
WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO * ui = SM_AddUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszNick, status);
+ USERINFO *ui = SM_AddUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszNick, status);
if (ui) {
ui->pszNick = mir_tstrdup(gce->ptszNick);
@@ -560,7 +547,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT return hwndNew; // return handle of the new dialog
}
-void ShowRoom(SESSION_INFO* si, WPARAM wp, BOOL bSetForeground)
+void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
{
if (!si)
return;
@@ -726,7 +713,7 @@ INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) pMod = gcd->pszModule;
}
else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) {
- SESSION_INFO* si = GetActiveSession();
+ SESSION_INFO *si = GetActiveSession();
if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
@@ -835,34 +822,20 @@ int CreateServiceFunctions(void) }
PluginConfig.m_chat_enabled = true;
- hServiceRegister = CreateServiceFunction(MS_GC_REGISTER, Service_Register);
- hServiceNewChat = CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
- hServiceAddEvent = CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
- hServiceGetAddEventPtr = CreateServiceFunction(MS_GC_GETEVENTPTR, Service_GetAddEventPtr);
- hServiceGetInfo = CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo);
- hServiceGetCount = CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount);
-
- hEventDoubleclicked = CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclicked);
- hEventPrebuildMenu = CreateServiceFunction("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc);
- hEventJoinChat = CreateServiceFunction("GChat/JoinChat", CList_JoinChat);
- hEventLeaveChat = CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat);
+ 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/PrebuildMenuEvent", CList_PrebuildContactMenuSvc);
+ CreateServiceFunction("GChat/JoinChat", CList_JoinChat);
+ CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat);
return 1;
}
-void DestroyServiceFunctions(void)
-{
- DestroyServiceFunction(hServiceRegister);
- DestroyServiceFunction(hServiceNewChat);
- DestroyServiceFunction(hServiceAddEvent);
- DestroyServiceFunction(hServiceGetAddEventPtr);
- DestroyServiceFunction(hServiceGetInfo);
- DestroyServiceFunction(hServiceGetCount);
- DestroyServiceFunction(hEventDoubleclicked);
- DestroyServiceFunction(hEventPrebuildMenu);
- DestroyServiceFunction(hEventJoinChat);
- DestroyServiceFunction(hEventLeaveChat);
-}
-
void CreateHookableEvents(void)
{
hSendEvent = CreateHookableEvent(ME_GC_EVENT);
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index f18d52b16b..dcb335c157 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -137,17 +137,17 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord, bool fToLower, bool fStripCR, TCHA static void __stdcall ShowRoomFromPopup(void * pi)
{
- SESSION_INFO* si = (SESSION_INFO*) pi;
+ SESSION_INFO *si = (SESSION_INFO*) pi;
ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
-static void TSAPI Chat_OpenPopup(SESSION_INFO* si, HWND hwndPopup)
+static void TSAPI Chat_OpenPopup(SESSION_INFO *si, HWND hwndPopup)
{
CallFunctionAsync(ShowRoomFromPopup, si);
PUDeletePopup(hwndPopup);
}
-static void TSAPI Chat_DismissPopup(const SESSION_INFO* si, HWND hwndPopup)
+static void TSAPI Chat_DismissPopup(const SESSION_INFO *si, HWND hwndPopup)
{
if (si->hContact)
if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
@@ -161,7 +161,7 @@ static void TSAPI Chat_DismissPopup(const SESSION_INFO* si, HWND hwndPopup) static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- SESSION_INFO* si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);;
+ SESSION_INFO *si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);;
switch (message) {
case WM_COMMAND:
@@ -188,7 +188,7 @@ static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA 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;
@@ -229,7 +229,7 @@ static int ShowPopup(HANDLE hContact, SESSION_INFO* si, HICON hIcon, char* pszP return PUAddPopupT(&pd);
}
-static BOOL DoTrayIcon(SESSION_INFO* si, GCEVENT * gce)
+static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
int iEvent = gce->pDest->iType;
@@ -293,7 +293,7 @@ static BOOL DoTrayIcon(SESSION_INFO* si, GCEVENT * gce) return TRUE;
}
-static BOOL DoPopup(SESSION_INFO* si, GCEVENT* gce, struct TWindowData* dat)
+static BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce, struct TWindowData* dat)
{
int iEvent = gce->pDest->iType;
TContainerData *pContainer = dat ? dat->pContainer : NULL;
@@ -512,7 +512,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p) free(p);
}
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO* si, GCEVENT * gce, BOOL bHighlight, int bManyFix)
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix)
{
FLASH_PARAMS* params;
struct TWindowData *dat = 0;
@@ -739,7 +739,7 @@ TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) * log the event to the log file
* allows selective logging of wanted events
*/
-BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce)
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
{
TCHAR szBuffer[4096];
TCHAR szLine[4096];
@@ -920,7 +920,7 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) return FALSE;
}
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO* si, TCHAR* pszUID, TCHAR* pszWordText)
+UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
GCMENUITEMS gcmi = {0};
int i;
@@ -1040,7 +1040,7 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex) BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem)
{
- SESSION_INFO* si;
+ SESSION_INFO *si;
GCHOOK* gch = (GCHOOK*)mir_alloc(sizeof(GCHOOK));
GCDEST* gcd = (GCDEST*)mir_alloc(sizeof(GCDEST));
@@ -1070,7 +1070,7 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem)
{
- SESSION_INFO* si;
+ SESSION_INFO *si;
GCHOOK gch = {0};
GCDEST gcd = {0};
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 9da631a99f..32e796d74e 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -349,7 +349,7 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) * initialize button bar, set all the icons and ensure proper button state
*/
-static void InitButtons(HWND hwndDlg, SESSION_INFO* si)
+static void InitButtons(HWND hwndDlg, SESSION_INFO *si)
{
BOOL isFlat = M.GetByte("tbflat", 1);
BOOL isThemed = PluginConfig.m_bIsXP;
@@ -403,7 +403,7 @@ static void Chat_ResizeIeView(const TWindowData *dat) static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
{
RECT rc, rcTabs;
- SESSION_INFO* si = (SESSION_INFO*)lParam;
+ SESSION_INFO *si = (SESSION_INFO*)lParam;
struct TWindowData *dat = (struct TWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
int TabHeight;
BOOL bToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR);
@@ -1676,7 +1676,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, TVHITTESTINFO hti;
int item;
int height;
- USERINFO * ui;
+ USERINFO *ui;
struct TWindowData *dat = (struct TWindowData *)GetWindowLongPtr(hwndParent, GWLP_USERDATA);
SESSION_INFO *parentdat = (SESSION_INFO *)dat->si;
@@ -1881,7 +1881,7 @@ int GetTextPixelSize(TCHAR* pszText, HFONT hFont, bool bWidth) static void __cdecl phase2(void * lParam)
{
- SESSION_INFO* si = (SESSION_INFO*) lParam;
+ SESSION_INFO *si = (SESSION_INFO*) lParam;
Sleep(30);
if (si && si->hWnd)
PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0);
@@ -2338,7 +2338,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int offset, x_offset = 0;
int height;
int index = dis->itemID;
- USERINFO * ui = UM_FindUserFromIndex(si->pUsers, index);
+ USERINFO *ui = UM_FindUserFromIndex(si->pUsers, index);
char szIndicator = 0;
if (ui) {
@@ -3066,7 +3066,7 @@ LABEL_SHOWWINDOW: if (HIWORD(wParam) == LBN_DBLCLK) {
TVHITTESTINFO hti;
int item;
- USERINFO * ui;
+ USERINFO *ui;
hti.pt.x = (short)LOWORD(GetMessagePos());
hti.pt.y = (short)HIWORD(GetMessagePos());
|