summaryrefslogtreecommitdiff
path: root/src/modules/chat
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/chat')
-rw-r--r--src/modules/chat/chat.h4
-rw-r--r--src/modules/chat/chat_opts.cpp21
-rw-r--r--src/modules/chat/chat_svc.cpp95
-rw-r--r--src/modules/chat/clist.cpp68
-rw-r--r--src/modules/chat/log.cpp5
-rw-r--r--src/modules/chat/manager.cpp146
6 files changed, 164 insertions, 175 deletions
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h
index b543d2f424..8392f7b8f8 100644
--- a/src/modules/chat/chat.h
+++ b/src/modules/chat/chat.h
@@ -47,8 +47,8 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData);
// clist.c
BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ...);
-HANDLE AddRoom(const char *pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType);
-HANDLE FindRoom(const char *pszModule, const TCHAR* pszRoom);
+HANDLE AddRoom(const char *pszModule, const TCHAR *pszRoom, const TCHAR *pszDisplayName, int iType);
+HANDLE FindRoom(const char *pszModule, const TCHAR *pszRoom);
BOOL SetAllOffline(BOOL bHide, const char *pszModule);
BOOL SetOffline(HANDLE hContact, BOOL bHide);
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp
index 341d56db21..832ac721ed 100644
--- a/src/modules/chat/chat_opts.cpp
+++ b/src/modules/chat/chat_opts.cpp
@@ -291,6 +291,19 @@ static void FreeGlobalSettings(void)
DeleteObject(ci.pSettings->UserListHeadingsFont);
}
+void SetIndentSize()
+{
+ if (ci.pSettings->ShowTime) {
+ LOGFONT lf;
+ LoadMsgDlgFont(0, &lf, NULL);
+ HFONT hFont = CreateFontIndirect(&lf);
+ int iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
+ DeleteObject(hFont);
+ ci.pSettings->LogTextIndent = iText * 12 / 10;
+ }
+ else ci.pSettings->LogTextIndent = 0;
+}
+
int GetTextPixelSize(TCHAR* pszText, HFONT hFont, BOOL bWidth)
{
if (!pszText || !hFont)
@@ -349,13 +362,7 @@ int OptionsInit(void)
if (ci.pSettings->LoggingEnabled)
CreateDirectoryTreeT(ci.pSettings->pszLogDir);
- LOGFONT lf2;
- LoadMsgDlgFont(0, &lf2, NULL);
- HFONT hFont = CreateFontIndirect(&lf2);
- int iText = GetTextPixelSize(MakeTimeStamp(ci.pSettings->pszTimeStamp, time(NULL)), hFont, TRUE);
- DeleteObject(hFont);
- ci.pSettings->LogTextIndent = iText;
- ci.pSettings->LogTextIndent = ci.pSettings->LogTextIndent * 12 / 10;
+ SetIndentSize();
return 0;
}
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index d7cf19655d..46586ea2c3 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -105,30 +105,27 @@ static INT_PTR Service_GetCount(WPARAM wParam, LPARAM lParam)
static INT_PTR Service_GetInfo(WPARAM wParam, LPARAM lParam)
{
GC_INFO *gci = (GC_INFO *)lParam;
- SESSION_INFO *si = NULL;
-
if (!gci || !gci->pszModule)
return 1;
mir_cslock lck(cs);
- if (gci->Flags&BYINDEX)
+ SESSION_INFO *si;
+ if (gci->Flags & BYINDEX)
si = ci.SM_FindSessionByIndex(gci->pszModule, gci->iItem);
else
si = ci.SM_FindSession(gci->pszID, gci->pszModule);
+ if (si == NULL)
+ return 1;
- if (si) {
- if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
- if (gci->Flags & HCONTACT) gci->hContact = si->hContact;
- if (gci->Flags & TYPE) gci->iType = si->iType;
- if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist;
- if (gci->Flags & USERS) gci->pszUsers = ci.SM_GetUsers(si);
- if (gci->Flags & ID) gci->pszID = si->ptszID;
- if (gci->Flags & NAME) gci->pszName = si->ptszName;
- return 0;
- }
-
- return 1;
+ if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
+ if (gci->Flags & HCONTACT) gci->hContact = si->hContact;
+ if (gci->Flags & TYPE) gci->iType = si->iType;
+ if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist;
+ if (gci->Flags & USERS) gci->pszUsers = ci.SM_GetUsers(si);
+ if (gci->Flags & ID) gci->pszID = si->ptszID;
+ if (gci->Flags & NAME) gci->pszName = si->ptszName;
+ return 0;
}
static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
@@ -146,13 +143,15 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
return GC_REGISTER_ERROR;
mi->ptszModDispName = mir_tstrdup(gcr->ptszDispName);
- mi->bBold = gcr->dwFlags & GC_BOLD;
- mi->bUnderline = gcr->dwFlags & GC_UNDERLINE;
- mi->bItalics = gcr->dwFlags & GC_ITALICS;
- mi->bColor = gcr->dwFlags & GC_COLOR;
- mi->bBkgColor = gcr->dwFlags & GC_BKGCOLOR;
- mi->bAckMsg = gcr->dwFlags & GC_ACKMSG;
- mi->bChanMgr = gcr->dwFlags & GC_CHANMGR;
+ mi->bBold = (gcr->dwFlags & GC_BOLD) != 0;
+ mi->bUnderline = (gcr->dwFlags & GC_UNDERLINE) != 0;
+ mi->bItalics = (gcr->dwFlags & GC_ITALICS) != 0;
+ mi->bColor = (gcr->dwFlags & GC_COLOR) != 0;
+ mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0;
+ mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
+ mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
+ mi->bSingleFormat = (gcr->dwFlags & GC_SINGLEFORMAT) != 0;
+ mi->bFontSize = (gcr->dwFlags & GC_FONTSIZE) != 0;
mi->iMaxText = gcr->iMaxText;
mi->nColorCount = gcr->nColors;
if (gcr->nColors > 0) {
@@ -189,13 +188,12 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
return GC_NEWSESSION_WRONGVER;
mir_cslock lck(cs);
- MODULEINFO* mi = ci.MM_FindModule(gcw->pszModule);
+ MODULEINFO *mi = ci.MM_FindModule(gcw->pszModule);
if (mi == NULL)
return GC_NEWSESSION_ERROR;
- SESSION_INFO *si = ci.SM_AddSession(gcw->ptszID, gcw->pszModule);
-
// create a new session and set the defaults
+ SESSION_INFO *si = ci.SM_AddSession(gcw->ptszID, gcw->pszModule);
if (si != NULL) {
si->dwItemData = gcw->dwItemData;
if (gcw->iType != GCW_SERVER)
@@ -223,7 +221,7 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
if (si->iType == GCW_SERVER)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName);
else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
+ _tcsncpy_s(szTemp, SIZEOF(szTemp), si->ptszName, _TRUNCATE);
si->hContact = ci.AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_unset(si->hContact, "CList", "StatusMsg");
@@ -232,18 +230,15 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
else
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
}
- else {
- SESSION_INFO *si2 = ci.SM_FindSession(gcw->ptszID, gcw->pszModule);
- if (si2) {
- ci.UM_RemoveAll(&si2->pUsers);
- ci.TM_RemoveAll(&si2->pStatuses);
+ else if (si = ci.SM_FindSession(gcw->ptszID, gcw->pszModule)) {
+ ci.UM_RemoveAll(&si->pUsers);
+ ci.TM_RemoveAll(&si->pStatuses);
- si2->iStatusCount = 0;
- si2->nUsersInNicklist = 0;
+ si->iStatusCount = 0;
+ si->nUsersInNicklist = 0;
- if (ci.OnSessionReplace)
- ci.OnSessionReplace(si2);
- }
+ if (ci.OnSessionReplace)
+ ci.OnSessionReplace(si);
}
return 0;
@@ -361,10 +356,8 @@ static void AddUser(GCEVENT *gce)
if (ui == NULL) return;
ui->pszNick = mir_tstrdup(gce->ptszNick);
-
if (gce->bIsMe)
si->pMe = ui;
-
ui->Status = status;
ui->Status |= si->pStatuses->Status;
@@ -392,6 +385,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
if (!IsEventSupported(gcd->iType))
return GC_EVENT_ERROR;
+ SESSION_INFO *si;
mir_cslock lck(cs);
// Do different things according to type of event
@@ -419,17 +413,14 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
return ci.SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
case GC_EVENT_TOPIC:
- {
- SESSION_INFO *si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si) {
- if (gce->ptszText) {
- replaceStrT(si->ptszTopic, gce->ptszText);
- db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
- if (ci.OnSetTopic)
- ci.OnSetTopic(si);
- if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
- db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic));
- }
+ if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
+ if (gce->ptszText) {
+ replaceStrT(si->ptszTopic, gce->ptszText);
+ db_set_ts(si->hContact, si->pszModule, "Topic", RemoveFormatting(si->ptszTopic));
+ if (ci.OnSetTopic)
+ ci.OnSetTopic(si);
+ if (db_get_b(NULL, "Chat", "TopicOnClist", 0))
+ db_set_ts(si->hContact, "CList", "StatusMsg", RemoveFormatting(si->ptszTopic));
}
}
break;
@@ -445,7 +436,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText) {
- SESSION_INFO *si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
+ si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
if (si && IsHighlighted(si, gce->ptszText))
bIsHighlighted = TRUE;
}
@@ -474,7 +465,7 @@ static 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 = ci.GetActiveSession();
+ si = ci.GetActiveSession();
if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
@@ -490,7 +481,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
// add to log
if (pWnd) {
- SESSION_INFO *si = ci.SM_FindSession(pWnd, pMod);
+ si = ci.SM_FindSession(pWnd, pMod);
// fix for IRC's old stuyle mode notifications. Should not affect any other protocol
if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp
index fec51f63ed..f8b30bcc68 100644
--- a/src/modules/chat/clist.cpp
+++ b/src/modules/chat/clist.cpp
@@ -22,57 +22,56 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "chat.h"
-HANDLE AddRoom(const char *pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
+HANDLE AddRoom(const char *pszModule, const TCHAR *pszRoom, const TCHAR *pszDisplayName, int iType)
{
HANDLE hContact = ci.FindRoom(pszModule, pszRoom);
DBVARIANT dbv;
TCHAR pszGroup[50];
*pszGroup = '\0';
- if ( !db_get_ts( NULL, "Chat", "AddToGroup", &dbv )) {
- if ( lstrlen( dbv.ptszVal ) > 0 )
- lstrcpyn( pszGroup, dbv.ptszVal, 50);
+ if (!db_get_ts(NULL, "Chat", "AddToGroup", &dbv)) {
+ if (lstrlen(dbv.ptszVal) > 0)
+ lstrcpyn(pszGroup, dbv.ptszVal, 50);
db_free(&dbv);
}
- else lstrcpyn( pszGroup, _T("Chat rooms"), 50);
+ else lstrcpyn(pszGroup, _T("Chat rooms"), 50);
- if ( pszGroup[0] )
+ if (pszGroup[0])
Clist_CreateGroup(0, pszGroup);
- if ( hContact ) { //contact exist, make sure it is in the right group
+ if (hContact) { //contact exist, make sure it is in the right group
if (pszGroup[0]) {
- ptrT grpName( db_get_tsa(hContact, "CList", "Group"));
- if ( !lstrcmp(pszGroup, grpName))
+ ptrT grpName(db_get_tsa(hContact, "CList", "Group"));
+ if (!lstrcmp(pszGroup, grpName))
db_set_ts(hContact, "CList", "Group", pszGroup);
}
- db_set_w( hContact, pszModule, "Status", ID_STATUS_OFFLINE );
- db_set_ts(hContact, pszModule, "Nick", pszDisplayName );
+ db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
+ db_set_ts(hContact, pszModule, "Nick", pszDisplayName);
return hContact;
}
// here we create a new one since no one is to be found
- if (( hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL )
+ if ((hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
return NULL;
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) pszModule );
- if ( pszGroup && lstrlen( pszGroup ) > 0 )
- db_set_ts(hContact, "CList", "Group", pszGroup );
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)pszModule);
+ if (pszGroup && lstrlen(pszGroup) > 0)
+ db_set_ts(hContact, "CList", "Group", pszGroup);
else
- db_unset( hContact, "CList", "Group" );
- db_set_ts( hContact, pszModule, "Nick", pszDisplayName );
- db_set_ts( hContact, pszModule, "ChatRoomID", pszRoom );
- db_set_b( hContact, pszModule, "ChatRoom", (BYTE)iType );
- db_set_w( hContact, pszModule, "Status", ID_STATUS_OFFLINE );
+ db_unset(hContact, "CList", "Group");
+ db_set_ts(hContact, pszModule, "Nick", pszDisplayName);
+ db_set_ts(hContact, pszModule, "ChatRoomID", pszRoom);
+ db_set_b(hContact, pszModule, "ChatRoom", (BYTE)iType);
+ db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
return hContact;
}
BOOL SetOffline(HANDLE hContact, BOOL bHide)
{
- if ( hContact ) {
- char* szProto = GetContactProto(hContact);
- int i = db_get_b(hContact, szProto, "ChatRoom", 0);
- db_set_w(hContact, szProto,"ApparentMode",(LPARAM) 0);
+ if (hContact) {
+ char *szProto = GetContactProto(hContact);
+ db_set_w(hContact, szProto, "ApparentMode", (LPARAM)0);
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
return TRUE;
}
@@ -98,12 +97,10 @@ BOOL SetAllOffline(BOOL bHide, const char *pszModule)
return TRUE;
}
-int RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
+int RoomDoubleclicked(WPARAM wParam, LPARAM lParam)
{
- BOOL bRedrawFlag = FALSE;
-
HANDLE hContact = (HANDLE)wParam;
- if ( !hContact )
+ if (!hContact)
return 0;
char *szProto = GetContactProto(hContact);
@@ -120,8 +117,7 @@ int RoomDoubleclicked( WPARAM wParam, LPARAM lParam )
if (si->hWnd != NULL
&& db_get_b(NULL, "Chat", "ToggleVisibility", 0) == 1
&& !CallService(MS_CLIST_GETEVENT, (WPARAM)hContact, 0)
- && IsWindowVisible(si->hWnd)
- && !IsIconic(si->hWnd))
+ && IsWindowVisible(si->hWnd) && !IsIconic(si->hWnd))
{
if (ci.OnSessionDblClick)
ci.OnSessionDblClick(si);
@@ -146,7 +142,7 @@ INT_PTR JoinChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
if (hContact) {
- char* szProto = GetContactProto(hContact);
+ char *szProto = GetContactProto(hContact);
if (szProto) {
if (db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE)
CallProtoService(szProto, PS_JOINCHAT, wParam, lParam);
@@ -162,7 +158,7 @@ INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
if (hContact) {
- char* szProto = GetContactProto(hContact);
+ char *szProto = GetContactProto(hContact);
if (szProto)
CallProtoService(szProto, PS_LEAVECHAT, wParam, lParam);
}
@@ -236,15 +232,15 @@ BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt,
return TRUE;
}
-HANDLE FindRoom (const char *pszModule, const TCHAR* pszRoom)
+HANDLE FindRoom(const char *pszModule, const TCHAR *pszRoom)
{
for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
- if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
+ if (!db_get_b(hContact, pszModule, "ChatRoom", 0))
continue;
DBVARIANT dbv;
- if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv )) {
- if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
+ if (!db_get_ts(hContact, pszModule, "ChatRoomID", &dbv)) {
+ if (!lstrcmpi(dbv.ptszVal, pszRoom)) {
db_free(&dbv);
return hContact;
}
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index 9f82a32b66..fc8788561e 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -97,7 +97,7 @@ static void Log_Append(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, co
if (charsDone >= 0)
break;
*cbBufferAlloced += 4096;
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced);
}
va_end(va);
*cbBufferEnd += charsDone;
@@ -111,7 +111,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
char* d;
va_start(va, fmt);
- lineLen = mir_vsntprintf( line, 8000, fmt, va);
+ lineLen = mir_vsntprintf(line, 8000, fmt, va);
if (lineLen < 0) lineLen = 8000;
line[lineLen] = 0;
va_end(va);
@@ -335,7 +335,6 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
// ### RTF HEADER
header = mi->pszHeader;
-
if (header)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, header);
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index cacb05eb50..b59420f8dd 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -25,10 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "chat.h"
#define WINDOWS_COMMANDS_MAX 30
-#define STATUSICONCOUNT 6
-SESSION_INFO *m_WndList = 0;
-MODULEINFO *m_ModList = 0;
+MODULEINFO *m_ModList = 0;
static void SetActiveSessionEx(SESSION_INFO *si)
{
@@ -51,7 +49,7 @@ static SESSION_INFO* GetActiveSession(void)
if (si)
return si;
- return m_WndList;
+ return ci.wndList;
}
//---------------------------------------------------
@@ -65,22 +63,22 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char *pszModule)
if (!pszID || !pszModule)
return NULL;
- if (!ci.SM_FindSession(pszID, pszModule)) {
- SESSION_INFO *node = (SESSION_INFO*)mir_calloc(sizeof(SESSION_INFO));
- node->ptszID = mir_tstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
+ if (ci.SM_FindSession(pszID, pszModule))
+ return NULL;
- if (m_WndList == NULL) { // list is empty
- m_WndList = node;
- node->next = NULL;
- }
- else {
- node->next = m_WndList;
- m_WndList = node;
- }
- return node;
+ SESSION_INFO *node = (SESSION_INFO*)mir_calloc(ci.cbSession);
+ node->ptszID = mir_tstrdup(pszID);
+ node->pszModule = mir_strdup(pszModule);
+
+ if (ci.wndList == NULL) { // list is empty
+ ci.wndList = node;
+ node->next = NULL;
}
- return NULL;
+ else {
+ node->next = ci.wndList;
+ ci.wndList = node;
+ }
+ return node;
}
static void SM_FreeSession(SESSION_INFO *si)
@@ -122,7 +120,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char *pszModule, BOOL remo
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
+ SESSION_INFO *pTemp = ci.wndList, *pLast = NULL;
while (pTemp != NULL) {
// match
if ((!pszID && pTemp->iType != GCW_SERVER || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
@@ -133,7 +131,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char *pszModule, BOOL remo
DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)pTemp->dwItemData);
if (pLast == NULL)
- m_WndList = pTemp->next;
+ ci.wndList = pTemp->next;
else
pLast->next = pTemp->next;
@@ -149,7 +147,7 @@ static int SM_RemoveSession(const TCHAR *pszID, const char *pszModule, BOOL remo
if (pLast)
pTemp = pLast->next;
else
- pTemp = m_WndList;
+ pTemp = ci.wndList;
}
else {
pLast = pTemp;
@@ -164,7 +162,7 @@ static SESSION_INFO* SM_FindSession(const TCHAR *pszID, const char *pszModule)
if (!pszID || !pszModule)
return NULL;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
return pTemp;
@@ -179,7 +177,7 @@ static BOOL SM_SetOffline(const TCHAR *pszID, const char *pszModule)
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
ci.UM_RemoveAll(&pTemp->pUsers);
@@ -198,7 +196,7 @@ static BOOL SM_SetOffline(const TCHAR *pszID, const char *pszModule)
static BOOL SM_SetStatusEx(const TCHAR *pszID, const char *pszModule, const TCHAR* pszText, int flags)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
if (!pszModule)
return FALSE;
@@ -247,7 +245,7 @@ static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce)
{
int bManyFix = 0;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpiA(pTemp->pszModule, gce->pDest->pszModule)) {
if (ci.UM_FindUser(pTemp->pUsers, gce->ptszUID)) {
@@ -276,7 +274,7 @@ static BOOL SM_AddEvent(const TCHAR *pszID, const char *pszModule, GCEVENT *gce,
if (!pszID || !pszModule)
return TRUE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
LOGINFO *li = ci.LM_AddEvent(&pTemp->pLog, &pTemp->pLogEnd);
@@ -309,7 +307,7 @@ static USERINFO* SM_AddUser(const TCHAR *pszID, const char *pszModule, const TCH
if (!pszID || !pszModule)
return NULL;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO *p = ci.UM_AddUser(pTemp->pStatuses, &pTemp->pUsers, pszUID, pszNick, wStatus);
@@ -329,7 +327,7 @@ static BOOL SM_MoveUser(const TCHAR *pszID, const char *pszModule, const TCHAR *
if (!pszID || !pszModule || !pszUID)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
ci.UM_SortUser(&pTemp->pUsers, pszUID);
@@ -346,7 +344,7 @@ static BOOL SM_RemoveUser(const TCHAR *pszID, const char *pszModule, const TCHAR
if (!pszModule || !pszUID)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
DWORD dw;
@@ -377,7 +375,7 @@ static USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char *pszModule,
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule))
return ci.UM_FindUserFromIndex(pTemp->pUsers, index);
@@ -393,7 +391,7 @@ STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char *pszModule, const TCHAR
if (!pszID || !pszModule)
return NULL;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
STATUSINFO *ti = ci.TM_AddStatus(&pTemp->pStatuses, pszStatus, &pTemp->iStatusCount);
@@ -414,7 +412,7 @@ static BOOL SM_GiveStatus(const TCHAR *pszID, const char *pszModule, const TCHAR
if (!pszID || !pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO *ui = ci.UM_GiveStatus(pTemp->pUsers, pszUID, ci.TM_StringToWord(pTemp->pStatuses, pszStatus));
@@ -436,7 +434,7 @@ static BOOL SM_SetContactStatus(const TCHAR *pszID, const char *pszModule, const
if (!pszID || !pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO *ui = ci.UM_SetContactStatus(pTemp->pUsers, pszUID, wStatus);
@@ -458,7 +456,7 @@ static BOOL SM_TakeStatus(const TCHAR *pszID, const char *pszModule, const TCHAR
if (!pszID || !pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO* ui = ci.UM_TakeStatus(pTemp->pUsers, pszUID, ci.TM_StringToWord(pTemp->pStatuses, pszStatus));
@@ -477,7 +475,7 @@ static BOOL SM_TakeStatus(const TCHAR *pszID, const char *pszModule, const TCHAR
static LRESULT SM_SendMessage(const TCHAR *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp && pszModule) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
@@ -499,7 +497,7 @@ static BOOL SM_PostMessage(const TCHAR *pszID, const char *pszModule, UINT msg,
if (!pszID || !pszModule)
return 0;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!lstrcmpi(pTemp->ptszID, pszID) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
if (pTemp->hWnd)
@@ -514,7 +512,7 @@ static BOOL SM_PostMessage(const TCHAR *pszID, const char *pszModule, UINT msg,
static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (!pszModule || !lstrcmpiA(pTemp->pszModule, pszModule)) {
if (pTemp->hWnd) {
@@ -534,7 +532,7 @@ static BOOL SM_SetStatus(const TCHAR *pszID, const char *pszModule, int wStatus)
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
pTemp->wStatus = wStatus;
@@ -561,7 +559,7 @@ static BOOL SM_SendUserMessage(const TCHAR *pszID, const char *pszModule, const
if (!pszModule || !pszText)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
if (pTemp->iType == GCW_CHATROOM)
@@ -580,7 +578,7 @@ static SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
return NULL;
BOOL bFound = FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (si == pTemp) {
if (bFound)
@@ -592,7 +590,7 @@ static SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
return pTemp;
pTemp = pTemp->next;
if (pTemp == NULL && bFound)
- pTemp = m_WndList;
+ pTemp = ci.wndList;
}
return NULL;
}
@@ -602,7 +600,7 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
if (!si)
return NULL;
- SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
+ SESSION_INFO *pTemp = ci.wndList, *pLast = NULL;
while (pTemp != NULL) {
if (si == pTemp) {
if (pLast) {
@@ -616,7 +614,7 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
pLast = pTemp;
pTemp = pTemp->next;
if (pTemp == NULL)
- pTemp = m_WndList;
+ pTemp = ci.wndList;
}
return NULL;
}
@@ -626,7 +624,7 @@ static BOOL SM_ChangeUID(const TCHAR *pszID, const char *pszModule, const TCHAR
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO* ui = ci.UM_FindUser(pTemp->pUsers, pszUID);
@@ -641,26 +639,12 @@ static BOOL SM_ChangeUID(const TCHAR *pszID, const char *pszModule, const TCHAR
return TRUE;
}
-
-static BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd)
-{
- SESSION_INFO *pTemp = m_WndList;
- while (pTemp != NULL) {
- if (si && si == pTemp)
- pTemp->hWnd = hwnd;
- else
- pTemp->hWnd = NULL;
- pTemp = pTemp->next;
- }
- return TRUE;
-}
-
static BOOL SM_ChangeNick(const TCHAR *pszID, const char *pszModule, GCEVENT *gce)
{
if (!pszModule)
return FALSE;
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if ((!pszID || !lstrcmpi(pTemp->ptszID, pszID)) && !lstrcmpiA(pTemp->pszModule, pszModule)) {
USERINFO* ui = ci.UM_FindUser(pTemp->pUsers, gce->ptszUID);
@@ -679,25 +663,38 @@ static BOOL SM_ChangeNick(const TCHAR *pszID, const char *pszModule, GCEVENT *gc
return TRUE;
}
+static BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd)
+{
+ SESSION_INFO *pTemp = ci.wndList;
+ while (pTemp != NULL) {
+ if (si && si == pTemp)
+ pTemp->hWnd = hwnd;
+ else
+ pTemp->hWnd = NULL;
+ pTemp = pTemp->next;
+ }
+ return TRUE;
+}
+
static BOOL SM_RemoveAll(void)
{
- while (m_WndList) {
- SESSION_INFO *pLast = m_WndList->next;
+ while (ci.wndList) {
+ SESSION_INFO *pLast = ci.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 (ci.wndList->hWnd)
+ SendMessage(ci.wndList->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+ DoEventHook(ci.wndList->ptszID, ci.wndList->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (DWORD)ci.wndList->dwItemData);
- SM_FreeSession(m_WndList);
- m_WndList = pLast;
+ SM_FreeSession(ci.wndList);
+ ci.wndList = pLast;
}
- m_WndList = NULL;
+ ci.wndList = NULL;
return TRUE;
}
static void SM_AddCommand(const TCHAR *pszID, const char *pszModule, const char* lpNewCommand)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match
COMMANDINFO *node = (COMMANDINFO *)mir_alloc(sizeof(COMMANDINFO));
@@ -734,7 +731,7 @@ static void SM_AddCommand(const TCHAR *pszID, const char *pszModule, const char*
static 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;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match
COMMANDINFO *pPrevCmd = NULL;
@@ -756,7 +753,7 @@ static char* SM_GetPrevCommand(const TCHAR *pszID, const char *pszModule) // get
static 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;
+ SESSION_INFO *pTemp = ci.wndList;
while (pTemp != NULL) {
if (lstrcmpi(pTemp->ptszID, pszID) == 0 && lstrcmpiA(pTemp->pszModule, pszModule) == 0) { // match
COMMANDINFO *pNextCmd = NULL;
@@ -773,7 +770,7 @@ static char* SM_GetNextCommand(const TCHAR *pszID, const char *pszModule) // get
static int SM_GetCount(const char *pszModule)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
int count = 0;
while (pTemp != NULL) {
@@ -787,7 +784,7 @@ static int SM_GetCount(const char *pszModule)
static SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
int count = 0;
while (pTemp != NULL) {
if (!lstrcmpiA(pszModule, pTemp->pszModule)) {
@@ -805,7 +802,7 @@ static SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem)
static char* SM_GetUsers(SESSION_INFO *si)
{
- SESSION_INFO *pTemp = m_WndList;
+ SESSION_INFO *pTemp = ci.wndList;
USERINFO *utemp = NULL;
char* p = NULL;
int alloced = 0;
@@ -1153,8 +1150,7 @@ USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR
}
// if (!UM_FindUser(*ppUserList, pszUI, wStatus)
- USERINFO *node = (USERINFO*)mir_alloc(sizeof(USERINFO));
- ZeroMemory(node, sizeof(USERINFO));
+ USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
replaceStrT(node->pszUID, pszUID);
if (*ppUserList == NULL) { // list is empty