bye-bye PackageMetadata

This commit is contained in:
Aaron Seigo 2011-05-31 01:04:33 +02:00
parent 36255d10cf
commit 584b9b8ec1
3 changed files with 5 additions and 538 deletions

View File

@ -57,14 +57,7 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1209)
########### next target ###############
set(plasmagik_SRCS
packagemetadata.cpp
packagestructure.cpp
package.cpp
)
set(plasma_LIB_SRCS
${plasmagik_SRCS}
abstractrunner.cpp
abstracttoolbox.cpp
animator.cpp
@ -102,8 +95,10 @@ set(plasma_LIB_SRCS
extenders/extender.cpp
extenders/extendergroup.cpp
extenders/extenderitem.cpp
pluginloader.cpp
packagestructure.cpp
package.cpp
paintutils.cpp
pluginloader.cpp
framesvg.cpp
plasma.cpp
popupapplet.cpp
@ -270,14 +265,6 @@ install(TARGETS plasma EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_AR
########### install files ###############
set(plasmagik_HEADERS
packagemetadata.h
packagestructure.h
package.h
)
install(FILES ${plasmagik_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/ COMPONENT Devel)
set(plasma_LIB_INCLUDES
abstractdialogmanager.h
abstractrunner.h
@ -302,6 +289,8 @@ set(plasma_LIB_INCLUDES
paintutils.h
windoweffects.h
framesvg.h
packagestructure.h
package.h
plasma.h
plasma_export.h
popupapplet.h

View File

@ -1,309 +0,0 @@
/******************************************************************************
* 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. *
*******************************************************************************/
#include <packagemetadata.h>
#include <QDir>
#include <kconfiggroup.h>
#include <kdesktopfile.h>
namespace Plasma
{
class PackageMetadataPrivate
{
public:
PackageMetadataPrivate()
: type("Service")
{
}
QString name;
QString icon;
QString description;
QStringList keywords;
QString author;
QString email;
QString version;
QString website;
QString license;
QString app;
QString category;
QString requiredVersion;
QString pluginName;
QString type;
QString serviceType;
QString api;
KUrl location;
};
PackageMetadata::PackageMetadata(const PackageMetadata &other)
: d(new PackageMetadataPrivate(*other.d))
{
}
PackageMetadata &PackageMetadata::operator=(const PackageMetadata &other)
{
*d = *other.d;
return *this;
}
PackageMetadata::PackageMetadata(const QString &path)
: d(new PackageMetadataPrivate)
{
read(path);
}
PackageMetadata::~PackageMetadata()
{
delete d;
}
bool PackageMetadata::isValid() const
{
return ! (d->name.isEmpty() ||
d->author.isEmpty() ||
d->license.isEmpty() ||
d->type.isEmpty());
}
void PackageMetadata::write(const QString &filename) const
{
KDesktopFile cfg(filename);
KConfigGroup config = cfg.desktopGroup();
config.writeEntry("Encoding", "UTF-8");
config.writeEntry("Name", d->name);
config.writeEntry("Icon", d->icon);
config.writeEntry("Comment", d->description);
config.writeEntry("Keywords", d->keywords);
config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
config.writeEntry("X-KDE-PluginInfo-Author", d->author);
config.writeEntry("X-KDE-PluginInfo-Email", d->email);
config.writeEntry("X-KDE-PluginInfo-Version", d->version);
config.writeEntry("X-KDE-PluginInfo-Website", d->website);
config.writeEntry("X-KDE-PluginInfo-License", d->license);
config.writeEntry("X-KDE-PluginInfo-Category", d->category);
config.writeEntry("X-Plasma-API", d->api);
config.writeEntry("X-KDE-ParentApp", d->app);
config.writeEntry("Type", d->type);
config.writeEntry("X-Plasma-RemoteLocation", d->location);
}
void PackageMetadata::read(const QString &filename)
{
if (filename.isEmpty()) {
return;
}
KDesktopFile cfg(filename);
KConfigGroup config = cfg.desktopGroup();
d->name = config.readEntry("Name", d->name);
d->icon = config.readEntry("Icon", d->icon);
d->description = config.readEntry("Comment", d->description);
d->keywords = config.readEntry("Keywords", d->keywords);
d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email);
d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website);
d->license = config.readEntry("X-KDE-PluginInfo-License", d->license);
d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category);
d->api = config.readEntry("X-Plasma-API", d->api);
d->app = config.readEntry("X-KDE-ParentApp", d->app);
d->type = config.readEntry("Type", d->type);
d->location = config.readEntry("X-Plasma-RemoteLocation", d->location);
}
QString PackageMetadata::name() const
{
return d->name;
}
QString PackageMetadata::description() const
{
return d->description;
}
QString PackageMetadata::serviceType() const
{
return d->serviceType;
}
QString PackageMetadata::author() const
{
return d->author;
}
QString PackageMetadata::email() const
{
return d->email;
}
QString PackageMetadata::icon() const
{
return d->icon;
}
void PackageMetadata::setIcon(const QString &icon)
{
d->icon = icon;
}
QString PackageMetadata::version() const
{
return d->version;
}
QString PackageMetadata::website() const
{
return d->website;
}
QString PackageMetadata::license() const
{
return d->license;
}
QString PackageMetadata::application() const
{
return d->app;
}
QString PackageMetadata::category() const
{
return d->category;
}
void PackageMetadata::setKeywords(const QStringList &keywords)
{
d->keywords = keywords;
}
QStringList PackageMetadata::keywords() const
{
return d->keywords;
}
QString PackageMetadata::requiredVersion() const
{
return d->requiredVersion;
}
KUrl PackageMetadata::remoteLocation() const
{
return d->location;
}
QString PackageMetadata::type() const
{
return d->type;
}
QString PackageMetadata::implementationApi() const
{
return d->api;
}
void PackageMetadata::setImplementationApi(const QString &api)
{
d->api = api;
}
QString PackageMetadata::pluginName() const
{
return d->pluginName;
}
void PackageMetadata::setPluginName(const QString &pluginName)
{
d->pluginName = pluginName;
}
void PackageMetadata::setName(const QString &name)
{
d->name = name;
}
void PackageMetadata::setDescription(const QString &description)
{
d->description = description;
}
void PackageMetadata::setServiceType(const QString &serviceType)
{
d->serviceType = serviceType;
}
void PackageMetadata::setAuthor(const QString &author)
{
d->author = author;
}
void PackageMetadata::setEmail(const QString &email)
{
d->email = email;
}
void PackageMetadata::setVersion(const QString &version)
{
d->version = version;
}
void PackageMetadata::setWebsite(const QString &website)
{
d->website = website;
}
void PackageMetadata::setLicense(const QString &license)
{
d->license = license;
}
void PackageMetadata::setApplication(const QString &application)
{
d->app = application;
}
void PackageMetadata::setCategory(const QString &category)
{
d->category = category;
}
void PackageMetadata::setRequiredVersion(const QString &requiredVersion)
{
d->requiredVersion = requiredVersion;
}
void PackageMetadata::setRemoteLocation(const KUrl &location)
{
d->location = location;
}
void PackageMetadata::setType(const QString &type)
{
d->type = type;
}
} // namespace Plasma

View File

@ -1,213 +0,0 @@
/******************************************************************************
* 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_PACKAGEMETADATA_H
#define PLASMA_PACKAGEMETADATA_H
#include <QtCore/QString>
#include <plasma/plasma_export.h>
#include <kurl.h>
namespace Plasma
{
class PackageMetadataPrivate;
/**
* @class PackageMetadata plasma/packagemetadata.h <Plasma/PackageMetadata>
*
* @short Provides metadata for a Package.
**/
class PLASMA_EXPORT PackageMetadata
{
public:
/**
* Constructs a metadata object using the values in the file at path
*
* @param path path to a metadata.desktop file
**/
explicit PackageMetadata(const QString &path = QString());
/**
* Copy constructor
**/
PackageMetadata(const PackageMetadata &other);
~PackageMetadata();
PackageMetadata &operator=(const PackageMetadata &other);
bool isValid() const;
/**
* Writes out the metadata to filename, which should be a .desktop
* file. It writes out the information in a format that is compatible
* with KPluginInfo
* @see KPluginInfo
*
* @arg filename path to the file to write to
**/
void write(const QString &filename) const;
/**
* Reads in metadata from a file, which should be a .desktop
* file. It writes out the information in a format that is compatible
* with KPluginInfo
* @see KPluginInfo
*
* @arg filename path to the file to write to
**/
void read(const QString &filename);
QString name() const;
QString description() const;
QStringList keywords() const;
QString serviceType() const;
QString author() const;
QString email() const;
QString version() const;
QString website() const;
QString license() const;
QString application() const;
QString category() const;
QString requiredVersion() const;
QString pluginName() const;
QString implementationApi() const;
KUrl remoteLocation() const;
QString type() const;
/**
* Set the name of the package used to displayed
* a short describing name.
*/
void setName(const QString &);
/**
* Set the description used to provide some general
* information what the package is about.
*/
void setDescription(const QString &);
/**
* Returns the icon name associated with this package, or QString() if none
* @since 4.5
*/
QString icon() const;
/**
* Set the icon name to be used with this package
* @since 4.5
*/
void setIcon(const QString &icon);
/**
* Set the keywords used to provide search and categorizations
* @param keywords the keywords to associate with this package
*/
void setKeywords(const QStringList &keywords);
/**
* Set the service-type which defines the X-KDE-ServiceTypes
* type within the desktop file. If not defined this
* defaults to "Plasma/Applet,Plasma/Containment" in the
* desktop file.
*/
void setServiceType(const QString &);
/**
* Set the name of the author of the package.
*/
void setAuthor(const QString &);
/**
* Set the E-Mail address of the author or of the project
* that provided the package.
*/
void setEmail(const QString &);
/**
* Set the version of the package.
*/
void setVersion(const QString &);
/**
* Set the website URL where the package is hosted or
* where additional details about the project are available.
*/
void setWebsite(const QString &);
/**
* Set the license the package is distributed under.
*/
void setLicense(const QString &);
/**
* Set the name of the application this package may
* belongs to. This is used only for display purposes
* so far.
*/
void setApplication(const QString &);
/**
* Sets the category this package belongs in
*/
void setCategory(const QString &);
/**
* Set the required version. See also the setVersion()
* method.
*/
void setRequiredVersion(const QString &);
/**
* Set the url where this package is hosted.
*/
void setRemoteLocation(const KUrl &);
/**
* Set the type of the package. If not defined this
* defaults to "Service" in the desktop file.
*/
void setType(const QString &type);
/**
* Set the plugin name of the package.
*
* The plugin name is used to locate the package;
* @code
* QString serviceName("plasma-applet-" + data.pluginName());
* QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
* @endcode
*/
void setPluginName(const QString &name);
/**
* Set the implementation API this package uses.
*/
void setImplementationApi(const QString &api);
private:
PackageMetadataPrivate * const d;
};
}
#endif