[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:       2012-12-11 0:55:29
Message-ID: 20121211005529.8E316AC867 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1328050 by pali:

Fix support for show Client Name & Version & OS for Jabber contacts in GUI

Use Capabilities Manager as fallback method for Name & Version (this can be read from \
capabilities cache) Ask Jabber contact for Client strings only if it reports support \
via "jabber:iq:version" disco info


 M  +27 -3     jabberbasecontact.cpp  
 M  +17 -5     jabberresource.cpp  
 M  +5 -0      jabberresource.h  


--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberbasecontact.cpp \
#1328049:1328050 @@ -39,6 +39,7 @@
 #include "jabberaccount.h"
 #include "jabberresource.h"
 #include "jabberresourcepool.h"
+#include "jabbercapabilitiesmanager.h"
 #include "kopetemetacontact.h"
 #include "kopetemessage.h"
 #include "kopeteuiglobal.h"
@@ -238,12 +239,35 @@
 								 (*it)->resource().name (), QString::number ( (*it)->resource().priority () \
) );  
 		// client name, version, OS
-		if ( !(*it)->clientName().isEmpty () )
+		QString clientName = (*it)->clientName ();
+		QString clientVersion = (*it)->clientVersion ();
+		QString clientSystem = (*it)->clientSystem ();
+
+		if ( clientName.isEmpty () )
 		{
-			resourceListStr += QString ( "<tr><td>%1: %2 (%3)</td></tr>" ).
-							   arg ( i18n ( "Client" ), (*it)->clientName (), (*it)->clientSystem () );
+			clientName = account()->protocol()->capabilitiesManager()->clientName ( \
(*it)->jid () );  }
 		
+		if ( clientVersion.isEmpty () )
+		{
+			clientVersion = account()->protocol()->capabilitiesManager()->clientVersion ( \
(*it)->jid () ); +		}
+
+		if ( !clientName.isEmpty () )
+		{
+			QString clientNameVersion = clientName;
+			if ( !clientVersion.isEmpty () )
+			{
+				clientNameVersion += ' ' + clientVersion;
+			}
+			resourceListStr += QString ( "<tr><td>%1: %2" ).arg ( i18n ( "Client" ), \
clientNameVersion ); +			if ( !clientSystem.isEmpty () )
+			{
+				resourceListStr += QString ( " (%1)" ).arg ( clientSystem );
+			}
+			resourceListStr += QString ( "</td></tr>" );
+		}
+		
 		// Supported features
 #if 0  //disabled because it's just an ugly and long list of incomprehensible \
namespaces to the user  QStringList supportedFeatures = (*it)->features().list();
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberresource.cpp #1328049:1328050
@@ -47,7 +47,7 @@
 	XMPP::Jid jid;
 	XMPP::Resource resource;
 	
-	QString clientName, clientSystem;
+	QString clientName, clientVersion, clientSystem;
 	XMPP::Features supportedFeatures;
 	bool capsEnabled;
 };
@@ -63,15 +63,16 @@
 
 	if ( account->isConnected () )
 	{
-#if 0  //disabled because that flood the server, specially bad with the irc gateway
-		QTimer::singleShot ( account->client()->getPenaltyTime () * 1000, this, SLOT \
                (slotGetTimedClientVersion()) );
-#endif
 		if(!d->capsEnabled)
 		{
 			QTimer::singleShot ( account->client()->getPenaltyTime () * 1000, this, SLOT \
(slotGetDiscoCapabilties()) );  }
+		else if(cm->features(jid).list().contains("jabber:iq:version"))
+		{
+			QTimer::singleShot ( account->client()->getPenaltyTime () * 1000, this, SLOT \
(slotGetTimedClientVersion()) );  }
 }
+}
 
 JabberResource::~JabberResource ()
 {
@@ -103,6 +104,11 @@
 	return d->clientName;
 }
 
+const QString &JabberResource::clientVersion () const
+{
+	return d->clientVersion;
+}
+
 const QString &JabberResource::clientSystem () const
 {
 	return d->clientSystem;
@@ -141,7 +147,8 @@
 
 	if ( clientVersion->success () )
 	{
-		d->clientName = clientVersion->name () + ' ' + clientVersion->version ();
+		d->clientName = clientVersion->name ();
+		d->clientVersion = clientVersion->version ();
 		d->clientSystem = clientVersion->os ();
 
 		emit updated ( this );
@@ -170,6 +177,11 @@
 	{
 		d->supportedFeatures = discoInfo->item().features();
 		
+		if(d->supportedFeatures.list().contains("jabber:iq:version"))
+		{
+			QTimer::singleShot ( d->account->client()->getPenaltyTime () * 1000, this, SLOT \
(slotGetTimedClientVersion()) ); +		}
+
 		emit updated ( this );
 	}
 }
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberresource.h #1328049:1328050
@@ -56,6 +56,11 @@
 	 */
 	const QString &clientName () const;
 	/**
+	 * Return the client version for this resource.
+	 * @return the client version
+	 */
+	const QString &clientVersion () const;
+	/**
 	 * Return the client system for this resource.
 	 * @return the client system.
 	 */


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

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