00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __kurifilter_h__
00026 #define __kurifilter_h__
00027
00028 #include <tqptrlist.h>
00029 #include <tqobject.h>
00030 #include <tqstringlist.h>
00031 #include <tqpixmap.h>
00032
00033 #include <kurl.h>
00034
00035 #ifdef Q_OS_WIN
00036 #undef ERROR
00037 #endif
00038
00039 class KURIFilterPrivate;
00040 class KURIFilterDataPrivate;
00041
00042 class TDECModule;
00043
00079 class TDEIO_EXPORT KURIFilterData
00080 {
00081 friend class KURIFilterPlugin;
00082
00083 public:
00100 enum URITypes { NET_PROTOCOL=0, LOCAL_FILE, LOCAL_DIR, EXECUTABLE, HELP, SHELL, BLOCKED, ERROR, UNKNOWN };
00101
00107 KURIFilterData() { init(); }
00108
00114 KURIFilterData( const KURL& url ) { init( url); }
00115
00121 KURIFilterData( const TQString& url ) { init( url ); }
00122
00131 KURIFilterData( const KURIFilterData& data);
00132
00136 ~KURIFilterData();
00137
00145 KDE_DEPRECATED bool hasBeenFiltered() const { return true; }
00146
00157 KURL uri() const { return m_pURI; }
00158
00169 TQString errorMsg() const { return m_strErrMsg; }
00170
00178 URITypes uriType() const { return m_iType; }
00179
00189 void setData( const TQString& url ) { reinit( url ); }
00190
00200 void setData( const KURL& url ) { reinit( url ); }
00201
00216 bool setAbsolutePath( const TQString& abs_path );
00217
00223 TQString absolutePath() const;
00224
00230 bool hasAbsolutePath() const;
00231
00238 TQString argsAndOptions() const;
00239
00245 bool hasArgsAndOptions() const;
00246
00258 TQString iconName();
00259
00268 TQPixmap customIconPixmap();
00269
00280 void setCheckForExecutables (bool check);
00281
00288 bool checkForExecutables() const { return m_bCheckForExecutables; }
00289
00294 TQString typedString() const;
00295
00304 KURIFilterData& operator=( const KURL& url ) { reinit( url ); return *this; }
00305
00314 KURIFilterData& operator=( const TQString& url ) { reinit( url ); return *this; }
00315
00316 protected:
00317
00322 void init( const KURL& url);
00323
00328 void init( const TQString& url = TQString::null );
00329
00330 private:
00331
00332
00333
00334 void reinit(const KURL& url);
00335 void reinit(const TQString& url = TQString::null);
00336
00337 bool m_bCheckForExecutables;
00338 bool m_bChanged;
00339
00340 TQString m_strErrMsg;
00341 TQString m_strIconName;
00342
00343 KURL m_pURI;
00344 URITypes m_iType;
00345 KURIFilterDataPrivate *d;
00346
00347 TQPixmap m_customIconPixmap;
00348 };
00349
00350
00363 class TDEIO_EXPORT KURIFilterPlugin : public TQObject
00364 {
00365 Q_OBJECT
00366
00367
00368 public:
00369
00378 KURIFilterPlugin( TQObject *parent = 0, const char *name = 0, double pri = 1.0 );
00379
00385 virtual TQString name() const { return m_strName; }
00386
00395 virtual double priority() const { return m_dblPriority; }
00396
00403 virtual bool filterURI( KURIFilterData& data ) const = 0;
00404
00413 virtual TDECModule *configModule( TQWidget*, const char* ) const { return 0; }
00414
00420 virtual TQString configName() const { return name(); }
00421
00422 protected:
00423
00427 void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
00428
00432 void setErrorMsg ( KURIFilterData& data, const TQString& errmsg ) const {
00433 data.m_strErrMsg = errmsg;
00434 }
00435
00439 void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
00440 data.m_iType = type;
00441 data.m_bChanged = true;
00442 }
00443
00448 void setArguments( KURIFilterData& data, const TQString& args ) const;
00449
00450 TQString m_strName;
00451 double m_dblPriority;
00452
00453 protected:
00454 virtual void virtual_hook( int id, void* data );
00455 private:
00456 class KURIFilterPluginPrivate *d;
00457 };
00458
00459
00463 class TDEIO_EXPORT KURIFilterPluginList : public TQPtrList<KURIFilterPlugin>
00464 {
00465 public:
00466 virtual int compareItems(Item a, Item b)
00467 {
00468 double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
00469 return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
00470 }
00471
00472 private:
00473 KURIFilterPrivate *d;
00474
00475 };
00476
00548 class TDEIO_EXPORT KURIFilter
00549 {
00550 public:
00554 ~KURIFilter ();
00555
00559 static KURIFilter* self();
00560
00572 bool filterURI( KURIFilterData& data, const TQStringList& filters = TQStringList() );
00573
00585 bool filterURI( KURL &uri, const TQStringList& filters = TQStringList() );
00586
00598 bool filterURI( TQString &uri, const TQStringList& filters = TQStringList() );
00599
00611 KURL filteredURI( const KURL &uri, const TQStringList& filters = TQStringList() );
00612
00624 TQString filteredURI( const TQString &uri, const TQStringList& filters = TQStringList() );
00625
00632 TQPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
00633
00640 TQStringList pluginNames() const;
00641
00642 protected:
00643
00651 KURIFilter();
00652
00659 void loadPlugins();
00660
00661 private:
00662 static KURIFilter *s_self;
00663 KURIFilterPluginList m_lstPlugins;
00664 KURIFilterPrivate *d;
00665 };
00666
00667 #endif