void Client::processResourceBind( const IQ& iq ) { switch( iq.subtype() ) { case IQ::Result: { const ResourceBind* rb = iq.findExtension<ResourceBind>( ExtResourceBind ); if( !rb || !rb->jid() ) { notifyOnResourceBindError( 0 ); break; } m_jid = rb->jid(); m_resourceBound = true; m_selectedResource = m_jid.resource(); notifyOnResourceBind( m_jid.resource() ); if( m_streamFeatures & StreamFeatureSession ) createSession(); else connected(); break; } case IQ::Error: { notifyOnResourceBindError( iq.error() ); break; } default: break; } }
void Client::processResourceBind( Stanza *stanza ) { switch( stanza->subtype() ) { case StanzaIqResult: { Tag *bind = stanza->findChild( "bind" ); Tag *jid = bind->findChild( "jid" ); m_jid.setJID( jid->cdata() ); m_resourceBound = true; if( m_streamFeatures & StreamFeatureSession ) createSession(); else connected(); break; } case StanzaIqError: { Tag *error = stanza->findChild( "error" ); if( stanza->hasChild( "error", "type", "modify" ) && error->hasChild( "bad-request", "xmlns", XMLNS_XMPP_STANZAS ) ) { notifyOnResourceBindError( RbErrorBadRequest ); } else if( stanza->hasChild( "error", "type", "cancel" ) ) { if( error->hasChild( "not-allowed", "xmlns", XMLNS_XMPP_STANZAS ) ) notifyOnResourceBindError( RbErrorNotAllowed ); else if( error->hasChild( "conflict", "xmlns", XMLNS_XMPP_STANZAS ) ) notifyOnResourceBindError( RbErrorConflict ); else notifyOnResourceBindError( RbErrorUnknownError ); } else notifyOnResourceBindError( RbErrorUnknownError ); break; } default: break; } }