2008-11-04 00:08:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
|
|
|
|
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
|
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef PLASMA_PACKAGE_H
|
|
|
|
#define PLASMA_PACKAGE_H
|
|
|
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <plasma/plasma.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <plasma/packagestructure.h>
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Package plasma/package.h <Plasma/Package>
|
|
|
|
*
|
|
|
|
* @short object representing an installed Plasmagik package
|
|
|
|
**/
|
|
|
|
|
|
|
|
class PackageMetadata;
|
|
|
|
class PackagePrivate;
|
|
|
|
|
|
|
|
class PLASMA_EXPORT Package
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2010-09-03 21:44:28 +02:00
|
|
|
* Default constructor that creates an invalid Package
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
explicit Package();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a Package object
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param packageRoot path to the package installation root
|
|
|
|
* @param package the name of the package
|
|
|
|
* @param structure the package structure describing this package
|
2008-11-04 00:08:39 +01:00
|
|
|
**/
|
|
|
|
Package(const QString &packageRoot, const QString &package,
|
|
|
|
PackageStructure::Ptr structure);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a Package object.
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param packagePath full path to the package directory
|
|
|
|
* @param structure the package structure describing this package
|
2008-11-04 00:08:39 +01:00
|
|
|
*/
|
|
|
|
Package(const QString &packagePath, PackageStructure::Ptr structure);
|
|
|
|
|
2010-09-03 21:44:28 +02:00
|
|
|
/**
|
|
|
|
* Copy constructore
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
Package(const Package &other);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
~Package();
|
|
|
|
|
2010-09-03 21:44:28 +02:00
|
|
|
/**
|
|
|
|
* Assignment operator
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
Package &operator=(const Package &rhs);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* @return true if all the required components as defined in
|
|
|
|
* the PackageStructure exist
|
|
|
|
**/
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the path to a given file.
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param fileType the type of file to look for, as defined in the
|
2008-11-04 00:08:39 +01:00
|
|
|
* package structure
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param filename the name of the file
|
2008-11-04 00:08:39 +01:00
|
|
|
* @return path to the file on disk. QString() if not found.
|
|
|
|
**/
|
|
|
|
QString filePath(const char *fileType, const QString &filename) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the path to a given file.
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param fileType the type of file to look for, as defined in the
|
2008-11-04 00:08:39 +01:00
|
|
|
* package structure. The type must refer to a file
|
|
|
|
* in the package structure and not a directory.
|
|
|
|
* @return path to the file on disk. QString() if not found
|
|
|
|
**/
|
|
|
|
QString filePath(const char *fileType) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of files of a given type.
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param fileType the type of file to look for, as defined in the
|
2008-11-04 00:08:39 +01:00
|
|
|
* package structure.
|
|
|
|
* @return list of files by name, suitable for passing to filePath
|
|
|
|
**/
|
|
|
|
QStringList entryList(const char *fileType) const;
|
|
|
|
|
|
|
|
/**
|
2009-05-13 01:05:40 +02:00
|
|
|
* @return the package metadata object.
|
|
|
|
*/
|
2008-11-04 00:08:39 +01:00
|
|
|
PackageMetadata metadata() const;
|
|
|
|
|
2009-05-13 01:05:40 +02:00
|
|
|
/**
|
|
|
|
* Sets the path to the root of this package
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param path and absolute path
|
2009-05-13 01:05:40 +02:00
|
|
|
* @since 4.3
|
|
|
|
*/
|
|
|
|
void setPath(const QString &path);
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
/**
|
|
|
|
* Publish this package on the network.
|
|
|
|
* @param methods the ways to announce this package on the network.
|
|
|
|
*/
|
|
|
|
void publish(AnnouncementMethods methods, const QString &name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove this package from the network.
|
|
|
|
*/
|
|
|
|
void unpublish(const QString &name = QString());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns whether or not this service is currently published on the network.
|
|
|
|
*/
|
|
|
|
bool isPublished() const;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* @return the path to the root of this particular package
|
|
|
|
*/
|
|
|
|
const QString path() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the PackageStructure use in this Package
|
|
|
|
*/
|
|
|
|
const PackageStructure::Ptr structure() const;
|
|
|
|
|
2009-09-21 23:37:44 +02:00
|
|
|
/**
|
|
|
|
* @return a SHA1 hash digest of the contents of the package in hexadecimal form
|
2009-09-22 02:55:30 +02:00
|
|
|
* @since 4.4
|
2009-09-21 23:37:44 +02:00
|
|
|
*/
|
2009-09-21 23:48:19 +02:00
|
|
|
QString contentsHash() const;
|
2009-09-21 23:37:44 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
2009-01-05 19:49:54 +01:00
|
|
|
* Returns a list of all installed packages by name
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* @param packageRoot path to the directory where Plasmagik packages
|
|
|
|
* have been installed to
|
|
|
|
* @return a list of installed Plasmagik packages
|
|
|
|
**/
|
|
|
|
static QStringList listInstalled(const QString &packageRoot);
|
|
|
|
|
2009-01-05 19:49:54 +01:00
|
|
|
/**
|
|
|
|
* Returns a list of all paths of installed packages in the given root
|
|
|
|
*
|
|
|
|
* @param packageRoot path to the directory where Plasmagik packages
|
|
|
|
* have been installed to
|
|
|
|
* @return a list of installed Plasmagik packages by path
|
|
|
|
**/
|
|
|
|
static QStringList listInstalledPaths(const QString &packageRoot);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* Installs a package.
|
|
|
|
*
|
|
|
|
* @param package path to the Plasmagik package
|
|
|
|
* @param packageRoot path to the directory where the package should be
|
|
|
|
* installed to
|
2009-01-10 01:08:31 +01:00
|
|
|
* @param servicePrefix the prefix for the desktop file, so as not to interfere
|
2009-07-25 11:34:19 +02:00
|
|
|
* with unrelated services (eg: "plasma-applet-"). If no prefix
|
|
|
|
* is set (e.g. a QString() is passed in), then the package will NOT
|
|
|
|
* be registered as a service
|
2008-11-04 00:08:39 +01:00
|
|
|
* @return true on successful installation, false otherwise
|
|
|
|
**/
|
|
|
|
static bool installPackage(const QString &package,
|
|
|
|
const QString &packageRoot,
|
|
|
|
const QString &servicePrefix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uninstalls a package.
|
|
|
|
*
|
|
|
|
* @param package path to the Plasmagik package
|
|
|
|
* @param packageRoot path to the directory where the package should be
|
|
|
|
* installed to
|
2009-01-10 01:08:31 +01:00
|
|
|
* @param servicePrefix the prefix for the desktop file, so as not to interfere
|
|
|
|
* with unrelated services (eg: "plasma-applet-")
|
2008-11-04 00:08:39 +01:00
|
|
|
* @return true on successful uninstallation, false otherwise
|
|
|
|
**/
|
|
|
|
static bool uninstallPackage(const QString &package,
|
|
|
|
const QString &packageRoot,
|
|
|
|
const QString &servicePrefix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a package described by the given desktop file
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param the full path to the desktop file (must be KPluginInfo compatible)
|
2008-11-04 00:08:39 +01:00
|
|
|
* @return true on success, false on failure
|
|
|
|
*/
|
|
|
|
static bool registerPackage(const PackageMetadata &data, const QString &iconPath);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a package based on the metadata from the files contained
|
|
|
|
* in the source directory
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param metadata description of the package to create
|
|
|
|
* @param source path to local directory containing the individual
|
2008-11-04 00:08:39 +01:00
|
|
|
* files to be added to the package
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param destination path to the package that should be created
|
|
|
|
* @param icon path to the package icon
|
2008-11-04 00:08:39 +01:00
|
|
|
**/
|
|
|
|
static bool createPackage(const PackageMetadata &metadata,
|
|
|
|
const QString &source,
|
|
|
|
const QString &destination,
|
|
|
|
const QString &icon = QString());
|
|
|
|
|
|
|
|
private:
|
|
|
|
PackagePrivate * const d;
|
2009-09-02 04:27:16 +02:00
|
|
|
|
|
|
|
friend class Applet;
|
|
|
|
friend class AppletPrivate;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace
|
|
|
|
|
2010-09-05 00:37:29 +02:00
|
|
|
Q_DECLARE_METATYPE(Plasma::Package)
|
2008-11-04 00:08:39 +01:00
|
|
|
#endif
|
|
|
|
|