kprotocolinfo.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Torben Weis <weis@kde.org> 00003 Copyright (C) 2000-2001 Waldo Bastian <bastian@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef __kprotocolinfo_h__ 00020 #define __kprotocolinfo_h__ 00021 00022 #include <tqstring.h> 00023 #include <tqstringlist.h> 00024 #include <tqdatastream.h> 00025 00026 #include <kurl.h> 00027 #include <ksycocaentry.h> 00028 #include <ksycocatype.h> 00029 00044 class KIO_EXPORT KProtocolInfo : public KSycocaEntry 00045 { 00046 friend class KProtocolInfoFactory; 00047 K_SYCOCATYPE( KST_KProtocolInfo, KSycocaEntry ) 00048 00049 public: 00050 typedef KSharedPtr<KProtocolInfo> Ptr; 00051 00052 public: 00057 KProtocolInfo( const TQString & path); // KDE4: make private and add friend class KProtocolInfoBuildFactory 00058 // Then we can get rid of the d pointer 00059 00064 virtual bool isValid() const { return !m_name.isEmpty(); } 00065 00074 virtual TQString name() const { return m_name; } 00075 00076 // 00077 // Static functions: 00078 // 00079 00084 static TQStringList protocols(); 00085 00093 static bool isKnownProtocol( const KURL &url ); 00094 00099 static bool isKnownProtocol( const TQString& protocol ) 00100 #ifdef KPROTOCOLINFO_KDECORE 00101 KDE_WEAK_SYMBOL 00102 #endif 00103 ; 00104 00116 static TQString exec( const TQString& protocol ); 00117 00121 enum Type { T_STREAM, 00122 T_FILESYSTEM, 00123 T_NONE, 00124 T_ERROR 00125 }; 00126 00137 static Type inputType( const KURL &url ); 00138 00149 static Type outputType( const KURL &url ); 00150 00163 static TQStringList listing( const KURL &url ); 00164 00175 struct ExtraField { 00176 ExtraField() {} // for QValueList 00177 ExtraField(const TQString& _name, const TQString& _type ) 00178 : name(_name), type(_type) { 00179 } 00180 TQString name; 00181 TQString type; // KDE4: make it TQVariant::Type 00182 }; 00183 typedef TQValueList<ExtraField > ExtraFieldList; 00193 static ExtraFieldList extraFields( const KURL& url ); 00194 00208 static bool isSourceProtocol( const KURL &url ); 00209 00222 static bool isHelperProtocol( const KURL &url ); 00223 00228 static bool isHelperProtocol( const TQString& protocol ) 00229 #ifdef KPROTOCOLINFO_KDECORE 00230 KDE_WEAK_SYMBOL 00231 #endif 00232 ; 00233 00250 static bool isFilterProtocol( const KURL &url ); 00251 00256 static bool isFilterProtocol( const TQString& protocol ) 00257 #ifdef KPROTOCOLINFO_KDECORE 00258 KDE_WEAK_SYMBOL 00259 #endif 00260 ; 00261 00277 static bool supportsListing( const KURL &url ); 00278 00288 static bool supportsReading( const KURL &url ); 00289 00299 static bool supportsWriting( const KURL &url ); 00300 00310 static bool supportsMakeDir( const KURL &url ); 00311 00321 static bool supportsDeleting( const KURL &url ); 00322 00332 static bool supportsLinking( const KURL &url ); 00333 00344 static bool supportsMoving( const KURL &url ); 00345 00358 static bool canCopyFromFile( const KURL &url ); 00359 00372 static bool canCopyToFile( const KURL &url ); 00373 00387 static bool canRenameFromFile( const KURL &url ); 00388 00402 static bool canRenameToFile( const KURL &url ); 00403 00416 static bool canDeleteRecursive( const KURL &url ); 00417 00418 typedef enum { Name, FromURL } FileNameUsedForCopying; 00419 00436 static FileNameUsedForCopying fileNameUsedForCopying( const KURL &url ); 00437 00446 static TQString defaultMimetype( const KURL& url ); 00447 00456 static TQString icon( const TQString& protocol ); 00457 00469 static TQString config( const TQString& protocol ); 00470 00483 static int maxSlaves( const TQString& protocol ); 00484 00496 static bool determineMimetypeFromExtension( const TQString &protocol ); 00497 00507 static TQString docPath( const TQString& protocol ); 00508 00525 static TQString protocolClass( const TQString& protocol ); 00526 00538 static bool showFilePreview( const TQString& protocol ); 00539 00555 static KURL::URIMode uriParseMode( const TQString& protocol ); 00556 00575 static TQStringList capabilities( const TQString& protocol ); 00576 00588 static TQString proxiedBy( const TQString& protocol ); 00589 00590 public: 00591 // Internal functions: 00595 KProtocolInfo( TQDataStream& _str, int offset); 00596 00597 virtual ~KProtocolInfo(); 00598 00603 virtual void load(TQDataStream& ); 00604 00609 virtual void save(TQDataStream& ); 00610 00612 // The following methods are deprecated: 00613 00615 static Type inputType( const TQString& protocol ) KDE_DEPRECATED; 00617 static Type outputType( const TQString& protocol ) KDE_DEPRECATED; 00624 static TQStringList listing( const TQString& protocol ) KDE_DEPRECATED; 00626 static bool isSourceProtocol( const TQString& protocol ) KDE_DEPRECATED; 00628 static bool supportsListing( const TQString& protocol ) KDE_DEPRECATED; 00630 static bool supportsReading( const TQString& protocol ) KDE_DEPRECATED; 00632 static bool supportsWriting( const TQString& protocol ) KDE_DEPRECATED; 00634 static bool supportsMakeDir( const TQString& protocol ) KDE_DEPRECATED; 00636 static bool supportsDeleting( const TQString& protocol ) KDE_DEPRECATED; 00638 static bool supportsLinking( const TQString& protocol ) KDE_DEPRECATED; 00640 static bool supportsMoving( const TQString& protocol ) KDE_DEPRECATED; 00642 static bool canCopyFromFile( const TQString& protocol ) KDE_DEPRECATED; 00644 static bool canCopyToFile( const TQString& protocol ) KDE_DEPRECATED; 00646 static TQString defaultMimetype( const TQString& protocol) KDE_DEPRECATED; 00648 00649 protected: 00650 TQString m_name; 00651 TQString m_exec; 00652 Type m_inputType; 00653 Type m_outputType; 00654 TQStringList m_listing; 00655 bool m_isSourceProtocol; 00656 bool m_isHelperProtocol; 00657 bool m_supportsListing; 00658 bool m_supportsReading; 00659 bool m_supportsWriting; 00660 bool m_supportsMakeDir; 00661 bool m_supportsDeleting; 00662 bool m_supportsLinking; 00663 bool m_supportsMoving; 00664 TQString m_defaultMimetype; 00665 bool m_determineMimetypeFromExtension; 00666 TQString m_icon; 00667 bool m_canCopyFromFile; 00668 bool m_canCopyToFile; 00669 TQString m_config; 00670 int m_maxSlaves; 00671 00672 bool canRenameFromFile() const; // for kprotocolinfo_kdecore 00673 bool canRenameToFile() const; // for kprotocolinfo_kdecore 00674 bool canDeleteRecursive() const; // for kprotocolinfo_kdecore 00675 FileNameUsedForCopying fileNameUsedForCopying() const; // for kprotocolinfo_kdecore 00676 static KProtocolInfo* findProtocol(const KURL &url); // for kprotocolinfo_kdecore 00677 00678 protected: 00679 virtual void virtual_hook( int id, void* data ); 00680 private: 00681 class KProtocolInfoPrivate; 00682 KProtocolInfoPrivate* d; 00683 }; 00684 00685 KIO_EXPORT TQDataStream& operator>>( TQDataStream& s, KProtocolInfo::ExtraField& field ); 00686 KIO_EXPORT TQDataStream& operator<<( TQDataStream& s, const KProtocolInfo::ExtraField& field ); 00687 00688 #endif