|
|
@ -30,32 +30,33 @@ JabberConnector::JabberConnector ( TQObject *parent, const char */*name*/ )
|
|
|
|
mErrorCode = KNetwork::TDESocketBase::NoError;
|
|
|
|
mErrorCode = KNetwork::TDESocketBase::NoError;
|
|
|
|
|
|
|
|
|
|
|
|
mByteStream = new JabberByteStream ( this );
|
|
|
|
mByteStream = new JabberByteStream ( this );
|
|
|
|
|
|
|
|
mSrvResolver = new SrvResolver;
|
|
|
|
|
|
|
|
|
|
|
|
connect ( mByteStream, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) );
|
|
|
|
connect ( mByteStream, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) );
|
|
|
|
connect ( mByteStream, TQT_SIGNAL ( error ( int ) ), this, TQT_SLOT ( slotError ( int ) ) );
|
|
|
|
connect ( mByteStream, TQT_SIGNAL ( error ( int ) ), this, TQT_SLOT ( slotError ( int ) ) );
|
|
|
|
|
|
|
|
connect ( mSrvResolver, TQT_SIGNAL( resultsReady() ), this, TQT_SLOT( slotSrvLookup() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JabberConnector::~JabberConnector ()
|
|
|
|
JabberConnector::~JabberConnector ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
delete mByteStream;
|
|
|
|
delete mByteStream;
|
|
|
|
|
|
|
|
delete mSrvResolver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void JabberConnector::connectToServer ( const TQString &server )
|
|
|
|
void JabberConnector::connectToServer ( const TQString &server )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug ( JABBER_DEBUG_GLOBAL ) << k_funcinfo << "Initiating connection to " << server << endl;
|
|
|
|
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;
|
|
|
|
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 ) ) )
|
|
|
|
if ( !mByteStream->connect ( mHost, TQString::number ( mPort ) ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Houston, we have a problem
|
|
|
|
// 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 ()
|
|
|
|
int JabberConnector::errorCode ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|