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
00106
00107
00108 void sendResumeAnswer( bool resume );
00109
00110 void setOffset( KIO::filesize_t offset );
00111 KIO::filesize_t offset() const;
00112
00113 signals:
00115
00117
00118 void data( const QByteArray & );
00119 void dataReq( );
00120 void error( int , const QString & );
00121 void connected();
00122 void finished();
00123 void slaveStatus(pid_t, const QCString &, const QString &, bool);
00124 void listEntries( const KIO::UDSEntryList& );
00125 void statEntry( const KIO::UDSEntry& );
00126 void needSubURLData();
00127 void needProgressId();
00128
00129 void canResume( KIO::filesize_t ) ;
00130
00132
00134 void metaData( const KIO::MetaData & );
00135 void totalSize( KIO::filesize_t ) ;
00136 void processedSize( KIO::filesize_t ) ;
00137 void redirection( const KURL& ) ;
00138
00139 void speed( unsigned long ) ;
00140 void errorPage() ;
00141 void mimeType( const QString & ) ;
00142 void warning( const QString & ) ;
00143 void infoMessage( const QString & ) ;
00144 void connectFinished();
00145
00149 void authorizationKey( const QCString&, const QCString&, bool );
00150
00154 void delAuthorization( const QCString& grpkey );
00155
00156 protected:
00158
00160
00161 virtual bool dispatch();
00162 virtual bool dispatch( int _cmd, const QByteArray &data );
00163
00203 void openPassDlg( KIO::AuthInfo& info );
00204
00208 void openPassDlg( const QString& prompt, const QString& user,
00209 const QString& caption, const QString& comment,
00210 const QString& label, bool readOnly ) KDE_DEPRECATED;
00211
00215 void openPassDlg( const QString& prompt, const QString& user, bool readOnly ) KDE_DEPRECATED;
00216
00217 void messageBox( int type, const QString &text, const QString &caption,
00218 const QString &buttonYes, const QString &buttonNo );
00219
00223 void messageBox( int type, const QString &text, const QString &caption,
00224 const QString &buttonYes, const QString &buttonNo, const QString &dontAskAgainName );
00225
00226
00227 void requestNetwork( const QString &, const QString &);
00228 void dropNetwork( const QString &, const QString &);
00229
00234 static void sigpipe_handler(int);
00235
00236 protected slots:
00237 void calcSpeed();
00238
00239 protected:
00240 Connection * m_pConnection;
00241
00242 private:
00243 int m_progressId;
00244 protected:
00245 virtual void virtual_hook( int id, void* data );
00246 private:
00247 SlaveInterfacePrivate *d;
00248 };
00249
00250 }
00251
00252 inline QDataStream &operator >>(QDataStream &s, KIO::UDSAtom &a )
00253 {
00254 Q_INT32 l;
00255 s >> a.m_uds;
00256
00257 if ( a.m_uds & KIO::UDS_LONG ) {
00258 s >> l;
00259 a.m_long = l;
00260 a.m_str = QString::null;
00261 } else if ( a.m_uds & KIO::UDS_STRING ) {
00262 s >> a.m_str;
00263 a.m_long = 0;
00264 } else {}
00265
00266
00267 return s;
00268 }
00269
00270 inline QDataStream &operator <<(QDataStream &s, const KIO::UDSAtom &a )
00271 {
00272 s << a.m_uds;
00273
00274 if ( a.m_uds & KIO::UDS_LONG )
00275 s << (Q_INT32) a.m_long;
00276 else if ( a.m_uds & KIO::UDS_STRING )
00277 s << a.m_str;
00278 else {}
00279
00280
00281 return s;
00282 }
00283
00284 KIO_EXPORT QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e );
00285 KIO_EXPORT QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e );
00286
00287 #endif