• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libplasma

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>
00025 #include <KDesktopFile>
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 description;
00040         QString author;
00041         QString email;
00042         QString version;
00043         QString website;
00044         QString license;
00045         QString app;
00046         QString category;
00047         QString requiredVersion;
00048         QString pluginName;
00049         QString type;
00050         QString serviceType;
00051         QString api;
00052 };
00053 
00054 PackageMetadata::PackageMetadata()
00055     : d(new PackageMetadataPrivate)
00056 {
00057 }
00058 
00059 PackageMetadata::PackageMetadata(const QString& path)
00060     : d(new PackageMetadataPrivate)
00061 {
00062     read(path);
00063 }
00064 
00065 PackageMetadata::~PackageMetadata()
00066 {
00067     delete d;
00068 }
00069 
00070 bool PackageMetadata::isValid() const
00071 {
00072     return ! (d->name.isEmpty() ||
00073               d->author.isEmpty() ||
00074               d->version.isEmpty() ||
00075               d->license.isEmpty() ||
00076               d->app.isEmpty() ||
00077               d->type.isEmpty());
00078 }
00079 
00080 void PackageMetadata::write(const QString &filename) const
00081 {
00082     KDesktopFile cfg(filename);
00083     KConfigGroup config = cfg.desktopGroup();
00084     config.writeEntry("Encoding", "UTF-8");
00085 
00086     config.writeEntry("Name", d->name);
00087     config.writeEntry("Comment", d->description);
00088     config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
00089     config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
00090     config.writeEntry("X-KDE-PluginInfo-Author", d->author);
00091     config.writeEntry("X-KDE-PluginInfo-Email", d->email);
00092     config.writeEntry("X-KDE-PluginInfo-Version", d->version);
00093     config.writeEntry("X-KDE-PluginInfo-Website", d->website);
00094     config.writeEntry("X-KDE-PluginInfo-License", d->license);
00095     config.writeEntry("X-KDE-PluginInfo-Category", d->category);
00096     config.writeEntry("X-Plasma-API", d->api);
00097     config.writeEntry("X-KDE-Plasmagik-ApplicationName", d->app);
00098     config.writeEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion);
00099 }
00100 
00101 void PackageMetadata::read(const QString& filename)
00102 {
00103     KConfig cfg(filename);
00104     KConfigGroup config(&cfg, "Desktop Entry");
00105 
00106     d->name = config.readEntry("Name", d->name);
00107     d->description = config.readEntry("Comment", d->description);
00108     d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
00109     d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
00110     d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
00111     d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email);
00112     d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
00113     d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website);
00114     d->license = config.readEntry("X-KDE-PluginInfo-License", d->license);
00115     d->type = config.readEntry("Type", d->type);
00116     d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category);
00117     d->app = config.readEntry("X-KDE-Plasmagik-ApplicationName", d->app);
00118     d->requiredVersion = config.readEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion);
00119 }
00120 
00121 QString PackageMetadata::name() const
00122 {
00123     return d->name;
00124 }
00125 
00126 QString PackageMetadata::description() const
00127 {
00128     return d->description;
00129 }
00130 
00131 QString PackageMetadata::serviceType() const
00132 {
00133     return d->serviceType;
00134 }
00135 
00136 QString PackageMetadata::author() const
00137 {
00138     return d->author;
00139 }
00140 
00141 QString PackageMetadata::email() const
00142 {
00143     return d->email;
00144 }
00145 
00146 QString PackageMetadata::version() const
00147 {
00148     return d->version;
00149 }
00150 
00151 QString PackageMetadata::website() const
00152 {
00153     return d->website;
00154 }
00155 
00156 QString PackageMetadata::license() const
00157 {
00158     return d->license;
00159 }
00160 
00161 QString PackageMetadata::application() const
00162 {
00163     return d->app;
00164 }
00165 
00166 QString PackageMetadata::category() const
00167 {
00168     return d->category;
00169 }
00170 
00171 QString PackageMetadata::requiredVersion() const
00172 {
00173     return d->requiredVersion;
00174 }
00175 
00176 QString PackageMetadata::type() const
00177 {
00178     return d->type;
00179 }
00180 
00181 QString PackageMetadata::implementationApi() const
00182 {
00183     return d->api;
00184 }
00185 
00186 void PackageMetadata::setImplementationApi(const QString& api)
00187 {
00188     d->api = api;
00189 }
00190 
00191 QString PackageMetadata::pluginName() const
00192 {
00193     return d->pluginName;
00194 }
00195 
00196 void PackageMetadata::setPluginName(const QString &pluginName)
00197 {
00198     d->pluginName = pluginName;
00199 }
00200 
00201 void PackageMetadata::setName(const QString &name)
00202 {
00203     d->name = name;
00204 }
00205 
00206 void PackageMetadata::setDescription(const QString &description)
00207 {
00208     d->description = description;
00209 }
00210 
00211 void PackageMetadata::setServiceType(const QString &serviceType)
00212 {
00213     d->serviceType = serviceType;
00214 }
00215 
00216 void PackageMetadata::setAuthor(const QString &author)
00217 {
00218     d->author = author;
00219 }
00220 
00221 void PackageMetadata::setEmail(const QString &email)
00222 {
00223     d->email = email;
00224 }
00225 
00226 void PackageMetadata::setVersion(const QString &version)
00227 {
00228     d->version = version;
00229 }
00230 
00231 void PackageMetadata::setWebsite(const QString &website)
00232 {
00233     d->website = website;
00234 }
00235 
00236 void PackageMetadata::setLicense(const QString &license)
00237 {
00238     d->license = license;
00239 }
00240 
00241 void PackageMetadata::setApplication(const QString &application)
00242 {
00243     d->app = application;
00244 }
00245 
00246 void PackageMetadata::setCategory(const QString &category)
00247 {
00248     d->category = category;
00249 }
00250 
00251 void PackageMetadata::setRequiredVersion(const QString &requiredVersion)
00252 {
00253     d->requiredVersion = requiredVersion;
00254 }
00255 
00256 void PackageMetadata::setType(const QString& type)
00257 {
00258     d->type = type;
00259 }
00260 
00261 } // namespace Plasma
00262 
00263 

libplasma

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

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal