diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 34 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 117 | ||||
-rw-r--r-- | src/mir_app/src/chat_log.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 320 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 22 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 49 |
9 files changed, 257 insertions, 303 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 18626e3f28..a4e82c1d98 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -59,6 +59,11 @@ HMENU g_hMenu = nullptr; GlobalLogSettings g_Settings; +static MODULEINFO* MM_CreateModule() +{ + return new MODULEINFO(); +} + static void OnDestroyModule(MODULEINFO *mi) { if (mi->hOnlineIcon) @@ -231,6 +236,7 @@ void Load_ChatModule() CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENW("Message sessions") L"/" LPGENW("Chat module"), FONTMODE_USE, &g_plugin }; Chat_CustomizeApi(&data); + g_chatApi.MM_CreateModule = MM_CreateModule; g_chatApi.OnCreateModule = OnCreateModule; g_chatApi.OnDestroyModule = OnDestroyModule; g_chatApi.OnReplaceSession = OnReplaceSession; diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 3f513be937..3f2750bdb7 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -141,10 +141,6 @@ void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton) if (pszRtf == nullptr) return; - MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); - if (mi == nullptr) - return; - g_chatApi.SM_AddCommand(m_si->ptszID, m_si->pszModule, pszRtf); CMStringW ptszText(ptrW(mir_utf8decodeW(pszRtf))); @@ -152,7 +148,7 @@ void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton) ptszText.Trim(); ptszText.Replace(L"%", L"%%"); - if (mi->bAckMsg) { + if (m_si->pMI->bAckMsg) { EnableWindow(m_message.GetHwnd(), FALSE); m_message.SendMsg(EM_SETREADONLY, TRUE, 0); } @@ -201,8 +197,7 @@ int CChatRoomDlg::GetImageId() const if ((m_si->wState & GC_EVENT_HIGHLIGHT) && (m_nFlash & 1)) return 0; - MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); - return (m_si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; + return (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->OnlineIconIndex : m_si->pMI->OfflineIconIndex; } void CChatRoomDlg::LoadSettings() @@ -268,7 +263,7 @@ void CChatRoomDlg::ShowFilterMenu() void CChatRoomDlg::UpdateNickList() { int i = m_nickList.SendMsg(LB_GETTOPINDEX, 0, 0); - m_nickList.SendMsg(LB_SETCOUNT, m_si->nUsersInNicklist, 0); + m_nickList.SendMsg(LB_SETCOUNT, m_si->getUserList().getCount(), 0); m_nickList.SendMsg(LB_SETTOPINDEX, i, 0); UpdateTitle(); @@ -279,7 +274,7 @@ void CChatRoomDlg::UpdateOptions() m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE)); m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE)); - MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); + MODULEINFO *mi = m_si->pMI; EnableWindow(m_btnBold.GetHwnd(), mi->bBold); EnableWindow(m_btnItalic.GetHwnd(), mi->bItalics); EnableWindow(m_btnUnderline.GetHwnd(), mi->bUnderline); @@ -330,8 +325,7 @@ void CChatRoomDlg::UpdateOptions() void CChatRoomDlg::UpdateStatusBar() { - MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); - wchar_t *ptszDispName = mi->ptszModDispName; + wchar_t *ptszDispName = m_si->pMI->ptszModDispName; int x = 12; x += Chat_GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_pOwner->m_hwndStatus, WM_GETFONT, 0, 0), TRUE); x += GetSystemMetrics(SM_CXSMICON); @@ -339,10 +333,10 @@ void CChatRoomDlg::UpdateStatusBar() SendMessage(m_pOwner->m_hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts); // stupid hack to make icons show. I dunno why this is needed currently - HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon; + HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; if (!hIcon) { g_chatApi.MM_IconsChanged(); - hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon; + hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; } SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon); @@ -353,17 +347,19 @@ void CChatRoomDlg::UpdateStatusBar() void CChatRoomDlg::UpdateTitle() { + int nUsers = m_si->getUserList().getCount(); + wchar_t szTemp[100]; switch (m_si->iType) { case GCW_CHATROOM: mir_snwprintf(szTemp, - (m_si->nUsersInNicklist == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"), - m_si->ptszName, m_si->nUsersInNicklist); + (nUsers == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"), + m_si->ptszName, nUsers); break; case GCW_PRIVMESS: mir_snwprintf(szTemp, - (m_si->nUsersInNicklist == 1) ? TranslateT("%s: message session") : TranslateT("%s: message session (%u users)"), - m_si->ptszName, m_si->nUsersInNicklist); + (nUsers == 1) ? TranslateT("%s: message session") : TranslateT("%s: message session (%u users)"), + m_si->ptszName, nUsers); break; case GCW_SERVER: mir_snwprintf(szTemp, L"%s: Server", m_si->ptszName); @@ -740,7 +736,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) wchar_t *pszSelName = (wchar_t *)mir_alloc(sizeof(wchar_t)*(end - start + 1)); mir_wstrncpy(pszSelName, pszText + start, end - start + 1); - wchar_t *pszName = g_chatApi.UM_FindUserAutoComplete(m_si->pUsers, szTabSave, pszSelName); + wchar_t *pszName = g_chatApi.UM_FindUserAutoComplete(m_si, szTabSave, pszSelName); if (pszName == nullptr) { pszName = szTabSave; m_message.SendMsg(EM_SETSEL, start, end); @@ -1019,7 +1015,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) m_btnNickList.Enable(true); m_btnFilter.Enable(true); if (m_si->iType == GCW_CHATROOM) - m_btnChannelMgr.Enable(g_chatApi.MM_FindModule(m_si->pszModule)->bChanMgr); + m_btnChannelMgr.Enable(m_si->pMI->bChanMgr); } CSuper::DlgProc(uMsg, wParam, lParam); // call built-in resizer diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 401adb6139..2172a014b9 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -29,8 +29,8 @@ void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags); void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwndDlg);
struct MODULEINFO : public GCModuleInfoBase {};
-struct SESSION_INFO : public GCSessionInfoBase {};
struct LOGSTREAMDATA : public GCLogStreamDataBase {};
+struct SESSION_INFO : public GCSessionInfoBase {};
class CChatRoomDlg : public CSrmmBaseDialog
{
@@ -52,74 +52,79 @@ extern MWindowList g_hWindowList; extern HANDLE hevSendEvent, hevBuildMenuEvent;
// log.c
-void LoadMsgLogBitmaps(void);
-void FreeMsgLogBitmaps(void);
-void ValidateFilename (wchar_t *filename);
-wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time);
-wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
-char* Log_CreateRtfHeader();
-char* Log_CreateRTF(LOGSTREAMDATA *streamData);
-char* Log_SetStyle(int style);
+void LoadMsgLogBitmaps(void);
+void FreeMsgLogBitmaps(void);
+void ValidateFilename (wchar_t *filename);
+wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time);
+wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
+char* Log_CreateRtfHeader();
+char* Log_CreateRTF(LOGSTREAMDATA *streamData);
+char* Log_SetStyle(int style);
// chat_manager.cpp
-BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted);
-BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
-char* SM_GetUsers(SESSION_INFO *si);
-BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
-BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
-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(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);
+MODULEINFO* MM_AddModule(const char *pszModule);
+
+BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted);
+BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
+char* SM_GetUsers(SESSION_INFO *si);
+BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
+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(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);
SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem);
-STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount);
-WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus);
+STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount);
+WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus);
-// clist.c
-BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...);
-MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
-MCONTACT FindRoom(const char *pszModule, const wchar_t *pszRoom);
-BOOL SetAllOffline(BOOL bHide, const char *pszModule);
-BOOL SetOffline(MCONTACT hContact, BOOL bHide);
+BOOL UM_RemoveAll(SESSION_INFO *si);
+BOOL UM_SetStatusEx(SESSION_INFO *si, const wchar_t* pszText, int flags);
+bool UM_SortUser(SESSION_INFO *si, const wchar_t *pszUID);
-int RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
-INT_PTR JoinChat(WPARAM wParam, LPARAM lParam);
-INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam);
-int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
+// clist.c
+BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...);
+MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
+MCONTACT FindRoom(const char *pszModule, const wchar_t *pszRoom);
+BOOL SetAllOffline(BOOL bHide, const char *pszModule);
+BOOL SetOffline(MCONTACT hContact, BOOL bHide);
+
+int RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR JoinChat(WPARAM wParam, LPARAM lParam);
+INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam);
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
// options.c
-int OptionsInit(void);
-int OptionsUnInit(void);
-void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour);
-void LoadGlobalSettings(void);
-HICON LoadIconEx(char* pszIcoLibName, bool big);
-void LoadLogFonts(void);
-void SetIndentSize(void);
-void RegisterFonts(void);
+int OptionsInit(void);
+int OptionsUnInit(void);
+void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour);
+void LoadGlobalSettings(void);
+HICON LoadIconEx(char* pszIcoLibName, bool big);
+void LoadLogFonts(void);
+void SetIndentSize(void);
+void RegisterFonts(void);
// services.c
-void LoadChatIcons(void);
-int LoadChatModule(void);
-void UnloadChatModule(void);
+void LoadChatIcons(void);
+int LoadChatModule(void);
+void UnloadChatModule(void);
// tools.c
-int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
-wchar_t *RemoveFormatting(const wchar_t* pszText);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int GetRichTextLength(HWND hwnd);
-bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
-BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
-BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
-BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce);
-int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
-
-const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
+int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
+wchar_t* RemoveFormatting(const wchar_t* pszText);
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+int GetRichTextLength(HWND hwnd);
+bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
+BOOL IsEventSupported(int eventType);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
+BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce);
+int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
+
+const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
#pragma comment(lib,"comctl32.lib")
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 5c0f4aed89..32dd87f67c 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -294,7 +294,7 @@ wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time) char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
SESSION_INFO *si = streamData->si;
- MODULEINFO *mi = g_chatApi.MM_FindModule(si->pszModule);
+ MODULEINFO *mi = si->pMI;
// guesstimate amount of memory for the RTF
CMStringA buf;
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index f28d82768e..4abff39ba8 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -26,6 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WINDOWS_COMMANDS_MAX 30
+static int CompareUser(const USERINFO *u1, const USERINFO *u2)
+{
+ return g_chatApi.UM_CompareItem(u1, u2);
+}
+
static int compareSessions(const SESSION_INFO *p1, const SESSION_INFO *p2)
{
int res = mir_strcmpi(p1->pszModule, p2->pszModule);
@@ -74,6 +79,18 @@ static SESSION_INFO* GetActiveSession(void) // Session Manager functions
// Keeps track of all sessions and its windows
+GCSessionInfoBase::GCSessionInfoBase() :
+ arUsers(10, CompareUser)
+{}
+
+GCSessionInfoBase::~GCSessionInfoBase()
+{}
+
+static SESSION_INFO* SM_CreateSession(void)
+{
+ return new SESSION_INFO();
+}
+
static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false)
{
if (g_clistApi.pfnGetEvent(si->hContact, 0))
@@ -98,12 +115,11 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false) db_unset(si->hContact, "CList", "StatusMsg");
}
- g_chatApi.UM_RemoveAll(&si->pUsers);
+ UM_RemoveAll(si);
g_chatApi.TM_RemoveAll(&si->pStatuses);
g_chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iStatusCount = 0;
- si->nUsersInNicklist = 0;
mir_free(si->pszModule);
mir_free(si->ptszID);
@@ -118,7 +134,7 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false) si->lpCommands = pNext;
}
- mir_free(si);
+ delete si;
}
int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, bool removeContact)
@@ -172,9 +188,9 @@ BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si) return TRUE;
}
- g_chatApi.UM_RemoveAll(&si->pUsers);
+ UM_RemoveAll(si);
si->pMe = nullptr;
- si->nUsersInNicklist = 0;
+
if (si->iType != GCW_SERVER)
si->bInitDone = false;
if (g_chatApi.OnOfflineSession)
@@ -222,19 +238,6 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool return TRUE;
}
-BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
-{
- if (!pszUID)
- return FALSE;
-
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == nullptr)
- return FALSE;
-
- g_chatApi.UM_SortUser(&si->pUsers, pszUID);
- return TRUE;
-}
-
BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
{
if (!pszModule || !pszUID)
@@ -244,15 +247,14 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
continue;
- USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, pszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si, pszUID);
if (ui) {
- si->nUsersInNicklist--;
if (g_chatApi.OnRemoveUser)
g_chatApi.OnRemoveUser(si, ui);
if (si->pMe == ui)
si->pMe = nullptr;
- g_chatApi.UM_RemoveUser(&si->pUsers, pszUID);
+ g_chatApi.UM_RemoveUser(si, pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
@@ -268,7 +270,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p static USERINFO* SM_GetUserFromIndex(const wchar_t *pszID, const char *pszModule, int index)
{
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- return (si == nullptr) ? nullptr : g_chatApi.UM_FindUserFromIndex(si->pUsers, index);
+ return (si == nullptr) ? nullptr : g_chatApi.UM_FindUserFromIndex(si, index);
}
BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
@@ -277,9 +279,9 @@ BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (si == nullptr)
return FALSE;
- USERINFO *ui = g_chatApi.UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = g_chatApi.UM_GiveStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ UM_SortUser(si, ui->pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
}
@@ -292,9 +294,9 @@ BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wcha if (si == nullptr)
return FALSE;
- USERINFO *ui = g_chatApi.UM_SetContactStatus(si->pUsers, pszUID, wStatus);
+ USERINFO *ui = g_chatApi.UM_SetContactStatus(si, pszUID, wStatus);
if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ UM_SortUser(si, ui->pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
}
@@ -307,9 +309,9 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (si == nullptr)
return FALSE;
- USERINFO *ui = g_chatApi.UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = g_chatApi.UM_TakeStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ UM_SortUser(si, ui->pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
}
@@ -366,10 +368,10 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) for (auto &si : g_arSessions) {
if ((!pszID || !mir_wstrcmpi(si->ptszID, pszID)) && !mir_strcmpi(si->pszModule, pszModule)) {
- USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si, gce->ptszUID);
if (ui) {
replaceStrW(ui->pszNick, gce->ptszText);
- SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
+ UM_SortUser(si, ui->pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
if (g_chatApi.OnChangeNick)
@@ -485,7 +487,6 @@ SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem) }
}
return nullptr;
-
}
char* SM_GetUsers(SESSION_INFO *si)
@@ -493,31 +494,12 @@ char* SM_GetUsers(SESSION_INFO *si) if (si == nullptr)
return nullptr;
- USERINFO *utemp = nullptr;
- for (auto &p : g_arSessions) {
- if (si == p) {
- if ((utemp = p->pUsers) == nullptr)
- return nullptr;
-
- break;
- }
- }
- if (utemp == nullptr)
- return nullptr;
-
- char *p = nullptr;
- size_t alloced = 0;
- do {
- size_t pLen = mir_strlen(p), nameLen = mir_wstrlen(utemp->pszUID);
- if (pLen + nameLen + 2 > alloced)
- p = (char*)mir_realloc(p, alloced += 4096);
+ CMStringA res;
+
+ for (auto &it : si->getUserList())
+ res.AppendFormat("%S ", it->pszNick);
- WideCharToMultiByte(CP_ACP, 0, utemp->pszUID, -1, p + pLen, (int)nameLen + 1, nullptr, nullptr);
- mir_strcpy(p + pLen + nameLen, " ");
- utemp = utemp->next;
- }
- while (utemp != nullptr);
- return p;
+ return res.Detach();
}
static void SM_InvalidateLogDirectories()
@@ -530,7 +512,14 @@ static void SM_InvalidateLogDirectories() // Module Manager functions
// Necessary to keep track of all modules that has registered with the plugin
-static MODULEINFO* MM_AddModule(const char *pszModule)
+GCModuleInfoBase::GCModuleInfoBase() :
+ arUsers(1, CompareUser)
+{}
+
+GCModuleInfoBase::~GCModuleInfoBase()
+{}
+
+MODULEINFO* MM_AddModule(const char *pszModule)
{
if (pszModule == nullptr)
return nullptr;
@@ -538,7 +527,7 @@ static MODULEINFO* MM_AddModule(const char *pszModule) if (g_chatApi.MM_FindModule(pszModule))
return nullptr;
- MODULEINFO *node = (MODULEINFO*)mir_calloc(g_cbModuleInfo);
+ MODULEINFO *node = g_chatApi.MM_CreateModule();
replaceStr(node->pszModule, pszModule);
if (g_chatApi.OnCreateModule)
g_chatApi.OnCreateModule(node);
@@ -547,6 +536,11 @@ static MODULEINFO* MM_AddModule(const char *pszModule) return node;
}
+static MODULEINFO* MM_CreateModule()
+{
+ return new MODULEINFO();
+}
+
static void MM_IconsChanged()
{
LoadChatIcons();
@@ -567,7 +561,9 @@ static MODULEINFO* MM_FindModule(const char *pszModule) if (!pszModule)
return nullptr;
- return g_arModules.find((MODULEINFO*)&pszModule);
+ MODULEINFO *tmp = (MODULEINFO*)_alloca(sizeof(MODULEINFO));
+ tmp->pszModule = (char*)pszModule;
+ return g_arModules.find(tmp);
}
static BOOL MM_RemoveAll(void)
@@ -579,7 +575,7 @@ static BOOL MM_RemoveAll(void) mir_free(mi->pszModule);
mir_free(mi->ptszModDispName);
mir_free(mi->pszHeader);
- mir_free(mi);
+ delete mi;
}
return TRUE;
}
@@ -677,123 +673,70 @@ static BOOL TM_RemoveAll(STATUSINFO **ppStatusList) // User manager functions
// Necessary to keep track of the users in a window nicklist
-static int UM_CompareItem(USERINFO *u1, const wchar_t *pszNick, WORD wStatus)
+static USERINFO* UM_FindUser(SESSION_INFO *si, const wchar_t *pszUID)
{
- WORD dw1 = u1->Status;
- WORD dw2 = wStatus;
+ if (!si || !pszUID)
+ return nullptr;
- for (int i = 0; i < 8; i++) {
- if ((dw1 & 1) && !(dw2 & 1))
- return -1;
- if ((dw2 & 1) && !(dw1 & 1))
- return 1;
- if ((dw1 & 1) && (dw2 & 1))
- return mir_wstrcmpi(u1->pszNick, pszNick);
+ for (auto &ui : si->getUserList())
+ if (!mir_wstrcmpi(ui->pszUID, pszUID))
+ return ui;
- dw1 = dw1 >> 1;
- dw2 = dw2 >> 1;
- }
- return mir_wstrcmpi(u1->pszNick, pszNick);
+ return nullptr;
}
-static USERINFO* UM_SortUser(USERINFO **ppUserList, const wchar_t *pszUID)
+static int compareStub(const void *p1, const void *p2)
{
- USERINFO *ui = *ppUserList, *pLast = nullptr;
- if (!ui || !pszUID)
- return nullptr;
-
- while (ui && mir_wstrcmpi(ui->pszUID, pszUID)) {
- pLast = ui;
- ui = ui->next;
- }
-
- if (ui == nullptr)
- return nullptr;
-
- USERINFO *node = ui;
- if (pLast)
- pLast->next = ui->next;
- else
- *ppUserList = ui->next;
- ui = *ppUserList;
-
- pLast = nullptr;
-
- while (ui && g_chatApi.UM_CompareItem(ui, node->pszNick, node->Status) <= 0) {
- pLast = ui;
- ui = ui->next;
- }
+ return CompareUser(*(USERINFO**)p1, *(USERINFO**)p2);
+}
- if (*ppUserList == nullptr) { // list is empty
- *ppUserList = node;
- node->next = nullptr;
- }
- else {
- if (pLast) {
- node->next = ui;
- pLast->next = node;
- }
- else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
- }
+bool UM_SortUser(SESSION_INFO *si, const wchar_t *pszUID)
+{
+ if (!UM_FindUser(si, pszUID))
+ return false;
- return node;
+ qsort(si->arUsers.getArray(), si->arUsers.getCount(), sizeof(void*), compareStub);
+ return true;
}
-USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus)
+USERINFO* UM_AddUser(STATUSINFO *pStatusList, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus)
{
- if (pStatusList == nullptr || ppUserList == nullptr || pszNick == nullptr)
+ if (pStatusList == nullptr || si == nullptr || pszNick == nullptr)
return nullptr;
- USERINFO *ui = *ppUserList, *pLast = nullptr;
- while (ui && g_chatApi.UM_CompareItem(ui, pszNick, wStatus) <= 0) {
- pLast = ui;
- ui = ui->next;
- }
-
- // if (!UM_FindUser(*ppUserList, pszUI, wStatus)
- USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
+ USERINFO *node = new USERINFO();
replaceStrW(node->pszUID, pszUID);
-
- if (*ppUserList == nullptr) { // list is empty
- *ppUserList = node;
- node->next = nullptr;
- }
- else {
- if (pLast) {
- node->next = ui;
- pLast->next = node;
- }
- else {
- node->next = *ppUserList;
- *ppUserList = node;
- }
- }
-
+ node->Status = wStatus;
+ si->getUserList().insert(node);
return node;
}
-static USERINFO* UM_FindUser(USERINFO *pUserList, const wchar_t *pszUID)
+static int UM_CompareItem(const USERINFO *u1, const USERINFO *u2)
{
- if (!pUserList || !pszUID)
- return nullptr;
+ WORD dw1 = u1->Status;
+ WORD dw2 = u2->Status;
- for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next)
- if (!mir_wstrcmpi(ui->pszUID, pszUID))
- return ui;
+ for (int i = 0; i < 8; i++) {
+ if ((dw1 & 1) && !(dw2 & 1))
+ return -1;
+ if ((dw2 & 1) && !(dw1 & 1))
+ return 1;
+ if ((dw1 & 1) && (dw2 & 1))
+ break;
- return nullptr;
+ dw1 = dw1 >> 1;
+ dw2 = dw2 >> 1;
+ }
+ return mir_wstrcmpi(u1->pszNick, u2->pszNick);
}
-static USERINFO* UM_FindUserFromIndex(USERINFO *pUserList, int index)
+static USERINFO* UM_FindUserFromIndex(SESSION_INFO *si, int index)
{
- if (!pUserList)
+ if (!si)
return nullptr;
int i = 0;
- for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) {
+ for (auto &ui : si->getUserList()) {
if (i == index)
return ui;
i++;
@@ -801,9 +744,9 @@ static USERINFO* UM_FindUserFromIndex(USERINFO *pUserList, int index) return nullptr;
}
-static USERINFO* UM_GiveStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status)
+static USERINFO* UM_GiveStatus(SESSION_INFO *si, const wchar_t *pszUID, WORD status)
{
- USERINFO *ui = UM_FindUser(pUserList, pszUID);
+ USERINFO *ui = UM_FindUser(si, pszUID);
if (ui == nullptr)
return nullptr;
@@ -811,9 +754,9 @@ static USERINFO* UM_GiveStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD return ui;
}
-static USERINFO* UM_SetContactStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status)
+static USERINFO* UM_SetContactStatus(SESSION_INFO *si, const wchar_t *pszUID, WORD status)
{
- USERINFO *ui = UM_FindUser(pUserList, pszUID);
+ USERINFO *ui = UM_FindUser(si, pszUID);
if (ui == nullptr)
return nullptr;
@@ -821,12 +764,21 @@ static USERINFO* UM_SetContactStatus(USERINFO *pUserList, const wchar_t *pszUID, return ui;
}
-static BOOL UM_SetStatusEx(USERINFO *pUserList, const wchar_t* pszText, int flags)
+BOOL UM_SetStatusEx(SESSION_INFO *si, const wchar_t* pszText, int flags)
{
int bOnlyMe = (flags & GC_SSE_ONLYLISTED) != 0, bSetStatus = (flags & GC_SSE_ONLINE) != 0;
char cDelimiter = (flags & GC_SSE_TABDELIMITED) ? '\t' : ' ';
- for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) {
+ if (bOnlyMe) {
+ USERINFO *ui = UM_FindUser(si, pszText);
+ if (ui == nullptr)
+ return FALSE;
+
+ ui->iStatusEx = (bSetStatus) ? 1 : 0;
+ return TRUE;
+ }
+
+ for (auto &ui : si->getUserList()) {
if (!bOnlyMe)
ui->iStatusEx = 0;
@@ -845,9 +797,9 @@ static BOOL UM_SetStatusEx(USERINFO *pUserList, const wchar_t* pszText, int flag return TRUE;
}
-static USERINFO* UM_TakeStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status)
+static USERINFO* UM_TakeStatus(SESSION_INFO *si, const wchar_t *pszUID, WORD status)
{
- USERINFO *ui = UM_FindUser(pUserList, pszUID);
+ USERINFO *ui = UM_FindUser(si, pszUID);
if (ui == nullptr)
return nullptr;
@@ -855,13 +807,13 @@ static USERINFO* UM_TakeStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD return ui;
}
-static wchar_t* UM_FindUserAutoComplete(USERINFO *pUserList, const wchar_t* pszOriginal, const wchar_t* pszCurrent)
+static wchar_t* UM_FindUserAutoComplete(SESSION_INFO *si, const wchar_t* pszOriginal, const wchar_t* pszCurrent)
{
- if (!pUserList || !pszOriginal || !pszCurrent)
+ if (!si || !pszOriginal || !pszCurrent)
return nullptr;
wchar_t *pszName = nullptr;
- for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next)
+ for (auto &ui : si->getUserList())
if (ui->pszNick && my_strstri(ui->pszNick, pszOriginal) == ui->pszNick)
if (mir_wstrcmpi(ui->pszNick, pszCurrent) > 0 && (!pszName || mir_wstrcmpi(ui->pszNick, pszName) < 0))
pszName = ui->pszNick;
@@ -869,42 +821,36 @@ static wchar_t* UM_FindUserAutoComplete(USERINFO *pUserList, const wchar_t* pszO return pszName;
}
-static BOOL UM_RemoveUser(USERINFO **ppUserList, const wchar_t *pszUID)
+static BOOL UM_RemoveUser(SESSION_INFO *si, const wchar_t *pszUID)
{
- if (!ppUserList || !pszUID)
+ if (!si || !pszUID)
return FALSE;
- USERINFO *ui = *ppUserList, *pLast = nullptr;
- while (ui != nullptr) {
+ auto &arUsers = si->getUserList();
+ for (auto &ui : arUsers) {
if (!mir_wstrcmpi(ui->pszUID, pszUID)) {
- if (pLast == nullptr)
- *ppUserList = ui->next;
- else
- pLast->next = ui->next;
mir_free(ui->pszNick);
mir_free(ui->pszUID);
- mir_free(ui);
+ arUsers.remove(arUsers.indexOf(&ui));
return TRUE;
}
- pLast = ui;
- ui = ui->next;
}
return FALSE;
}
-static BOOL UM_RemoveAll(USERINFO **ppUserList)
+BOOL UM_RemoveAll(SESSION_INFO *si)
{
- if (!ppUserList)
+ if (!si)
return FALSE;
- while (*ppUserList != nullptr) {
- USERINFO *pLast = ppUserList[0]->next;
- mir_free(ppUserList[0]->pszUID);
- mir_free(ppUserList[0]->pszNick);
- mir_free(*ppUserList);
- *ppUserList = pLast;
+ if (!si->pMI->bSharedUsers) {
+ auto &arUsers = si->getUserList();
+ for (auto &ui : arUsers) {
+ mir_free(ui->pszUID);
+ mir_free(ui->pszNick);
+ }
+ arUsers.destroy();
}
- *ppUserList = nullptr;
return TRUE;
}
@@ -983,7 +929,7 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) mir_cslock lck(csChat);
for (auto &p : g_arSessions) {
- SESSION_INFO *p1 = (SESSION_INFO*)mir_realloc(p, pInit->cbSession);
+ SESSION_INFO *p1 = (SESSION_INFO*)realloc(p, pInit->cbSession);
memset(PBYTE(p1) + sizeof(GCSessionInfoBase), 0, pInit->cbSession - sizeof(GCSessionInfoBase));
if (p1 != p) { // realloc could change a pointer, reinsert a structure
g_arSessions.remove(p);
@@ -995,7 +941,7 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) mir_cslock lck(csChat);
for (auto &mi : g_arModules) {
- MODULEINFO *p1 = (MODULEINFO*)mir_realloc(mi, pInit->cbModuleInfo);
+ MODULEINFO *p1 = (MODULEINFO*)realloc(mi, pInit->cbModuleInfo);
memset(PBYTE(p1) + sizeof(GCModuleInfoBase), 0, pInit->cbModuleInfo - sizeof(GCModuleInfoBase));
if (p1 != mi) { // realloc could change a pointer, reinsert a structure
g_arModules.remove(mi);
@@ -1013,6 +959,7 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) g_chatApi.SetActiveSession = SetActiveSession;
g_chatApi.GetActiveSession = GetActiveSession;
+ g_chatApi.SM_CreateSession = SM_CreateSession;
g_chatApi.SM_FindSession = SM_FindSession;
g_chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
g_chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
@@ -1024,7 +971,7 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) g_chatApi.SM_GetUserFromIndex = SM_GetUserFromIndex;
g_chatApi.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
- g_chatApi.MM_AddModule = MM_AddModule;
+ g_chatApi.MM_CreateModule = MM_CreateModule;
g_chatApi.MM_FindModule = MM_FindModule;
g_chatApi.MM_FontsChanged = MM_FontsChanged;
g_chatApi.MM_IconsChanged = MM_IconsChanged;
@@ -1034,9 +981,8 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) g_chatApi.TM_WordToString = TM_WordToString;
g_chatApi.TM_RemoveAll = TM_RemoveAll;
- g_chatApi.UM_SetStatusEx = UM_SetStatusEx;
g_chatApi.UM_AddUser = UM_AddUser;
- g_chatApi.UM_SortUser = UM_SortUser;
+ g_chatApi.UM_CompareItem = UM_CompareItem;
g_chatApi.UM_FindUser = UM_FindUser;
g_chatApi.UM_FindUserFromIndex = UM_FindUserFromIndex;
g_chatApi.UM_GiveStatus = UM_GiveStatus;
@@ -1044,8 +990,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) g_chatApi.UM_TakeStatus = UM_TakeStatus;
g_chatApi.UM_FindUserAutoComplete = UM_FindUserAutoComplete;
g_chatApi.UM_RemoveUser = UM_RemoveUser;
- g_chatApi.UM_RemoveAll = UM_RemoveAll;
- g_chatApi.UM_CompareItem = UM_CompareItem;
g_chatApi.LM_AddEvent = LM_AddEvent;
g_chatApi.LM_TrimLog = LM_TrimLog;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index db9a72be2d..c9e20939c5 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -142,7 +142,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) if (gci->Flags & GCF_DATA) gci->pItemData = si->pItemData;
if (gci->Flags & GCF_HCONTACT) gci->hContact = si->hContact;
if (gci->Flags & GCF_TYPE) gci->iType = si->iType;
- if (gci->Flags & GCF_COUNT) gci->iCount = si->nUsersInNicklist;
+ if (gci->Flags & GCF_COUNT) gci->iCount = si->getUserList().getCount();
if (gci->Flags & GCF_USERS) gci->pszUsers = SM_GetUsers(si);
if (gci->Flags & GCF_ID) gci->pszID = si->ptszID;
if (gci->Flags & GCF_NAME) gci->pszName = si->ptszName;
@@ -158,7 +158,7 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) return GC_ERROR;
mir_cslock lck(csChat);
- MODULEINFO *mi = g_chatApi.MM_AddModule(gcr->pszModule);
+ MODULEINFO *mi = MM_AddModule(gcr->pszModule);
if (mi == nullptr)
return GC_ERROR;
@@ -170,6 +170,7 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0;
mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
+ mi->bSharedUsers = (gcr->dwFlags & GC_SHAREDUSERS) != 0;
mi->iMaxText = gcr->iMaxText;
mi->pszHeader = g_chatApi.Log_CreateRtfHeader();
@@ -195,12 +196,11 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( // try to restart a session first
SESSION_INFO *si = SM_FindSession(ptszID, pszModule);
if (si != nullptr) {
- g_chatApi.UM_RemoveAll(&si->pUsers);
+ UM_RemoveAll(si);
g_chatApi.TM_RemoveAll(&si->pStatuses);
lck.unlock();
si->iStatusCount = 0;
- si->nUsersInNicklist = 0;
si->pMe = nullptr;
if (g_chatApi.OnReplaceSession)
@@ -209,9 +209,10 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( }
// create a new session
- si = (SESSION_INFO*)mir_calloc(g_cbSession);
+ si = g_chatApi.SM_CreateSession();
si->ptszID = mir_wstrdup(ptszID);
si->pszModule = mir_strdup(pszModule);
+ si->pMI = mi;
g_chatApi.arSessions.insert(si);
lck.unlock();
@@ -369,11 +370,10 @@ static void AddUser(GCEVENT *gce) WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO *ui = g_chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status);
+ USERINFO *ui = g_chatApi.UM_AddUser(si->pStatuses, si, gce->ptszUID, gce->ptszNick, status);
if (ui == nullptr)
return;
- si->nUsersInNicklist++;
if (g_chatApi.OnAddUser)
g_chatApi.OnAddUser(si, ui);
@@ -398,7 +398,7 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) if (!si->bInitDone || mir_strcmpi(si->pszModule, gce->pszModule))
continue;
- if (!g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID))
+ if (!g_chatApi.UM_FindUser(si, gce->ptszUID))
continue;
if (g_chatApi.OnEventBroadcast)
@@ -533,7 +533,7 @@ static INT_PTR CALLBACK sttEventStub(void *_param) if (si && (si->bInitDone || gce->iType == GC_EVENT_TOPIC || (gce->iType == GC_EVENT_JOIN && gce->bIsMe))) {
if (gce->ptszNick == nullptr && gce->ptszUID != nullptr) {
- USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si, gce->ptszUID);
if (ui != nullptr)
gce->ptszNick = ui->pszNick;
}
@@ -625,7 +625,7 @@ MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, c if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
- USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, wszOldId);
+ USERINFO *ui = g_chatApi.UM_FindUser(si, wszOldId);
if (ui)
replaceStrW(ui->pszUID, wszNewId);
if (wszId)
@@ -691,7 +691,7 @@ MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, in if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
- g_chatApi.UM_SetStatusEx(si->pUsers, wszText, flags);
+ UM_SetStatusEx(si, wszText, flags);
if (si->pDlg)
RedrawWindow(GetDlgItem(si->pDlg->GetHwnd(), IDC_LIST), nullptr, nullptr, RDW_INVALIDATE);
if (wszId)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 1ebcb18629..25c27789a7 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -661,3 +661,8 @@ g_hevEventEdited @693 NONAME g_hevEventFiltered @694 NONAME
g_hevMarkedRead @695 NONAME
g_hevSettingChanged @696 NONAME
+??0GCModuleInfoBase@@QAE@XZ @697 NONAME
+??0GCSessionInfoBase@@QAE@XZ @698 NONAME
+??1GCModuleInfoBase@@QAE@XZ @699 NONAME
+??1GCSessionInfoBase@@QAE@XZ @700 NONAME
+?getUserList@GCSessionInfoBase@@QAEAAU?$OBJLIST@UUSERINFO@@@@XZ @701 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 5b9ec3aaf3..3c09b922e7 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -661,3 +661,8 @@ g_hevEventEdited @693 NONAME g_hevEventFiltered @694 NONAME
g_hevMarkedRead @695 NONAME
g_hevSettingChanged @696 NONAME
+??0GCModuleInfoBase@@QEAA@XZ @697 NONAME
+??0GCSessionInfoBase@@QEAA@XZ @698 NONAME
+??1GCModuleInfoBase@@QEAA@XZ @699 NONAME
+??1GCSessionInfoBase@@QEAA@XZ @700 NONAME
+?getUserList@GCSessionInfoBase@@QEAAAEAU?$OBJLIST@UUSERINFO@@@@XZ @701 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 923b34f58f..7c3a8ef9d4 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -66,16 +66,13 @@ CSrmmBaseDialog::CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, SESSION_IN if (si) { m_hContact = si->hContact; - MODULEINFO *mi = g_chatApi.MM_FindModule(si->pszModule); - if (mi != nullptr) { - if (mi->bColor) { - m_iFG = 4; - m_bFGSet = true; - } - if (mi->bBkgColor) { - m_iBG = 2; - m_bBGSet = true; - } + if (si->pMI->bColor) { + m_iFG = 4; + m_bFGSet = true; + } + if (si->pMI->bBkgColor) { + m_iBG = 2; + m_bBGSet = true; } } } @@ -578,8 +575,10 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam if (dc == nullptr) break; + int nUsers = m_si->getUserList().getCount(); + int index = m_nickList.SendMsg(LB_GETTOPINDEX, 0, 0); - if (index == LB_ERR || m_si->nUsersInNicklist <= 0) + if (index == LB_ERR || nUsers <= 0) break; int height = m_nickList.SendMsg(LB_GETITEMHEIGHT, 0, 0); @@ -588,7 +587,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam GetClientRect(m_nickList.GetHwnd(), &rc); - int items = m_si->nUsersInNicklist - index; + int items = nUsers - index; if (rc.bottom - rc.top > items * height) { rc.top = items * height; FillRect(dc, &rc, g_chatApi.hListBkgBrush); @@ -851,12 +850,10 @@ void CSrmmBaseDialog::onClick_History(CCtrlButton *pButton) if (!pButton->Enabled()) return; - if (m_si != nullptr) { - MODULEINFO *pInfo = g_chatApi.MM_FindModule(m_si->pszModule); - if (pInfo) - ShellExecute(m_hwnd, nullptr, g_chatApi.GetChatLogsFilename(m_si, 0), nullptr, nullptr, SW_SHOW); - } - else CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0); + if (m_si != nullptr) + ShellExecute(m_hwnd, nullptr, g_chatApi.GetChatLogsFilename(m_si, 0), nullptr, nullptr, SW_SHOW); + else + CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0); } void CSrmmBaseDialog::onClick_ChanMgr(CCtrlButton *pButton) @@ -873,7 +870,7 @@ void CSrmmBaseDialog::onDblClick_List(CCtrlListBox *pList) ScreenToClient(pList->GetHwnd(), &hti.pt); int item = LOWORD(pList->SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y))); - USERINFO *ui = g_chatApi.UM_FindUserFromIndex(m_si->pUsers, item); + USERINFO *ui = g_chatApi.UM_FindUserFromIndex(m_si, item); if (ui == nullptr) return; @@ -975,11 +972,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR; m_message.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); - MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); - if (mi == nullptr) - return; - - if (mi->bColor) { + if (m_si->pMI->bColor) { bool bState = m_btnColor.IsPushed(); if (!bState && cf.crTextColor != m_clrInputFG) m_btnColor.Push(true); @@ -987,7 +980,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) m_btnColor.Push(false); } - if (mi->bBkgColor) { + if (m_si->pMI->bBkgColor) { bool bState = m_btnBkColor.IsPushed(); if (!bState && cf.crBackColor != m_clrInputBG) m_btnBkColor.Push(true); @@ -995,7 +988,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) m_btnBkColor.Push(false); } - if (mi->bBold) { + if (m_si->pMI->bBold) { bool bState = m_btnBold.IsPushed(); UINT u2 = cf.dwEffects & CFE_BOLD; if (!bState && u2 != 0) @@ -1004,7 +997,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) m_btnBold.Push(false); } - if (mi->bItalics) { + if (m_si->pMI->bItalics) { bool bState = m_btnItalic.IsPushed(); UINT u2 = cf.dwEffects & CFE_ITALIC; if (!bState && u2 != 0) @@ -1013,7 +1006,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) m_btnItalic.Push(false); } - if (mi->bUnderline) { + if (m_si->pMI->bUnderline) { bool bState = m_btnUnderline.IsPushed(); UINT u2 = cf.dwEffects & CFE_UNDERLINE; if (!bState && u2 != 0) |