diff options
author | Slávek Banko <[email protected]> | 2016-10-15 18:52:11 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2016-10-15 18:52:22 +0200 |
commit | 8988b1a5f34c544c0a6ffbb9b36ba6e051fdbdfa (patch) | |
tree | 19da777c08c52bb6c7b81f5451204deb7b401bed /kopete/protocols | |
parent | adad10233b442bc490659083b574da8acceaa56b (diff) | |
download | tdenetwork-8988b1a5f34c544c0a6ffbb9b36ba6e051fdbdfa.tar.gz tdenetwork-8988b1a5f34c544c0a6ffbb9b36ba6e051fdbdfa.zip |
Kopete - jabber: Allow SRV lookup for server+port
Signed-off-by: Slávek Banko <[email protected]>
(cherry picked from commit d2625220de85b072b73682f696c4b287bedd19c3)
Diffstat (limited to 'kopete/protocols')
-rw-r--r-- | kopete/protocols/jabber/jabberconnector.cpp | 35 | ||||
-rw-r--r-- | kopete/protocols/jabber/jabberconnector.h | 3 |
2 files changed, 28 insertions, 10 deletions
diff --git a/kopete/protocols/jabber/jabberconnector.cpp b/kopete/protocols/jabber/jabberconnector.cpp index 6d43d305..1a2febf2 100644 --- a/kopete/protocols/jabber/jabberconnector.cpp +++ b/kopete/protocols/jabber/jabberconnector.cpp @@ -30,32 +30,33 @@ JabberConnector::JabberConnector ( TQObject *parent, const char */*name*/ ) mErrorCode = KNetwork::TDESocketBase::NoError; mByteStream = new JabberByteStream ( this ); + mSrvResolver = new SrvResolver; connect ( mByteStream, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) ); connect ( mByteStream, TQT_SIGNAL ( error ( int ) ), this, TQT_SLOT ( slotError ( int ) ) ); - + connect ( mSrvResolver, TQT_SIGNAL( resultsReady() ), this, TQT_SLOT( slotSrvLookup() ) ); } JabberConnector::~JabberConnector () { - delete mByteStream; - + delete mSrvResolver; } void JabberConnector::connectToServer ( const TQString &server ) { kdDebug ( JABBER_DEBUG_GLOBAL ) << k_funcinfo << "Initiating connection to " << server << endl; - /* - * FIXME: we should use a SRV lookup to determine the - * actual server to connect to. As this is currently - * not supported yet, we're using setOptHostPort(). - * For XMPP 1.0, we need to enable this! - */ - mErrorCode = KNetwork::TDESocketBase::NoError; + if( mHost.isEmpty() ) { + if( mSrvResolver->isBusy() ) { + mSrvResolver->stop(); + } + mSrvResolver->resolve(server, "xmpp-client", "tcp"); + return; + } + if ( !mByteStream->connect ( mHost, TQString::number ( mPort ) ) ) { // Houston, we have a problem @@ -86,6 +87,20 @@ void JabberConnector::slotError ( int code ) } +void JabberConnector::slotSrvLookup() +{ + if( mSrvResolver->failed() ) { + mErrorCode = KNetwork::TDESocketBase::LookupFailure; + emit error (); + return; + } + + if( !mByteStream->connect( mSrvResolver->resultAddress().toString(), TQString::number( mSrvResolver->resultPort() ))) { + mErrorCode = mByteStream->socket()->error (); + emit error (); + } +} + int JabberConnector::errorCode () { diff --git a/kopete/protocols/jabber/jabberconnector.h b/kopete/protocols/jabber/jabberconnector.h index 5116c823..10a7c44b 100644 --- a/kopete/protocols/jabber/jabberconnector.h +++ b/kopete/protocols/jabber/jabberconnector.h @@ -22,6 +22,7 @@ #include <xmpp.h> #include "jabberbytestream.h" +#include "libiris/cutestuff/network/srvresolver.h" class ByteStream; class KResolverEntry; @@ -53,6 +54,7 @@ public: private slots: void slotConnected (); void slotError ( int ); + void slotSrvLookup (); private: TQString mHost; @@ -60,6 +62,7 @@ private: int mErrorCode; JabberByteStream *mByteStream; + SrvResolver *mSrvResolver; }; |