diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-01 08:34:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-01 08:34:43 +0000 |
commit | 3925d34399b4859a329f4f670e53dafcfeaae0dd (patch) | |
tree | cb4cd1450ed699e3f43a4d4dd2ce8306b076db70 /protocols/JabberG | |
parent | 00506aeae4b1668c73a0b7b98ba9084fca7331a2 (diff) |
fix for grabbing nick from the 'subscribe' presence
git-svn-id: http://svn.miranda-ng.org/main/trunk@6284 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
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;
}
|