00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __kio_slaveinterface_h
00021 #define __kio_slaveinterface_h
00022
00023 #include <unistd.h>
00024 #include <sys/types.h>
00025
00026 #include <QtCore/QObject>
00027 #include <QtNetwork/QHostInfo>
00028
00029 #include <kio/global.h>
00030 #include <kio/udsentry.h>
00031 #include <kio/authinfo.h>
00032
00033 class KUrl;
00034
00035 namespace KIO {
00036
00037 class Connection;
00038
00039 class SlaveInterfacePrivate;
00040
00041
00042
00046 enum Info {
00047 INF_TOTAL_SIZE = 10,
00048 INF_PROCESSED_SIZE = 11,
00049 INF_SPEED,
00050 INF_REDIRECTION = 20,
00051 INF_MIME_TYPE = 21,
00052 INF_ERROR_PAGE = 22,
00053 INF_WARNING = 23,
00054 INF_GETTING_FILE,
00055 INF_UNUSED = 25,
00056 INF_INFOMESSAGE,
00057 INF_META_DATA,
00058 INF_NETWORK_STATUS,
00059 INF_MESSAGEBOX,
00060 INF_POSITION
00061
00062 };
00063
00067 enum Message {
00068 MSG_DATA = 100,
00069 MSG_DATA_REQ,
00070 MSG_ERROR,
00071 MSG_CONNECTED,
00072 MSG_FINISHED,
00073 MSG_STAT_ENTRY,
00074 MSG_LIST_ENTRIES,
00075 MSG_RENAMED,
00076 MSG_RESUME,
00077 MSG_SLAVE_STATUS,
00078 MSG_SLAVE_ACK,
00079 MSG_NET_REQUEST,
00080 MSG_NET_DROP,
00081 MSG_NEED_SUBURL_DATA,
00082 MSG_CANRESUME,
00083 MSG_AUTH_KEY,
00084 MSG_DEL_AUTH_KEY,
00085 MSG_OPENED,
00086 MSG_WRITTEN,
00087 MSG_HOST_INFO_REQ
00088
00089 };
00090
00098 class KIO_EXPORT SlaveInterface : public QObject
00099 {
00100 Q_OBJECT
00101
00102 protected:
00103 SlaveInterface(SlaveInterfacePrivate &dd, QObject *parent = 0);
00104 public:
00105 virtual ~SlaveInterface();
00106
00107 void setConnection( Connection* connection );
00108 Connection *connection() const;
00109
00110
00111
00112 void sendResumeAnswer( bool resume );
00113
00114 void setOffset( KIO::filesize_t offset );
00115 KIO::filesize_t offset() const;
00116
00117 Q_SIGNALS:
00119
00121
00122 void data( const QByteArray & );
00123 void dataReq( );
00124 void error( int , const QString & );
00125 void connected();
00126 void finished();
00127 void slaveStatus(pid_t, const QByteArray&, const QString &, bool);
00128 void listEntries( const KIO::UDSEntryList& );
00129 void statEntry( const KIO::UDSEntry& );
00130 void needSubUrlData();
00131
00132 void canResume( KIO::filesize_t );
00133
00134 void open();
00135 void written( KIO::filesize_t );
00136
00138
00140 void metaData( const KIO::MetaData & );
00141 void totalSize( KIO::filesize_t );
00142 void processedSize( KIO::filesize_t );
00143 void redirection( const KUrl& );
00144 void position( KIO::filesize_t );
00145
00146 void speed( unsigned long );
00147 void errorPage();
00148 void mimeType( const QString & );
00149 void warning( const QString & );
00150 void infoMessage( const QString & );
00151
00152
00153 protected:
00155
00157
00158 virtual bool dispatch();
00159 virtual bool dispatch( int _cmd, const QByteArray &data );
00160
00161 void messageBox( int type, const QString &text, const QString &caption,
00162 const QString &buttonYes, const QString &buttonNo );
00163
00164 void messageBox( int type, const QString &text, const QString &caption,
00165 const QString &buttonYes, const QString &buttonNo,
00166 const QString &dontAskAgainName );
00167
00168
00169 void requestNetwork( const QString &, const QString &);
00170 void dropNetwork( const QString &, const QString &);
00171
00172 protected Q_SLOTS:
00173 void calcSpeed();
00174 protected:
00175 SlaveInterfacePrivate* const d_ptr;
00176 Q_DECLARE_PRIVATE(SlaveInterface)
00177 private:
00178 Q_PRIVATE_SLOT(d_func(), void slotHostInfo(QHostInfo))
00179 };
00180
00181 }
00182
00183
00184
00185
00186
00187 #endif