Port KProgressBar's to QProgressBar's.
[kdenetwork.git] / kopete / libkopete / kopetemimetypehandler.h
blobbe76aba836b9822540abeabbbb09b9eb9311310c
1 /*
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 *************************************************************************
9 * *
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. *
14 * *
15 *************************************************************************
18 #ifndef KOPETEMIMETYPEHANDLER_H
19 #define KOPETEMIMETYPEHANDLER_H
21 #include <kurl.h>
23 class QString;
24 class QStringList;
26 #include "kopete_export.h"
28 namespace Kopete
31 /**
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
38 protected:
39 MimeTypeHandler( bool canAcceptRemoteFiles = false );
40 public:
41 virtual ~MimeTypeHandler();
43 /**
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 );
52 /**
53 * Returns a list of mime types this object is registered to handle
55 const QStringList mimeTypes() const;
57 /**
58 * Returns a list of protocols this object is registered to handle
60 const QStringList protocols() const;
62 /**
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;
69 /**
70 * Handles the URL @p url
72 * @param url The url to handle
74 virtual void handleURL( const KUrl &url ) const;
76 /**
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;
84 protected:
85 /**
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 );
93 /**
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 );
101 private:
103 * Helper function.
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 );
114 class Private;
115 Private *d;
119 * Mime-type handler class for Kopete emoticon files
121 class KOPETE_EXPORT EmoticonMimeTypeHandler : public MimeTypeHandler
123 public:
124 EmoticonMimeTypeHandler();
126 const QStringList mimeTypes() const;
128 void handleURL( const QString &mimeType, const KUrl &url ) const;
131 } // Kopete
133 #endif
134 // vim: set noet ts=4 sts=4 sw=4: