Re: X-google-token causing problems with gloox
From: Jakob Schroeter <js@xxxxxxxxxx>
Date: Tue, 16 Mar 2010 17:38:24 +0100 (CET)
Quoting satyam saxena <satty8610@xxxxxxxxx>:

Hi,
Thanx a lot for the help. I configured gloox with openssl and the encryption
problem was solved.
But now there's a problem with JID. It gives the error:
"If set, the &apos;from&apos; attribute must be set to the user&apos;s full
JID"

Hi,

That's a bug with using non-SASL authentication (which is not necessary with gtalk). Fixed in SVN, patch attached.

cheers,
Jakob
Index: src/clientbase.h
===================================================================
--- src/clientbase.h    (revision 4349)
+++ src/clientbase.h    (revision 4350)
@@ -830,8 +830,10 @@
       /** A list of permanent presence extensions. */
       StanzaExtensionList m_presenceExtensions;
 
-      std::string m_selectedResource;    /**< The currently selected resource.
-                                          * See Client::selectResource() and 
Client::binRessource(). */
+      GLOOX_DEPRECATED std::string m_selectedResource; /**< The currently 
selected resource.
+                                          * See Client::selectResource() and 
Client::bindRessource().
+                                          * @deprecated Not used anymore. Will 
be removed for 1.1.
+                                          * @todo Remove for 1.1 */
       std::string m_clientCerts;         /**< TLS client certificates. */
       std::string m_clientKey;           /**< TLS client private key. */
       std::string m_namespace;           /**< Default namespace. */
Index: src/clientbase.cpp
===================================================================
--- src/clientbase.cpp  (revision 4349)
+++ src/clientbase.cpp  (revision 4350)
@@ -862,10 +862,7 @@
     if( !m_authed /*for IQ Auth */ || !tag || tag->hasAttribute( "from" ) )
       return;
 
-    if ( m_selectedResource.empty() )
-      tag->addAttribute( "from", m_jid.bare() );
-    else
-      tag->addAttribute( "from", m_jid.bare() + '/' + m_selectedResource );
+    tag->addAttribute( "from", m_jid.full() );
   }
 
   void ClientBase::addNamespace( Tag* tag )
Index: src/client.cpp
===================================================================
--- src/client.cpp      (revision 4349)
+++ src/client.cpp      (revision 4350)
@@ -438,11 +438,12 @@
 
   bool Client::selectResource( const std::string& resource )
   {
+    m_selectedResource = resource; // TODO: remove for 1.1
+    m_jid.setResource( resource );
+
     if( !( m_streamFeatures & StreamFeatureUnbind ) )
       return false;
 
-    m_selectedResource = resource;
-
     return true;
   }
 
Index: src/client.h
===================================================================
--- src/client.h        (revision 4349)
+++ src/client.h        (revision 4350)
@@ -149,7 +149,7 @@
        * Use this function to select a resource identifier that has been bound
        * previously by means of bindResource(). It is not necessary to call 
this function
        * if only one resource is bound. Use hasResourceBind() to find out if 
the
-       * server supports binding of multiple resources. selectResource() is a 
NOOP if it doesn't.
+       * server supports binding of multiple resources.
        * @param resource A resource string that has been bound previously.
        * @note If the resource string has not been bound previously, future 
sending of
        * stanzas will fail.
Index: src/nonsaslauth.cpp
===================================================================
--- src/nonsaslauth.cpp (revision 4349)
+++ src/nonsaslauth.cpp (revision 4350)
@@ -160,6 +160,7 @@
             break;
           }
           case TrackSendAuth:
+            m_parent->selectResource( m_parent->jid().resource() );
             m_parent->setAuthed( true );
             m_parent->connected();
             break;
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 4349)
+++ ChangeLog   (revision 4350)
@@ -15,6 +15,7 @@
 - PubSub: added optional subid
 - SOCKS5BytestreamServer: expose local socket
 - RosterManager: don't use string-comparison on JIDs; use JID class
+- NonSASLAuth: fixed resource usage by deprecating 
ClientBase::m_selectedResource
 
 
 v1.0 -- 31 Oct 2009