kio Library: kurifilter.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kurifilter.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2000-2001,2003 Dawit Alemayehu <adawit at kde.org>
    00004  *
    00005  *  Original author
    00006  *  Copyright (C) 2000 Yves Arrouye <yves@realnames.com>
    00007  *
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU Library General Public
    00011  *  License as published by the Free Software Foundation; either
    00012  *  version 2 of the License, or (at your option) any later version.
    00013  *
    00014  *  This library is distributed in the hope that it will be useful,
    00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00017  *  Library General Public License for more details.
    00018  *
    00019  *  You should have received a copy of the GNU Library General Public License
    00020  *  along with this library; see the file COPYING.LIB.  If not, write to
    00021  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00022  *  Boston, MA 02111-1307, USA.
    00023  **/
    00024
    00025 #ifndef __kurifilter_h__
    00026 #define __kurifilter_h__
    00027
    00028 #include <qptrlist.h>
    00029 #include <qobject.h>
    00030 #include <qstringlist.h>
    00031
    00032 #include <kurl.h>
    00033
    00034 #ifdef Q_OS_WIN
    00035 #undef ERROR
    00036 #endif
    00037
    00038 class KURIFilterPrivate;
    00039 class KURIFilterDataPrivate;
    00040
    00041 class KCModule;
    00042
    00078 class KIO_EXPORT KURIFilterData
    00079 {
    00080 friend class KURIFilterPlugin;
    00081
    00082 public:
    00099     enum URITypes { NET_PROTOCOL=0, LOCAL_FILE, LOCAL_DIR, EXECUTABLE, HELP, SHELL, BLOCKED, ERROR, UNKNOWN };
    00100
    00106     KURIFilterData() { init(); }
    00107
    00113     KURIFilterData( const KURL& url ) { init( url); }
    00114
    00120     KURIFilterData( const QString& url ) { init( url ); }
    00121
    00130     KURIFilterData( const KURIFilterData& data);
    00131
    00135     ~KURIFilterData();
    00136
    00144     KDE_DEPRECATED bool hasBeenFiltered() const { return true; }
    00145
    00156     KURL uri() const { return m_pURI; }
    00157
    00168     QString errorMsg() const { return m_strErrMsg; }
    00169
    00177     URITypes uriType() const { return m_iType; }
    00178
    00188     void setData( const QString& url ) { init( url ); }
    00189
    00199     void setData( const KURL& url ) { init( url ); }
    00200
    00215     bool setAbsolutePath( const QString& abs_path );
    00216
    00222     QString absolutePath() const;
    00223
    00229     bool hasAbsolutePath() const;
    00230
    00237     QString argsAndOptions() const;
    00238
    00244     bool hasArgsAndOptions() const;
    00245
    00257     QString iconName();
    00258
    00269     void setCheckForExecutables (bool check);
    00270
    00277     bool checkForExecutables() const { return m_bCheckForExecutables; }
    00278
    00283     QString typedString() const;
    00284
    00293     KURIFilterData& operator=( const KURL& url ) { init( url ); return *this; }
    00294
    00303     KURIFilterData& operator=( const QString& url ) { init( url ); return *this; }
    00304
    00305 protected:
    00306
    00311     void init( const KURL& url);
    00312
    00317     void init( const QString& url = QString::null );
    00318
    00319 private:
    00320     bool m_bCheckForExecutables;
    00321     bool m_bChanged;
    00322
    00323     QString m_strErrMsg;
    00324     QString m_strIconName;
    00325
    00326     KURL m_pURI;
    00327     URITypes m_iType;
    00328     KURIFilterDataPrivate *d;
    00329 };
    00330
    00331
    00344 class KIO_EXPORT KURIFilterPlugin : public QObject
    00345 {
    00346     Q_OBJECT
    00347
    00348 public:
    00349
    00358     KURIFilterPlugin( QObject *parent = 0, const char *name = 0, double pri = 1.0 );
    00359
    00365     virtual QString name() const { return m_strName; }
    00366
    00375     virtual double priority() const { return m_dblPriority; }
    00376
    00383     virtual bool filterURI( KURIFilterData& data ) const = 0;
    00384
    00393     virtual KCModule *configModule( QWidget*, const char* ) const { return 0; }
    00394
    00400     virtual QString configName() const { return name(); }
    00401
    00402 protected:
    00403
    00407     void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
    00408
    00412     void setErrorMsg ( KURIFilterData& data, const QString& errmsg ) const {
    00413         data.m_strErrMsg = errmsg;
    00414     }
    00415
    00419     void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
    00420         data.m_iType = type;
    00421         data.m_bChanged = true;
    00422     }
    00423
    00428     void setArguments( KURIFilterData& data, const QString& args ) const;
    00429
    00430     QString m_strName;
    00431     double m_dblPriority;
    00432
    00433 protected:
    00434     virtual void virtual_hook( int id, void* data );
    00435 private:
    00436     class KURIFilterPluginPrivate *d;
    00437 };
    00438
    00439
    00443 class KIO_EXPORT KURIFilterPluginList : public QPtrList<KURIFilterPlugin>
    00444 {
    00445 public:
    00446     virtual int compareItems(Item a, Item b)
    00447     {
    00448       double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
    00449       return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
    00450     }
    00451
    00452 private:
    00453     KURIFilterPrivate *d;
    00454
    00455 };
    00456
    00528 class KIO_EXPORT KURIFilter
    00529 {
    00530 public:
    00534     ~KURIFilter ();
    00535
    00539     static KURIFilter* self();
    00540
    00552     bool filterURI( KURIFilterData& data, const QStringList& filters = QStringList() );
    00553
    00565     bool filterURI( KURL &uri, const QStringList& filters = QStringList() );
    00566
    00578     bool filterURI( QString &uri, const QStringList& filters = QStringList() );
    00579
    00591     KURL filteredURI( const KURL &uri, const QStringList& filters = QStringList() );
    00592
    00604     QString filteredURI( const QString &uri, const QStringList& filters = QStringList() );
    00605
    00612     QPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
    00613
    00620     QStringList pluginNames() const;
    00621
    00622 protected:
    00623
    00631     KURIFilter();
    00632
    00639     void loadPlugins();
    00640
    00641 private:
    00642     static KURIFilter *m_self;
    00643     KURIFilterPluginList m_lstPlugins;
    00644     KURIFilterPrivate *d;
    00645 };
    00646
    00647 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003