KIO
connection.h
Go to the documentation of this file.
00001 // -*- c++ -*- 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 2000 Stephan Kulow <coolo@kde.org> 00004 David Faure <faure@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 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
KDE 4.6 API Reference