From 3925d34399b4859a329f4f670e53dafcfeaae0dd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 1 Oct 2013 08:34:43 +0000 Subject: fix for grabbing nick from the 'subscribe' presence git-svn-id: http://svn.miranda-ng.org/main/trunk@6284 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_thread.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 48a14ebc1d..11c27885ca 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1716,6 +1716,16 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info) if (hContact = HContactFromJID(from)) AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBE); + ptrT tszNick( JabberNickFromJID(from)); + HXML xNick = xmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK); + if (xNick != NULL) { + LPCTSTR xszNick = xmlGetText(xNick); + if (xszNick != NULL && *xszNick) { + Log("Grabbed nick from presence: %S", xszNick); + tszNick = mir_tstrdup(xszNick); + } + } + // automatically send authorization allowed to agent/transport if (_tcschr(from, '@') == NULL || m_options.AutoAcceptAuthorization) { ListAdd(LIST_ROSTER, from); @@ -1724,21 +1734,18 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info) if (m_options.AutoAdd == TRUE) { if ((item = ListGetItemPtr(LIST_ROSTER, from)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { Log("Try adding contact automatically jid = %S", from); - if ((hContact=AddToListByJID(from, 0)) != NULL) { - // Trigger actual add by removing the "NotOnList" added by AddToListByJID() - // See AddToListByJID() and JabberDbSettingChanged(). + if ((hContact = AddToListByJID(from, 0)) != NULL) { + db_set_ts(hContact, "CList", "Nick", tszNick); db_unset(hContact, "CList", "NotOnList"); - } } } + } + } + } RebuildInfoFrame(); } else { - HXML n = xmlGetChild(node, "nick"); - nick = (n == NULL) ? JabberNickFromJID(from) : mir_tstrdup(xmlGetText(n)); - if (nick != NULL) { - Log("%S (%S) requests authorization", nick, from); - DBAddAuthRequest(from, nick); - mir_free(nick); - } } + Log("%S (%S) requests authorization", tszNick, from); + DBAddAuthRequest(from, tszNick); + } return; } -- cgit v1.2.3