kio Library API Documentation

netaccess.h

00001 /*  $Id: netaccess.h,v 1.61.2.1 2004/10/07 12:49:37 zrusin Exp $
00002 
00003     This file is part of the KDE libraries
00004     Copyright (C) 1997 Torben Weis (weis@kde.org)
00005     Copyright (C) 1998 Matthias Ettrich (ettrich@kde.org)
00006     Copyright (C) 1999 David Faure (faure@kde.org)
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021     Boston, MA 02111-1307, USA.
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     // KDE4: rename to file_copy
00176 
00180     static bool copy( const KURL& src, const KURL& target ) KDE_DEPRECATED;
00181     // KDE4: merge with above
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; // KDE4: merge
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; // KDE4: merge
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; // not really needed, the ctor is private already.
00498 };
00499 
00500 }
00501 
00502 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Feb 18 15:10:44 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003