diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-19 14:48:33 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-19 14:48:33 +0300 |
commit | 9439b05189ce9db2cbe552796995cf67126af308 (patch) | |
tree | 0b360ab24a0f7e3969b096293cbaa56801a76cee | |
parent | a6bb80933c2984cf9a703e6dae6f1f18851c19b6 (diff) |
SESSION_INFO: separate list for the interface support eliminated, now there's the only list of USERINFO sorted by their unique IDs
-rw-r--r-- | include/m_chat.h | 3 | ||||
-rw-r--r-- | include/m_chat_int.h | 5 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 262034 -> 261638 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 261036 -> 260630 bytes | |||
-rw-r--r-- | plugins/Scriver/src/msgutils.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 67 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 17 |
13 files changed, 28 insertions, 74 deletions
diff --git a/include/m_chat.h b/include/m_chat.h index bd5967dc9f..4a05f7ea80 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -443,7 +443,6 @@ MIR_APP_DLL(int) Chat_Terminate(const char *szModule); #define GCF_NAME 0x0020 // pszName is valid
#define GCF_TYPE 0x0040 // iType is valid
#define GCF_COUNT 0x0080 // iCount is valid
-#define GCF_USERS 0x0100 // pszUsers is valid
struct GC_INFO
{
@@ -455,8 +454,6 @@ struct GC_INFO LPTSTR pszName; // display name of the session
void* pItemData; // user specified data.
int iCount; // count of users in the nicklist
- LPSTR pszUsers; // space separated string containing the UID's of the users in the user list.
- // NOTE. Use Mirandas mmi_free() on the returned string.
MCONTACT hContact; // hContact for the session (can be NULL)
};
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 042eda91e6..83034f9677 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -176,7 +176,6 @@ struct MIR_APP_EXPORT SESSION_INFO : public MZeroedObject, public MNonCopyable MODULEINFO *pMI;
SESSION_INFO *pParent;
- LIST<USERINFO> arKeys;
OBJLIST<USERINFO> arUsers;
OBJLIST<LOGINFO> arEvents;
@@ -190,10 +189,6 @@ struct MIR_APP_EXPORT SESSION_INFO : public MZeroedObject, public MNonCopyable { return (pParent != nullptr) ? pParent->arUsers : arUsers;
}
- __forceinline LIST<USERINFO>& getKeyList()
- { return (pParent != nullptr) ? pParent->arKeys : arKeys;
- }
-
const char* getSoundName(int iEventType) const;
};
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex db0b17d5af..982985afca 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 063c6c6e23..fbabe22008 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index c6d9b8589e..e0e8cd0325 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -723,7 +723,7 @@ void CMsgDialog::UpdateTitle() tbd.hIconBig = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIconBig : m_si->pMI->hOfflineIconBig; tbd.hIconNot = (m_si->wState & (GC_EVENT_HIGHLIGHT | STATE_TALK)) ? g_plugin.getIcon(IDI_OVERLAY) : nullptr; - int nUsers = m_si->getUserList().getCount(); + int nUsers = m_nickList.GetCount(); switch (m_si->iType) { case GCW_CHATROOM: wszTitle.Format((nUsers == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"), m_si->ptszName, nUsers); diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 4b7e2e23ea..52b26b29b8 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2725,7 +2725,7 @@ void CMsgDialog::UpdateTitle() CMStringW wszTitle;
HICON hIcon = nullptr;
- int nUsers = m_si->getUserList().getCount();
+ int nUsers = m_nickList.GetCount();
switch (m_si->iType) {
case GCW_CHATROOM:
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index a13c704257..4254e28119 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1488,7 +1488,7 @@ void CMsgDialog::UpdateTitle() {
wchar_t newtitle[256];
if (isChat()) {
- int nUsers = m_si->getUserList().getCount();
+ int nUsers = m_nickList.GetCount();
switch (m_si->iType) {
case GCW_CHATROOM:
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index d1082c802e..6be46ab3ba 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -90,7 +90,6 @@ USERINFO* UM_AddUser(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t BOOL UM_RemoveAll(SESSION_INFO *si);
BOOL UM_SetStatusEx(SESSION_INFO *si, const wchar_t* pszText, int flags);
void UM_SortKeys(SESSION_INFO *si);
-void UM_SortUser(SESSION_INFO *si);
// clist.c
MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 0474d942bb..589c03610d 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -28,14 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static USERINFO* UM_FindUser(SESSION_INFO *si, const wchar_t *pszUID);
-static int CompareKeys(const USERINFO *u1, const USERINFO *u2)
-{
- return mir_wstrcmp(u1->pszUID, u2->pszUID);
-}
-
static int CompareUser(const USERINFO *u1, const USERINFO *u2)
{
- return g_chatApi.UM_CompareItem(u1, u2);
+ return mir_wstrcmp(u1->pszUID, u2->pszUID);
}
static int compareSessions(const SESSION_INFO *p1, const SESSION_INFO *p2)
@@ -68,7 +63,6 @@ static int CompareEvents(const LOGINFO *p1, const LOGINFO *p2) }
SESSION_INFO::SESSION_INFO() :
- arKeys(10, CompareKeys),
arUsers(10, CompareUser),
arEvents(10, CompareEvents)
{
@@ -237,10 +231,6 @@ BOOL SM_RemoveUser(SESSION_INFO *si, const wchar_t *pszUID) if (si->pMe == ui)
si->pMe = nullptr;
- auto &arKeys = si->getKeyList();
- if (arKeys.remove(ui) == -1)
- DebugBreak();
-
auto &arUsers = si->getUserList();
for (auto &it : arUsers) {
if (!mir_wstrcmpi(it->pszUID, pszUID)) {
@@ -263,11 +253,8 @@ BOOL SM_GiveStatus(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszSt return FALSE;
USERINFO *ui = g_chatApi.UM_GiveStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
- if (ui) {
- UM_SortUser(si);
- if (si->pDlg)
- si->pDlg->UpdateNickList();
- }
+ if (ui && si->pDlg)
+ si->pDlg->UpdateNickList();
return TRUE;
}
@@ -277,11 +264,8 @@ BOOL SM_SetContactStatus(SESSION_INFO *si, const wchar_t *pszUID, uint16_t wStat return FALSE;
USERINFO *ui = g_chatApi.UM_SetContactStatus(si, pszUID, wStatus);
- if (ui) {
- UM_SortUser(si);
- if (si->pDlg)
- si->pDlg->UpdateNickList();
- }
+ if (ui && si->pDlg)
+ si->pDlg->UpdateNickList();
return TRUE;
}
@@ -291,11 +275,8 @@ BOOL SM_TakeStatus(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszSt return FALSE;
USERINFO *ui = g_chatApi.UM_TakeStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
- if (ui) {
- UM_SortUser(si);
- if (si->pDlg)
- si->pDlg->UpdateNickList();
- }
+ if (ui && si->pDlg)
+ si->pDlg->UpdateNickList();
return TRUE;
}
@@ -344,7 +325,6 @@ BOOL SM_ChangeNick(SESSION_INFO *si, GCEVENT *gce) USERINFO *ui = UM_FindUser(si, gce->pszUID.w);
if (ui) {
replaceStrW(ui->pszNick, gce->pszText.w);
- UM_SortUser(si);
if (si->pDlg)
si->pDlg->UpdateNickList();
if (g_chatApi.OnChangeNick)
@@ -399,19 +379,6 @@ SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem) return nullptr;
}
-char* SM_GetUsers(SESSION_INFO *si)
-{
- if (si == nullptr)
- return nullptr;
-
- CMStringA res;
-
- for (auto &it : si->getUserList())
- res.AppendFormat("%S ", it->pszNick);
-
- return res.Detach();
-}
-
static void SM_InvalidateLogDirectories()
{
for (auto &si : g_arSessions)
@@ -584,31 +551,19 @@ static USERINFO* UM_FindUser(SESSION_INFO *si, const wchar_t *pszUID) mir_cslock lck(si->csLock);
USERINFO tmp;
tmp.pszUID = (wchar_t*)pszUID;
- return si->getKeyList().find(&tmp);
+ return si->getUserList().find(&tmp);
}
/////////////////////////////////////////////////////////////////////////////////////////
static int compareKeysStub(const void *p1, const void *p2)
{
- return CompareKeys(*(USERINFO**)p1, *(USERINFO**)p2);
-}
-
-void UM_SortKeys(SESSION_INFO *si)
-{
- qsort(si->arKeys.getArray(), si->arKeys.getCount(), sizeof(void*), compareKeysStub);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static int compareStub(const void *p1, const void *p2)
-{
return CompareUser(*(USERINFO**)p1, *(USERINFO**)p2);
}
-void UM_SortUser(SESSION_INFO *si)
+void UM_SortKeys(SESSION_INFO *si)
{
- qsort(si->arUsers.getArray(), si->arUsers.getCount(), sizeof(void*), compareStub);
+ qsort(si->arUsers.getArray(), si->arUsers.getCount(), sizeof(void*), compareKeysStub);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -623,7 +578,6 @@ USERINFO* UM_AddUser(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *psz if (pUser == nullptr) {
pUser = new USERINFO();
replaceStrW(pUser->pszUID, pszUID);
- si->getKeyList().insert(pUser);
si->getUserList().insert(pUser);
}
@@ -737,7 +691,6 @@ BOOL UM_RemoveAll(SESSION_INFO *si) mir_free(ui->pszUID);
mir_free(ui->pszNick);
}
- si->arKeys.destroy();
si->arUsers.destroy();
}
return TRUE;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index aebd340a80..d68448b53e 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -158,7 +158,6 @@ MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) 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->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;
return 0;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 161aad88ce..0e5b7801ad 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -629,7 +629,6 @@ db_mc_tryMeta @732 ?setUString@PROTO_INTERFACE@@QAEXPBD0@Z @742 NONAME
?setUString@CMPluginBase@@QAEXIPBD0@Z @743 NONAME
?setUString@CMPluginBase@@QAEXPBD0@Z @744 NONAME
-?getKeyList@SESSION_INFO@@QAEAAU?$LIST@UUSERINFO@@@@XZ @745 NONAME
PUAddPopup @746
PUAddPopupW @747
PUChangeTextW @748
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 55a7147c2c..8950337b68 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -629,7 +629,6 @@ db_mc_tryMeta @732 ?setUString@PROTO_INTERFACE@@QEAAXPEBD0@Z @742 NONAME
?setUString@CMPluginBase@@QEAAXIPEBD0@Z @743 NONAME
?setUString@CMPluginBase@@QEAAXPEBD0@Z @744 NONAME
-?getKeyList@SESSION_INFO@@QEAAAEAU?$LIST@UUSERINFO@@@@XZ @745 NONAME
PUAddPopup @746
PUAddPopupW @747
PUChangeTextW @748
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index e2a0912349..39cc182ea2 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -425,7 +425,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam if (dc == nullptr)
break;
- int nUsers = m_si->getUserList().getCount();
+ int nUsers = m_nickList.GetCount();
int index = m_nickList.SendMsg(LB_GETTOPINDEX, 0, 0);
if (index == LB_ERR || nUsers <= 0)
@@ -675,13 +675,26 @@ void CSrmmBaseDialog::UpdateFilterButton() m_btnFilter.SendMsg(BUTTONADDTOOLTIP, (WPARAM)(m_bFilterEnabled ? TranslateT("Disable the event filter (Ctrl+F)") : TranslateT("Enable the event filter (Ctrl+F)")), BATF_UNICODE);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int compareStub(const void *p1, const void *p2)
+{
+ return g_chatApi.UM_CompareItem(*(USERINFO **)p1, *(USERINFO **)p2);
+}
+
void CSrmmBaseDialog::UpdateNickList()
{
int idx = m_nickList.SendMsg(LB_GETTOPINDEX, 0, 0);
m_nickList.SetDraw(false);
m_nickList.ResetContent();
- for (auto &ui : m_si->getUserList())
+
+ auto &fromList = m_si->getUserList();
+ LIST<USERINFO> tmpList(fromList.getCount());
+ List_Copy((SortedList *)&fromList, (SortedList *)&tmpList, sizeof(void *));
+ qsort(tmpList.getArray(), tmpList.getCount(), sizeof(void *), compareStub);
+
+ for (auto &ui : tmpList)
m_nickList.AddString(ui->pszNick, LPARAM(ui));
m_nickList.SendMsg(LB_SETTOPINDEX, idx, 0);
|