From 1bf0fece31876c453bea93479e6d0d40bd8a564d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Feb 2019 00:26:13 +0300 Subject: fixes #1865 (Joining Password Protected Jabber Conference is not working since last updates) + code cleaning --- protocols/JabberG/src/jabber_chat.cpp | 2 +- protocols/JabberG/src/jabber_groupchat.cpp | 14 +++++++------- protocols/JabberG/src/jabber_proto.cpp | 6 +++--- protocols/JabberG/src/jabber_proto.h | 8 ++++---- protocols/JabberG/src/jabber_util.cpp | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'protocols') diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index e29c2a9d75..5baaf0ddb5 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1258,7 +1258,7 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g if (ppro->ListGetItemPtr(LIST_CHATROOM, roomJid) != nullptr) { char text[1024]; mir_snprintf(text, "%s/%s", roomJid.get(), szBuffer.c_str()); - ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, nullptr); + ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text); } } break; diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 2719ba4690..a23038c6a2 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -255,11 +255,11 @@ void CJabberProto::GroupchatJoinRoom(const char *server, const char *room, const replaceStr(item->password, info.m_password); int status = (m_iStatus == ID_STATUS_INVISIBLE) ? ID_STATUS_ONLINE : m_iStatus; - XmlNode x("x"); x << XATTR("xmlns", JABBER_FEAT_MUC); - if (info.m_password && info.m_password[0]) - x << XCHILD("password", info.m_password); - - SendPresenceTo(status, text, x.ToElement()); + if (mir_strlen(info.m_password)) { + XmlNode x("x"); x << XATTR("xmlns", JABBER_FEAT_MUC) << XCHILD("password", info.m_password); + SendPresenceTo(status, text, x); + } + else SendPresenceTo(status, text); } //////////////////////////////////////////////////////////////////////////////// @@ -744,7 +744,7 @@ static VOID CALLBACK JabberGroupchatChangeNickname(void* arg) if (param->ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) { T2Utf newNick(szBuffer); replaceStr(item->nick, newNick); - param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringA(FORMAT, "%s/%s", item->jid, newNick.get()), nullptr); + param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringA(FORMAT, "%s/%s", item->jid, newNick.get())); } } @@ -992,7 +992,7 @@ void CJabberProto::GroupchatProcessPresence(const TiXmlElement *node) replaceStr(item->nick, newNick); char text[1024]; mir_snprintf(text, "%s/%s", item->jid, newNick); - SendPresenceTo(m_iStatus, text, nullptr); + SendPresenceTo(m_iStatus, text); } else { CallFunctionAsync(JabberGroupchatChangeNickname, new JabberGroupchatChangeNicknameParam(this, from)); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 6547c4accc..9533b031dc 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -1064,13 +1064,13 @@ int CJabberProto::SetApparentMode(MCONTACT hContact, int mode) break; case ID_STATUS_OFFLINE: if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE) - SendPresenceTo(ID_STATUS_INVISIBLE, jid, nullptr); + SendPresenceTo(ID_STATUS_INVISIBLE, jid); break; case 0: if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE) - SendPresenceTo(ID_STATUS_INVISIBLE, jid, nullptr); + SendPresenceTo(ID_STATUS_INVISIBLE, jid); else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE) - SendPresenceTo(m_iStatus, jid, nullptr); + SendPresenceTo(m_iStatus, jid); break; } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 4714ce05fa..b2b0ed2a3e 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -809,7 +809,7 @@ struct CJabberProto : public PROTO, public IJabberInterface MCONTACT HContactFromJID(const char *jid, bool bStripResource = true); MCONTACT ChatRoomHContactFromJID(const char *jid); void SendVisibleInvisiblePresence(bool invisible); - void SendPresenceTo(int status, const char* to, TiXmlElement *extra, const char *msg = nullptr); + void SendPresenceTo(int status, const char* to, const TiXmlElement *extra = nullptr, const char *msg = nullptr); void SendPresence(int m_iStatus, bool bSendToAll); void RebuildInfoFrame(void); @@ -819,9 +819,9 @@ struct CJabberProto : public PROTO, public IJabberInterface char* GetClientJID(MCONTACT hContact, char *dest, size_t destLen); char* GetClientJID(const char *jid, char *dest, size_t destLen); - void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount=JABBER_DEFAULT_RECENT_COUNT); - void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount=JABBER_DEFAULT_RECENT_COUNT); - BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0); + void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount = JABBER_DEFAULT_RECENT_COUNT); + void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount = JABBER_DEFAULT_RECENT_COUNT); + BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount = JABBER_DEFAULT_RECENT_COUNT, int timeout = 0); bool IsMyOwnJID(const char *szJID); void __cdecl LoadHttpAvatars(void* param); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 659d3b391f..7ae125f069 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -301,7 +301,7 @@ void CJabberProto::SendVisibleInvisiblePresence(bool invisible) if (invisible && apparentMode == ID_STATUS_OFFLINE) m_ThreadInfo->send(XmlNode("presence") << XATTR("to", item->jid) << XATTR("type", "invisible")); else if (!invisible && apparentMode == ID_STATUS_ONLINE) - SendPresenceTo(m_iStatus, item->jid, nullptr); + SendPresenceTo(m_iStatus, item->jid); } } @@ -356,7 +356,7 @@ time_t JabberIsoToUnixTime(const char *stamp) return (t >= 0) ? t : 0; } -void CJabberProto::SendPresenceTo(int status, const char *to, TiXmlElement *extra, const char *msg) +void CJabberProto::SendPresenceTo(int status, const char *to, const TiXmlElement *extra, const char *msg) { if (!m_bJabberOnline) return; @@ -372,7 +372,7 @@ void CJabberProto::SendPresenceTo(int status, const char *to, TiXmlElement *extr p << XATTR("to", to); if (extra) - p.InsertEndChild(extra); + p.InsertEndChild(extra->DeepClone(&p)->ToElement()); // XEP-0115:Entity Capabilities if (m_bAllowVersionRequests) { @@ -486,7 +486,7 @@ void CJabberProto::SendPresenceTo(int status, const char *to, TiXmlElement *extr void CJabberProto::SendPresence(int status, bool bSendToAll) { - SendPresenceTo(status, nullptr, nullptr); + SendPresenceTo(status, nullptr); SendVisibleInvisiblePresence(status == ID_STATUS_INVISIBLE); // Also update status in all chatrooms @@ -497,7 +497,7 @@ void CJabberProto::SendPresence(int status, bool bSendToAll) if (item != nullptr && item->nick != nullptr) { char text[1024]; mir_snprintf(text, "%s/%s", item->jid, item->nick); - SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, nullptr); + SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text); } } } -- cgit v1.2.3