1 /******************************************************************************
2 * Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
3 * Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Library General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2 of the License, or (at your option) any later version. *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Library General Public License for more details. *
15 * You should have received a copy of the GNU Library General Public License *
16 * along with this library; see the file COPYING.LIB. If not, write to *
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301, USA. *
19 *******************************************************************************/
21 #ifndef PLASMA_PACKAGE_H
22 #define PLASMA_PACKAGE_H
24 #include <QtCore/QStringList>
26 #include <plasma/plasma_export.h>
27 #include <plasma/packagestructure.h>
33 * @class Package plasma/package.h <Plasma/Package>
35 * @short object representing an installed Plasmagik package
38 class PackageMetadata
;
41 class PLASMA_EXPORT Package
47 * @arg packageRoot path to the package installation root
48 * @arg package the name of the package
49 * @arg structure the package structure describing this package
51 Package(const QString
&packageRoot
, const QString
&package
,
52 PackageStructure::Ptr structure
);
55 * Construct a Package object.
57 * @arg packagePath full path to the package directory
58 * @arg structure the package structure describing this package
60 Package(const QString
&packagePath
, PackageStructure::Ptr structure
);
62 //TODO for 4.1: be able to load an uninstalled/uncompressed file.
67 * @return true if all the required components as defined in
68 * the PackageStructure exist
73 * Get the path to a given file.
75 * @arg fileType the type of file to look for, as defined in the
77 * @arg filename the name of the file
78 * @return path to the file on disk. QString() if not found.
80 QString
filePath(const char *fileType
, const QString
&filename
) const;
83 * Get the path to a given file.
85 * @arg fileType the type of file to look for, as defined in the
86 * package structure. The type must refer to a file
87 * in the package structure and not a directory.
88 * @return path to the file on disk. QString() if not found
90 QString
filePath(const char *fileType
) const;
93 * Get the list of files of a given type.
95 * @arg fileType the type of file to look for, as defined in the
97 * @return list of files by name, suitable for passing to filePath
99 QStringList
entryList(const char *fileType
) const;
102 * @return the package metadata object.
104 PackageMetadata
metadata() const;
107 * @return the path to the root of this particular package
109 const QString
path() const;
112 * @return the PackageStructure use in this Package
114 const PackageStructure::Ptr
structure() const;
117 * Returns a list of all installed packages by name
119 * @param packageRoot path to the directory where Plasmagik packages
120 * have been installed to
121 * @return a list of installed Plasmagik packages
123 static QStringList
listInstalled(const QString
&packageRoot
);
126 * Returns a list of all paths of installed packages in the given root
128 * @param packageRoot path to the directory where Plasmagik packages
129 * have been installed to
130 * @return a list of installed Plasmagik packages by path
132 static QStringList
listInstalledPaths(const QString
&packageRoot
);
135 * Installs a package.
137 * @param package path to the Plasmagik package
138 * @param packageRoot path to the directory where the package should be
140 * @param servicePrefix the prefix for the desktop file, so as not to interfere
141 * with unrelated services (eg: "plasma-applet-")
142 * @return true on successful installation, false otherwise
144 static bool installPackage(const QString
&package
,
145 const QString
&packageRoot
,
146 const QString
&servicePrefix
);
149 * Uninstalls a package.
151 * @param package path to the Plasmagik package
152 * @param packageRoot path to the directory where the package should be
154 * @param servicePrefix the prefix for the desktop file, so as not to interfere
155 * with unrelated services (eg: "plasma-applet-")
156 * @return true on successful uninstallation, false otherwise
158 static bool uninstallPackage(const QString
&package
,
159 const QString
&packageRoot
,
160 const QString
&servicePrefix
);
163 * Registers a package described by the given desktop file
165 * @arg the full path to the desktop file (must be KPluginInfo compatible)
166 * @return true on success, false on failure
168 static bool registerPackage(const PackageMetadata
&data
, const QString
&iconPath
);
171 * Creates a package based on the metadata from the files contained
172 * in the source directory
174 * @arg metadata description of the package to create
175 * @arg source path to local directory containing the individual
176 * files to be added to the package
177 * @arg destination path to the package that should be created
178 * @arg icon path to the package icon
180 static bool createPackage(const PackageMetadata
&metadata
,
181 const QString
&source
,
182 const QString
&destination
,
183 const QString
&icon
= QString());
186 Q_DISABLE_COPY(Package
)
187 PackagePrivate
* const d
;