RazorAutostartEntry => LxQt::AutostartEntry
[lxde/liblxqt.git] / razorplugininfo.h
CommitLineData
4ef6cee9 1/* BEGIN_COMMON_COPYRIGHT_HEADER
c4af778e 2 * (c)LGPL2+
4ef6cee9 3 *
4 * Razor - a lightweight, Qt based, desktop toolset
5 * http://razor-qt.org
6 *
7 * Copyright: 2010-2011 Razor team
8 * Authors:
626f1f31 9 * Alexander Sokoloff <sokoloff.a@gmail.com>
4ef6cee9 10 *
11 * This program or library is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
c4af778e 14 * version 2.1 of the License, or (at your option) any later version.
4ef6cee9 15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20
21 * You should have received a copy of the GNU Lesser General
22 * Public License along with this library; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
25 *
26 * END_COMMON_COPYRIGHT_HEADER */
27
28
29#ifndef RAZORPLUGININFO_H
30#define RAZORPLUGININFO_H
31
32#include <qtxdg/xdgdesktopfile.h>
33#include <QtCore/QString>
34#include <QtCore/QList>
35
36#include <QtCore/QFileInfo>
37//#include <QtCore/QDir>
38#include <QtCore/QtAlgorithms>
39#include <QtCore/QDebug>
40
41class QLibrary;
42
43/*!
44Every plugin needs a .desktop file that describes it. The basename of this file must
45be same as the basename of the plugin library.
46
47razorpanel_clock2.desktop file
48
49[Desktop Entry]
50 Type=Service
51 ServiceTypes=RazorPanel/Plugin
52 Name=Clock
53 Comment=Clock and calendar
54
55RazorPluginInfo class gives the interface for reading the values from the plugin .desktop file.
56This is a pure virtual class, you must implement libraryDir(), translationDir(), and instance() methods.
57*/
58class RazorPluginInfo: public XdgDesktopFile
59{
4ef6cee9 60public:
17bfc61e
AS
61 /// Constructs a RazorPluginInfo object for accessing the info stored in the .desktop file.
62 explicit RazorPluginInfo();
4ef6cee9 63
64 //! Reimplemented from XdgDesktopFile.
17bfc61e
AS
65 virtual bool load(const QString& fileName);
66
4ef6cee9 67
68 //! Reimplemented from XdgDesktopFile.
17bfc61e 69 //RazorPluginInfo& operator=(const RazorPluginInfo& other);
4ef6cee9 70
71
72 //! Returns identification string of this plugin, identified plugin type. Now id is part of the filename.
73 QString id() const { return mId; }
74
75 //! This function is provided for convenience. It's equivalent to calling value("ServiceTypes").toString().
76 QString serviceType() const { return value("ServiceTypes").toString(); }
77
78 //! Reimplemented from XdgDesktopFile.
79 virtual bool isValid() const;
80
81 /*! Loads the library and returns QLibrary object if the library was loaded successfully; otherwise returns 0.
17bfc61e 82 @parm libDir directory where placed the plugin .so file. */
4ef6cee9 83 QLibrary* loadLibrary(const QString& libDir) const;
84
4ef6cee9 85
040e9d7f
AS
86 /*! Returns a list of RazorPluginInfo objects for the matched files in the directories.
87 @param desktopFilesDirs - scanned directories names.
4ef6cee9 88 @param serviceType - type of the plugin, for example "RazorPanel/Plugin".
040e9d7f
AS
89 @param nameFilter - wildcard filter that understands * and ? wildcards.
90
91 If the same filename is located under multiple directories only the first file should be used.
92 */
93 static QList<RazorPluginInfo> search(const QStringList& desktopFilesDirs, const QString& serviceType, const QString& nameFilter="*");
94
95 /// This function is provided for convenience. It's equivalent to new calling search(QString(desktopFilesDir), serviceType, nameFilter)
17bfc61e 96 static QList<RazorPluginInfo> search(const QString& desktopFilesDir, const QString& serviceType, const QString& nameFilter="*");
040e9d7f 97
17bfc61e
AS
98private:
99 QString mId;
4ef6cee9 100};
101
17bfc61e
AS
102typedef QList<RazorPluginInfo> RazorPluginInfoList;
103
4ef6cee9 104
105QDebug operator<<(QDebug dbg, const RazorPluginInfo& pi);
106QDebug operator<<(QDebug dbg, const RazorPluginInfo* const pi);
107
108QDebug operator<<(QDebug dbg, const RazorPluginInfoList& list);
109QDebug operator<<(QDebug dbg, const RazorPluginInfoList* const pluginInfoList);
110
111#endif // RAZORPLUGININFO_H