diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-27 19:48:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-27 19:48:42 +0300 |
commit | 899221e2d058f5afe30bb2ecdbf168c8ad3c15a6 (patch) | |
tree | ea2346678575a4fc5fdd9575b6a9174bd30c70dc /protocols/JabberG | |
parent | c736d08681747a9453bd4c266f6dd54d8cbd79eb (diff) |
Group chats: all old APIs with lookup by module+session removed
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 22 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 23 |
3 files changed, 28 insertions, 28 deletions
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 90bf730ac4..6326adf716 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -109,16 +109,16 @@ int JabberGcGetStatus(JABBER_RESOURCE_STATUS *r) return JabberGcGetStatus(r->m_affiliation, r->m_role);
}
-int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
+SESSION_INFO* CJabberProto::GcInit(JABBER_LIST_ITEM *item)
{
if (item->si)
- return 1;
+ return item->si;
Utf2T wszJid(item->jid);
ptrA szNick(JabberNickFromJID(item->jid));
SESSION_INFO *si = item->si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszJid, Utf2T(szNick));
if (si == nullptr)
- return 2;
+ return nullptr;
item->hContact = si->hContact;
@@ -153,15 +153,15 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
Chat_AddGroup(si, TranslateW(Utf2T(sttStatuses[i])));
- Chat_Control(m_szModuleName, wszJid, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
- Chat_Control(m_szModuleName, wszJid, SESSION_ONLINE);
+ Chat_Control(si, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
+ Chat_Control(si, SESSION_ONLINE);
time_t lastDate = getDword(si->hContact, "LastGetVcard"), now = time(0);
if (now - lastDate > 24 * 60 * 60) {
SendGetVcard(si->hContact);
setDword(si->hContact, "LastGetVcard", now);
}
- return 0;
+ return si;
}
void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type)
@@ -226,7 +226,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus if (!buf.IsEmpty()) {
buf.Replace("%", "%%");
- GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_INFORMATION };
+ GCEVENT gce = { item->si, GC_EVENT_INFORMATION };
gce.dwFlags = GCEF_UTF8 + GCEF_ADDTOLOG;
gce.pszNick.a = gce.pszUID.a = user->m_szResourceName;
gce.pszText.a = buf;
@@ -251,7 +251,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *r if (myNick == nullptr)
myNick = JabberNickFromJID(m_szJabberJID);
- GCEVENT gce = { m_szModuleName, item->jid, 0 };
+ GCEVENT gce = { item->si, 0 };
gce.dwFlags = GCEF_UTF8 | ((item->bChatLogging) ? 0 : GCEF_SILENT);
gce.pszNick.a = nick;
gce.pszUID.a = resource;
@@ -292,7 +292,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *r int flags = GC_SSE_ONLYLISTED;
if (statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND)
flags += GC_SSE_ONLINE;
- Chat_SetStatusEx(m_szModuleName, Utf2T(item->jid), flags, Utf2T(nick));
+ Chat_SetStatusEx(item->si, flags, Utf2T(nick));
gce.iType = GC_EVENT_SETCONTACTSTATUS;
gce.pszText.a = nick;
@@ -320,9 +320,9 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, const TiXmlElement * Utf2T wszRoomJid(item->jid);
if (code == 200)
- Chat_Terminate(m_szModuleName, wszRoomJid);
+ Chat_Terminate(item->si);
else
- Chat_Control(m_szModuleName, wszRoomJid, SESSION_OFFLINE);
+ Chat_Control(item->si, SESSION_OFFLINE);
Contact::Hide(item->hContact, false);
item->si = nullptr;
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 719144a127..92f774fce6 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -768,11 +768,10 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const char *old setUString(hContact, "MyNick", newNick);
}
- Chat_ChangeUserId(m_szModuleName, Utf2T(item->jid), Utf2T(oldNick), Utf2T(newNick));
+ Chat_ChangeUserId(item->si, Utf2T(oldNick), Utf2T(newNick));
- GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_NICK };
+ GCEVENT gce = { item->si, GC_EVENT_NICK };
gce.dwFlags = GCEF_UTF8;
- gce.pszID.a = item->jid;
gce.pszUserInfo.a = jid;
gce.time = time(0);
gce.pszNick.a = oldNick;
@@ -1001,7 +1000,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node) if (!mir_strcmp(type, "error"))
return;
- GCEVENT gce = { m_szModuleName, item->jid, 0 };
+ GCEVENT gce = {};
gce.dwFlags = GCEF_UTF8;
const char *resource = strchr(from, '/'), *msgText;
@@ -1056,7 +1055,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node) else gce.iType = GC_EVENT_MESSAGE;
}
- GcInit(item);
+ gce.si = GcInit(item);
time_t msgTime = 0;
if (!JabberReadXep203delay(node, msgTime)) {
@@ -1095,7 +1094,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node) Chat_Event(&gce);
if (gce.iType == GC_EVENT_TOPIC)
- Chat_SetStatusbarText(m_szModuleName, Utf2T(item->jid), Utf2T(szText));
+ Chat_SetStatusbarText(item->si, Utf2T(szText));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index cf27af0ea8..c2eaba0b3f 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -445,17 +445,18 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface //---- jabber_chat.cpp ---------------------------------------------------------------
- int GcInit(JABBER_LIST_ITEM *item);
- void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode = -1);
- void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type);
- void GcQuit(JABBER_LIST_ITEM* jid, int code, const TiXmlElement *reason);
-
- void AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal);
- void AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo, void *pInfo = nullptr);
- void AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn);
- void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str);
- void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *reason);
- void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char* jid);
+ SESSION_INFO* GcInit(JABBER_LIST_ITEM *item);
+
+ void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode = -1);
+ void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type);
+ void GcQuit(JABBER_LIST_ITEM* jid, int code, const TiXmlElement *reason);
+
+ void AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal);
+ void AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo, void *pInfo = nullptr);
+ void AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *reason);
+ void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char* jid);
//---- jabber_console.cpp ------------------------------------------------------------
|