2007-06-17 02:25:16 +02:00
|
|
|
/******************************************************************************
|
2007-11-02 16:30:53 +01:00
|
|
|
* 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. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include <packagemetadata.h>
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
#include <KConfigGroup>
|
2008-02-29 09:14:32 +01:00
|
|
|
#include <KDesktopFile>
|
2007-06-17 02:25:16 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class PackageMetadata::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QString name;
|
|
|
|
QString description;
|
|
|
|
QString author;
|
|
|
|
QString email;
|
|
|
|
QString version;
|
|
|
|
QString website;
|
|
|
|
QString license;
|
|
|
|
QString app;
|
|
|
|
QString requiredVersion;
|
2008-02-29 09:14:32 +01:00
|
|
|
QString pluginName;
|
2007-06-17 02:25:16 +02:00
|
|
|
QString type;
|
2007-07-20 06:14:13 +02:00
|
|
|
QString serviceType;
|
2008-04-29 18:24:14 +02:00
|
|
|
QString api;
|
2007-06-17 02:25:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
PackageMetadata::PackageMetadata()
|
|
|
|
: d(new Private)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageMetadata::PackageMetadata(const QString& path)
|
|
|
|
: d(new Private)
|
|
|
|
{
|
|
|
|
read(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageMetadata::~PackageMetadata()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2008-04-26 17:37:42 +02:00
|
|
|
bool PackageMetadata::isValid() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
2007-07-20 06:14:13 +02:00
|
|
|
return ! (d->name.isEmpty() ||
|
|
|
|
d->author.isEmpty() ||
|
|
|
|
d->version.isEmpty() ||
|
|
|
|
d->license.isEmpty() ||
|
|
|
|
d->app.isEmpty() ||
|
|
|
|
d->type.isEmpty());
|
2007-06-17 02:25:16 +02:00
|
|
|
}
|
|
|
|
|
2008-04-26 17:48:47 +02:00
|
|
|
void PackageMetadata::write(const QString &filename) const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
2008-02-29 09:14:32 +01:00
|
|
|
KDesktopFile cfg(filename);
|
|
|
|
KConfigGroup config = cfg.desktopGroup();
|
2007-06-17 02:25:16 +02:00
|
|
|
config.writeEntry("Encoding", "UTF-8");
|
|
|
|
|
|
|
|
config.writeEntry("Name", d->name);
|
2008-02-29 09:14:32 +01:00
|
|
|
config.writeEntry("Comment", d->description);
|
2007-11-26 20:16:40 +01:00
|
|
|
config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
|
2008-02-29 09:14:32 +01:00
|
|
|
config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
|
2007-06-17 02:25:16 +02:00
|
|
|
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->type);
|
2008-04-29 18:24:14 +02:00
|
|
|
config.writeEntry("X-Plasma-API", d->api);
|
2007-06-17 02:25:16 +02:00
|
|
|
config.writeEntry("X-KDE-Plasmagik-ApplicationName", d->app);
|
|
|
|
config.writeEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageMetadata::read(const QString& filename)
|
|
|
|
{
|
|
|
|
KConfig cfg(filename);
|
|
|
|
KConfigGroup config(&cfg, "Desktop Entry");
|
|
|
|
|
2008-03-02 11:44:12 +01:00
|
|
|
d->name = config.readEntry("Name", d->name);
|
|
|
|
d->description = config.readEntry("Comment", d->description);
|
2007-11-26 20:16:40 +01:00
|
|
|
d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
|
2008-03-02 11:44:12 +01:00
|
|
|
d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
|
2007-06-17 02:25:16 +02:00
|
|
|
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->type = config.readEntry("X-KDE-PluginInfo-Category", d->type);
|
|
|
|
d->app = config.readEntry("X-KDE-Plasmagik-ApplicationName", d->app);
|
|
|
|
d->requiredVersion = config.readEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion);
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::name() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->name;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::description() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->description;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::serviceType() const
|
|
|
|
{
|
|
|
|
return d->serviceType;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PackageMetadata::author() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->author;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::email() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->email;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::version() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->version;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::website() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->website;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::license() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->license;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::application() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->app;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::requiredVersion() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->requiredVersion;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
QString PackageMetadata::type() const
|
2007-06-17 02:25:16 +02:00
|
|
|
{
|
|
|
|
return d->type;
|
|
|
|
}
|
|
|
|
|
2008-04-29 18:24:14 +02:00
|
|
|
QString PackageMetadata::implementationApi() const
|
2008-02-29 09:14:32 +01:00
|
|
|
{
|
2008-04-29 18:24:14 +02:00
|
|
|
return d->api;
|
2008-02-29 09:14:32 +01:00
|
|
|
}
|
|
|
|
|
2008-04-29 18:24:14 +02:00
|
|
|
void PackageMetadata::setImplementationApi(const QString& api)
|
2008-02-29 09:14:32 +01:00
|
|
|
{
|
2008-04-29 18:24:14 +02:00
|
|
|
d->api = api;
|
2008-02-29 09:14:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString PackageMetadata::pluginName() const
|
|
|
|
{
|
|
|
|
return d->pluginName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageMetadata::setPluginName(const QString &pluginName)
|
|
|
|
{
|
|
|
|
d->pluginName = pluginName;
|
|
|
|
}
|
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
void PackageMetadata::setName(const QString &name)
|
|
|
|
{
|
|
|
|
d->name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageMetadata::setDescription(const QString &description)
|
|
|
|
{
|
|
|
|
d->description = description;
|
|
|
|
}
|
|
|
|
|
2007-07-20 06:14:13 +02:00
|
|
|
void PackageMetadata::setServiceType(const QString &serviceType)
|
|
|
|
{
|
|
|
|
d->serviceType = serviceType;
|
|
|
|
}
|
|
|
|
|
2007-06-17 02:25:16 +02:00
|
|
|
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::setRequiredVersion(const QString &requiredVersion)
|
|
|
|
{
|
|
|
|
d->requiredVersion = requiredVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageMetadata::setType(const QString& type)
|
|
|
|
{
|
|
|
|
d->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
|