• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

Plasma

packagemetadata.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 *   Copyright 2007 by Riccardo Iaconelli  <riccardo@kde.org>                *
00003 *                                                                             *
00004 *   This library is free software; you can redistribute it and/or             *
00005 *   modify it under the terms of the GNU Library General Public               *
00006 *   License as published by the Free Software Foundation; either              *
00007 *   version 2 of the License, or (at your option) any later version.          *
00008 *                                                                             *
00009 *   This library is distributed in the hope that it will be useful,           *
00010 *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00011 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU          *
00012 *   Library General Public License for more details.                          *
00013 *                                                                             *
00014 *   You should have received a copy of the GNU Library General Public License *
00015 *   along with this library; see the file COPYING.LIB.  If not, write to      *
00016 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,      *
00017 *   Boston, MA 02110-1301, USA.                                               *
00018 *******************************************************************************/
00019 
00020 #include <packagemetadata.h>
00021 
00022 #include <QDir>
00023 
00024 #include <kconfiggroup.h>
00025 #include <kdesktopfile.h>
00026 
00027 namespace Plasma
00028 {
00029 
00030 class PackageMetadataPrivate
00031 {
00032     public:
00033         PackageMetadataPrivate()
00034             : type("Service")
00035         {
00036         }
00037 
00038         QString name;
00039         QString icon;
00040         QString description;
00041         QStringList keywords;
00042         QString author;
00043         QString email;
00044         QString version;
00045         QString website;
00046         QString license;
00047         QString app;
00048         QString category;
00049         QString requiredVersion;
00050         QString pluginName;
00051         QString type;
00052         QString serviceType;
00053         QString api;
00054         KUrl location;
00055         QStringList requiredDataEngines;
00056 };
00057 
00058 PackageMetadata::PackageMetadata(const PackageMetadata &other)
00059     : d(new PackageMetadataPrivate(*other.d))
00060 {
00061 }
00062 
00063 PackageMetadata &PackageMetadata::operator=(const PackageMetadata &other)
00064 {
00065     *d = *other.d;
00066     return *this;
00067 }
00068 
00069 PackageMetadata::PackageMetadata(const QString &path)
00070     : d(new PackageMetadataPrivate)
00071 {
00072     read(path);
00073 }
00074 
00075 PackageMetadata::~PackageMetadata()
00076 {
00077     delete d;
00078 }
00079 
00080 bool PackageMetadata::isValid() const
00081 {
00082     return ! (d->name.isEmpty() ||
00083               d->author.isEmpty() ||
00084               d->license.isEmpty() ||
00085               d->type.isEmpty());
00086 }
00087 
00088 void PackageMetadata::write(const QString &filename) const
00089 {
00090     KDesktopFile cfg(filename);
00091     KConfigGroup config = cfg.desktopGroup();
00092     config.writeEntry("Encoding", "UTF-8");
00093 
00094     config.writeEntry("Name", d->name);
00095     config.writeEntry("Icon", d->icon);
00096     config.writeEntry("Comment", d->description);
00097     config.writeEntry("Keywords", d->keywords);
00098     config.deleteEntry("X-KDE-Keywords");
00099     config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
00100     config.deleteEntry("ServiceTypes");
00101     config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
00102     config.writeEntry("X-KDE-PluginInfo-Author", d->author);
00103     config.writeEntry("X-KDE-PluginInfo-Email", d->email);
00104     config.writeEntry("X-KDE-PluginInfo-Version", d->version);
00105     config.writeEntry("X-KDE-PluginInfo-Website", d->website);
00106     config.writeEntry("X-KDE-PluginInfo-License", d->license);
00107     config.writeEntry("X-KDE-PluginInfo-Category", d->category);
00108     config.writeEntry("X-Plasma-API", d->api);
00109     config.writeEntry("X-KDE-ParentApp", d->app);
00110     config.writeEntry("Type", d->type);
00111     config.writeEntry("X-Plasma-RemoteLocation", d->location);
00112     config.writeEntry("X-Plasma-RequiredDataEngines", d->requiredDataEngines);
00113 }
00114 
00115 void PackageMetadata::read(const QString &filename)
00116 {
00117     if (filename.isEmpty()) {
00118         return;
00119     }
00120 
00121     KDesktopFile cfg(filename);
00122     KConfigGroup config = cfg.desktopGroup();
00123 
00124     d->name = config.readEntry("Name", d->name);
00125     d->icon = config.readEntry("Icon", d->icon);
00126     d->description = config.readEntry("Comment", d->description);
00127     bool hasKeywords = config.hasKey("Keywords");
00128     bool hasXKdeKeywords = config.hasKey("X-KDE-Keywords");
00129     if (hasKeywords && hasXKdeKeywords) {
00130         d->keywords = config.readEntry("Keywords", d->keywords);
00131         d->keywords.append(config.readEntry("X-KDE-Keywords", d->keywords));
00132     } else if (hasKeywords) {
00133         d->keywords = config.readEntry("Keywords", d->keywords);
00134     } else if (hasXKdeKeywords) {
00135         d->keywords = config.readEntry("X-KDE-Keywords", d->keywords);
00136     }
00137     bool hasServiceTypes = config.hasKey("ServiceTypes");
00138     bool hasXKdeServiceTypes = config.hasKey("X-KDE-ServiceTypes");
00139     if (hasServiceTypes && hasXKdeServiceTypes) {
00140         d->serviceType = config.readEntry("ServiceTypes", d->serviceType);
00141         d->serviceType.append(',');
00142         d->serviceType.append(config.readEntry("X-KDE-ServiceTypes", d->serviceType));
00143     } else if (hasServiceTypes) {
00144         d->serviceType = config.readEntry("ServiceTypes", d->serviceType);
00145     } else if (hasXKdeServiceTypes) {
00146         d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
00147     }
00148     d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
00149     d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
00150     d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email);
00151     d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
00152     d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website);
00153     d->license = config.readEntry("X-KDE-PluginInfo-License", d->license);
00154     d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category);
00155     d->api = config.readEntry("X-Plasma-API", d->api);
00156     d->app = config.readEntry("X-KDE-ParentApp", d->app);
00157     d->type = config.readEntry("Type", d->type);
00158     d->location = config.readEntry("X-Plasma-RemoteLocation", d->location);
00159     d->requiredDataEngines = config.readEntry("X-Plasma-RequiredDataEngines", d->requiredDataEngines);
00160 }
00161 
00162 QString PackageMetadata::name() const
00163 {
00164     return d->name;
00165 }
00166 
00167 QString PackageMetadata::description() const
00168 {
00169     return d->description;
00170 }
00171 
00172 QString PackageMetadata::serviceType() const
00173 {
00174     return d->serviceType;
00175 }
00176 
00177 QString PackageMetadata::author() const
00178 {
00179     return d->author;
00180 }
00181 
00182 QString PackageMetadata::email() const
00183 {
00184     return d->email;
00185 }
00186 
00187 QString PackageMetadata::icon() const
00188 {
00189     return d->icon;
00190 }
00191 
00192 void PackageMetadata::setIcon(const QString &icon)
00193 {
00194     d->icon = icon;
00195 }
00196 
00197 QString PackageMetadata::version() const
00198 {
00199     return d->version;
00200 }
00201 
00202 QString PackageMetadata::website() const
00203 {
00204     return d->website;
00205 }
00206 
00207 QString PackageMetadata::license() const
00208 {
00209     return d->license;
00210 }
00211 
00212 QString PackageMetadata::application() const
00213 {
00214     return d->app;
00215 }
00216 
00217 QString PackageMetadata::category() const
00218 {
00219     return d->category;
00220 }
00221 
00222 void PackageMetadata::setKeywords(const QStringList &keywords)
00223 {
00224     d->keywords = keywords;
00225 }
00226 
00227 QStringList PackageMetadata::keywords() const
00228 {
00229     return d->keywords;
00230 }
00231 
00232 QString PackageMetadata::requiredVersion() const
00233 {
00234     return d->requiredVersion;
00235 }
00236 
00237 KUrl PackageMetadata::remoteLocation() const
00238 {
00239     return d->location;
00240 }
00241 
00242 QString PackageMetadata::type() const
00243 {
00244     return d->type;
00245 }
00246 
00247 QString PackageMetadata::implementationApi() const
00248 {
00249     return d->api;
00250 }
00251 
00252 QStringList PackageMetadata::requiredDataEngines() const
00253 {
00254     return d->requiredDataEngines;
00255 }
00256 
00257 void PackageMetadata::setImplementationApi(const QString &api)
00258 {
00259     d->api = api;
00260 }
00261 
00262 QString PackageMetadata::pluginName() const
00263 {
00264     return d->pluginName;
00265 }
00266 
00267 void PackageMetadata::setPluginName(const QString &pluginName)
00268 {
00269     d->pluginName = pluginName;
00270 }
00271 
00272 void PackageMetadata::setName(const QString &name)
00273 {
00274     d->name = name;
00275 }
00276 
00277 void PackageMetadata::setDescription(const QString &description)
00278 {
00279     d->description = description;
00280 }
00281 
00282 void PackageMetadata::setServiceType(const QString &serviceType)
00283 {
00284     d->serviceType = serviceType;
00285 }
00286 
00287 void PackageMetadata::setAuthor(const QString &author)
00288 {
00289     d->author = author;
00290 }
00291 
00292 void PackageMetadata::setEmail(const QString &email)
00293 {
00294     d->email = email;
00295 }
00296 
00297 void PackageMetadata::setVersion(const QString &version)
00298 {
00299     d->version = version;
00300 }
00301 
00302 void PackageMetadata::setWebsite(const QString &website)
00303 {
00304     d->website = website;
00305 }
00306 
00307 void PackageMetadata::setLicense(const QString &license)
00308 {
00309     d->license = license;
00310 }
00311 
00312 void PackageMetadata::setApplication(const QString &application)
00313 {
00314     d->app = application;
00315 }
00316 
00317 void PackageMetadata::setCategory(const QString &category)
00318 {
00319     d->category = category;
00320 }
00321 
00322 void PackageMetadata::setRequiredVersion(const QString &requiredVersion)
00323 {
00324     d->requiredVersion = requiredVersion;
00325 }
00326 
00327 void PackageMetadata::setRemoteLocation(const KUrl &location)
00328 {
00329     d->location = location;
00330 }
00331 
00332 void PackageMetadata::setRequiredDataEngines(const QStringList &requiredDataEngines)
00333 {
00334     d->requiredDataEngines = requiredDataEngines;
00335 }
00336 
00337 void PackageMetadata::setType(const QString &type)
00338 {
00339     d->type = type;
00340 }
00341 
00342 } // namespace Plasma
00343 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 20:51:36 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.8.3 API Reference

Skip menu "kdelibs-4.8.3 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal