• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • 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 };
00056 
00057 PackageMetadata::PackageMetadata(const PackageMetadata &other)
00058     : d(new PackageMetadataPrivate(*other.d))
00059 {
00060 }
00061 
00062 PackageMetadata &PackageMetadata::operator=(const PackageMetadata &other)
00063 {
00064     *d = *other.d;
00065     return *this;
00066 }
00067 
00068 PackageMetadata::PackageMetadata(const QString &path)
00069     : d(new PackageMetadataPrivate)
00070 {
00071     read(path);
00072 }
00073 
00074 PackageMetadata::~PackageMetadata()
00075 {
00076     delete d;
00077 }
00078 
00079 bool PackageMetadata::isValid() const
00080 {
00081     return ! (d->name.isEmpty() ||
00082               d->author.isEmpty() ||
00083               d->license.isEmpty() ||
00084               d->type.isEmpty());
00085 }
00086 
00087 void PackageMetadata::write(const QString &filename) const
00088 {
00089     KDesktopFile cfg(filename);
00090     KConfigGroup config = cfg.desktopGroup();
00091     config.writeEntry("Encoding", "UTF-8");
00092 
00093     config.writeEntry("Name", d->name);
00094     config.writeEntry("Icon", d->icon);
00095     config.writeEntry("Comment", d->description);
00096     config.writeEntry("Keywords", d->keywords);
00097     config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
00098     config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
00099     config.writeEntry("X-KDE-PluginInfo-Author", d->author);
00100     config.writeEntry("X-KDE-PluginInfo-Email", d->email);
00101     config.writeEntry("X-KDE-PluginInfo-Version", d->version);
00102     config.writeEntry("X-KDE-PluginInfo-Website", d->website);
00103     config.writeEntry("X-KDE-PluginInfo-License", d->license);
00104     config.writeEntry("X-KDE-PluginInfo-Category", d->category);
00105     config.writeEntry("X-Plasma-API", d->api);
00106     config.writeEntry("X-KDE-ParentApp", d->app);
00107     config.writeEntry("Type", d->type);
00108     config.writeEntry("X-Plasma-RemoteLocation", d->location);
00109 }
00110 
00111 void PackageMetadata::read(const QString &filename)
00112 {
00113     if (filename.isEmpty()) {
00114         return;
00115     }
00116 
00117     KDesktopFile cfg(filename);
00118     KConfigGroup config = cfg.desktopGroup();
00119 
00120     d->name = config.readEntry("Name", d->name);
00121     d->icon = config.readEntry("Icon", d->icon);
00122     d->description = config.readEntry("Comment", d->description);
00123     d->keywords = config.readEntry("Keywords", d->keywords);
00124     d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
00125     d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
00126     d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
00127     d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email);
00128     d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
00129     d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website);
00130     d->license = config.readEntry("X-KDE-PluginInfo-License", d->license);
00131     d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category);
00132     d->api = config.readEntry("X-Plasma-API", d->api);
00133     d->app = config.readEntry("X-KDE-ParentApp", d->app);
00134     d->type = config.readEntry("Type", d->type);
00135     d->location = config.readEntry("X-Plasma-RemoteLocation", d->location);
00136 }
00137 
00138 QString PackageMetadata::name() const
00139 {
00140     return d->name;
00141 }
00142 
00143 QString PackageMetadata::description() const
00144 {
00145     return d->description;
00146 }
00147 
00148 QString PackageMetadata::serviceType() const
00149 {
00150     return d->serviceType;
00151 }
00152 
00153 QString PackageMetadata::author() const
00154 {
00155     return d->author;
00156 }
00157 
00158 QString PackageMetadata::email() const
00159 {
00160     return d->email;
00161 }
00162 
00163 QString PackageMetadata::icon() const
00164 {
00165     return d->icon;
00166 }
00167 
00168 void PackageMetadata::setIcon(const QString &icon)
00169 {
00170     d->icon = icon;
00171 }
00172 
00173 QString PackageMetadata::version() const
00174 {
00175     return d->version;
00176 }
00177 
00178 QString PackageMetadata::website() const
00179 {
00180     return d->website;
00181 }
00182 
00183 QString PackageMetadata::license() const
00184 {
00185     return d->license;
00186 }
00187 
00188 QString PackageMetadata::application() const
00189 {
00190     return d->app;
00191 }
00192 
00193 QString PackageMetadata::category() const
00194 {
00195     return d->category;
00196 }
00197 
00198 void PackageMetadata::setKeywords(const QStringList &keywords)
00199 {
00200     d->keywords = keywords;
00201 }
00202 
00203 QStringList PackageMetadata::keywords() const
00204 {
00205     return d->keywords;
00206 }
00207 
00208 QString PackageMetadata::requiredVersion() const
00209 {
00210     return d->requiredVersion;
00211 }
00212 
00213 KUrl PackageMetadata::remoteLocation() const
00214 {
00215     return d->location;
00216 }
00217 
00218 QString PackageMetadata::type() const
00219 {
00220     return d->type;
00221 }
00222 
00223 QString PackageMetadata::implementationApi() const
00224 {
00225     return d->api;
00226 }
00227 
00228 void PackageMetadata::setImplementationApi(const QString &api)
00229 {
00230     d->api = api;
00231 }
00232 
00233 QString PackageMetadata::pluginName() const
00234 {
00235     return d->pluginName;
00236 }
00237 
00238 void PackageMetadata::setPluginName(const QString &pluginName)
00239 {
00240     d->pluginName = pluginName;
00241 }
00242 
00243 void PackageMetadata::setName(const QString &name)
00244 {
00245     d->name = name;
00246 }
00247 
00248 void PackageMetadata::setDescription(const QString &description)
00249 {
00250     d->description = description;
00251 }
00252 
00253 void PackageMetadata::setServiceType(const QString &serviceType)
00254 {
00255     d->serviceType = serviceType;
00256 }
00257 
00258 void PackageMetadata::setAuthor(const QString &author)
00259 {
00260     d->author = author;
00261 }
00262 
00263 void PackageMetadata::setEmail(const QString &email)
00264 {
00265     d->email = email;
00266 }
00267 
00268 void PackageMetadata::setVersion(const QString &version)
00269 {
00270     d->version = version;
00271 }
00272 
00273 void PackageMetadata::setWebsite(const QString &website)
00274 {
00275     d->website = website;
00276 }
00277 
00278 void PackageMetadata::setLicense(const QString &license)
00279 {
00280     d->license = license;
00281 }
00282 
00283 void PackageMetadata::setApplication(const QString &application)
00284 {
00285     d->app = application;
00286 }
00287 
00288 void PackageMetadata::setCategory(const QString &category)
00289 {
00290     d->category = category;
00291 }
00292 
00293 void PackageMetadata::setRequiredVersion(const QString &requiredVersion)
00294 {
00295     d->requiredVersion = requiredVersion;
00296 }
00297 
00298 void PackageMetadata::setRemoteLocation(const KUrl &location)
00299 {
00300     d->location = location;
00301 }
00302 
00303 void PackageMetadata::setType(const QString &type)
00304 {
00305     d->type = type;
00306 }
00307 
00308 } // namespace Plasma
00309 

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
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