• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

kurifilter.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00022  *  Boston, MA 02110-1301, 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 ) { reinit( url ); }
00189 
00199     void setData( const KURL& url ) { reinit( 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 ) { reinit( url ); return *this; }
00294 
00303     KURIFilterData& operator=( const QString& url ) { reinit( 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 
00321     // BC hack to avoid leaking KURIFilterDataPrivate objects.
00322     // setData() and operator= used to call init() without deleting `d'
00323     void reinit(const KURL& url);
00324     void reinit(const QString& url = QString::null);
00325 
00326     bool m_bCheckForExecutables;
00327     bool m_bChanged;
00328 
00329     QString m_strErrMsg;
00330     QString m_strIconName;
00331 
00332     KURL m_pURI;
00333     URITypes m_iType;
00334     KURIFilterDataPrivate *d;
00335 };
00336 
00337 
00350 class KIO_EXPORT KURIFilterPlugin : public QObject
00351 {
00352     Q_OBJECT
00353 
00354 public:
00355 
00364     KURIFilterPlugin( QObject *parent = 0, const char *name = 0, double pri = 1.0 );
00365 
00371     virtual QString name() const { return m_strName; }
00372 
00381     virtual double priority() const { return m_dblPriority; }
00382 
00389     virtual bool filterURI( KURIFilterData& data ) const = 0;
00390 
00399     virtual KCModule *configModule( QWidget*, const char* ) const { return 0; }
00400 
00406     virtual QString configName() const { return name(); }
00407 
00408 protected:
00409 
00413     void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
00414 
00418     void setErrorMsg ( KURIFilterData& data, const QString& errmsg ) const {
00419         data.m_strErrMsg = errmsg;
00420     }
00421 
00425     void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
00426         data.m_iType = type;
00427         data.m_bChanged = true;
00428     }
00429 
00434     void setArguments( KURIFilterData& data, const QString& args ) const;
00435 
00436     QString m_strName;
00437     double m_dblPriority;
00438 
00439 protected:
00440     virtual void virtual_hook( int id, void* data );
00441 private:
00442     class KURIFilterPluginPrivate *d;
00443 };
00444 
00445 
00449 class KIO_EXPORT KURIFilterPluginList : public QPtrList<KURIFilterPlugin>
00450 {
00451 public:
00452     virtual int compareItems(Item a, Item b)
00453     {
00454       double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
00455       return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
00456     }
00457 
00458 private:
00459     KURIFilterPrivate *d;
00460 
00461 };
00462 
00534 class KIO_EXPORT KURIFilter
00535 {
00536 public:
00540     ~KURIFilter ();
00541 
00545     static KURIFilter* self();
00546 
00558     bool filterURI( KURIFilterData& data, const QStringList& filters = QStringList() );
00559 
00571     bool filterURI( KURL &uri, const QStringList& filters = QStringList() );
00572 
00584     bool filterURI( QString &uri, const QStringList& filters = QStringList() );
00585 
00597     KURL filteredURI( const KURL &uri, const QStringList& filters = QStringList() );
00598 
00610     QString filteredURI( const QString &uri, const QStringList& filters = QStringList() );
00611 
00618     QPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
00619 
00626     QStringList pluginNames() const;
00627 
00628 protected:
00629 
00637     KURIFilter();
00638 
00645     void loadPlugins();
00646 
00647 private:
00648     static KURIFilter *s_self;
00649     KURIFilterPluginList m_lstPlugins;
00650     KURIFilterPrivate *d;
00651 };
00652 
00653 #endif

kio

Skip menu "kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal