kio Library API Documentation

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__ "$Id: kurifilter.h,v 1.41 2003/08/30 08:56:21 raabe Exp $"
00027 
00028 #include <qptrlist.h>
00029 #include <qobject.h>
00030 #include <qstringlist.h>
00031 
00032 #include <kurl.h>
00033 #include <kdemacros.h>
00034 
00035 class KURIFilterPrivate;
00036 class KURIFilterDataPrivate;
00037 
00038 class KCModule;
00039 
00075 class KURIFilterData
00076 {
00077 friend class KURIFilterPlugin;
00078 
00079 public:
00096     enum URITypes { NET_PROTOCOL=0, LOCAL_FILE, LOCAL_DIR, EXECUTABLE, HELP, SHELL, BLOCKED, ERROR, UNKNOWN };
00097 
00103     KURIFilterData() { init(); }
00104 
00110     KURIFilterData( const KURL& url ) { init( url); }
00111 
00117     KURIFilterData( const QString& url ) { init( url ); }
00118 
00127     KURIFilterData( const KURIFilterData& data);
00128 
00132     ~KURIFilterData();
00133 
00141     KDE_DEPRECATED bool hasBeenFiltered() const { return true; }
00142 
00153     KURL uri() const { return m_pURI; }
00154 
00165     QString errorMsg() const { return m_strErrMsg; }
00166 
00174     URITypes uriType() const { return m_iType; }
00175 
00185     void setData( const QString& url ) { init( url ); }
00186 
00196     void setData( const KURL& url ) { init( url ); }
00197 
00212     bool setAbsolutePath( const QString& abs_path );
00213 
00219     QString absolutePath() const;
00220 
00226     bool hasAbsolutePath() const;
00227 
00234     QString argsAndOptions() const;
00235 
00241     bool hasArgsAndOptions() const;
00242 
00254     QString iconName();
00255 
00266     void setCheckForExecutables (bool check);
00267 
00274     bool checkForExecutables() const { return m_bCheckForExecutables; }
00275 
00280     QString typedString() const;
00281 
00290     KURIFilterData& operator=( const KURL& url ) { init( url ); return *this; }
00291 
00300     KURIFilterData& operator=( const QString& url ) { init( url ); return *this; }
00301 
00302 protected:
00303 
00308     void init( const KURL& url);
00309 
00314     void init( const QString& url = QString::null );
00315 
00316 private:
00317     bool m_bCheckForExecutables;
00318     bool m_bChanged;
00319 
00320     QString m_strErrMsg;
00321     QString m_strIconName;
00322 
00323     KURL m_pURI;
00324     URITypes m_iType;
00325     KURIFilterDataPrivate *d;
00326 };
00327 
00328 
00341 class KURIFilterPlugin : public QObject
00342 {
00343     Q_OBJECT
00344 
00345 public:
00346 
00355     KURIFilterPlugin( QObject *parent = 0, const char *name = 0, double pri = 1.0 );
00356 
00362     virtual QString name() const { return m_strName; }
00363 
00372     virtual double priority() const { return m_dblPriority; }
00373 
00380     virtual bool filterURI( KURIFilterData& data ) const = 0;
00381 
00390     virtual KCModule *configModule( QWidget*, const char* ) const { return 0; }
00391 
00397     virtual QString configName() const { return name(); }
00398 
00399 protected:
00400 
00404     void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
00405 
00409     void setErrorMsg ( KURIFilterData& data, const QString& errmsg ) const {
00410         data.m_strErrMsg = errmsg;
00411     }
00412 
00416     void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
00417         data.m_iType = type;
00418         data.m_bChanged = true;
00419     }
00420 
00425     void setArguments( KURIFilterData& data, const QString& args ) const;
00426 
00427     QString m_strName;
00428     double m_dblPriority;
00429 
00430 protected:
00431     virtual void virtual_hook( int id, void* data );
00432 private:
00433     class KURIFilterPluginPrivate *d;
00434 };
00435 
00436 
00440 class KURIFilterPluginList : public QPtrList<KURIFilterPlugin>
00441 {
00442 public:
00443     virtual int compareItems(Item a, Item b)
00444     {
00445       double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
00446       return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
00447     }
00448 
00449 private:
00450     KURIFilterPrivate *d;
00451 
00452 };
00453 
00525 class KURIFilter
00526 {
00527 public:
00531     ~KURIFilter ();
00532 
00536     static KURIFilter* self();
00537 
00549     bool filterURI( KURIFilterData& data, const QStringList& filters = QStringList() );
00550 
00562     bool filterURI( KURL &uri, const QStringList& filters = QStringList() );
00563 
00575     bool filterURI( QString &uri, const QStringList& filters = QStringList() );
00576 
00588     KURL filteredURI( const KURL &uri, const QStringList& filters = QStringList() );
00589 
00601     QString filteredURI( const QString &uri, const QStringList& filters = QStringList() );
00602 
00609     QPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
00610 
00617     QStringList pluginNames() const;
00618 
00619 protected:
00620 
00628     KURIFilter();
00629 
00636     void loadPlugins();
00637 
00638 private:
00639     static KURIFilter *m_self;
00640     KURIFilterPluginList m_lstPlugins;
00641     KURIFilterPrivate *d;
00642 };
00643 
00644 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:03:23 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003