summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/manager.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-07-07 13:20:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-07-07 13:20:17 +0000
commit7cb44a3c4447a149004189b046a67def1b65a356 (patch)
tree2d7e0b08597167d5d9e24a99602a49c83492b631 /plugins/TabSRMM/src/chat/manager.cpp
parent5801a85ed970b55b2041c588914f982039dc8031 (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/manager.cpp')
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp894
1 files changed, 369 insertions, 525 deletions
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;