summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mir_app/src/chat.h4
-rw-r--r--src/mir_app/src/chat_manager.cpp29
-rw-r--r--src/mir_app/src/chat_svc.cpp22
3 files changed, 41 insertions, 14 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 7fff02b700..136ea36752 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -67,8 +67,8 @@ void SM_RemoveAll(void);
int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, bool removeContact);
BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus);
-BOOL SM_SetOffline(SESSION_INFO *si);
-BOOL SM_SetStatus(SESSION_INFO *si, int wStatus);
+BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si);
+BOOL SM_SetStatus(const char *pszModule, SESSION_INFO *si, int wStatus);
BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index f2b6fa00cb..378d3d6812 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -159,10 +159,19 @@ SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule)
return g_arSessions.find(&tmp);
}
-BOOL SM_SetOffline(SESSION_INFO *si)
+BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si)
{
- if (si == nullptr)
- return FALSE;
+ if (si == nullptr) {
+ if (pszModule == nullptr)
+ return FALSE;
+
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ si = g_arSessions[i];
+ if (!_strcmpi(si->pszModule, pszModule))
+ SM_SetOffline(pszModule, si);
+ }
+ return TRUE;
+ }
chatApi.UM_RemoveAll(&si->pUsers);
si->pMe = nullptr;
@@ -329,8 +338,20 @@ static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam,
return TRUE;
}
-BOOL SM_SetStatus(SESSION_INFO *si, int wStatus)
+BOOL SM_SetStatus(const char *pszModule, SESSION_INFO *si, int wStatus)
{
+ if (si == nullptr) {
+ if (pszModule == nullptr)
+ return FALSE;
+
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ si = g_arSessions[i];
+ if (!_strcmpi(si->pszModule, pszModule))
+ SM_SetStatus(pszModule, si, wStatus);
+ }
+ return TRUE;
+ }
+
si->wStatus = wStatus;
if (si->hContact) {
if (si->iType != GCW_SERVER && wStatus != ID_STATUS_OFFLINE)
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 5b57d79b00..cc64cd31d1 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -279,39 +279,45 @@ static INT_PTR __stdcall stubRoomControl(void *param)
ChatConrolParam *p = (ChatConrolParam*)param;
mir_cslock lck(csChat);
- SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule);
- if (si == nullptr)
- return GC_EVENT_ERROR;
+ SESSION_INFO *si = nullptr;
+ if (p->szModule)
+ si = chatApi.SM_FindSession(p->wszId, p->szModule);
switch (p->command) {
case WINDOW_HIDDEN:
+ if (si == nullptr)
+ return GC_EVENT_ERROR;
SetInitDone(si);
chatApi.SetActiveSession(si);
break;
case WINDOW_VISIBLE:
case SESSION_INITDONE:
+ if (si == nullptr)
+ return GC_EVENT_ERROR;
SetInitDone(si);
if (p->command != SESSION_INITDONE || db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) == 0)
chatApi.ShowRoom(si);
break;
case SESSION_OFFLINE:
- SM_SetOffline(si);
- SM_SetStatus(si, ID_STATUS_OFFLINE);
- if (si->pDlg) {
+ SM_SetOffline(p->szModule, si);
+ SM_SetStatus(p->szModule, si, ID_STATUS_OFFLINE);
+ if (si && si->pDlg) {
si->pDlg->UpdateStatusBar();
si->pDlg->UpdateNickList();
}
break;
case SESSION_ONLINE:
- SM_SetStatus(si, ID_STATUS_ONLINE);
- if (si->pDlg)
+ SM_SetStatus(p->szModule, si, ID_STATUS_ONLINE);
+ if (si && si->pDlg)
si->pDlg->UpdateStatusBar();
break;
case WINDOW_CLEARLOG:
+ if (si == nullptr)
+ return GC_EVENT_ERROR;
chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iEventCount = 0;
si->LastTime = 0;