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 <qobject.h>
00027
00028 #include <kurl.h>
00029 #include <kio/global.h>
00030 #include <kio/authinfo.h>
00031 #include <kdatastream.h>
00032
00033 namespace KIO {
00034
00035 class Connection;
00036
00037 class SlaveInterfacePrivate;
00038
00039
00040
00044 enum Info {
00045 INF_TOTAL_SIZE = 10,
00046 INF_PROCESSED_SIZE = 11,
00047 INF_SPEED,
00048 INF_REDIRECTION = 20,
00049 INF_MIME_TYPE = 21,
00050 INF_ERROR_PAGE = 22,
00051 INF_WARNING = 23,
00052 INF_GETTING_FILE,
00053 INF_NEED_PASSWD = 25,
00054 INF_INFOMESSAGE,
00055 INF_META_DATA,
00056 INF_NETWORK_STATUS,
00057 INF_MESSAGEBOX
00058
00059 };
00060
00064 enum Message {
00065 MSG_DATA = 100,
00066 MSG_DATA_REQ,
00067 MSG_ERROR,
00068 MSG_CONNECTED,
00069 MSG_FINISHED,
00070 MSG_STAT_ENTRY,
00071 MSG_LIST_ENTRIES,
00072 MSG_RENAMED,
00073 MSG_RESUME,
00074 MSG_SLAVE_STATUS,
00075 MSG_SLAVE_ACK,
00076 MSG_NET_REQUEST,
00077 MSG_NET_DROP,
00078 MSG_NEED_SUBURL_DATA,
00079 MSG_CANRESUME,
00080 MSG_AUTH_KEY,
00081 MSG_DEL_AUTH_KEY
00082
00083 };
00084
00092 class KIO_EXPORT SlaveInterface : public QObject
00093 {
00094 Q_OBJECT
00095
00096 public:
00097 SlaveInterface( Connection *connection );
00098 virtual ~SlaveInterface();
00099
00100 void setConnection( Connection* connection ) { m_pConnection = connection; }
00101 Connection *connection() const { return m_pConnection; }
00102
00103 void setProgressId( int id ) { m_progressId = id; }
00104 int progressId() const { return m_progressId; }
00105
00109 void sendResumeAnswer( bool resume );
00110
00111 void setOffset( KIO::filesize_t offset );
00112 KIO::filesize_t offset() const;
00113
00114 signals:
00116
00118
00119 void data( const QByteArray & );
00120 void dataReq( );
00121 void error( int , const QString & );
00122 void connected();
00123 void finished();
00124 void slaveStatus(pid_t, const QCString &, const QString &, bool);
00125 void listEntries( const KIO::UDSEntryList& );
00126 void statEntry( const KIO::UDSEntry& );
00127 void needSubURLData();
00128 void needProgressId();
00129
00130 void canResume( KIO::filesize_t ) ;
00131
00133
00135 void metaData( const KIO::MetaData & );
00136 void totalSize( KIO::filesize_t ) ;
00137 void processedSize( KIO::filesize_t ) ;
00138 void redirection( const KURL& ) ;
00139
00140 void speed( unsigned long ) ;
00141 void errorPage() ;
00142 void mimeType( const QString & ) ;
00143 void warning( const QString & ) ;
00144 void infoMessage( const QString & ) ;
00145 void connectFinished();
00146
00150 void authorizationKey( const QCString&, const QCString&, bool );
00151
00155 void delAuthorization( const QCString& grpkey );
00156
00157 protected:
00159
00161
00162 virtual bool dispatch();
00163 virtual bool dispatch( int _cmd, const QByteArray &data );
00164
00204 void openPassDlg( KIO::AuthInfo& info );
00205
00209 void openPassDlg( const QString& prompt, const QString& user,
00210 const QString& caption, const QString& comment,
00211 const QString& label, bool readOnly ) KDE_DEPRECATED;
00212
00216 void openPassDlg( const QString& prompt, const QString& user, bool readOnly ) KDE_DEPRECATED;
00217
00218 void messageBox( int type, const QString &text, const QString &caption,
00219 const QString &buttonYes, const QString &buttonNo );
00220
00224 void messageBox( int type, const QString &text, const QString &caption,
00225 const QString &buttonYes, const QString &buttonNo, const QString &dontAskAgainName );
00226
00227
00228 void requestNetwork( const QString &, const QString &);
00229 void dropNetwork( const QString &, const QString &);
00230
00235 static void sigpipe_handler(int);
00236
00237 protected slots:
00238 void calcSpeed();
00239
00240 protected:
00241 Connection * m_pConnection;
00242
00243 private:
00244 int m_progressId;
00245 protected:
00246 virtual void virtual_hook( int id, void* data );
00247 private:
00248 SlaveInterfacePrivate *d;
00249 };
00250
00251 }
00252
00253 inline QDataStream &operator >>(QDataStream &s, KIO::UDSAtom &a )
00254 {
00255 Q_INT32 l;
00256 s >> a.m_uds;
00257
00258 if ( a.m_uds & KIO::UDS_LONG ) {
00259 s >> l;
00260 a.m_long = l;
00261 a.m_str = QString::null;
00262 } else if ( a.m_uds & KIO::UDS_STRING ) {
00263 s >> a.m_str;
00264 a.m_long = 0;
00265 } else {}
00266
00267
00268 return s;
00269 }
00270
00271 inline QDataStream &operator <<(QDataStream &s, const KIO::UDSAtom &a )
00272 {
00273 s << a.m_uds;
00274
00275 if ( a.m_uds & KIO::UDS_LONG )
00276 s << (Q_INT32) a.m_long;
00277 else if ( a.m_uds & KIO::UDS_STRING )
00278 s << a.m_str;
00279 else {}
00280
00281
00282 return s;
00283 }
00284
00285 KIO_EXPORT QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e );
00286 KIO_EXPORT QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e );
00287
00288 #endif