00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __kio_netaccess_h
00025 #define __kio_netaccess_h
00026
00027 #include <qobject.h>
00028 #include <qstring.h>
00029 #include <kio/global.h>
00030 #include <kdemacros.h>
00031
00032 class QStringList;
00033 class QWidget;
00034 class KURL;
00035 template<typename T, typename K> class QMap;
00036
00037 namespace KIO {
00038
00039 class Job;
00040
00061 class NetAccess : public QObject
00062 {
00063 Q_OBJECT
00064
00065 public:
00111 static bool download(const KURL& src, QString & target, QWidget* window);
00112
00116 static bool download(const KURL& src, QString & target) KDE_DEPRECATED;
00117
00129 static void removeTempFile(const QString& name);
00130
00149 static bool upload(const QString& src, const KURL& target, QWidget* window);
00150
00154 static bool upload(const QString& src, const KURL& target) KDE_DEPRECATED;
00155
00174 static bool copy( const KURL& src, const KURL& target, QWidget* window );
00175
00176
00180 static bool copy( const KURL& src, const KURL& target ) KDE_DEPRECATED;
00181
00182
00186 static bool file_copy( const KURL& src, const KURL& dest, int permissions=-1,
00187 bool overwrite=false, bool resume=false, QWidget* window = 0L );
00188
00194 static bool file_move( const KURL& src, const KURL& target, int permissions=-1,
00195 bool overwrite=false, bool resume=false, QWidget* window = 0L );
00196
00197
00217 static bool dircopy( const KURL& src, const KURL& target, QWidget* window );
00218
00222 static bool dircopy( const KURL& src, const KURL& target ) KDE_DEPRECATED;
00223
00227 static bool dircopy( const KURL::List& src, const KURL& target, QWidget* window = 0L );
00228
00234 static bool move( const KURL& src, const KURL& target, QWidget* window = 0L );
00235
00241 static bool move( const KURL::List& src, const KURL& target, QWidget* window = 0L );
00242
00258 static bool exists(const KURL& url, bool source, QWidget* window);
00259
00263 static bool exists(const KURL& url, QWidget* window) KDE_DEPRECATED;
00264
00268 static bool exists(const KURL& url) KDE_DEPRECATED;
00269
00273 static bool exists(const KURL& url, bool source) KDE_DEPRECATED;
00274
00291 static bool stat(const KURL& url, KIO::UDSEntry & entry, QWidget* window);
00292
00296 static bool stat(const KURL& url, KIO::UDSEntry & entry) KDE_DEPRECATED;
00297
00312 static bool del( const KURL & url, QWidget* window );
00313
00317 static bool del( const KURL & url ) KDE_DEPRECATED;
00318
00333 static bool mkdir( const KURL & url, QWidget* window, int permissions = -1 );
00334
00338 static bool mkdir( const KURL & url, int permissions = -1 ) KDE_DEPRECATED;
00339
00358 static QString fish_execute( const KURL & url, const QString command, QWidget* window );
00359
00394 static bool synchronousRun( Job* job, QWidget* window, QByteArray* data=0,
00395 KURL* finalURL=0, QMap<QString,QString>* metaData=0 );
00396
00419 static QString mimetype( const KURL & url, QWidget* window );
00420
00424 static QString mimetype( const KURL & url ) KDE_DEPRECATED;
00425
00430 static QString lastErrorString() { return lastErrorMsg ? *lastErrorMsg : QString::null; }
00431
00437 static int lastError() { return lastErrorCode; }
00438
00439 private:
00443 NetAccess() : m_metaData(0), d(0) {}
00444
00448 ~NetAccess() {}
00449
00453 bool filecopyInternal(const KURL& src, const KURL& target, int permissions,
00454 bool overwrite, bool resume, QWidget* window, bool move);
00455 bool dircopyInternal(const KURL::List& src, const KURL& target,
00456 QWidget* window, bool move);
00457 bool statInternal(const KURL & url, int details, bool source, QWidget* window = 0);
00458
00459 bool delInternal(const KURL & url, QWidget* window = 0);
00460 bool mkdirInternal(const KURL & url, int permissions, QWidget* window = 0);
00461 QString fish_executeInternal(const KURL & url, const QString command, QWidget* window = 0);
00462 bool synchronousRunInternal( Job* job, QWidget* window, QByteArray* data,
00463 KURL* finalURL, QMap<QString,QString>* metaData );
00464
00465 QString mimetypeInternal(const KURL & url, QWidget* window = 0);
00466 void enter_loop();
00467
00471 static QStringList* tmpfiles;
00472
00473 static QString* lastErrorMsg;
00474 static int lastErrorCode;
00475
00476 friend class I_like_this_class;
00477
00478 private slots:
00479 void slotResult( KIO::Job * job );
00480 void slotMimetype( KIO::Job * job, const QString & type );
00481 void slotData( KIO::Job*, const QByteArray& );
00482 void slotRedirection( KIO::Job*, const KURL& );
00483
00484 private:
00485 UDSEntry m_entry;
00486 QString m_mimetype;
00487 QByteArray m_data;
00488 KURL m_url;
00489 QMap<QString, QString> *m_metaData;
00490
00494 bool bJobOK;
00495
00496 private:
00497 class NetAccessPrivate* d;
00498 };
00499
00500 }
00501
00502 #endif