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

Plasma

  • sources
  • kde-4.14
  • kdelibs
  • plasma
packagestructure.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 * Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
3 * *
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. *
8 * *
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. *
13 * *
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 *******************************************************************************/
19 
20 #include "packagestructure.h"
21 
22 #include "config-plasma.h"
23 
24 #include <QDirIterator>
25 #include <QDir>
26 #include <QMap>
27 #include <QMutableListIterator>
28 #include <QFileInfo>
29 
30 #include <kconfiggroup.h>
31 #include <kdebug.h>
32 #ifndef PLASMA_NO_KIO
33 #include <kio/job.h>
34 #endif
35 #include <kmimetype.h>
36 #include <kstandarddirs.h>
37 #include <kservicetypetrader.h>
38 #include <ktar.h>
39 #include <ktemporaryfile.h>
40 #include <ktempdir.h>
41 #include <kurl.h>
42 #include <kzip.h>
43 
44 #include "package.h"
45 #include "private/packages_p.h"
46 #include "theme.h"
47 
48 namespace Plasma
49 {
50 
51 class ContentStructure
52 {
53  public:
54  ContentStructure()
55  : directory(false),
56  required(false)
57  {
58  }
59 
60  ContentStructure(const ContentStructure &other)
61  {
62  paths = other.paths;
63  name = other.name;
64  mimetypes = other.mimetypes;
65  directory = other.directory;
66  required = other.required;
67  }
68 
69  QStringList paths;
70  QString name;
71  QStringList mimetypes;
72  bool directory : 1;
73  bool required : 1;
74 };
75 
76 class PackageStructurePrivate
77 {
78 public:
79  PackageStructurePrivate(const QString &t)
80  : type(t),
81  packageRoot("plasma/plasmoids"),
82  servicePrefix("plasma-applet-"),
83  metadata(0),
84  externalPaths(false)
85  {
86  contentsPrefixPaths << "contents/";
87  }
88 
89  ~PackageStructurePrivate()
90  {
91  delete metadata;
92  }
93 
94  void createPackageMetadata(const QString &path);
95  QStringList entryList(const QString &prefix, const QString &requestedPath);
96 
97  QString type;
98  QString path;
99  QStringList contentsPrefixPaths;
100  QString packageRoot;
101  QString servicePrefix;
102  QMap<QByteArray, ContentStructure> contents;
103  QStringList mimetypes;
104  PackageMetadata *metadata;
105  bool externalPaths;
106  };
107 
108 PackageStructure::PackageStructure(QObject *parent, const QString &type)
109  : QObject(parent),
110  d(new PackageStructurePrivate(type))
111 {
112 }
113 
114 PackageStructure::~PackageStructure()
115 {
116  delete d;
117 }
118 
119 PackageStructure::Ptr PackageStructure::load(const QString &packageFormat)
120 {
121  if (packageFormat.isEmpty()) {
122  return Ptr(new PackageStructure());
123  }
124 
125  PackageStructure::Ptr structure;
126 
127  if (packageFormat == "Plasma/Applet") {
128  structure = defaultPackageStructure(AppletComponent);
129  structure->d->type = "Plasma/Applet";
130  } else if (packageFormat == "Plasma/DataEngine") {
131  structure = defaultPackageStructure(DataEngineComponent);
132  structure->d->type = "Plasma/DataEngine";
133  } else if (packageFormat == "Plasma/Runner") {
134  structure = defaultPackageStructure(RunnerComponent);
135  structure->d->type = "Plasma/Runner";
136  } else if (packageFormat == "Plasma/Wallpaper") {
137  structure = defaultPackageStructure(WallpaperComponent);
138  structure->d->type = "Plasma/Wallpaper";
139  } else if (packageFormat == "Plasma/Theme") {
140  structure = Theme::packageStructure();
141  structure->d->type = "Plasma/Theme";
142  } else if (packageFormat == "Plasma/Generic") {
143  structure = defaultPackageStructure(GenericComponent);
144  structure->d->type = "Plasma/Generic";
145  structure->setDefaultPackageRoot("plasma/packages/");
146  }
147 
148  if (structure) {
149  return structure;
150  }
151 
152  // first we check for plugins in sycoca
153  QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat);
154  KService::List offers =
155  KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint);
156 
157  QVariantList args;
158  QString error;
159  foreach (const KService::Ptr &offer, offers) {
160  PackageStructure::Ptr structure(
161  offer->createInstance<Plasma::PackageStructure>(0, args, &error));
162 
163  if (structure) {
164  return structure;
165  }
166 
167  kDebug() << "Couldn't load PackageStructure for" << packageFormat
168  << "! reason given: " << error;
169  }
170 
171  // if that didn't give us any love, then we try to load from a config file
172  structure = new PackageStructure();
173  QString configPath("plasma/packageformats/%1rc");
174  configPath = KStandardDirs::locate("data", configPath.arg(packageFormat));
175 
176  if (!configPath.isEmpty()) {
177  KConfig config(configPath);
178  structure->read(&config);
179  return structure;
180  }
181 
182  // try to load from absolute file path
183  KUrl url(packageFormat);
184  if (url.isLocalFile()) {
185  KConfig config(url.toLocalFile(), KConfig::SimpleConfig);
186  structure->read(&config);
187  }
188 #ifndef PLASMA_NO_KIO
189  else {
190  KTemporaryFile tmp;
191  if (tmp.open()) {
192  KIO::Job *job = KIO::file_copy(url, KUrl(tmp.fileName()),
193  -1, KIO::Overwrite | KIO::HideProgressInfo);
194  if (job->exec()) {
195  KConfig config(tmp.fileName(), KConfig::SimpleConfig);
196  structure->read(&config);
197  }
198  }
199  }
200 #endif
201 
202  return structure;
203 }
204 
205 PackageStructure &PackageStructure::operator=(const PackageStructure &rhs)
206 {
207  if (this == &rhs) {
208  return *this;
209  }
210 
211  *d = *rhs.d;
212  return *this;
213 }
214 
215 QString PackageStructure::type() const
216 {
217  return d->type;
218 }
219 
220 QList<const char*> PackageStructure::directories() const
221 {
222  QList<const char*> dirs;
223  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
224  while (it != d->contents.constEnd()) {
225  if (it.value().directory) {
226  dirs << it.key();
227  }
228  ++it;
229  }
230  return dirs;
231 }
232 
233 QList<const char*> PackageStructure::requiredDirectories() const
234 {
235  QList<const char*> dirs;
236  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
237  while (it != d->contents.constEnd()) {
238  if (it.value().directory &&
239  it.value().required) {
240  dirs << it.key();
241  }
242  ++it;
243  }
244  return dirs;
245 }
246 
247 QList<const char*> PackageStructure::files() const
248 {
249  QList<const char*> files;
250  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
251  while (it != d->contents.constEnd()) {
252  if (!it.value().directory) {
253  files << it.key();
254  }
255  ++it;
256  }
257  return files;
258 }
259 
260 QList<const char*> PackageStructure::requiredFiles() const
261 {
262  QList<const char*> files;
263  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
264  while (it != d->contents.constEnd()) {
265  if (!it.value().directory && it.value().required) {
266  files << it.key();
267  }
268  ++it;
269  }
270  return files;
271 }
272 
273 QStringList PackageStructure::entryList(const char *key)
274 {
275  QString p = path(key);
276 
277  if (p.isEmpty()) {
278  return QStringList();
279  }
280 
281  QStringList list;
282  if (d->contentsPrefixPaths.isEmpty()) {
283  // no prefixes is the same as d->contentsPrefixPths with QStringList() << QString()
284  list << d->entryList(QString(), p);
285  } else {
286  foreach (QString prefix, d->contentsPrefixPaths) {
287  list << d->entryList(prefix, p);
288  }
289  }
290 
291  return list;
292 }
293 
294 QStringList PackageStructurePrivate::entryList(const QString &prefix, const QString &requestedPath)
295 {
296  QDir dir(path + prefix + requestedPath);
297 
298  if (externalPaths) {
299  return dir.entryList(QDir::Files | QDir::Readable);
300  }
301 
302  // ensure that we don't return files outside of our base path
303  // due to symlink or ../ games
304  QString canonicalized = dir.canonicalPath();
305  if (canonicalized.startsWith(path)) {
306  return dir.entryList(QDir::Files | QDir::Readable);
307  }
308 
309  return QStringList();
310 }
311 
312 void PackageStructure::addDirectoryDefinition(const char *key,
313  const QString &path, const QString &name)
314 {
315  ContentStructure s;
316 
317  if (d->contents.contains(key)) {
318  s = d->contents[key];
319  }
320 
321  if (!name.isEmpty()) {
322  s.name = name;
323  }
324 
325  s.paths.append(path);
326  s.directory = true;
327 
328  d->contents[key] = s;
329 }
330 
331 void PackageStructure::addFileDefinition(const char *key, const QString &path, const QString &name)
332 {
333  ContentStructure s;
334 
335  if (d->contents.contains(key)) {
336  s = d->contents[key];
337  }
338 
339  if (!name.isEmpty()) {
340  s.name = name;
341  }
342 
343  s.paths.append(path);
344  s.directory = false;
345 
346  d->contents[key] = s;
347 }
348 
349 void PackageStructure::removeDefinition(const char *key)
350 {
351  d->contents.remove(key);
352 }
353 
354 QString PackageStructure::path(const char *key) const
355 {
356  //kDebug() << "looking for" << key;
357  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
358  if (it == d->contents.constEnd()) {
359  return QString();
360  }
361 
362  //kDebug() << "found" << key << "and the value is" << it.value().paths.first();
363  return it.value().paths.first();
364 }
365 
366 QStringList PackageStructure::searchPath(const char *key) const
367 {
368  //kDebug() << "looking for" << key;
369  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
370  if (it == d->contents.constEnd()) {
371  return QStringList();
372  }
373 
374  //kDebug() << "found" << key << "and the value is" << it.value().paths;
375  return it.value().paths;
376 }
377 
378 QString PackageStructure::name(const char *key) const
379 {
380  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
381  if (it == d->contents.constEnd()) {
382  return QString();
383  }
384 
385  return it.value().name;
386 }
387 
388 void PackageStructure::setRequired(const char *key, bool required)
389 {
390  QMap<QByteArray, ContentStructure>::iterator it = d->contents.find(key);
391  if (it == d->contents.end()) {
392  return;
393  }
394 
395  it.value().required = required;
396 }
397 
398 bool PackageStructure::isRequired(const char *key) const
399 {
400  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
401  if (it == d->contents.constEnd()) {
402  return false;
403  }
404 
405  return it.value().required;
406 }
407 
408 void PackageStructure::setDefaultMimetypes(QStringList mimetypes)
409 {
410  d->mimetypes = mimetypes;
411 }
412 
413 void PackageStructure::setMimetypes(const char *key, QStringList mimetypes)
414 {
415  QMap<QByteArray, ContentStructure>::iterator it = d->contents.find(key);
416  if (it == d->contents.end()) {
417  return;
418  }
419 
420  it.value().mimetypes = mimetypes;
421 }
422 
423 QStringList PackageStructure::mimetypes(const char *key) const
424 {
425  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
426  if (it == d->contents.constEnd()) {
427  return QStringList();
428  }
429 
430  if (it.value().mimetypes.isEmpty()) {
431  return d->mimetypes;
432  }
433 
434  return it.value().mimetypes;
435 }
436 
437 void PackageStructure::setPath(const QString &path)
438 {
439  KUrl url(path);
440  QDir dir(url.toLocalFile());
441  QString basePath = dir.canonicalPath();
442  bool valid = QFile::exists(basePath);
443 
444  if (valid) {
445  QFileInfo info(basePath);
446  if (info.isDir() && !basePath.endsWith('/')) {
447  basePath.append('/');
448  }
449  //kDebug() << "basePath is" << basePath;
450  } else {
451  kDebug() << path << "invalid, basePath is" << basePath;
452  return;
453  }
454 
455  if (d->path == basePath) {
456  return;
457  }
458 
459  d->path = basePath;
460  delete d->metadata;
461  d->metadata = 0;
462  pathChanged();
463 }
464 
465 QString PackageStructure::path() const
466 {
467  return d->path;
468 }
469 
470 void PackageStructure::pathChanged()
471 {
472  // default impl does nothing, this is a hook for subclasses.
473 }
474 
475 void PackageStructure::read(const KConfigBase *config)
476 {
477  d->contents.clear();
478  d->mimetypes.clear();
479  KConfigGroup general(config, QString());
480  d->type = general.readEntry("Type", QString());
481  d->contentsPrefixPaths = general.readEntry("ContentsPrefixPaths", d->contentsPrefixPaths);
482  d->packageRoot = general.readEntry("DefaultPackageRoot", d->packageRoot);
483  d->externalPaths = general.readEntry("AllowExternalPaths", d->externalPaths);
484 
485  QStringList groups = config->groupList();
486  foreach (const QString &group, groups) {
487  KConfigGroup entry(config, group);
488  QByteArray key = group.toLatin1();
489 
490  QString path = entry.readEntry("Path", QString());
491  QString name = entry.readEntry("Name", QString());
492  QStringList mimetypes = entry.readEntry("Mimetypes", QStringList());
493  bool directory = entry.readEntry("Directory", false);
494  bool required = entry.readEntry("Required", false);
495 
496  if (directory) {
497  addDirectoryDefinition(key, path, name);
498  } else {
499  addFileDefinition(key, path, name);
500  }
501 
502  setMimetypes(key, mimetypes);
503  setRequired(key, required);
504  }
505 }
506 
507 void PackageStructure::write(KConfigBase *config) const
508 {
509  KConfigGroup general = KConfigGroup(config, "");
510  general.writeEntry("Type", type());
511  general.writeEntry("ContentsPrefixPaths", d->contentsPrefixPaths);
512  general.writeEntry("DefaultPackageRoot", d->packageRoot);
513  general.writeEntry("AllowExternalPaths", d->externalPaths);
514 
515  QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
516  while (it != d->contents.constEnd()) {
517  KConfigGroup group = config->group(it.key());
518  group.writeEntry("Path", it.value().paths);
519  group.writeEntry("Name", it.value().name);
520  if (!it.value().mimetypes.isEmpty()) {
521  group.writeEntry("Mimetypes", it.value().mimetypes);
522  }
523  if (it.value().directory) {
524  group.writeEntry("Directory", true);
525  }
526  if (it.value().required) {
527  group.writeEntry("Required", true);
528  }
529 
530  ++it;
531  }
532 }
533 
534 QString PackageStructure::contentsPrefix() const
535 {
536  return d->contentsPrefixPaths.isEmpty() ? QString() : d->contentsPrefixPaths.first();
537 }
538 
539 void PackageStructure::setContentsPrefix(const QString &prefix)
540 {
541  d->contentsPrefixPaths.clear();
542  d->contentsPrefixPaths << prefix;
543 }
544 
545 QStringList PackageStructure::contentsPrefixPaths() const
546 {
547  return d->contentsPrefixPaths;
548 }
549 
550 void PackageStructure::setContentsPrefixPaths(const QStringList &prefixPaths)
551 {
552  d->contentsPrefixPaths = prefixPaths;
553 
554  // the code assumes that the prefixes have a trailing slash
555  // so let's make that true here
556  QMutableStringListIterator it(d->contentsPrefixPaths);
557  while (it.hasNext()) {
558  it.next();
559 
560  if (!it.value().endsWith('/')) {
561  it.setValue(it.value() % '/');
562  }
563  }
564 }
565 
566 bool PackageStructure::installPackage(const QString &package, const QString &packageRoot)
567 {
568  return Package::installPackage(package, packageRoot, d->servicePrefix);
569 }
570 
571 bool PackageStructure::uninstallPackage(const QString &packageName, const QString &packageRoot)
572 {
573  return Package::uninstallPackage(packageName, packageRoot, d->servicePrefix);
574 }
575 
576 void PackageStructure::createNewWidgetBrowser(QWidget *parent)
577 {
578  Q_UNUSED(parent)
579  emit newWidgetBrowserFinished();
580 }
581 
582 QString PackageStructure::defaultPackageRoot() const
583 {
584  return d->packageRoot;
585 }
586 
587 QString PackageStructure::servicePrefix() const
588 {
589  return d->servicePrefix;
590 }
591 
592 void PackageStructure::setDefaultPackageRoot(const QString &packageRoot)
593 {
594  d->packageRoot = packageRoot;
595 }
596 
597 void PackageStructure::setServicePrefix(const QString &servicePrefix)
598 {
599  d->servicePrefix = servicePrefix;
600 }
601 
602 void PackageStructurePrivate::createPackageMetadata(const QString &path)
603 {
604  delete metadata;
605  metadata = 0;
606 
607  QString metadataPath(path + "/metadata.desktop");
608  if (!QFile::exists(metadataPath)) {
609  kWarning() << "No metadata file in the package, expected it at:" << metadataPath;
610  metadataPath.clear();
611  }
612 
613  metadata = new PackageMetadata(metadataPath);
614 }
615 
616 //FIXME KDE5: should be const
617 PackageMetadata PackageStructure::metadata()
618 {
619  if (!d->metadata && !d->path.isEmpty()) {
620  QFileInfo fileInfo(d->path);
621 
622  if (fileInfo.isDir()) {
623  d->createPackageMetadata(d->path);
624  } else if (fileInfo.exists()) {
625  KArchive *archive = 0;
626  KMimeType::Ptr mimetype = KMimeType::findByPath(d->path);
627 
628  if (mimetype->is("application/zip")) {
629  archive = new KZip(d->path);
630  } else if (mimetype->is("application/x-compressed-tar") || mimetype->is("application/x-gzip") ||
631  mimetype->is("application/x-xz-compressed-tar") || mimetype->is("application/x-lzma-compressed-tar") ||
632  mimetype->is("application/x-tar")|| mimetype->is("application/x-bzip-compressed-tar")) {
633  archive = new KTar(d->path);
634  } else {
635  kWarning() << "Could not open package file, unsupported archive format:" << d->path << mimetype->name();
636  }
637 
638  if (archive && archive->open(QIODevice::ReadOnly)) {
639  const KArchiveDirectory *source = archive->directory();
640  KTempDir tempdir;
641  source->copyTo(tempdir.name());
642 
643  // This is to help with the theme packages, which include an extra folder in their package archive.
644  // Question: Would it be better to search just the first level dirs for metadata.desktop file?
645  // As in /path/Theme Name/Dir1/metadata.desktop and not /path/Theme Name/Dir1/Dir2/metadata.desktop
646  // This fixes bug https://bugs.kde.org/show_bug.cgi?id=149479 properly.
647  // 2nd rev. Search an extra first directory only.
648 
649  QDir dir(tempdir.name());
650  QString filename = "metadata.desktop";
651  QFileInfo metadataFileInfo(dir, filename);
652 
653  if (metadataFileInfo.exists()) {
654  d->createPackageMetadata(metadataFileInfo.absolutePath());
655  } else {
656  dir.setFilter(QDir::NoDotAndDotDot|QDir::Dirs);
657  dir.setSorting(QDir::DirsFirst);
658  QFileInfo firstDir(dir.entryInfoList().first());
659  metadataFileInfo = QFileInfo(firstDir.filePath(), filename);
660  if (metadataFileInfo.exists()) {
661  kWarning() << "Found in: " << metadataFileInfo.absolutePath();
662  d->createPackageMetadata(metadataFileInfo.absolutePath());
663  }
664  }
665  } else {
666  kWarning() << "Could not open package file:" << d->path;
667  }
668 
669  delete archive;
670  }
671  }
672 
673  if (!d->metadata) {
674  d->metadata = new PackageMetadata();
675  }
676 
677  return *d->metadata;
678 }
679 
680 bool PackageStructure::allowExternalPaths() const
681 {
682  return d->externalPaths;
683 }
684 
685 void PackageStructure::setAllowExternalPaths(bool allow)
686 {
687  d->externalPaths = allow;
688 }
689 
690 } // Plasma namespace
691 
692 #include "packagestructure.moc"
693 
Plasma::PackageStructure::files
QList< const char * > files() const
The individual files, by key, that are defined for this package.
Definition: packagestructure.cpp:247
Plasma::PackageStructure::write
void write(KConfigBase *config) const
Write this package structure to a config file.
Definition: packagestructure.cpp:507
QWidget
Plasma::WallpaperComponent
Plasma::Wallpaper based plugins.
Definition: plasma.h:231
QByteArray
Plasma::PackageStructure::contentsPrefix
QString contentsPrefix() const
Definition: packagestructure.cpp:534
Plasma::PackageStructure::entryList
QStringList entryList(const char *key)
Get the list of files of a given type.
Definition: packagestructure.cpp:273
Plasma::PackageStructure::~PackageStructure
virtual ~PackageStructure()
Destructor.
Definition: packagestructure.cpp:114
Plasma::PackageStructure::setPath
void setPath(const QString &path)
Sets the path to the package.
Definition: packagestructure.cpp:437
QMap< QByteArray, ContentStructure >
Plasma::PackageStructure::contentsPrefixPaths
QStringList contentsPrefixPaths() const
Definition: packagestructure.cpp:545
theme.h
Plasma::PackageStructure::setServicePrefix
void setServicePrefix(const QString &servicePrefix)
Sets service prefix.
Definition: packagestructure.cpp:597
Plasma::PackageStructure::setDefaultMimetypes
void setDefaultMimetypes(QStringList mimetypes)
Defines the default mimetypes for any definitions that do not have associated mimetypes.
Definition: packagestructure.cpp:408
QFile::exists
bool exists() const
Plasma::PackageStructure::newWidgetBrowserFinished
void newWidgetBrowserFinished()
Emitted when the new widget browser process completes.
Plasma::defaultPackageStructure
PackageStructure::Ptr defaultPackageStructure(ComponentType type)
Definition: scriptengine.cpp:254
Plasma::Theme::packageStructure
static PackageStructure::Ptr packageStructure()
Definition: theme.cpp:590
Plasma::PackageStructure::addFileDefinition
void addFileDefinition(const char *key, const QString &path, const QString &name)
Adds a file to the structure of the package.
Definition: packagestructure.cpp:331
Plasma::GenericComponent
Definition: plasma.h:232
QObject::name
const char * name() const
Plasma::Package::uninstallPackage
static bool uninstallPackage(const QString &package, const QString &packageRoot, const QString &servicePrefix)
Uninstalls a package.
Definition: package.cpp:628
Plasma::Package::installPackage
static bool installPackage(const QString &package, const QString &packageRoot, const QString &servicePrefix)
Installs a package.
Definition: package.cpp:464
Plasma::PackageStructure::operator=
PackageStructure & operator=(const PackageStructure &rhs)
Assignment operator.
Definition: packagestructure.cpp:205
Plasma::PackageStructure::setRequired
void setRequired(const char *key, bool required)
Sets whether or not a given part of the structure is required or not.
Definition: packagestructure.cpp:388
Plasma::PackageStructure::setContentsPrefix
void setContentsPrefix(const QString &prefix)
Sets the prefix that all the contents in this package should appear under.
Definition: packagestructure.cpp:539
QFileInfo::isDir
bool isDir() const
QObject
Plasma::PackageStructure::createNewWidgetBrowser
virtual void createNewWidgetBrowser(QWidget *parent=0)
When called, the package plugin should display a window to the user that they can use to browser...
Definition: packagestructure.cpp:576
Plasma::PackageStructure::defaultPackageRoot
QString defaultPackageRoot() const
Definition: packagestructure.cpp:582
Plasma::PackageStructure::PackageStructure
PackageStructure(QObject *parent=0, const QString &type=i18nc("A non-functional package","Invalid"))
Default constructor for a package structure definition.
Definition: packagestructure.cpp:108
Plasma::PackageStructure::setDefaultPackageRoot
void setDefaultPackageRoot(const QString &packageRoot)
Sets preferred package root.
Definition: packagestructure.cpp:592
QString::isEmpty
bool isEmpty() const
Plasma::PackageStructure::requiredFiles
QList< const char * > requiredFiles() const
The individual required files, by key, that are defined for this package.
Definition: packagestructure.cpp:260
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Plasma::PackageStructure::uninstallPackage
virtual bool uninstallPackage(const QString &packageName, const QString &packageRoot)
Uninstalls a package matching this package structure.
Definition: packagestructure.cpp:571
Plasma::PackageStructure::Ptr
KSharedPtr< PackageStructure > Ptr
Definition: packagestructure.h:77
QString
QList
QStringList
QFileInfo
QFileInfo::exists
bool exists() const
Plasma::PackageStructure::addDirectoryDefinition
void addDirectoryDefinition(const char *key, const QString &path, const QString &name)
Adds a directory to the structure of the package.
Definition: packagestructure.cpp:312
Plasma::PackageStructure::mimetypes
QStringList mimetypes(const char *key) const
Definition: packagestructure.cpp:423
Plasma::RunnerComponent
Plasma::AbstractRunner based plugsin.
Definition: plasma.h:228
Plasma::PackageStructure::pathChanged
virtual void pathChanged()
Called whenever the path changes so that subclasses may take package specific actions.
Definition: packagestructure.cpp:470
Plasma::PackageStructure::setContentsPrefixPaths
void setContentsPrefixPaths(const QStringList &prefixPaths)
Sets the prefixes that all the contents in this package should appear under.
Definition: packagestructure.cpp:550
QMap::key
const Key key(const T &value) const
QDir
Plasma::PackageStructure::load
static PackageStructure::Ptr load(const QString &packageFormat)
Loads a package format by name.
Definition: packagestructure.cpp:119
Plasma::AppletComponent
Plasma::Applet based plugins.
Definition: plasma.h:226
QString::toLatin1
QByteArray toLatin1() const
Plasma::type
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
Definition: easingcurve.cpp:63
Plasma::DataEngineComponent
Plasma::DataEngine based plugins.
Definition: plasma.h:227
Plasma::PackageStructure::servicePrefix
QString servicePrefix() const
Definition: packagestructure.cpp:587
Plasma::PackageStructure::searchPath
QStringList searchPath(const char *key) const
Definition: packagestructure.cpp:366
package.h
Plasma::PackageStructure::setAllowExternalPaths
void setAllowExternalPaths(bool allow)
Sets whether or not external paths/symlinks can be followed by a package.
Definition: packagestructure.cpp:685
packagestructure.h
Plasma::PackageMetadata
Provides metadata for a Package.
Definition: packagemetadata.h:39
Plasma::PackageStructure::installPackage
virtual bool installPackage(const QString &archivePath, const QString &packageRoot)
Installs a package matching this package structure.
Definition: packagestructure.cpp:566
Plasma::PackageStructure::removeDefinition
void removeDefinition(const char *key)
Removes a definition from the structure of the package.
Definition: packagestructure.cpp:349
Plasma::PackageStructure::isRequired
bool isRequired(const char *key) const
Definition: packagestructure.cpp:398
Plasma::PackageStructure::path
QString path() const
Definition: packagestructure.cpp:465
Plasma::PackageStructure::setMimetypes
void setMimetypes(const char *key, QStringList mimetypes)
Define mimetypes for a given part of the structure The path must already have been added using addDir...
Definition: packagestructure.cpp:413
Plasma::PackageStructure::type
QString type() const
Type of package this structure describes.
Definition: packagestructure.cpp:215
QFileInfo::absolutePath
QString absolutePath() const
Plasma::PackageStructure::allowExternalPaths
bool allowExternalPaths() const
Definition: packagestructure.cpp:680
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Plasma::PackageStructure::read
void read(const KConfigBase *config)
Read a package structure from a config file.
Definition: packagestructure.cpp:475
Plasma::PackageStructure::metadata
virtual PackageMetadata metadata()
Definition: packagestructure.cpp:617
Plasma::PackageStructure::requiredDirectories
QList< const char * > requiredDirectories() const
The required directories defined for this package.
Definition: packagestructure.cpp:233
Plasma::PackageStructure
A description of the expected file structure of a given package type.
Definition: packagestructure.h:72
QMap::value
const T value(const Key &key) const
Plasma::PackageStructure::directories
QList< const char * > directories() const
The directories defined for this package.
Definition: packagestructure.cpp:220
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:12 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

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