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

# kurifilter.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2000 Yves Arrouye <yves@realnames.com>
    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 as published by the Free Software Foundation; either
    00008  *  version 2 of the License, or (at your option) any later version.
    00009  *
    00010  *  This library is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  *  Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this library; see the file COPYING.LIB.  If not, write to
    00017  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  *  Boston, MA 02111-1307, USA.
    00019  **/
    00020
    00021 #ifndef __kurifilter_h__
    00022 #define __kurifilter_h__ "$Id: kurifilter.h,v 1.27.2.1 2003/06/06 09:12:16 mueller Exp $"
    00023
    00024 #include <qstringlist.h>
    00025 #include <qobject.h>
    00026
    00027 #include <kurl.h>
    00028
    00029 class KURIFilterPrivate;
    00030 class KURIFilterDataPrivate;
    00031
    00032 class QStringList;
    00033 class KCModule;
    00034
    00064 class KURIFilterData
    00065 {
    00066 friend class KURIFilterPlugin;
    00067
    00068 public:
    00087     enum URITypes { NET_PROTOCOL=0, LOCAL_FILE, LOCAL_DIR, EXECUTABLE, HELP, SHELL, BLOCKED, ERROR, UNKNOWN };
    00088
    00094     KURIFilterData() { init(); }
    00095
    00101     KURIFilterData( const KURL& url ) { init( url); }
    00102
    00108     KURIFilterData( const QString& url ) { init( url ); }
    00109
    00118     KURIFilterData( const KURIFilterData& /*data*/);
    00119
    00123     ~KURIFilterData();
    00124
    00132     bool hasBeenFiltered() const { return m_bFiltered; }
    00133
    00144     KURL uri() const { return m_pURI; }
    00145
    00156     QString errorMsg() const { return m_strErrMsg; }
    00157
    00164     URITypes uriType() const { return m_iType; }
    00165
    00175     void setData( const QString& url ) { init( url ); }
    00176
    00186     void setData( const KURL& url ) { init( url ); }
    00187
    00204     bool setAbsolutePath( const QString& /* abs_path */ );
    00205
    00209     QString absolutePath() const;
    00210
    00214     bool hasAbsolutePath() const;
    00215
    00222     QString argsAndOptions() const;
    00223
    00228     bool hasArgsAndOptions() const;
    00229
    00240     QString iconName();
    00241
    00250     KURIFilterData& operator=( const KURL& url ) { init( url ); return *this; }
    00251
    00260     KURIFilterData& operator=( const QString& url ) { init( url ); return *this; }
    00261
    00262 protected:
    00263
    00267     void init( const KURL& url = QString::null );
    00268
    00269 private:
    00270     bool m_bFiltered;
    00271     bool m_bChanged;
    00272
    00273     QString m_strErrMsg;
    00274     QString m_strIconName;
    00275
    00276     KURL m_pURI;
    00277     URITypes m_iType;
    00278     KURIFilterDataPrivate *d;
    00279 };
    00280
    00281
    00296 class KURIFilterPlugin : public QObject
    00297 {
    00298     Q_OBJECT
    00299
    00300 public:
    00301
    00310     KURIFilterPlugin( QObject *parent = 0, const char *name = 0, double pri = 1.0 );
    00311
    00317     virtual QString name() const { return m_strName; }
    00318
    00327     virtual double priority() const { return m_dblPriority; }
    00328
    00335     virtual bool filterURI( KURIFilterData& data ) const = 0;
    00336
    00345     virtual KCModule *configModule( QWidget*, const char* ) const { return 0; }
    00346
    00352     virtual QString configName() const { return name(); }
    00353
    00354 protected:
    00355
    00359     void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
    00360
    00364     void setErrorMsg ( KURIFilterData& data, const QString& errmsg ) const {
    00365         data.m_strErrMsg = errmsg;
    00366     }
    00367
    00371     void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
    00372         data.m_iType = type;
    00373         data.m_bChanged = true;
    00374     }
    00375
    00380     void setArguments( KURIFilterData& data, const QString& args ) const;
    00381
    00382     QString m_strName;
    00383     double m_dblPriority;
    00384
    00385 protected:
    00386     virtual void virtual_hook( int id, void* data );
    00387 private:
    00388     class KURIFilterPluginPrivate *d;
    00389 };
    00390
    00391
    00392 class KURIFilterPluginList : public QPtrList<KURIFilterPlugin>
    00393 {
    00394 public:
    00395     virtual int compareItems(Item a, Item b)
    00396     {
    00397             double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
    00398         return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
    00399     }
    00400
    00401 private:
    00402     KURIFilterPrivate *d;
    00403
    00404 };
    00405
    00469 class KURIFilter
    00470 {
    00471 public:
    00475     ~KURIFilter ();
    00476
    00480     static KURIFilter* self();
    00481
    00495     bool filterURI( KURIFilterData& data, const QStringList& filters = QStringList() );
    00496
    00510     bool filterURI( KURL &uri, const QStringList& filters = QStringList() );
    00511
    00525     bool filterURI( QString &uri, const QStringList& filters = QStringList() );
    00526
    00540     KURL filteredURI( const KURL &uri, const QStringList& filters = QStringList() );
    00541
    00555     QString filteredURI( const QString &uri, const QStringList& filters = QStringList() );
    00556
    00563     QPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
    00564
    00572     QStringList pluginNames() const;
    00573
    00574 protected:
    00575
    00583     KURIFilter();
    00584
    00591     void loadPlugins();
    00592
    00593 private:
    00594
    00595     static KURIFilter *m_self;
    00596     KURIFilterPluginList m_lstPlugins;
    00597     KURIFilterPrivate *d;
    00598
    00599 };
    00600
    00601 #endif
    00602

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:31 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001