2 /***************************************************************************
3 gwconnector.cpp - Socket Connector for KNetwork
6 copyright : (C) 2004 by Till Gerken <till@tantalo.net>
8 Kopete (C) 2004-2007 Kopete developers <kopete-devel@kde.org>
9 ***************************************************************************/
11 /***************************************************************************
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU Lesser General Public License as *
15 * published by the Free Software Foundation; either version 2.1 of the *
16 * License, or (at your option) any later version. *
18 ***************************************************************************/
20 #include <k3bufferedsocket.h>
22 #include <k3resolver.h>
24 #include "gwconnector.h"
26 #include "gwbytestream.h"
28 KNetworkConnector::KNetworkConnector ( QObject
*parent
)
29 : Connector ( parent
)
31 kDebug () << "New KNetwork connector.";
35 mByteStream
= new KNetworkByteStream ( this );
37 connect ( mByteStream
, SIGNAL ( connected () ), this, SLOT ( slotConnected () ) );
38 connect ( mByteStream
, SIGNAL ( error ( int ) ), this, SLOT ( slotError ( int ) ) );
42 KNetworkConnector::~KNetworkConnector ()
49 void KNetworkConnector::connectToServer ( const QString
&server
)
51 kDebug () << "Initiating connection to " << mHost
;
52 Q_ASSERT( !mHost
.isNull() );
55 * FIXME: we should use a SRV lookup to determine the
56 * actual server to connect to. As this is currently
57 * not supported yet, we're using setOptHostPort().
58 * For XMPP 1.0, we need to enable this!
63 mByteStream
->connect ( mHost
, QString::number ( mPort
) );
66 void KNetworkConnector::slotConnected ()
68 kDebug() << "We are connected.";
70 // FIXME: setPeerAddress() is something different, find out correct usage later
71 //KInetSocketAddress inetAddress = mStreamSocket->address().asInet().makeIPv6 ();
72 //setPeerAddress ( QHostAddress ( inetAddress.ipAddress().addr () ), inetAddress.port () );
78 void KNetworkConnector::slotError ( int code
)
80 kDebug() << "Error detected: " << code
;
86 int KNetworkConnector::errorCode ()
93 ByteStream
*KNetworkConnector::stream () const
100 void KNetworkConnector::done ()
103 mByteStream
->close ();
106 void KNetworkConnector::setOptHostPort ( const QString
&host
, quint16 port
)
108 kDebug () << "Manually specifying host " << host
<< " and port " << port
;
115 void KNetworkConnector::setOptSSL ( bool ssl
)
117 kDebug () << "Setting SSL to " << ssl
;
123 #include "gwconnector.moc"