[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/jabber
From:       Pali Rohár <pali.rohar () gmail ! com>
Date:       2013-06-02 9:55:37
Message-ID: 20130602095537.171DDAC85D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1356782 by pali:

Show real jabber resource assigned from server for jabber myself contact

* Jabber server can force us which resource to use, but Kopete show only resource \
                configured in account dialog
* This patch update jabber resource for myself contact after jabber server return it


 M  +32 -2     jabberaccount.cpp  
 M  +3 -0      jabberaccount.h  


--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberaccount.cpp #1356781:1356782
@@ -1093,15 +1093,45 @@
 	newStatus.setPriority ( newPriority );
 	kDebug(JABBER_DEBUG_GLOBAL) << "New priority: " << newPriority;
 
-	XMPP::Jid jid ( myself()->contactId () );
-	XMPP::Resource newResource ( resource (), newStatus );
+	XMPP::Jid jid;
 
+	if ( client() )
+		jid = client()->jid ();
+
+	if ( jid.isEmpty() && myself() )
+		jid = myself()->contactId ();
+
+	if ( jid.isEmpty() )
+		return;
+
+	XMPP::Resource oldResource ( m_lastResource );
+
+	kDebug(JABBER_DEBUG_GLOBAL) << "Old resource:" << m_lastResource;
+
+	// update resource from jabber client
+	m_lastResource = jid.resource();
+	if ( m_lastResource.isEmpty() )
+		m_lastResource = resource();
+
+	XMPP::Resource newResource ( m_lastResource, newStatus );
+
+	// for resource pool we need capabilities manager
+	// JabberAccount::setPresence can be called when deleting JabberAccount
+	if (protocol() && protocol()->capabilitiesManager())
+	{
 	// update our resource in the resource pool
 	resourcePool()->addResource ( jid, newResource );
 
 	// make sure that we only consider our own resource locally
 	resourcePool()->lockToResource ( jid, newResource );
 
+		// remove old resource if was changed and was not empty
+		if ( ! oldResource.name().isEmpty() && oldResource.name() != newResource.name() )
+			resourcePool()->removeResource ( jid, oldResource );
+	}
+
+	kDebug(JABBER_DEBUG_GLOBAL) << "New resource:" << m_lastResource;
+
 	/*
 	 * Unless we are in the connecting status, send a presence packet to the server
 	 */
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberaccount.h #1356781:1356782
@@ -253,6 +253,9 @@
 	   jabber transfer port, to avoid popup insanity */
 	bool m_notifiedUserCannotBindTransferPort;
 
+	/* last resource for this account */
+	QString m_lastResource;
+
 #ifdef GOOGLETALK_SUPPORT
 	GoogleTalk * m_googleTalk;
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic