KDECore
k3bufferedsocket.h
Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org> 00003 * 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining 00006 * a copy of this software and associated documentation files (the 00007 * "Software"), to deal in the Software without restriction, including 00008 * without limitation the rights to use, copy, modify, merge, publish, 00009 * distribute, sublicense, and/or sell copies of the Software, and to 00010 * permit persons to whom the Software is furnished to do so, subject to 00011 * the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 #ifndef KBUFFEREDSOCKET_H 00026 #define KBUFFEREDSOCKET_H 00027 00028 #include <kdecore_export.h> 00029 #include "k3streamsocket.h" 00030 00031 #include <QtCore/QObject> 00032 #include <QtCore/QByteArray> 00033 #include <QtCore/QList> 00034 00035 namespace KNetwork { 00036 00037 class KBufferedSocketPrivate; 00058 class KDECORE_EXPORT KBufferedSocket: public KStreamSocket 00059 { 00060 Q_OBJECT 00061 public: 00069 explicit KBufferedSocket(const QString& node = QString(), const QString& service = QString(), 00070 QObject* parent = 0L); 00071 00075 virtual ~KBufferedSocket(); 00076 00080 virtual void setSocketDevice(KSocketDevice* device); 00081 00082 protected: 00086 virtual bool setSocketOptions(int opts); 00087 00088 public: 00095 virtual void close(); 00096 00100 virtual qint64 bytesAvailable() const; 00101 00105 virtual qint64 waitForMore(int msecs, bool *timeout = 0L); 00106 00110 virtual void enableRead(bool enable); 00111 00115 virtual void enableWrite(bool enable); 00116 00120 void setInputBuffering(bool enable); 00121 00125 void setOutputBuffering(bool enable); 00126 00130 virtual qint64 bytesToWrite() const; 00131 00138 virtual void closeNow(); 00139 00143 virtual bool canReadLine() const; 00144 00145 // KDE4: make virtual, add timeout to match the Qt4 signature 00146 // and move to another class up the hierarchy 00151 void waitForConnect(); 00152 00153 protected: 00159 virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from); 00160 00166 virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from); 00167 00173 virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to); 00174 00178 virtual qint64 readLineData(char *data, qint64 maxSize); 00179 00183 virtual void stateChanging(SocketState newState); 00184 00185 protected Q_SLOTS: 00189 virtual void slotReadActivity(); 00190 00194 virtual void slotWriteActivity(); 00195 00196 #if 0 00197 // Already present in QIODevice 00198 Q_SIGNALS: 00202 void bytesWritten(int bytes); 00203 #endif 00204 00205 private: 00206 KBufferedSocket(const KBufferedSocket&); 00207 KBufferedSocket& operator=(const KBufferedSocket&); 00208 00209 KBufferedSocketPrivate* const d; 00210 }; 00211 00212 } // namespace KNetwork 00213 00214 #endif
KDE 4.6 API Reference