netaccess.h
00001 /* 00002 This file is part of the KDE libraries 00003 Copyright (C) 1997 Torben Weis (weis@kde.org) 00004 Copyright (C) 1998 Matthias Ettrich (ettrich@kde.org) 00005 Copyright (C) 1999-2004 David Faure (faure@kde.org) 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __kio_netaccess_h 00024 #define __kio_netaccess_h 00025 00026 #include <tqobject.h> 00027 #include <tqstring.h> 00028 #include <kio/global.h> 00029 00030 class TQStringList; 00031 class TQWidget; 00032 class KURL; 00033 template<typename T, typename K> class TQMap; 00034 00035 namespace KIO { 00036 00037 class Job; 00038 00059 class KIO_EXPORT NetAccess : public TQObject 00060 { 00061 Q_OBJECT 00062 00063 public: 00117 static bool download(const KURL& src, TQString & target, TQWidget* window); 00118 00122 static bool download(const KURL& src, TQString & target) KDE_DEPRECATED; 00123 00135 static void removeTempFile(const TQString& name); 00136 00156 static bool upload(const TQString& src, const KURL& target, TQWidget* window); 00157 00161 static bool upload(const TQString& src, const KURL& target) KDE_DEPRECATED; 00162 00181 static bool copy( const KURL& src, const KURL& target, TQWidget* window ); 00182 // KDE4: rename to file_copy 00183 00187 static bool copy( const KURL& src, const KURL& target ) KDE_DEPRECATED; 00188 // KDE4: merge with above 00189 00193 static bool file_copy( const KURL& src, const KURL& dest, int permissions=-1, 00194 bool overwrite=false, bool resume=false, TQWidget* window = 0L ); 00195 00201 static bool file_move( const KURL& src, const KURL& target, int permissions=-1, 00202 bool overwrite=false, bool resume=false, TQWidget* window = 0L ); 00203 00204 00224 static bool dircopy( const KURL& src, const KURL& target, TQWidget* window ); 00225 00229 static bool dircopy( const KURL& src, const KURL& target ) KDE_DEPRECATED; // KDE4: merge 00230 00234 static bool dircopy( const KURL::List& src, const KURL& target, TQWidget* window = 0L ); 00235 00241 static bool move( const KURL& src, const KURL& target, TQWidget* window = 0L ); 00242 00248 static bool move( const KURL::List& src, const KURL& target, TQWidget* window = 0L ); 00249 00266 static bool exists(const KURL& url, bool source, TQWidget* window); 00267 00272 static bool exists(const KURL& url, TQWidget* window) KDE_DEPRECATED; 00273 00277 static bool exists(const KURL& url) KDE_DEPRECATED; 00278 00282 static bool exists(const KURL& url, bool source) KDE_DEPRECATED; // KDE4: merge 00283 00300 static bool stat(const KURL& url, KIO::UDSEntry & entry, TQWidget* window); 00301 00305 static bool stat(const KURL& url, KIO::UDSEntry & entry) KDE_DEPRECATED; 00306 00323 static KURL mostLocalURL(const KURL& url, TQWidget* window); 00324 00339 static bool del( const KURL & url, TQWidget* window ); 00340 00347 static bool del( const KURL & url ) KDE_DEPRECATED; 00348 00364 static bool mkdir( const KURL & url, TQWidget* window, int permissions = -1 ); 00365 00372 static bool mkdir( const KURL & url, int permissions = -1 ) KDE_DEPRECATED; 00373 00392 static TQString fish_execute( const KURL & url, const TQString command, TQWidget* window ); 00393 00428 static bool synchronousRun( Job* job, TQWidget* window, TQByteArray* data=0, 00429 KURL* finalURL=0, TQMap<TQString,TQString>* metaData=0 ); 00430 00453 static TQString mimetype( const KURL & url, TQWidget* window ); 00454 00461 static TQString mimetype( const KURL & url ) KDE_DEPRECATED; 00462 00468 static TQString lastErrorString() { return lastErrorMsg ? *lastErrorMsg : TQString::null; } 00469 00475 static int lastError() { return lastErrorCode; } 00476 00477 private: 00481 NetAccess() : m_metaData(0), d(0) {} 00482 00486 ~NetAccess() {} 00487 00491 bool filecopyInternal(const KURL& src, const KURL& target, int permissions, 00492 bool overwrite, bool resume, TQWidget* window, bool move); 00493 bool dircopyInternal(const KURL::List& src, const KURL& target, 00494 TQWidget* window, bool move); 00495 bool statInternal(const KURL & url, int details, bool source, TQWidget* window = 0); 00496 00497 bool delInternal(const KURL & url, TQWidget* window = 0); 00498 bool mkdirInternal(const KURL & url, int permissions, TQWidget* window = 0); 00499 TQString fish_executeInternal(const KURL & url, const TQString command, TQWidget* window = 0); 00500 bool synchronousRunInternal( Job* job, TQWidget* window, TQByteArray* data, 00501 KURL* finalURL, TQMap<TQString,TQString>* metaData ); 00502 00503 TQString mimetypeInternal(const KURL & url, TQWidget* window = 0); 00504 void enter_loop(); 00505 00509 static TQStringList* tmpfiles; 00510 00511 static TQString* lastErrorMsg; 00512 static int lastErrorCode; 00513 00514 friend class I_like_this_class; 00515 00516 private slots: 00517 void slotResult( KIO::Job * job ); 00518 void slotMimetype( KIO::Job * job, const TQString & type ); 00519 void slotData( KIO::Job*, const TQByteArray& ); 00520 void slotRedirection( KIO::Job*, const KURL& ); 00521 00522 private: 00523 UDSEntry m_entry; 00524 TQString m_mimetype; 00525 TQByteArray m_data; 00526 KURL m_url; 00527 TQMap<TQString, TQString> *m_metaData; 00528 00532 bool bJobOK; 00533 00534 private: 00535 class NetAccessPrivate* d; // not really needed, the ctor is private already. 00536 }; 00537 00538 } 00539 00540 #endif