|
Lines 30-61
JabberConnector::JabberConnector ( TQObject *parent, const char */*name*/ )
Link Here
|
| 30 |
mErrorCode = KNetwork::TDESocketBase::NoError; |
30 |
mErrorCode = KNetwork::TDESocketBase::NoError; |
| 31 |
|
31 |
|
| 32 |
mByteStream = new JabberByteStream ( this ); |
32 |
mByteStream = new JabberByteStream ( this ); |
|
|
33 |
mSrvResolver = new SrvResolver; |
| 33 |
|
34 |
|
| 34 |
connect ( mByteStream, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) ); |
35 |
connect ( mByteStream, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) ); |
| 35 |
connect ( mByteStream, TQT_SIGNAL ( error ( int ) ), this, TQT_SLOT ( slotError ( int ) ) ); |
36 |
connect ( mByteStream, TQT_SIGNAL ( error ( int ) ), this, TQT_SLOT ( slotError ( int ) ) ); |
| 36 |
|
37 |
connect ( mSrvResolver, TQT_SIGNAL( resultsReady() ), this, TQT_SLOT( slotSrvLookup() ) ); |
| 37 |
} |
38 |
} |
| 38 |
|
39 |
|
| 39 |
JabberConnector::~JabberConnector () |
40 |
JabberConnector::~JabberConnector () |
| 40 |
{ |
41 |
{ |
| 41 |
|
|
|
| 42 |
delete mByteStream; |
42 |
delete mByteStream; |
| 43 |
|
43 |
delete mSrvResolver; |
| 44 |
} |
44 |
} |
| 45 |
|
45 |
|
| 46 |
void JabberConnector::connectToServer ( const TQString &server ) |
46 |
void JabberConnector::connectToServer ( const TQString &server ) |
| 47 |
{ |
47 |
{ |
| 48 |
kdDebug ( JABBER_DEBUG_GLOBAL ) << k_funcinfo << "Initiating connection to " << server << endl; |
48 |
kdDebug ( JABBER_DEBUG_GLOBAL ) << k_funcinfo << "Initiating connection to " << server << endl; |
| 49 |
|
49 |
|
| 50 |
/* |
|
|
| 51 |
* FIXME: we should use a SRV lookup to determine the |
| 52 |
* actual server to connect to. As this is currently |
| 53 |
* not supported yet, we're using setOptHostPort(). |
| 54 |
* For XMPP 1.0, we need to enable this! |
| 55 |
*/ |
| 56 |
|
| 57 |
mErrorCode = KNetwork::TDESocketBase::NoError; |
50 |
mErrorCode = KNetwork::TDESocketBase::NoError; |
| 58 |
|
51 |
|
|
|
52 |
if( mHost.isEmpty() ) { |
| 53 |
if( mSrvResolver->isBusy() ) { |
| 54 |
mSrvResolver->stop(); |
| 55 |
} |
| 56 |
mSrvResolver->resolve(server, "xmpp-client", "tcp"); |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 59 |
if ( !mByteStream->connect ( mHost, TQString::number ( mPort ) ) ) |
60 |
if ( !mByteStream->connect ( mHost, TQString::number ( mPort ) ) ) |
| 60 |
{ |
61 |
{ |
| 61 |
// Houston, we have a problem |
62 |
// Houston, we have a problem |
|
Lines 86-91
void JabberConnector::slotError ( int code )
Link Here
|
| 86 |
|
87 |
|
| 87 |
} |
88 |
} |
| 88 |
|
89 |
|
|
|
90 |
void JabberConnector::slotSrvLookup() |
| 91 |
{ |
| 92 |
if( mSrvResolver->failed() ) { |
| 93 |
mErrorCode = KNetwork::TDESocketBase::LookupFailure; |
| 94 |
emit error (); |
| 95 |
return; |
| 96 |
} |
| 97 |
|
| 98 |
if( !mByteStream->connect( mSrvResolver->resultAddress().toString(), TQString::number( mSrvResolver->resultPort() ))) { |
| 99 |
mErrorCode = mByteStream->socket()->error (); |
| 100 |
emit error (); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 89 |
int JabberConnector::errorCode () |
104 |
int JabberConnector::errorCode () |
| 90 |
{ |
105 |
{ |
| 91 |
|
106 |
|