00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __tdeio_slaveinterface_h
00021 #define __tdeio_slaveinterface_h
00022
00023 #include <unistd.h>
00024 #include <sys/types.h>
00025
00026 #include <tqobject.h>
00027
00028 #include <kurl.h>
00029 #include <tdeio/global.h>
00030 #include <tdeio/authinfo.h>
00031 #include <kdatastream.h>
00032
00033 namespace TDEIO {
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 INF_LOCALURL
00059
00060 };
00061
00065 enum Message {
00066 MSG_DATA = 100,
00067 MSG_DATA_REQ,
00068 MSG_ERROR,
00069 MSG_CONNECTED,
00070 MSG_FINISHED,
00071 MSG_STAT_ENTRY,
00072 MSG_LIST_ENTRIES,
00073 MSG_RENAMED,
00074 MSG_RESUME,
00075 MSG_SLAVE_STATUS,
00076 MSG_SLAVE_ACK,
00077 MSG_NET_REQUEST,
00078 MSG_NET_DROP,
00079 MSG_NEED_SUBURL_DATA,
00080 MSG_CANRESUME,
00081 MSG_AUTH_KEY,
00082 MSG_DEL_AUTH_KEY
00083
00084 };
00085
00093 class TDEIO_EXPORT SlaveInterface : public TQObject
00094 {
00095 Q_OBJECT
00096
00097 public:
00098 SlaveInterface( Connection *connection );
00099 virtual ~SlaveInterface();
00100
00101 void setConnection( Connection* connection ) { m_pConnection = connection; }
00102 Connection *connection() const { return m_pConnection; }
00103
00104 void setProgressId( int id ) { m_progressId = id; }
00105 int progressId() const { return m_progressId; }
00106
00110 void sendResumeAnswer( bool resume );
00111
00112 void setOffset( TDEIO::filesize_t offset );
00113 TDEIO::filesize_t offset() const;
00114
00115 signals:
00117
00119
00120 void data( const TQByteArray & );
00121 void dataReq( );
00122 void error( int , const TQString & );
00123 void connected();
00124 void finished();
00125 void slaveStatus(pid_t, const TQCString &, const TQString &, bool);
00126 void listEntries( const TDEIO::UDSEntryList& );
00127 void statEntry( const TDEIO::UDSEntry& );
00128 void needSubURLData();
00129 void needProgressId();
00130
00131 void canResume( TDEIO::filesize_t ) ;
00132
00134
00136 void metaData( const TDEIO::MetaData & );
00137 void totalSize( TDEIO::filesize_t ) ;
00138 void processedSize( TDEIO::filesize_t ) ;
00139 void redirection( const KURL& ) ;
00140 void localURL( const KURL&, bool ) ;
00141
00142 void speed( unsigned long ) ;
00143 void errorPage() ;
00144 void mimeType( const TQString & ) ;
00145 void warning( const TQString & ) ;
00146 void infoMessage( const TQString & ) ;
00147 void connectFinished();
00148
00152 void authorizationKey( const TQCString&, const TQCString&, bool );
00153
00157 void delAuthorization( const TQCString& grpkey );
00158
00159 protected:
00161
00163
00164 virtual bool dispatch();
00165 virtual bool dispatch( int _cmd, const TQByteArray &data );
00166
00206 void openPassDlg( TDEIO::AuthInfo& info );
00207
00211 void openPassDlg( const TQString& prompt, const TQString& user,
00212 const TQString& caption, const TQString& comment,
00213 const TQString& label, bool readOnly ) KDE_DEPRECATED;
00214
00218 void openPassDlg( const TQString& prompt, const TQString& user, bool readOnly ) KDE_DEPRECATED;
00219
00220 void messageBox( int type, const TQString &text, const TQString &caption,
00221 const TQString &buttonYes, const TQString &buttonNo );
00222
00226 void messageBox( int type, const TQString &text, const TQString &caption,
00227 const TQString &buttonYes, const TQString &buttonNo, const TQString &dontAskAgainName );
00228
00229
00230 void requestNetwork( const TQString &, const TQString &);
00231 void dropNetwork( const TQString &, const TQString &);
00232
00237 static void sigpipe_handler(int);
00238
00239 protected slots:
00240 void calcSpeed();
00241
00242 protected:
00243 Connection * m_pConnection;
00244
00245 private:
00246 int m_progressId;
00247 protected:
00248 virtual void virtual_hook( int id, void* data );
00249 private:
00250 SlaveInterfacePrivate *d;
00251 };
00252
00253 }
00254
00255 inline TQDataStream &operator >>(TQDataStream &s, TDEIO::UDSAtom &a )
00256 {
00257 TQ_INT32 l;
00258 s >> a.m_uds;
00259
00260 if ( a.m_uds & TDEIO::UDS_LONG ) {
00261 s >> l;
00262 a.m_long = l;
00263 a.m_str = TQString::null;
00264 } else if ( a.m_uds & TDEIO::UDS_STRING ) {
00265 s >> a.m_str;
00266 a.m_long = 0;
00267 } else {}
00268
00269
00270 return s;
00271 }
00272
00273 inline TQDataStream &operator <<(TQDataStream &s, const TDEIO::UDSAtom &a )
00274 {
00275 s << a.m_uds;
00276
00277 if ( a.m_uds & TDEIO::UDS_LONG )
00278 s << (TQ_INT32) a.m_long;
00279 else if ( a.m_uds & TDEIO::UDS_STRING )
00280 s << a.m_str;
00281 else {}
00282
00283
00284 return s;
00285 }
00286
00287 TDEIO_EXPORT TQDataStream &operator <<(TQDataStream &s, const TDEIO::UDSEntry &e );
00288 TDEIO_EXPORT TQDataStream &operator >>(TQDataStream &s, TDEIO::UDSEntry &e );
00289
00290 #endif