summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat.h1
-rw-r--r--include/m_chat_int.h13
-rw-r--r--libs/win32/mir_app.libbin184756 -> 185102 bytes
-rw-r--r--libs/win64/mir_app.libbin179984 -> 180340 bytes
-rw-r--r--plugins/TabSRMM/src/muchighlight.cpp4
-rw-r--r--protocols/Discord/src/connection.cpp2
-rw-r--r--protocols/Discord/src/dispatch.cpp2
-rw-r--r--protocols/Discord/src/guilds.cpp26
-rw-r--r--protocols/Discord/src/proto.cpp4
-rw-r--r--protocols/Discord/src/proto.h3
-rw-r--r--src/mir_app/src/chat_manager.cpp10
-rw-r--r--src/mir_app/src/chat_svc.cpp1
-rw-r--r--src/mir_app/src/chat_tools.cpp8
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
15 files changed, 38 insertions, 38 deletions
diff --git a/include/m_chat.h b/include/m_chat.h
index d6d2e398ae..978e1e1860 100644
--- a/include/m_chat.h
+++ b/include/m_chat.h
@@ -133,7 +133,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GC_ACKMSG 0x0020 // the protocol must acknowlege messages sent
#define GC_TYPNOTIF 0x0040 // enable typing notifications.
#define GC_CHANMGR 0x0080 // enable the 'channel settings' button
-#define GC_SHAREDUSERS 0x0100 // array of users is the same for all group chats
// Error messages
#define GC_ERROR 1 // An internal error occurred.
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 154edc854e..472d08cf8c 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -103,11 +103,9 @@ struct MIR_APP_EXPORT GCModuleInfoBase : public MZeroedObject, public MNonCopyab
bool bBold, bItalics, bUnderline;
bool bColor, bBkgColor;
- bool bChanMgr, bAckMsg, bSharedUsers;
+ bool bChanMgr, bAckMsg;
int iMaxText;
-
- OBJLIST<USERINFO> arUsers; // for shared list of users
};
struct COMMANDINFO
@@ -180,15 +178,18 @@ struct MIR_APP_EXPORT GCSessionInfoBase : public MZeroedObject, public MNonCopya
USERINFO *pMe;
STATUSINFO *pStatuses;
MODULEINFO *pMI;
+ GCSessionInfoBase *pParent;
OBJLIST<USERINFO> arUsers;
wchar_t pszLogFileName[MAX_PATH];
+ __forceinline USERINFO* getMe() const
+ { return (pParent != nullptr) ? pParent->pMe : pMe;
+ }
+
__forceinline OBJLIST<USERINFO>& getUserList()
- {
- GCModuleInfoBase *mi = (GCModuleInfoBase*)pMI;
- return (mi->bSharedUsers) ? mi->arUsers : arUsers;
+ { return (pParent != nullptr) ? pParent->arUsers : arUsers;
}
};
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 24c1bd4901..a107d733cc 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 74d05788f8..d256af4b1d 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/TabSRMM/src/muchighlight.cpp b/plugins/TabSRMM/src/muchighlight.cpp
index e32c086051..afbbcb907f 100644
--- a/plugins/TabSRMM/src/muchighlight.cpp
+++ b/plugins/TabSRMM/src/muchighlight.cpp
@@ -118,13 +118,13 @@ bool CMUCHighlight::match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dw
return false;
if ((m_dwFlags & MATCH_TEXT) && (dwFlags & MATCH_TEXT) && (m_fHighlightMe || m_iTextPatterns > 0) && psi != nullptr) {
- wchar_t *p = g_chatApi.RemoveFormatting(pgce->ptszText);
+ wchar_t *p = g_chatApi.RemoveFormatting(pgce->ptszText);
p = NEWWSTR_ALLOCA(p);
if (p == nullptr)
return false;
CharLower(p);
- wchar_t *tszMe = ((psi && psi->pMe) ? NEWWSTR_ALLOCA(psi->pMe->pszNick) : nullptr);
+ wchar_t *tszMe = (psi && psi->getMe()) ? NEWWSTR_ALLOCA(psi->getMe()->pszNick) : nullptr;
if (tszMe)
CharLower(tszMe);
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp
index 1034ecc2b3..d23ad64041 100644
--- a/protocols/Discord/src/connection.cpp
+++ b/protocols/Discord/src/connection.cpp
@@ -87,7 +87,7 @@ void CDiscordProto::OnLoggedOut()
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE);
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- setAllContactStatuses(ID_STATUS_OFFLINE, true);
+ setAllContactStatuses(ID_STATUS_OFFLINE, false);
}
void CDiscordProto::ShutdownSession()
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index fa301ee37c..a0bf365e2a 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -377,7 +377,7 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot)
pm->wszNick = pRoot["user"]["username"].as_mstring() + L"#" + pRoot["user"]["discriminator"].as_mstring();
pGuild->arChatUsers.insert(pm);
- AddGuildUser(pGuild->id, *pm);
+ AddGuildUser(pGuild, *pm);
}
ParseSpecialChars(si, wszText);
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp
index 1d0a137fea..b30dcf8aef 100644
--- a/protocols/Discord/src/guilds.cpp
+++ b/protocols/Discord/src/guilds.cpp
@@ -76,7 +76,12 @@ void CDiscordProto::ProcessGuild(const JSONNode &p)
GCSessionInfoBase *si = Chat_NewSession(GCW_SERVER, m_szModuleName, pGuild->wszName, pGuild->wszName, pGuild);
Chat_Control(m_szModuleName, pGuild->wszName, WINDOW_HIDDEN);
Chat_Control(m_szModuleName, pGuild->wszName, SESSION_ONLINE);
-
+ BuildStatusList(pGuild, pGuild->wszName);
+
+ for (auto &it : pGuild->arChatUsers)
+ AddGuildUser(pGuild, *it);
+
+ pGuild->pParentSi = si;
pGuild->hContact = si->hContact;
setId(si->hContact, DB_KEY_CHANNELID, guildId);
@@ -104,6 +109,7 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS
CMStringW wszTopic = pch["topic"].as_mstring();
GCSessionInfoBase *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszChannelId, wszChannelName);
+ si->pParent = pGuild->pParentSi;
BuildStatusList(pGuild, wszChannelId);
Chat_Control(m_szModuleName, wszChannelId, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE);
@@ -143,18 +149,8 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS
/////////////////////////////////////////////////////////////////////////////////////////
-void CDiscordProto::AddGuildUser(SnowFlake guildId, const CDiscordGuildMember &pUser)
+void CDiscordProto::AddGuildUser(CDiscordGuild *pGuild, const CDiscordGuildMember &pUser)
{
- const CDiscordUser *pChannel = nullptr;
- for (auto &it : arUsers)
- if (it->guildId == guildId) {
- pChannel = it;
- break;
- }
-
- if (pChannel == nullptr)
- return;
-
int flags = GC_SSE_ONLYLISTED;
switch (pUser.iStatus) {
case ID_STATUS_ONLINE: case ID_STATUS_NA: case ID_STATUS_DND:
@@ -165,7 +161,7 @@ void CDiscordProto::AddGuildUser(SnowFlake guildId, const CDiscordGuildMember &p
return;
}
- GCEVENT gce = { m_szModuleName, pChannel->wszUsername, GC_EVENT_JOIN };
+ GCEVENT gce = { m_szModuleName, pGuild->pParentSi->ptszID, GC_EVENT_JOIN };
gce.time = time(0);
gce.dwFlags = GCEF_SILENT;
@@ -178,7 +174,7 @@ void CDiscordProto::AddGuildUser(SnowFlake guildId, const CDiscordGuildMember &p
gce.ptszNick = pUser.wszNick;
Chat_Event(&gce);
- Chat_SetStatusEx(m_szModuleName, pChannel->wszUsername, flags, wszUserId);
+ Chat_SetStatusEx(m_szModuleName, pGuild->pParentSi->ptszID, flags, wszUserId);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -230,5 +226,5 @@ void CDiscordProto::ParseGuildContents(CDiscordGuild *pGuild, const JSONNode &pR
}
for (auto &pm : newMembers)
- AddGuildUser(pGuild->id, *pm);
+ AddGuildUser(pGuild, *pm);
}
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index f6a91aca67..129e9eee64 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -108,7 +108,7 @@ void CDiscordProto::OnModulesLoaded()
}
GCREGISTER gcr = {};
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_SHAREDUSERS;
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
Chat_Register(&gcr);
@@ -169,7 +169,7 @@ int CDiscordProto::SetStatus(int iNewStatus)
ShutdownSession();
}
m_iStatus = m_iDesiredStatus;
- setAllContactStatuses(ID_STATUS_OFFLINE, true);
+ setAllContactStatuses(ID_STATUS_OFFLINE, false);
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
}
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 5e6d537b24..a99bfa22d2 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -112,6 +112,7 @@ struct CDiscordGuild : public MZeroedObject
CMStringW wszName;
MCONTACT hContact;
+ GCSessionInfoBase *pParentSi;
OBJLIST<CDiscordGuildMember> arChatUsers;
OBJLIST<CDiscordRole> arRoles; // guild roles
};
@@ -227,7 +228,7 @@ class CDiscordProto : public PROTO<CDiscordProto>
}
void ProcessGuild(const JSONNode&);
- void AddGuildUser(SnowFlake guildId, const CDiscordGuildMember &pUser);
+ void AddGuildUser(CDiscordGuild *guild, const CDiscordGuildMember &pUser);
void ParseGuildContents(CDiscordGuild *guild, const JSONNode &);
CDiscordUser* ProcessGuildChannel(CDiscordGuild *guild, const JSONNode&);
void ProcessRole(CDiscordGuild *guild, const JSONNode&);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 4abff39ba8..b7404c1e4c 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -512,8 +512,7 @@ static void SM_InvalidateLogDirectories()
// Module Manager functions
// Necessary to keep track of all modules that has registered with the plugin
-GCModuleInfoBase::GCModuleInfoBase() :
- arUsers(1, CompareUser)
+GCModuleInfoBase::GCModuleInfoBase()
{}
GCModuleInfoBase::~GCModuleInfoBase()
@@ -843,13 +842,12 @@ BOOL UM_RemoveAll(SESSION_INFO *si)
if (!si)
return FALSE;
- if (!si->pMI->bSharedUsers) {
- auto &arUsers = si->getUserList();
- for (auto &ui : arUsers) {
+ if (!si->pParent) {
+ for (auto &ui : si->arUsers) {
mir_free(ui->pszUID);
mir_free(ui->pszNick);
}
- arUsers.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 c9e20939c5..55d2e56db8 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -170,7 +170,6 @@ 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();
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 9ac61b5ae7..8bc297ec50 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -360,12 +360,16 @@ static wchar_t szTrimString[] = L":,.!?;\'>)";
bool IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
- if (!g_Settings->bHighlightEnabled || !g_Settings->pszHighlightWords || !gce || !si || !si->pMe)
+ if (!g_Settings->bHighlightEnabled || !g_Settings->pszHighlightWords || !gce || !si)
return FALSE;
if (gce->ptszText == nullptr)
return FALSE;
+ USERINFO *pMe = si->getMe();
+ if (pMe == nullptr)
+ return FALSE;
+
wchar_t *buf = RemoveFormatting(NEWWSTR_ALLOCA(gce->ptszText));
int iStart = 0;
@@ -378,7 +382,7 @@ bool IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
// replace %m with the users nickname
if (tszToken == L"%m")
- tszToken = si->pMe->pszNick;
+ tszToken = pMe->pszNick;
if (tszToken.Find('*') == -1)
tszToken = '*' + tszToken + '*';
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 25c27789a7..7bbe2c533e 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -666,3 +666,4 @@ g_hevSettingChanged @696 NONAME
??1GCModuleInfoBase@@QAE@XZ @699 NONAME
??1GCSessionInfoBase@@QAE@XZ @700 NONAME
?getUserList@GCSessionInfoBase@@QAEAAU?$OBJLIST@UUSERINFO@@@@XZ @701 NONAME
+?getMe@GCSessionInfoBase@@QBEPAUUSERINFO@@XZ @702 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 3c09b922e7..c7260c9440 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -666,3 +666,4 @@ g_hevSettingChanged @696 NONAME
??1GCModuleInfoBase@@QEAA@XZ @699 NONAME
??1GCSessionInfoBase@@QEAA@XZ @700 NONAME
?getUserList@GCSessionInfoBase@@QEAAAEAU?$OBJLIST@UUSERINFO@@@@XZ @701 NONAME
+?getMe@GCSessionInfoBase@@QEBAPEAUUSERINFO@@XZ @702 NONAME