kio Library API Documentation

KURIFilterData Class Reference

This is a basic message object used for exchanging filtering information between the filter plugins and the application whenever the application requires more information about the URI than just a filtered version of it. A message object for exchanging filtering URI info. More...

#include <kurifilter.h>

List of all members.

Public Types

enum  URITypes
 Describes the type of URI to be filtered. More...


Public Methods

 KURIFilterData ()
 Default constructor.

 KURIFilterData (const KURL &url)
 Creates a URIFilterData object from the given URL.

 KURIFilterData (const QString &url)
 Creates a URIFilterData object from the given string.

 KURIFilterData (const KURIFilterData &)
 Copy constructor.

 ~KURIFilterData ()
 Destructor.

bool hasBeenFiltered () const
 This method has been deprecated and will always return TRUE.

KURL uri () const
 Returns the filtered or the original URL.

QString errorMsg () const
 Returns an error message.

URITypes uriType () const
 Returns the URI type.

void setData (const QString &url)
 Sets the URL to be filtered.

void setData (const KURL &url)
 Same as above except the argument is a URL.

bool setAbsolutePath (const QString &)
 Sets the absolute path to be used whenever the supplied data is a relative local URL.

QString absolutePath () const
 Returns the absolute path if one has already been set.

bool hasAbsolutePath () const
 Returns true if the supplied data has an absolute path.

QString argsAndOptions () const
 Returns the command line options and arguments for a local resource when present.

bool hasArgsAndOptions () const
 Returns true if the current data is a local resource with command line options and arguments.

QString iconName ()
 Returns the name of the icon that matches the current filtered URL.

KURIFilterData & operator= (const KURL &url)
 Overloaded assigenment operator.

KURIFilterData & operator= (const QString &url)
 Overloaded assigenment operator.


Protected Methods

void init (const KURL &url=QString::null)
 Initializes the KURIFilterData on construction.


Detailed Description

This is a basic message object used for exchanging filtering information between the filter plugins and the application whenever the application requires more information about the URI than just a filtered version of it. A message object for exchanging filtering URI info.

Any application can create an instance of this class and send it to KURIFilter to have the filter plugins fill the necessary information.

Example

   QString text = "kde.org";
   KURIFilterData d = text;
   bool filtered = KURIFilter::self()->filter( d );
   if( filtered )
     print ( "URI: s
"Filtered URI: s
URI Type: i
"Was Filtered: i" text.latin1(), d.uri().url().latin1(), d.uriType(), filtered );

The above code should yield the following output:

   URI: kde.org
   Filtered URI: http://kde.org
   URI Type: 0            <== means NET_PROTOCOL
   Was Filtered: 1        <== means the URL was successfully filtered
 

Definition at line 64 of file kurifilter.h.


Member Enumeration Documentation

enum KURIFilterData::URITypes
 

Describes the type of URI to be filtered.

This enumerator prvoides the return value for uriType. A brief description for each value:

  • NET_PROTOCOL - Any network protocol: http, ftp, nttp, pop3, etc...
  • LOCAL_FILE - A local file whose executable flag is not set
  • LOCAL_DIR - A local directory
  • EXECUTABLE - A local file whose executable flag is set
  • HELP - A man or info page
  • SHELL - A shell executable (ex: echo "Test..." >> ~/testfile)
  • BLOCKED - A URI that should be blocked/filtered (ex: ad filtering)
  • ERROR - An incorrect URI (ex: "~johndoe" when user johndoe does not exist in that system )
  • UNKNOWN - A URI that is not identified. Default value when a KURIFilterData is first created.

Definition at line 87 of file kurifilter.h.

Referenced by KURIFilterPlugin::setURIType(), and uriType().


Constructor & Destructor Documentation

KURIFilterData::KURIFilterData   [inline]
 

Default constructor.

Creates a URIFilterData object.

Definition at line 94 of file kurifilter.h.

References init().

KURIFilterData::KURIFilterData const KURL   url [inline]
 

Creates a URIFilterData object from the given URL.

Parameters:
url  is the URL to be filtered.

Definition at line 101 of file kurifilter.h.

References init().

KURIFilterData::KURIFilterData const QString   url [inline]
 

Creates a URIFilterData object from the given string.

Parameters:
url  is the string to be filtered.

Definition at line 108 of file kurifilter.h.

References init().

KURIFilterData::KURIFilterData const KURIFilterData &   
 

Copy constructor.

Creates a URIFilterData object from another URI filter data object.

Parameters:
data  the uri filter data to be copied.

Definition at line 58 of file kurifilter.cpp.

