diff options
-rw-r--r-- | protocols/JabberG/src/jabber_iq_handlers.cpp | 26 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_iqid.cpp | 66 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 2 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 29 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_strm_mgmt.cpp | 2 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_thread.cpp | 70 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_util.cpp | 31 |
7 files changed, 94 insertions, 132 deletions
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index d29f87b706..7e0af838b6 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -210,32 +210,10 @@ bool CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo db_set_utf(hContact, m_szModuleName, "jid", jid);
JABBER_LIST_ITEM *item = ListAdd(LIST_ROSTER, jid, hContact);
- replaceStr(item->nick, nick);
item->bRealContact = true;
-
+ replaceStr(item->nick, nick);
replaceStr(item->group, XmlGetChildText(itemNode, "group"));
-
- if (name != nullptr) {
- ptrA tszNick(getUStringA(hContact, "Nick"));
- if (tszNick != nullptr) {
- if (!m_bIgnoreRoster) {
- if (mir_strcmp(nick, tszNick) != 0)
- db_set_utf(hContact, "CList", "MyHandle", nick);
- else
- db_unset(hContact, "CList", "MyHandle");
- }
- }
- else db_set_utf(hContact, "CList", "MyHandle", nick);
- }
- else db_unset(hContact, "CList", "MyHandle");
-
- if (!m_bIgnoreRoster) {
- if (item->group != nullptr) {
- Clist_GroupCreate(0, Utf2T(item->group));
- db_set_utf(hContact, "CList", "Group", item->group);
- }
- else db_unset(hContact, "CList", "Group");
- }
+ UpdateItem(item, name);
}
}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index a37df3e741..a9496a5d41 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -89,23 +89,20 @@ void CJabberProto::OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJab bPrivateStorageSupport = true;
auto *xmlDelimiter = XmlGetChildByTag(XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_PRIVATE_STORAGE), "roster", "xmlns", JABBER_FEAT_NESTED_ROSTER_GROUPS);
if (xmlDelimiter)
- szGroupDelimiter = xmlDelimiter->GetText();
+ if (!mir_strcmp(szGroupDelimiter = xmlDelimiter->GetText(), "\\"))
+ szGroupDelimiter = nullptr;
}
- // global fuckup
- if (m_ThreadInfo == nullptr)
- return;
-
// is our default delimiter?
- if ((!szGroupDelimiter && bPrivateStorageSupport) || (szGroupDelimiter && mir_strcmp(szGroupDelimiter, "\\")))
+ if (!szGroupDelimiter && bPrivateStorageSupport)
m_ThreadInfo->send(
XmlNodeIq("set", SerialNext()) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
<< XCHILD("roster", "\\") << XATTR("xmlns", JABBER_FEAT_NESTED_ROSTER_GROUPS));
// roster request
- char *szUserData = mir_strdup(szGroupDelimiter ? szGroupDelimiter : "\\");
+ m_szGroupDelimiter = mir_strdup(szGroupDelimiter);
m_ThreadInfo->send(
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, nullptr, szUserData))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET))
<< XCHILDNS("query", JABBER_FEAT_IQ_ROSTER));
}
@@ -363,7 +360,6 @@ void CJabberProto::GroupchatJoinByHContact(MCONTACT hContact, bool autojoin) void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
debugLogA("<iq/> iqIdGetRoster");
- ptrA szGroupDelimiter((char *)pInfo->GetUserData());
if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT)
return;
@@ -374,9 +370,6 @@ void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo if (mir_strcmp(XmlGetAttr(queryNode, "xmlns"), JABBER_FEAT_IQ_ROSTER))
return;
- if (!mir_strcmp(szGroupDelimiter, "\\"))
- szGroupDelimiter = nullptr;
-
LIST<void> chatRooms(10);
OBJLIST<JABBER_HTTP_AVATARS> *httpavatars = new OBJLIST<JABBER_HTTP_AVATARS>(20, JABBER_HTTP_AVATARS::compare);
@@ -410,55 +403,21 @@ void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo item->subscription = sub;
item->bRealContact = true;
- mir_free(item->nick); item->nick = nick;
+ replaceStr(item->nick, nick);
replaceStr(item->group, XmlGetChildText(itemNode, "group"));
-
- // check group delimiters
- if (item->group && szGroupDelimiter) {
- CMStringA szNewGroup(item->group);
- szNewGroup.Replace(szGroupDelimiter, "\\");
- replaceStr(item->group, szNewGroup.Detach());
- }
-
- if (name != nullptr) {
- ptrA tszNick(getUStringA(hContact, "Nick"));
- if (tszNick != nullptr) {
- if (!m_bIgnoreRoster) {
- if (mir_strcmp(nick, tszNick) != 0)
- db_set_utf(hContact, "CList", "MyHandle", nick);
- else
- db_unset(hContact, "CList", "MyHandle");
- }
- }
- else db_set_utf(hContact, "CList", "MyHandle", nick);
- }
- else db_unset(hContact, "CList", "MyHandle");
+ UpdateItem(item, name);
if (isChatRoom(hContact)) {
- char *wszTitle = NEWSTR_ALLOCA(jid);
- if (char *p = strchr(wszTitle, '@')) *p = 0;
- Chat_NewSession(GCW_CHATROOM, m_szModuleName, Utf2T(jid), Utf2T(wszTitle));
+ char *szTitle = NEWSTR_ALLOCA(jid);
+ if (char *p = strchr(szTitle, '@'))
+ *p = 0;
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, Utf2T(jid), Utf2T(szTitle));
Contact_Hide(hContact, false);
chatRooms.insert((HANDLE)hContact);
}
else UpdateSubscriptionInfo(hContact, item);
- if (!m_bIgnoreRoster) {
- if (item->group != nullptr) {
- Clist_GroupCreate(0, Utf2T(item->group));
-
- // Don't set group again if already correct, or Miranda may show wrong group count in some case
- ptrA tszGroup(db_get_utfa(hContact, "CList", "Group"));
- if (tszGroup != nullptr) {
- if (mir_strcmp(tszGroup, item->group))
- db_set_utf(hContact, "CList", "Group", item->group);
- }
- else db_set_utf(hContact, "CList", "Group", item->group);
- }
- else db_unset(hContact, "CList", "Group");
- }
-
if (hContact != 0) {
if (bIsTransport)
setByte(hContact, "IsTransport", true);
@@ -502,9 +461,6 @@ void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
- if (szGroupDelimiter)
- mir_free(szGroupDelimiter);
-
OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_ROSTER);
RebuildInfoFrame();
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 2a0db6ff00..8980e02cba 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -236,7 +236,7 @@ CJabberProto::~CJabberProto() ListWipe();
mir_free(m_tszSelectedLang);
- mir_free(m_AuthMechs.m_gssapiHostName);
+ mir_free(m_gssapiHostName);
mir_free(m_modeMsgs.szOnline);
mir_free(m_modeMsgs.szAway);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index ed7ab8584a..110eb41083 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -647,6 +647,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface void OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hContact, bool &hasPhoto);
void SetBookmarkRequest(XmlNodeIq &iqId);
+ void UpdateItem(JABBER_LIST_ITEM *pItem, const char *name);
//---- jabber_menu.cpp ---------------------------------------------------------------
@@ -775,23 +776,19 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface bool SendHttpAuthReply(CJabberHttpAuthParams *pParams, bool bAuthorized);
//---- jabber_thread.c ----------------------------------------------
-
+ ptrA m_szGroupDelimiter;
ptrW m_savedPassword;
- typedef struct {
- bool isPlainAvailable;
- bool isPlainOldAvailable;
- bool isMd5Available;
- bool isScramAvailable;
- bool isNtlmAvailable;
- bool isSpnegoAvailable;
- bool isKerberosAvailable;
- bool isAuthAvailable;
- bool isSessionAvailable;
- char *m_gssapiHostName;
- } AUTHMECHS;
-
- AUTHMECHS m_AuthMechs;
+ bool m_isPlainAvailable;
+ bool m_isPlainOldAvailable;
+ bool m_isMd5Available;
+ bool m_isScramAvailable;
+ bool m_isNtlmAvailable;
+ bool m_isSpnegoAvailable;
+ bool m_isKerberosAvailable;
+ bool m_isAuthAvailable;
+ bool m_isSessionAvailable;
+ char* m_gssapiHostName;
void __cdecl ServerThread(JABBER_CONN_DATA *info);
@@ -843,7 +840,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface void RebuildInfoFrame(void);
void InitInfoFrame(void);
-
+
// returns buf or nullptr on error
char* GetClientJID(MCONTACT hContact, char *dest, size_t destLen);
char* GetClientJID(const char *jid, char *dest, size_t destLen);
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp index 94b89e4eae..151de8203e 100755 --- a/protocols/JabberG/src/jabber_strm_mgmt.cpp +++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp @@ -275,7 +275,7 @@ void strm_mgmt::FinishLoginProcess(ThreadData *info) << XCHILDNS("bind", JABBER_FEAT_BIND)
<< XCHILD("resource", info->resource));
- if (proto->m_AuthMechs.isSessionAvailable)
+ if (proto->m_isSessionAvailable)
info->bIsSessionAvailable = true;
return;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index b8c0206230..fb01d0f0c5 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -593,8 +593,8 @@ void CJabberProto::PerformAuthentication(ThreadData *info) info->auth = nullptr;
}
- if (m_AuthMechs.isSpnegoAvailable) {
- m_AuthMechs.isSpnegoAvailable = false;
+ if (m_isSpnegoAvailable) {
+ m_isSpnegoAvailable = false;
auth = new TNtlmAuth(info, "GSS-SPNEGO");
if (!auth->isValid()) {
delete auth;
@@ -602,9 +602,9 @@ void CJabberProto::PerformAuthentication(ThreadData *info) }
}
- if (auth == nullptr && m_AuthMechs.isKerberosAvailable) {
- m_AuthMechs.isKerberosAvailable = false;
- auth = new TNtlmAuth(info, "GSSAPI", m_AuthMechs.m_gssapiHostName);
+ if (auth == nullptr && m_isKerberosAvailable) {
+ m_isKerberosAvailable = false;
+ auth = new TNtlmAuth(info, "GSSAPI", m_gssapiHostName);
if (!auth->isValid()) {
delete auth;
auth = nullptr;
@@ -618,8 +618,8 @@ void CJabberProto::PerformAuthentication(ThreadData *info) }
}
- if (auth == nullptr && m_AuthMechs.isNtlmAvailable) {
- m_AuthMechs.isNtlmAvailable = false;
+ if (auth == nullptr && m_isNtlmAvailable) {
+ m_isNtlmAvailable = false;
auth = new TNtlmAuth(info, "NTLM");
if (!auth->isValid()) {
delete auth;
@@ -627,29 +627,29 @@ void CJabberProto::PerformAuthentication(ThreadData *info) }
}
- if (auth == nullptr && m_AuthMechs.isScramAvailable) {
- m_AuthMechs.isScramAvailable = false;
+ if (auth == nullptr && m_isScramAvailable) {
+ m_isScramAvailable = false;
auth = new TScramAuth(info);
}
- if (auth == nullptr && m_AuthMechs.isMd5Available) {
- m_AuthMechs.isMd5Available = false;
+ if (auth == nullptr && m_isMd5Available) {
+ m_isMd5Available = false;
auth = new TMD5Auth(info);
}
- if (auth == nullptr && m_AuthMechs.isPlainAvailable) {
- m_AuthMechs.isPlainAvailable = false;
+ if (auth == nullptr && m_isPlainAvailable) {
+ m_isPlainAvailable = false;
auth = new TPlainAuth(info, false);
}
- if (auth == nullptr && m_AuthMechs.isPlainOldAvailable) {
- m_AuthMechs.isPlainOldAvailable = false;
+ if (auth == nullptr && m_isPlainOldAvailable) {
+ m_isPlainOldAvailable = false;
auth = new TPlainAuth(info, true);
}
if (auth == nullptr) {
- if (m_AuthMechs.isAuthAvailable) { // no known mechanisms but iq_auth is available
- m_AuthMechs.isAuthAvailable = false;
+ if (m_isAuthAvailable) { // no known mechanisms but iq_auth is available
+ m_isAuthAvailable = false;
PerformIqAuth(info);
return;
}
@@ -702,37 +702,37 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) }
if (!mir_strcmp(pszName, "mechanisms")) {
- m_AuthMechs.isPlainAvailable = false;
- m_AuthMechs.isPlainOldAvailable = false;
- m_AuthMechs.isMd5Available = false;
- m_AuthMechs.isScramAvailable = false;
- m_AuthMechs.isNtlmAvailable = false;
- m_AuthMechs.isSpnegoAvailable = false;
- m_AuthMechs.isKerberosAvailable = false;
- mir_free(m_AuthMechs.m_gssapiHostName); m_AuthMechs.m_gssapiHostName = nullptr;
+ m_isPlainAvailable = false;
+ m_isPlainOldAvailable = false;
+ m_isMd5Available = false;
+ m_isScramAvailable = false;
+ m_isNtlmAvailable = false;
+ m_isSpnegoAvailable = false;
+ m_isKerberosAvailable = false;
+ mir_free(m_gssapiHostName); m_gssapiHostName = nullptr;
areMechanismsDefined = true;
//JabberLog("%d mechanisms\n",n->numChild);
for (auto *c : TiXmlEnum(n)) {
if (!mir_strcmp(c->Name(), "mechanism")) {
const char *szMechanism = c->GetText();
- if (!mir_strcmp(szMechanism, "PLAIN")) m_AuthMechs.isPlainOldAvailable = m_AuthMechs.isPlainAvailable = true;
- else if (!mir_strcmp(szMechanism, "DIGEST-MD5")) m_AuthMechs.isMd5Available = true;
- else if (!mir_strcmp(szMechanism, "SCRAM-SHA-1")) m_AuthMechs.isScramAvailable = true;
- else if (!mir_strcmp(szMechanism, "NTLM")) m_AuthMechs.isNtlmAvailable = true;
- else if (!mir_strcmp(szMechanism, "GSS-SPNEGO")) m_AuthMechs.isSpnegoAvailable = true;
- else if (!mir_strcmp(szMechanism, "GSSAPI")) m_AuthMechs.isKerberosAvailable = true;
+ if (!mir_strcmp(szMechanism, "PLAIN")) m_isPlainOldAvailable = m_isPlainAvailable = true;
+ else if (!mir_strcmp(szMechanism, "DIGEST-MD5")) m_isMd5Available = true;
+ else if (!mir_strcmp(szMechanism, "SCRAM-SHA-1")) m_isScramAvailable = true;
+ else if (!mir_strcmp(szMechanism, "NTLM")) m_isNtlmAvailable = true;
+ else if (!mir_strcmp(szMechanism, "GSS-SPNEGO")) m_isSpnegoAvailable = true;
+ else if (!mir_strcmp(szMechanism, "GSSAPI")) m_isKerberosAvailable = true;
}
else if (!mir_strcmp(c->Name(), "hostname")) {
const char *mech = XmlGetAttr(c, "mechanism");
if (mech && mir_strcmpi(mech, "GSSAPI") == 0)
- m_AuthMechs.m_gssapiHostName = mir_strdup(c->GetText());
+ m_gssapiHostName = mir_strdup(c->GetText());
}
}
}
else if (!mir_strcmp(pszName, "register")) isRegisterAvailable = true;
- else if (!mir_strcmp(pszName, "auth")) m_AuthMechs.isAuthAvailable = true;
- else if (!mir_strcmp(pszName, "session")) m_AuthMechs.isSessionAvailable = true;
+ else if (!mir_strcmp(pszName, "auth")) m_isAuthAvailable = true;
+ else if (!mir_strcmp(pszName, "session")) m_isSessionAvailable = true;
else if (m_bEnableStreamMgmt && !mir_strcmp(pszName, "sm"))
m_StrmMgmt.CheckStreamFeatures(n);
else if (!mir_strcmp(pszName, "csi") && n->Attribute("xmlns", JABBER_FEAT_CSI))
@@ -757,7 +757,7 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) << XCHILDNS("bind", JABBER_FEAT_BIND)
<< XCHILD("resource", info->resource));
- if (m_AuthMechs.isSessionAvailable)
+ if (m_isSessionAvailable)
info->bIsSessionAvailable = true;
return;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 6a079d734e..0e02fe260a 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -76,6 +76,37 @@ CMStringA MakeJid(const char *jid, const char *resource) return ret;
}
+void CJabberProto::UpdateItem(JABBER_LIST_ITEM *pItem, const char *name)
+{
+ if (name != nullptr) {
+ ptrA tszNick(getUStringA(pItem->hContact, "Nick"));
+ if (tszNick != nullptr) {
+ if (!m_bIgnoreRoster) {
+ if (mir_strcmp(pItem->nick, tszNick) != 0)
+ db_set_utf(pItem->hContact, "CList", "MyHandle", pItem->nick);
+ else
+ db_unset(pItem->hContact, "CList", "MyHandle");
+ }
+ }
+ else db_set_utf(pItem->hContact, "CList", "MyHandle", pItem->nick);
+ }
+ else db_unset(pItem->hContact, "CList", "MyHandle");
+
+ // check group delimiters
+ if (pItem->group && m_szGroupDelimiter) {
+ CMStringA szNewGroup(pItem->group);
+ szNewGroup.Replace(m_szGroupDelimiter, "\\");
+ replaceStr(pItem->group, szNewGroup.Detach());
+ }
+
+ if (!m_bIgnoreRoster) {
+ if (pItem->group != nullptr) {
+ Clist_GroupCreate(0, Utf2T(pItem->group));
+ db_set_utf(pItem->hContact, "CList", "Group", pItem->group);
+ }
+ else db_unset(pItem->hContact, "CList", "Group");
+ }
+}
char* JabberNickFromJID(const char *jid)
{
|