2007-06-17 02:25:16 +02:00
|
|
|
/******************************************************************************
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
|
|
|
|
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
|
2007-06-17 02:25:16 +02:00
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2007-06-17 11:28:42 +02:00
|
|
|
#ifndef PLASMA_PACKAGE_H
|
|
|
|
#define PLASMA_PACKAGE_H
|
|
|
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
2008-02-26 05:07:07 +01:00
|
|
|
#include <plasma/packagestructure.h>
|
2007-06-17 11:28:42 +02:00
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief object representing an installed Plasmagik package
|
|
|
|
**/
|
|
|
|
|
2007-07-20 06:23:27 +02:00
|
|
|
class PackageMetadata;
|
2007-06-17 02:25:16 +02:00
|
|
|
|
2007-06-17 11:28:42 +02:00
|
|
|
class PLASMA_EXPORT Package
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*
|
|
|
|
* @arg packageRoot path to the package installation root
|
|
|
|
* @arg package the name of the package
|
|
|
|
* @arg structure the package structure describing this package
|
|
|
|
**/
|
|
|
|
Package(const QString& packageRoot, const QString& package,
|
2008-02-28 14:07:59 +01:00
|
|
|
PackageStructure::Ptr structure);
|
2008-02-26 05:07:07 +01:00
|
|
|
|
2007-11-26 20:16:40 +01:00
|
|
|
/**
|
|
|
|
* Construct a Package object.
|
|
|
|
*
|
|
|
|
* @arg packagePath full path to the package directory
|
|
|
|
* @arg structure the package structure describing this package
|
|
|
|
*/
|
2008-02-28 14:07:59 +01:00
|
|
|
Package(const QString &packagePath, PackageStructure::Ptr structure);
|
2008-01-03 21:55:42 +01:00
|
|
|
|
|
|
|
//TODO for 4.1: be able to load an uninstalled/uncompressed file.
|
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
~Package();
|
|
|
|
|
2007-07-20 05:21:40 +02:00
|
|
|
/**
|
|
|
|
* @return true if all the required components as defined in
|
|
|
|
* the PackageStructure exist
|
|
|
|
**/
|
2007-07-23 09:26:28 +02:00
|
|
|
bool isValid() const;
|
2007-07-20 05:21:40 +02:00
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
/**
|
|
|
|
* Get the path to a given file.
|
|
|
|
*
|
|
|
|
* @arg fileType the type of file to look for, as defined in the
|
|
|
|
* package structure
|
|
|
|
* @arg filename the name of the file
|
|
|
|
* @return path to the file on disk. QString() if not found.
|
|
|
|
**/
|
2007-07-23 09:26:28 +02:00
|
|
|
QString filePath(const char* fileType, const QString& filename) const;
|
2007-06-17 02:25:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the path to a given file.
|
|
|
|
*
|
|
|
|
* @arg fileType the type of file to look for, as defined in the
|
|
|
|
* 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
|
|
|
|
**/
|
2007-07-23 09:26:28 +02:00
|
|
|
QString filePath(const char* fileType) const;
|
2007-06-17 02:25:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of files of a given type.
|
|
|
|
*
|
|
|
|
* @arg fileType the type of file to look for, as defined in the
|
|
|
|
* package structure.
|
|
|
|
* @return list of files by name, suitable for passing to filePath
|
|
|
|
**/
|
2007-07-23 09:26:28 +02:00
|
|
|
QStringList entryList(const char* fileType) const;
|
2007-06-17 02:25:16 +02:00
|
|
|
|
2007-12-02 13:04:57 +01:00
|
|
|
/**
|
|
|
|
* @return the package metadata object.
|
|
|
|
*/
|
|
|
|
const PackageMetadata *metadata() const;
|
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
/**
|
2008-02-28 04:53:26 +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;
|
|
|
|
|
|
|
|
/**
|
2007-07-20 06:23:27 +02:00
|
|
|
* Returns a list of all installed packages
|
2007-06-17 02:25:16 +02:00
|
|
|
*
|
|
|
|
* @param packageRoot path to the directory where Plasmagik packages
|
|
|
|
* have been installed to
|
|
|
|
* @return a list of installed Plasmagik packages
|
|
|
|
**/
|
2008-04-27 21:22:29 +02:00
|
|
|
static QStringList listInstalled(const QString &packageRoot);
|
2007-06-17 02:25:16 +02:00
|
|
|
|
|
|
|
/**
|
2007-07-20 06:23:27 +02:00
|
|
|
* Installs a package.
|
|
|
|
*
|
2007-06-17 02:25:16 +02:00
|
|
|
* @param package path to the Plasmagik package
|
|
|
|
* @param packageRoot path to the directory where the package should be
|
|
|
|
* installed to
|
|
|
|
* @return true on successful installation, false otherwise
|
|
|
|
**/
|
2007-07-20 06:23:27 +02:00
|
|
|
static bool installPackage(const QString &package,
|
|
|
|
const QString &packageRoot);
|
2007-06-17 02:25:16 +02:00
|
|
|
|
2008-02-27 01:51:04 +01:00
|
|
|
/**
|
|
|
|
* Registers a package described by the given desktop file
|
|
|
|
*
|
|
|
|
* @arg the full path to the desktop file (must be KPluginInfo compatible)
|
|
|
|
* @return true on success, false on failure
|
|
|
|
*/
|
2008-02-29 09:14:32 +01:00
|
|
|
static bool registerPackage(const PackageMetadata &data, const QString &iconPath);
|
2008-02-27 01:51:04 +01:00
|
|
|
|
2007-07-20 06:23:27 +02:00
|
|
|
/**
|
|
|
|
* Creates a package based on the metadata from the files contained
|
|
|
|
* in the source directory
|
|
|
|
*
|
|
|
|
* @arg metadata description of the package to create
|
|
|
|
* @arg source path to local directory containing the individual
|
|
|
|
* files to be added to the package
|
2007-12-02 13:04:57 +01:00
|
|
|
* @arg destination path to the package that should be created
|
|
|
|
* @arg icon path to the package icon
|
2007-07-20 06:23:27 +02:00
|
|
|
**/
|
|
|
|
static bool createPackage(const PackageMetadata &metadata,
|
|
|
|
const QString &source,
|
2007-12-02 13:04:57 +01:00
|
|
|
const QString &destination,
|
|
|
|
const QString &icon = QString());
|
2007-07-20 06:23:27 +02:00
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
private:
|
2007-07-20 05:21:40 +02:00
|
|
|
Q_DISABLE_COPY(Package)
|
2007-06-17 02:25:16 +02:00
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace
|
2007-06-17 11:28:42 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|