References absolutePath(), m_bChanged, m_iType, m_pURI, m_strErrMsg, and m_strIconName.

KURIFilterData::~KURIFilterData  
 

Destructor.

Definition at line 69 of file kurifilter.cpp.


Member Function Documentation

bool KURIFilterData::hasBeenFiltered   const [inline]
 

This method has been deprecated and will always return TRUE.

You should instead use the result from the KURIFilter::filterURI() calls.

Deprecated:

Definition at line 132 of file kurifilter.h.

KURL KURIFilterData::uri   const [inline]
 

Returns the filtered or the original URL.

This function returns the filtered url if one of the plugins sucessfully filtered the original URL. Otherwise, it returns the original URL. See hasBeenFiltered() and

Returns:
the filtered or original url.

Definition at line 144 of file kurifilter.h.

Referenced by KURIFilter::filteredURI(), KURIFilter::filterURI(), and KURIFilterPlugin::setFilteredURI().

QString KURIFilterData::errorMsg   const [inline]
 

Returns an error message.

This functions returns the error message set by the plugin whenever the uri type is set to KURIFilterData::ERROR. Otherwise, it returns a QString::null.

Returns:
the error message or a NULL when there is none.

Definition at line 156 of file kurifilter.h.

URITypes KURIFilterData::uriType   const [inline]
 

Returns the URI type.

This method always returns KURIFilterData::UNKNOWN if the given URL was not filtered.

Definition at line 164 of file kurifilter.h.

References URITypes.

void KURIFilterData::setData const QString   url [inline]
 

Sets the URL to be filtered.

Use this function to set the string to be filtered when you construct an empty filter object.

Parameters:
url  the string to be filtered.

Definition at line 175 of file kurifilter.h.

References init().

void KURIFilterData::setData const KURL   url [inline]
 

Same as above except the argument is a URL.

Use this function to set the string to be filtered when you construct an empty filter object.

Parameters:
url  the URL to be filtered.

Definition at line 186 of file kurifilter.h.

References init().

bool KURIFilterData::setAbsolutePath const QString  
 

Sets the absolute path to be used whenever the supplied data is a relative local URL.

NOTE: This function works only for a local resource and expects the absolute path to the relative URL set in this meta object. If you are extracting the absolute path from a KURL object, make sure you always set the argument below using KURL::path() instead of KURL::url() so that "file:/" would not be appended! Otherwise, the filter might not be able to make correct determination whether the relative URL locally exists!

Parameters:
abs_path  the abolute path to the local resource.
Returns:
true if absolute path is successfully set. Otherwise, false.

Definition at line 96 of file kurifilter.cpp.

References KURL::isLocalFile(), and KURL::isMalformed().

QString KURIFilterData::absolutePath  
 

Returns the absolute path if one has already been set.

Definition at line 108 of file kurifilter.cpp.

Referenced by KURIFilterData().

bool KURIFilterData::hasAbsolutePath  
 

Returns true if the supplied data has an absolute path.

Definition at line 91 of file kurifilter.cpp.

QString KURIFilterData::argsAndOptions  
 

Returns the command line options and arguments for a local resource when present.

Returns:
options and arguments when present, otherwise QString::null

Definition at line 113 of file kurifilter.cpp.

bool KURIFilterData::hasArgsAndOptions  
 

Returns true if the current data is a local resource with command line options and arguments.

Definition at line 86 of file kurifilter.cpp.

QString KURIFilterData::iconName  
 

Returns the name of the icon that matches the current filtered URL.

NOTE that this function will return a NULL string by default and when no associated icon is found.

Returns:
the name of the icon associated with the resource

Definition at line 118 of file kurifilter.cpp.

References QString::fromLatin1(), KMimeType::iconForURL(), KService::serviceByDesktopName(), and KURL::url().

KURIFilterData& KURIFilterData::operator= const KURL   url [inline]
 

Overloaded assigenment operator.

This function allows you to easily assign a KURL to a KURIFilterData object.

Returns:
an instance of a KURIFilterData object.

Definition at line 250 of file kurifilter.h.

References init().

KURIFilterData& KURIFilterData::operator= const QString   url [inline]
 

Overloaded assigenment operator.

This function allows you to easily assign a QString to a KURIFilterData object.

Returns:
an instance of a KURIFilterData object.

Definition at line 260 of file kurifilter.h.

References init().

void KURIFilterData::init const KURL   url = QString::null [protected]
 

Initializes the KURIFilterData on construction.

Definition at line 75 of file kurifilter.cpp.

Referenced by KURIFilterData(), operator=(), and setData().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:37 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001