From 831ad8a0121f9f9ee5c4f38d4a0d209b3c2bdb60 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 16 Jan 2014 21:40:14 +0000 Subject: kernel chats, part 3, tabsrmm git-svn-id: http://svn.miranda-ng.org/main/trunk@7684 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/chat/chat.h | 2 ++ src/modules/chat/chat_svc.cpp | 6 ++-- src/modules/chat/clist.cpp | 78 ++++++++++++++++++++----------------------- src/modules/chat/manager.cpp | 11 +++++- src/modules/chat/tools.cpp | 4 +-- 5 files changed, 54 insertions(+), 47 deletions(-) (limited to 'src/modules') diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h index c916ca565a..91caba9bde 100644 --- a/src/modules/chat/chat.h +++ b/src/modules/chat/chat.h @@ -87,6 +87,8 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char *pszModule, in 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 DoPopup(SESSION_INFO *si, GCEVENT *gce); +int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...); const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2); diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index a89d70cc3e..f39318bc32 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -397,12 +397,12 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_TOPIC: 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)); + replaceStrT(si->ptszTopic, RemoveFormatting(gce->ptszText)); + db_set_ts(si->hContact, si->pszModule, "Topic", 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)); + db_set_ts(si->hContact, "CList", "StatusMsg", si->ptszTopic); } } break; diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp index f8b30bcc68..07dace2d3b 100644 --- a/src/modules/chat/clist.cpp +++ b/src/modules/chat/clist.cpp @@ -24,21 +24,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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); - db_free(&dbv); + TCHAR pszGroup[50]; *pszGroup = '\0'; + ptrT groupName(db_get_tsa(NULL, "Chat", "AddToGroup")); + if (groupName) + _tcsncpy_s(pszGroup, SIZEOF(pszGroup), groupName, _TRUNCATE); + else + _tcscpy(pszGroup, _T("Chat rooms")); + + if (pszGroup[0]) { + HANDLE hGroup = Clist_GroupExists(pszGroup); + if (hGroup == 0) { + hGroup = Clist_CreateGroup(0, pszGroup); + if (hGroup) { + CallService(MS_CLUI_GROUPADDED, (WPARAM)hGroup, 0); + CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)hGroup, 1); + } + } } - else lstrcpyn(pszGroup, _T("Chat rooms"), 50); - - if (pszGroup[0]) - Clist_CreateGroup(0, pszGroup); + HANDLE hContact = ci.FindRoom(pszModule, pszRoom); if (hContact) { //contact exist, make sure it is in the right group if (pszGroup[0]) { ptrT grpName(db_get_tsa(hContact, "CList", "Group")); @@ -109,28 +113,25 @@ int RoomDoubleclicked(WPARAM wParam, LPARAM lParam) if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0) return 0; - DBVARIANT dbv; - if (!db_get_ts(hContact, szProto, "ChatRoomID", &dbv)) { - SESSION_INFO *si = ci.SM_FindSession(dbv.ptszVal, szProto); - if (si) { - // is the "toggle visibility option set, so we need to close the window? - 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)) - { - if (ci.OnSessionDblClick) - ci.OnSessionDblClick(si); - db_free(&dbv); - return 1; - } - ci.ShowRoom(si, WINDOW_VISIBLE, TRUE); + ptrT roomid(db_get_tsa(hContact, szProto, "ChatRoomID")); + if (roomid == NULL) + return 0; + + SESSION_INFO *si = ci.SM_FindSession(roomid, szProto); + if (si) { + // is the "toggle visibility option set, so we need to close the window? + 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)) + { + if (ci.OnSessionDblClick) + ci.OnSessionDblClick(si); + return 1; } - db_free(&dbv); - return 1; + ci.ShowRoom(si, WINDOW_VISIBLE, TRUE); } - - return 0; + return 1; } INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam) @@ -238,14 +239,9 @@ HANDLE FindRoom(const char *pszModule, const TCHAR *pszRoom) if (!db_get_b(hContact, pszModule, "ChatRoom", 0)) continue; - DBVARIANT dbv; - if (!db_get_ts(hContact, pszModule, "ChatRoomID", &dbv)) { - if (!lstrcmpi(dbv.ptszVal, pszRoom)) { - db_free(&dbv); - return hContact; - } - db_free(&dbv); - } + ptrT roomid(db_get_tsa(hContact, pszModule, "ChatRoomID")); + if (roomid != NULL && !lstrcmpi(roomid, pszRoom)) + return hContact; } return 0; diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp index 488b038a7d..7dd26e8713 100644 --- a/src/modules/chat/manager.cpp +++ b/src/modules/chat/manager.cpp @@ -70,6 +70,9 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char *pszModule) node->ptszID = mir_tstrdup(pszID); node->pszModule = mir_strdup(pszModule); + if (ci.OnCreateSession) + ci.OnCreateSession(node, ci.MM_FindModule(pszModule)); + if (ci.wndList == NULL) { // list is empty ci.wndList = node; node->next = NULL; @@ -292,6 +295,7 @@ static BOOL SM_AddEvent(const TCHAR *pszID, const char *pszModule, GCEVENT *gce, if (ci.pSettings->iEventLimit > 0 && pTemp->iEventCount > ci.pSettings->iEventLimit + 20) { ci.LM_TrimLog(&pTemp->pLog, &pTemp->pLogEnd, pTemp->iEventCount - ci.pSettings->iEventLimit); + pTemp->bTrimmed = true; pTemp->iEventCount = ci.pSettings->iEventLimit; return FALSE; } @@ -652,6 +656,8 @@ static BOOL SM_ChangeNick(const TCHAR *pszID, const char *pszModule, GCEVENT *gc SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID); if (pTemp->hWnd) SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0); + if (ci.OnChangeNick) + ci.OnChangeNick(pTemp); } if (pszID) @@ -1455,7 +1461,10 @@ CHAT_MANAGER ci = FindRoom, Log_CreateRTF, LoadMsgDlgFont, - MakeTimeStamp + MakeTimeStamp, + DoPopup, + ShowPopup, + RemoveFormatting }; INT_PTR SvcGetChatManager(WPARAM, LPARAM lParam) diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index 665bd61ecb..c34c1064bb 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -116,7 +116,7 @@ static LRESULT 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, ...) +int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...) { static TCHAR szBuf[4 * 1024]; @@ -214,7 +214,7 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) return TRUE; } -static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) +BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { int iEvent = gce->pDest->iType; -- cgit v1.2.3