KIO
connection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KIO_CONNECTION_H
00023 #define KIO_CONNECTION_H
00024
00025 #if defined(MAKE_KIO_LIB) || defined(MAKE_KLAUNCHER)
00026 # define KIO_CONNECTION_EXPORT KIO_EXPORT
00027 #else
00028 # define KIO_CONNECTION_EXPORT KIO_EXPORT_DEPRECATED
00029 #endif
00030
00031 #include "kio_export.h"
00032
00033 #include <QtCore/QObject>
00034 #include <QtCore/QString>
00035
00036 namespace KIO {
00037
00038 class ConnectionPrivate;
00039 class ConnectionServer;
00048 class KIO_CONNECTION_EXPORT Connection : public QObject
00049 {
00050 Q_OBJECT
00051 public:
00056 explicit Connection(QObject *parent = 0);
00057 virtual ~Connection();
00058
00062 void connectToRemote(const QString &address);
00063
00065 void close();
00066
00067 QString errorString() const;
00068
00069 bool isConnected() const;
00070
00076 bool inited() const;
00077
00084 bool send(int cmd, const QByteArray &arr = QByteArray());
00085
00092 bool sendnow( int _cmd, const QByteArray &data );
00093
00099 bool hasTaskAvailable() const;
00100
00107 bool waitForIncomingTask(int ms = 30000);
00108
00118 int read( int* _cmd, QByteArray &data );
00119
00123 void suspend();
00124
00128 void resume();
00129
00134 bool suspended() const;
00135
00136 Q_SIGNALS:
00137 void readyRead();
00138
00139 private:
00140 Q_PRIVATE_SLOT(d, void dequeue())
00141 Q_PRIVATE_SLOT(d, void commandReceived(Task))
00142 Q_PRIVATE_SLOT(d, void disconnected())
00143 friend class ConnectionPrivate;
00144 friend class ConnectionServer;
00145 class ConnectionPrivate* const d;
00146 };
00147
00148 class ConnectionServerPrivate;
00154 class KIO_EXPORT ConnectionServer : public QObject
00155 {
00156 Q_OBJECT
00157 public:
00158 ConnectionServer(QObject *parent = 0);
00159 ~ConnectionServer();
00160
00165 void listenForRemote();
00166 bool isListening() const;
00168 void close();
00169
00174 QString address() const;
00175
00176 Connection *nextPendingConnection();
00177 void setNextPendingConnection(Connection *conn);
00178 Q_SIGNALS:
00179 void newConnection();
00180
00181 private:
00182 friend class ConnectionServerPrivate;
00183 ConnectionServerPrivate * const d;
00184 };
00185
00186 }
00187
00188 #undef KIO_CONNECTION_EXPORT
00189
00190 #endif