kurifilter.h
/*
* This file is part of the KDE libraries
* Copyright (C) 2000-2001,2003 Dawit Alemayehu <adawit at kde.org>
*
* Original author
* Copyright (C) 2000 Yves Arrouye <yves@realnames.com>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef __kurifilter_h__
#define __kurifilter_h__
#include <qptrlist.h>
#include <qobject.h>
#include <qstringlist.h>
#include <kurl.h>
#ifdef Q_OS_WIN
#undef ERROR
#endif
class KURIFilterPrivate;
class KURIFilterDataPrivate;
class KCModule;
class KIO_EXPORT KURIFilterData
{
friend class KURIFilterPlugin;
public:
enum URITypes { NET_PROTOCOL=0, LOCAL_FILE, LOCAL_DIR, EXECUTABLE, HELP, SHELL, BLOCKED, ERROR, UNKNOWN };
KURIFilterData() { init(); }
KURIFilterData( const KURL& url ) { init( url); }
KURIFilterData( const QString& url ) { init( url ); }
KURIFilterData( const KURIFilterData& data);
~KURIFilterData();
KDE_DEPRECATED bool hasBeenFiltered() const { return true; }
KURL uri() const { return m_pURI; }
QString errorMsg() const { return m_strErrMsg; }
URITypes uriType() const { return m_iType; }
void setData( const QString& url ) { reinit( url ); }
void setData( const KURL& url ) { reinit( url ); }
bool setAbsolutePath( const QString& abs_path );
QString absolutePath() const;
bool hasAbsolutePath() const;
QString argsAndOptions() const;
bool hasArgsAndOptions() const;
QString iconName();
void setCheckForExecutables (bool check);
bool checkForExecutables() const { return m_bCheckForExecutables; }
QString typedString() const;
KURIFilterData& operator=( const KURL& url ) { reinit( url ); return *this; }
KURIFilterData& operator=( const QString& url ) { reinit( url ); return *this; }
protected:
void init( const KURL& url);
void init( const QString& url = QString::null );
private:
// BC hack to avoid leaking KURIFilterDataPrivate objects.
// setData() and operator= used to call init() without deleting `d'
void reinit(const KURL& url);
void reinit(const QString& url = QString::null);
bool m_bCheckForExecutables;
bool m_bChanged;
QString m_strErrMsg;
QString m_strIconName;
KURL m_pURI;
URITypes m_iType;
KURIFilterDataPrivate *d;
};
class KIO_EXPORT KURIFilterPlugin : public QObject
{
Q_OBJECT
public:
KURIFilterPlugin( QObject *parent = 0, const char *name = 0, double pri = 1.0 );
virtual QString name() const { return m_strName; }
virtual double priority() const { return m_dblPriority; }
virtual bool filterURI( KURIFilterData& data ) const = 0;
virtual KCModule *configModule( QWidget*, const char* ) const { return 0; }
virtual QString configName() const { return name(); }
protected:
void setFilteredURI ( KURIFilterData& data, const KURL& uri ) const;
void setErrorMsg ( KURIFilterData& data, const QString& errmsg ) const {
data.m_strErrMsg = errmsg;
}
void setURIType ( KURIFilterData& data, KURIFilterData::URITypes type) const {
data.m_iType = type;
data.m_bChanged = true;
}
void setArguments( KURIFilterData& data, const QString& args ) const;
QString m_strName;
double m_dblPriority;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KURIFilterPluginPrivate *d;
};
class KIO_EXPORT KURIFilterPluginList : public QPtrList<KURIFilterPlugin>
{
public:
virtual int compareItems(Item a, Item b)
{
double diff = ((KURIFilterPlugin *) a)->priority() - ((KURIFilterPlugin *) b)->priority();
return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
}
private:
KURIFilterPrivate *d;
};
class KIO_EXPORT KURIFilter
{
public:
~KURIFilter ();
static KURIFilter* self();
bool filterURI( KURIFilterData& data, const QStringList& filters = QStringList() );
bool filterURI( KURL &uri, const QStringList& filters = QStringList() );
bool filterURI( QString &uri, const QStringList& filters = QStringList() );
KURL filteredURI( const KURL &uri, const QStringList& filters = QStringList() );
QString filteredURI( const QString &uri, const QStringList& filters = QStringList() );
QPtrListIterator<KURIFilterPlugin> pluginsIterator() const;
QStringList pluginNames() const;
protected:
KURIFilter();
void loadPlugins();
private:
static KURIFilter *s_self;
KURIFilterPluginList m_lstPlugins;
KURIFilterPrivate *d;
};
#endif
KURIFilterPlugin::name
virtual QString name() const
Returns the filter's name.
Definition: kurifilter.h:371
KURIFilterPlugin::configName
virtual QString configName() const
Returns the name of the configuration module for the filter.
Definition: kurifilter.h:406
KURIFilterData::operator=
KURIFilterData & operator=(const KURL &url)
Overloaded assigenment operator.
Definition: kurifilter.h:293
KURIFilterPluginList
A list of filter plugins.
Definition: kurifilter.h:449
KURIFilterData::KURIFilterData
KURIFilterData()
Default constructor.
Definition: kurifilter.h:106
KURIFilterData::uriType
URITypes uriType() const
Returns the URI type.
Definition: kurifilter.h:177
KURIFilterData::operator=
KURIFilterData & operator=(const QString &url)
Overloaded assigenment operator.
Definition: kurifilter.h:303
KURIFilterData::hasBeenFiltered
KDE_DEPRECATED bool hasBeenFiltered() const
This method has been deprecated and will always return true.
Definition: kurifilter.h:144
KURIFilterData::uri
KURL uri() const
Returns the filtered or the original URL.
Definition: kurifilter.h:156
KURIFilterPlugin::configModule
virtual KCModule * configModule(QWidget *, const char *) const
Creates a configuration module for the filter.
Definition: kurifilter.h:399
KURIFilterPlugin::setURIType
void setURIType(KURIFilterData &data, KURIFilterData::URITypes type) const
Sets the URI type in data to type.
Definition: kurifilter.h:425
KURIFilterData::KURIFilterData
KURIFilterData(const QString &url)
Creates a URIFilterData object from the given string.
Definition: kurifilter.h:120
KURIFilterPlugin::setErrorMsg
void setErrorMsg(KURIFilterData &data, const QString &errmsg) const
Sets the error message in data to errormsg.
Definition: kurifilter.h:418
KURIFilterData
A basic message object used for exchanging filtering information between the filter plugins and the a...
Definition: kurifilter.h:78
KURIFilterPlugin::priority
virtual double priority() const
Returns the filter's priority.
Definition: kurifilter.h:381
KURIFilter
Manages the filtering of URIs.
Definition: kurifilter.h:534
KURIFilterData::setData
void setData(const QString &url)
Sets the URL to be filtered.
Definition: kurifilter.h:188
KURIFilterData::checkForExecutables
bool checkForExecutables() const
Definition: kurifilter.h:277
KURIFilterData::errorMsg
QString errorMsg() const
Returns an error message.
Definition: kurifilter.h:168
KURIFilterData::setData
void setData(const KURL &url)
Same as above except the argument is a URL.
Definition: kurifilter.h:199
KURIFilterData::URITypes
URITypes
Describes the type of the URI that was filtered.
Definition: kurifilter.h:99
KURIFilterPlugin
Base class for URI filter plugins.
Definition: kurifilter.h:350
KURIFilterData::KURIFilterData
KURIFilterData(const KURL &url)
Creates a URIFilterData object from the given URL.
Definition: kurifilter.h:113

KDE Home | KDE Accessibility Home | Description of Access Keys