summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-07-08 12:30:02 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-07-08 12:30:02 +0000
commit08de90128cd5f63f7d15595de1cc0e7535e0b759 (patch)
tree1ef8f45b9e75df7ea118b0ffd2c164183bb64c21 /src
parent3648326de11bfda978907c9af22c541331dcd192 (diff)
chat engine:
- double session existence check removed; - crash fix for syntax highlights in restarted chats git-svn-id: http://svn.miranda-ng.org/main/trunk@14510 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/chat_manager.cpp3
-rw-r--r--src/mir_app/src/chat_svc.cpp87
2 files changed, 46 insertions, 44 deletions
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index cde5bc8437..df700a1030 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -65,9 +65,6 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char *pszModule)
if (!pszID || !pszModule)
return NULL;
- if (ci.SM_FindSession(pszID, pszModule))
- return NULL;
-
SESSION_INFO *node = (SESSION_INFO*)mir_calloc(g_cbSession);
node->ptszID = mir_tstrdup(pszID);
node->pszModule = mir_strdup(pszModule);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 91de28faef..044457ef4c 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -206,58 +206,63 @@ static INT_PTR Service_NewChat(WPARAM, LPARAM lParam)
if (mi == NULL)
return GC_NEWSESSION_ERROR;
- // 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)
- si->wStatus = ID_STATUS_ONLINE;
- si->iType = gcw->iType;
- si->dwFlags = gcw->dwFlags;
- si->ptszName = mir_tstrdup(gcw->ptszName);
- si->ptszStatusbarText = mir_tstrdup(gcw->ptszStatusbarText);
- si->iSplitterX = g_Settings->iSplitterX;
- si->iSplitterY = g_Settings->iSplitterY;
- si->iLogFilterFlags = db_get_dw(NULL, CHAT_MODULE, "FilterFlags", 0x03E0);
- si->bFilterEnabled = db_get_b(NULL, CHAT_MODULE, "FilterEnabled", 0);
- si->bNicklistEnabled = db_get_b(NULL, CHAT_MODULE, "ShowNicklist", 1);
-
- if (mi->bColor) {
- si->iFG = 4;
- si->bFGSet = TRUE;
- }
- if (mi->bBkgColor) {
- si->iBG = 2;
- si->bBGSet = TRUE;
- }
- TCHAR szTemp[256];
- if (si->iType == GCW_SERVER)
- mir_sntprintf(szTemp, _T("Server: %s"), si->ptszName);
- else
- _tcsncpy_s(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");
- if (si->ptszStatusbarText)
- db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->hContact, si->pszModule, "StatusBar", "");
-
- if (ci.OnCreateSession)
- ci.OnCreateSession(si, mi);
- }
- else if (si = ci.SM_FindSession(gcw->ptszID, gcw->pszModule)) {
+ // try to restart a session first
+ SESSION_INFO *si = ci.SM_FindSession(gcw->ptszID, gcw->pszModule);
+ if (si != NULL) {
ci.UM_RemoveAll(&si->pUsers);
ci.TM_RemoveAll(&si->pStatuses);
si->iStatusCount = 0;
si->nUsersInNicklist = 0;
+ si->pMe = NULL;
if (ci.OnReplaceSession)
ci.OnReplaceSession(si);
+ return 0;
}
+
+ // create a new session and set the defaults
+ if ((si = ci.SM_AddSession(gcw->ptszID, gcw->pszModule)) == NULL)
+ return GC_NEWSESSION_ERROR;
+
+ si->dwItemData = gcw->dwItemData;
+ if (gcw->iType != GCW_SERVER)
+ si->wStatus = ID_STATUS_ONLINE;
+ si->iType = gcw->iType;
+ si->dwFlags = gcw->dwFlags;
+ si->ptszName = mir_tstrdup(gcw->ptszName);
+ si->ptszStatusbarText = mir_tstrdup(gcw->ptszStatusbarText);
+ si->iSplitterX = g_Settings->iSplitterX;
+ si->iSplitterY = g_Settings->iSplitterY;
+ si->iLogFilterFlags = db_get_dw(NULL, CHAT_MODULE, "FilterFlags", 0x03E0);
+ si->bFilterEnabled = db_get_b(NULL, CHAT_MODULE, "FilterEnabled", 0);
+ si->bNicklistEnabled = db_get_b(NULL, CHAT_MODULE, "ShowNicklist", 1);
+
+ if (mi->bColor) {
+ si->iFG = 4;
+ si->bFGSet = TRUE;
+ }
+ if (mi->bBkgColor) {
+ si->iBG = 2;
+ si->bBGSet = TRUE;
+ }
+
+ TCHAR szTemp[256];
+ if (si->iType == GCW_SERVER)
+ mir_sntprintf(szTemp, _T("Server: %s"), si->ptszName);
+ else
+ _tcsncpy_s(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");
+ if (si->ptszStatusbarText)
+ db_set_ts(si->hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
+ else
+ db_set_s(si->hContact, si->pszModule, "StatusBar", "");
+ if (ci.OnCreateSession)
+ ci.OnCreateSession(si, mi);
return 0;
}