2 kopetemimetypehandler.h - Kopete Mime-type Handlers
4 Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
6 Kopete (c) 2004 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
15 *************************************************************************
18 #ifndef KOPETEMIMETYPEHANDLER_H
19 #define KOPETEMIMETYPEHANDLER_H
26 #include "kopete_export.h"
32 * @brief A handler for some set of mime-types
33 * A mime type handler is responsible for handling requests to open files of
34 * certain mime types presented to the main application.
36 class KOPETE_EXPORT MimeTypeHandler
39 MimeTypeHandler( bool canAcceptRemoteFiles
= false );
41 virtual ~MimeTypeHandler();
44 * Finds a MimeTypeHandler for a given URL, and tells that handler to handle it
46 * @param url the url to dispatch
48 * @return true if a handler was registered for the mime type, false otherwise
50 static bool dispatchURL( const KUrl
&url
);
53 * Returns a list of mime types this object is registered to handle
55 const QStringList
mimeTypes() const;
58 * Returns a list of protocols this object is registered to handle
60 const QStringList
protocols() const;
63 * Returns true if this handler can accept remote files direcltly;
64 * If false, remote files are downloaded via KIO::NetAccess before
65 * being passed to handleURL
67 bool canAcceptRemoteFiles() const;
70 * Handles the URL @p url
72 * @param url The url to handle
74 virtual void handleURL( const KUrl
&url
) const;
77 * Handles the URL @p url, which has the mime type @p mimeType
79 * @param mimeType The mime type of the URL
80 * @param url The url to handle
82 virtual void handleURL( const QString
&mimeType
, const KUrl
&url
) const;
86 * Register this object as the handler of type @p mimeType.
87 * @param mimeType the mime type to handle
88 * @return true if registration succeeded, false if another handler is
89 * already set for this mime type.
91 bool registerAsMimeHandler( const QString
&mimeType
);
94 * Register this object as the handler of type @p protocol.
95 * @param protocol the protocol to handle
96 * @return true if registration succeeded, false if another handler is
97 * already set for this protocol.
99 bool registerAsProtocolHandler( const QString
&protocol
);
104 * Attempts to dispatch a given URL to a given handler
106 * @param url The url to dispatch
107 * @param mimeType The mime type of the url
108 * @param handler The handler to attempt
110 * @return true if a handler was able to process the URL, false otherwise
112 static bool dispatchToHandler( const KUrl
&url
, const QString
&mimeType
, MimeTypeHandler
*handler
);
119 * Mime-type handler class for Kopete emoticon files
121 class KOPETE_EXPORT EmoticonMimeTypeHandler
: public MimeTypeHandler
124 EmoticonMimeTypeHandler();
126 const QStringList
mimeTypes() const;
128 void handleURL( const QString
&mimeType
, const KUrl
&url
) const;
134 // vim: set noet ts=4 sts=4 sw=4: