1 /******************************************************************************
2 * Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Library General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2 of the License, or (at your option) any later version. *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Library General Public License for more details. *
14 * You should have received a copy of the GNU Library General Public License *
15 * along with this library; see the file COPYING.LIB. If not, write to *
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301, USA. *
18 *******************************************************************************/
20 #include <packagemetadata.h>
24 #include <KConfigGroup>
25 #include <KDesktopFile>
30 class PackageMetadata::Private
41 QString requiredVersion
;
48 PackageMetadata::PackageMetadata()
53 PackageMetadata::PackageMetadata(const QString
& path
)
59 PackageMetadata::~PackageMetadata()
64 bool PackageMetadata::isComplete() const
66 return ! (d
->name
.isEmpty() ||
67 d
->author
.isEmpty() ||
68 d
->version
.isEmpty() ||
69 d
->license
.isEmpty() ||
74 void PackageMetadata::write(const QString
&filename
, const QString
&icon
) const
76 KDesktopFile
cfg(filename
);
77 KConfigGroup config
= cfg
.desktopGroup();
78 config
.writeEntry("Encoding", "UTF-8");
80 //TODO: this will be a problem for localized names?
81 config
.writeEntry("Name", d
->name
);
82 config
.writeEntry("Comment", d
->description
);
84 config
.writeEntry("Icon", icon
);
86 config
.writeEntry("X-KDE-ServiceTypes", d
->serviceType
);
87 config
.writeEntry("X-KDE-PluginInfo-Name", d
->pluginName
);
88 config
.writeEntry("X-KDE-PluginInfo-Author", d
->author
);
89 config
.writeEntry("X-KDE-PluginInfo-Email", d
->email
);
90 config
.writeEntry("X-KDE-PluginInfo-Version", d
->version
);
91 config
.writeEntry("X-KDE-PluginInfo-Website", d
->website
);
92 config
.writeEntry("X-KDE-PluginInfo-License", d
->license
);
93 config
.writeEntry("X-KDE-PluginInfo-Category", d
->type
);
94 config
.writeEntry("X-Plasma-Language", d
->language
);
95 config
.writeEntry("X-KDE-Plasmagik-ApplicationName", d
->app
);
96 config
.writeEntry("X-KDE-Plasmagik-RequiredVersion", d
->requiredVersion
);
99 void PackageMetadata::read(const QString
& filename
)
101 KConfig
cfg(filename
);
102 KConfigGroup
config(&cfg
, "Desktop Entry");
104 //TODO: this will be a problem for localized names?
105 d
->name
= config
.readEntry("X-KDE-PluginInfo-Name", d
->name
);
106 d
->description
= config
.readEntry("Description", d
->description
);
107 d
->serviceType
= config
.readEntry("X-KDE-ServiceTypes", d
->serviceType
);
108 d
->author
= config
.readEntry("X-KDE-PluginInfo-Author", d
->author
);
109 d
->email
= config
.readEntry("X-KDE-PluginInfo-Email", d
->email
);
110 d
->version
= config
.readEntry("X-KDE-PluginInfo-Version", d
->version
);
111 d
->website
= config
.readEntry("X-KDE-PluginInfo-Website", d
->website
);
112 d
->license
= config
.readEntry("X-KDE-PluginInfo-License", d
->license
);
113 d
->type
= config
.readEntry("X-KDE-PluginInfo-Category", d
->type
);
114 d
->app
= config
.readEntry("X-KDE-Plasmagik-ApplicationName", d
->app
);
115 d
->requiredVersion
= config
.readEntry("X-KDE-Plasmagik-RequiredVersion", d
->requiredVersion
);
118 QString
PackageMetadata::name() const
123 QString
PackageMetadata::description() const
125 return d
->description
;
128 QString
PackageMetadata::serviceType() const
130 return d
->serviceType
;
133 QString
PackageMetadata::author() const
138 QString
PackageMetadata::email() const
143 QString
PackageMetadata::version() const
148 QString
PackageMetadata::website() const
153 QString
PackageMetadata::license() const
158 QString
PackageMetadata::application() const
163 QString
PackageMetadata::requiredVersion() const
165 return d
->requiredVersion
;
168 QString
PackageMetadata::type() const
173 QString
PackageMetadata::implementationLanguage() const
178 void PackageMetadata::setImplementationLanguage(const QString
& language
)
180 d
->language
= language
;
183 QString
PackageMetadata::pluginName() const
185 return d
->pluginName
;
188 void PackageMetadata::setPluginName(const QString
&pluginName
)
190 d
->pluginName
= pluginName
;
193 void PackageMetadata::setName(const QString
&name
)
198 void PackageMetadata::setDescription(const QString
&description
)
200 d
->description
= description
;
203 void PackageMetadata::setServiceType(const QString
&serviceType
)
205 d
->serviceType
= serviceType
;
208 void PackageMetadata::setAuthor(const QString
&author
)
213 void PackageMetadata::setEmail(const QString
&email
)
218 void PackageMetadata::setVersion(const QString
&version
)
220 d
->version
= version
;
223 void PackageMetadata::setWebsite(const QString
&website
)
225 d
->website
= website
;
228 void PackageMetadata::setLicense(const QString
&license
)
230 d
->license
= license
;
233 void PackageMetadata::setApplication(const QString
&application
)
235 d
->app
= application
;
238 void PackageMetadata::setRequiredVersion(const QString
&requiredVersion
)
240 d
->requiredVersion
= requiredVersion
;
243 void PackageMetadata::setType(const QString
& type
)
248 } // namespace Plasma