• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • plasma
skpackage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Sebastian Sauer <mail@dipe.org>
3  *
4  * This file is part of SuperKaramba.
5  *
6  * SuperKaramba is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * SuperKaramba is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SuperKaramba; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "skpackage.h"
22 
23 #include "themefile.h"
24 
25 #include <kconfiggroup.h>
26 #include <kdebug.h>
27 #include <kstandarddirs.h>
28 
29 K_EXPORT_PLASMA_PACKAGESTRUCTURE(superkaramba, SkPackage)
30 
31 SkPackage::SkPackage(QObject *parent, const QVariantList &args)
32  : Plasma::PackageStructure(parent)
33 {
34  Q_UNUSED(args);
35  setDefaultMimetypes( QStringList() << "application/zip" << "application/x-superkaramba" );
36 }
37 
38 SkPackage::~SkPackage()
39 {
40 }
41 
42 bool SkPackage::installPackage(const QString &archivePath, const QString &packageRoot)
43 {
44  kDebug()<<"archivePath="<<archivePath<<"packageRoot="<<packageRoot;
45 
46  ThemeFile theme(archivePath);
47 
48  QDir root(packageRoot);
49  const QString name = QString("sk_%1").arg(theme.id());
50  if( !root.cd(name) && ( !root.mkdir(name) || !root.cd(name) ) ) {
51  return false;
52  }
53 
54  const QString path = root.path();
55  //if( ! theme.extractArchiveTo(path) ) {
56  if( ! theme.copyArchiveTo(path) ) {
57  kWarning()<<"Failed to copy archive="<<archivePath<<" to path="<<path;
58  return false;
59  }
60 
61  setPath(path);
62 
63  Plasma::PackageMetadata data;
64  data.setPluginName(name);
65  data.setImplementationApi("superkaramba");
66  data.setCategory("SuperKaramba");
67  //data.setServiceType(const QString &);
68  data.setName(theme.name());
69  data.setDescription(i18n("SuperKaramba Theme"));
70  data.setAuthor(theme.author());
71  data.setEmail(theme.authorEmail());
72  data.setVersion(theme.version());
73  data.setWebsite(theme.homepage());
74  data.setLicense(theme.license());
75  //data.setApplication("superkaramba");
76  //data.setRequiredVersion(const QString &);
77 
78  QString iconfile = "superkaramba";
79  if( ! theme.iconName().isEmpty() ) {
80  theme.extractArchiveFileTo(theme.iconName(), path);
81  QFileInfo fi(path, theme.iconName());
82  if( fi.exists() )
83  iconfile = fi.absoluteFilePath();
84  }
85 
86  Plasma::Package::registerPackage(data, iconfile);
87 
88 #if 0
89  // write a desktop-file that is used by Plasma to know about our new applet.
90  const QString desktopfile = KStandardDirs::locateLocal("services", QString("plasma-scriptengine-%1.desktop").arg(name));
91  KDesktopFile desktop(desktopfile);
92  KConfigGroup group = desktop.desktopGroup();
93 
94  group.writeEntry("Name", theme.name());
95  group.writeEntry("Comment", i18n("SuperKaramba Theme"));
96  group.writeEntry("Type", "Service");
97  group.writeEntry("ServiceTypes", "Plasma/Applet");
98 
99  QString iconfile = "superkaramba";
100  if( ! theme.iconName().isEmpty() ) {
101  QFileInfo fi(path, theme.iconName());
102  if( fi.exists() )
103  iconfile = fi.absoluteFilePath();
104  }
105  group.writeEntry("Icon", iconfile);
106 
107  group.writeEntry("X-KDE-PluginInfo-Name", name);
108  group.writeEntry("X-KDE-PluginInfo-Version", theme.version());
109  group.writeEntry("X-KDE-PluginInfo-Author", theme.author());
110  group.writeEntry("X-KDE-PluginInfo-Email", theme.authorEmail());
111  group.writeEntry("X-KDE-PluginInfo-Website", theme.homepage());
112  group.writeEntry("X-KDE-PluginInfo-License", theme.license());
113  group.writeEntry("X-KDE-PluginInfo-Category", "SuperKaramba");
114  group.writeEntry("X-KDE-PluginInfo-EnabledByDefault", "true");
115 
116  // the SkAppletScript ScriptEngine implementation is responsible for our new applet.
117  group.writeEntry("X-Plasma-API", "superkaramba");
118  // it is an applet.
119  group.writeEntry("X-Plasma-ComponentTypes", "Applet");
120  // the SkPackage PackageStructure implementation is responsible for the applets package format.
121  group.writeEntry("X-Plasma-PackageFormat", "superkaramba");
122 
123  group.sync();
124 
125  // rebuild the cache to let e.g. Plasma know about our new desktop-file.
126  //FIXME would be better if we just let plasma know about the new desktop-file and let it add on the fly without using the sycoca
127  QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KSycoca", "notifyDatabaseChanged" );
128  msg << QStringList();
129  if( QDBusConnection::sessionBus().isConnected() )
130  QDBusConnection::sessionBus().send(msg);
131 #endif
132  return true;
133 }
134 
135 #include "skpackage.moc"
ThemeFile
Definition: themefile.h:41
ThemeFile::authorEmail
const QString & authorEmail() const
Definition: themefile.cpp:586
ThemeFile::copyArchiveTo
bool copyArchiveTo(const QString &path)
Definition: themefile.cpp:519
skpackage.h
QObject
SkPackage::installPackage
virtual bool installPackage(const QString &archivePath, const QString &packageRoot)
Installs a package matching this package structure.
Definition: skpackage.cpp:42
ThemeFile::id
const QString & id() const
Definition: themefile.cpp:551
themefile.h
ThemeFile::name
const QString & name() const
Definition: themefile.cpp:536
ThemeFile::extractArchiveFileTo
bool extractArchiveFileTo(const QString &file, const QString &path)
Definition: themefile.cpp:514
ThemeFile::homepage
const QString & homepage() const
Definition: themefile.cpp:591
ThemeFile::version
const QString & version() const
Definition: themefile.cpp:541
SkPackage
The SkPackage class implements a Plasma::PackageStructure to deal with SuperKaramba Theme Files - tho...
Definition: skpackage.h:33
SkPackage::~SkPackage
virtual ~SkPackage()
Destructor.
Definition: skpackage.cpp:38
ThemeFile::iconName
QString iconName() const
Definition: themefile.cpp:270
ThemeFile::author
const QString & author() const
Definition: themefile.cpp:581
ThemeFile::license
const QString & license() const
Definition: themefile.cpp:546
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

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

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



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