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 <kdemacros.h>
00030
00031 #include <kio/global.h>
00032 #include <kio/authinfo.h>
00033 #include <kdatastream.h>
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_NEED_PASSWD = 25,
00056 INF_INFOMESSAGE,
00057 INF_META_DATA,
00058 INF_NETWORK_STATUS,
00059 INF_MESSAGEBOX
00060
00061 };
00062
00066 enum Message {
00067 MSG_DATA = 100,
00068 MSG_DATA_REQ,
00069 MSG_ERROR,
00070 MSG_CONNECTED,
00071 MSG_FINISHED,
00072 MSG_STAT_ENTRY,
00073 MSG_LIST_ENTRIES,
00074 MSG_RENAMED,
00075 MSG_RESUME,
00076 MSG_SLAVE_STATUS,
00077 MSG_SLAVE_ACK,
00078 MSG_NET_REQUEST,
00079 MSG_NET_DROP,
00080 MSG_NEED_SUBURL_DATA,
00081 MSG_CANRESUME,
00082 MSG_AUTH_KEY,
00083 MSG_DEL_AUTH_KEY
00084
00085 };
00086
00094 class SlaveInterface : public QObject
00095 {
00096 Q_OBJECT
00097
00098 public:
00099 SlaveInterface( Connection *connection );
00100 virtual ~SlaveInterface();
00101
00102 void setConnection( Connection* connection ) { m_pConnection = connection; }
00103 Connection *connection() const { return m_pConnection; }
00104
00105 void setProgressId( int id ) { m_progressId = id; }
00106 int progressId() const { return m_progressId; }
00107
00108
00109
00110 void sendResumeAnswer( bool resume );
00111
00112 void setOffset( KIO::filesize_t offset );
00113 KIO::filesize_t offset() const;
00114
00115 signals:
00117
00119
00120 void data( const QByteArray & );
00121 void dataReq( );
00122 void error( int , const QString & );
00123 void connected();
00124 void finished();
00125 void slaveStatus(pid_t, const QCString &, const QString &, bool);
00126 void listEntries( const KIO::UDSEntryList& );
00127 void statEntry( const KIO::UDSEntry& );
00128 void needSubURLData();
00129 void needProgressId();
00130
00131 void canResume( KIO::filesize_t ) ;
00132
00134
00136 void metaData( const KIO::MetaData & );
00137 void totalSize( KIO::filesize_t ) ;
00138 void processedSize( KIO::filesize_t ) ;
00139 void redirection( const KURL& ) ;
00140
00141 void speed( unsigned long ) ;
00142 void errorPage() ;
00143 void mimeType( const QString & ) ;
00144 void warning( const QString & ) ;
00145 void infoMessage( const QString & ) ;
00146 void connectFinished();
00147
00151 void authorizationKey( const QCString&, const QCString&, bool );
00152
00156 void delAuthorization( const QCString& grpkey );
00157
00158 protected:
00160
00162
00163 virtual bool dispatch();
00164 virtual bool dispatch( int _cmd, const QByteArray &data );
00165
00205 void openPassDlg( KIO::AuthInfo& info );
00206
00210 void openPassDlg( const QString& prompt, const QString& user,
00211 const QString& caption, const QString& comment,
00212 const QString& label, bool readOnly ) KDE_DEPRECATED;
00213
00217 void openPassDlg( const QString& prompt, const QString& user, bool readOnly ) KDE_DEPRECATED;
00218
00219 void messageBox( int type, const QString &text, const QString &caption,
00220 const QString &buttonYes, const QString &buttonNo );
00221
00222
00223 void requestNetwork( const QString &, const QString &);
00224 void dropNetwork( const QString &, const QString &);
00225
00230 static void sigpipe_handler(int);
00231
00232 protected slots:
00233 void calcSpeed();
00234
00235 protected:
00236 Connection * m_pConnection;
00237
00238 private:
00239 int m_progressId;
00240 protected:
00241 virtual void virtual_hook( int id, void* data );
00242 private:
00243 SlaveInterfacePrivate *d;
00244 };
00245
00246 }
00247
00248 inline QDataStream &operator >>(QDataStream &s, KIO::UDSAtom &a )
00249 {
00250 long l;
00251 s >> a.m_uds;
00252
00253 if ( a.m_uds & KIO::UDS_LONG ) {
00254 s >> l;
00255 a.m_long = l;
00256 a.m_str = QString::null;
00257 } else if ( a.m_uds & KIO::UDS_STRING ) {
00258 s >> a.m_str;
00259 a.m_long = 0;
00260 } else {}
00261
00262
00263 return s;
00264 }
00265
00266 inline QDataStream &operator <<(QDataStream &s, const KIO::UDSAtom &a )
00267 {
00268 s << a.m_uds;
00269
00270 if ( a.m_uds & KIO::UDS_LONG )
00271 s << (long) a.m_long;
00272 else if ( a.m_uds & KIO::UDS_STRING )
00273 s << a.m_str;
00274 else {}
00275
00276
00277 return s;
00278 }
00279
00280 QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e );
00281 QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e );
00282
00283 #endif