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

Plasma

qedje_package.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Artur Duque de Souza <morpheuz@gmail.com>       *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  *   This program 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         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program; if not, write to the                         *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
00018  ***************************************************************************/
00019 
00020 #include <qedje_package.h>
00021 #include <qedje.h>
00022 
00023 #include <QtCore/QDir>
00024 #include <QtCore/QFile>
00025 #include <QDir>
00026 #include <QFile>
00027 
00028 #include <Plasma/Package>
00029 #include <Plasma/PackageStructure>
00030 #include <Plasma/PackageMetadata>
00031 
00032 K_EXPORT_PLASMA_PACKAGESTRUCTURE(qedjescripts, QEdjePackage)
00033 
00034 QEdjePackage::QEdjePackage(QObject *parent, const QVariantList &args)
00035 : Plasma::PackageStructure(parent) {
00036     Q_UNUSED(args);
00037     addFileDefinition("edje_file", "file.edj", i18n("Main Edje File"));
00038     setRequired("edje_file", true);
00039 }
00040 
00041 QEdjePackage::~QEdjePackage() {
00042 }
00043 
00044 
00045 bool QEdjePackage::installPackage(const QString &archive_path,
00046                                   const QString &package_root) {
00047 
00048   kDebug() << "QEdjePackage::installPackage archivePath="
00049            << archive_path
00050            << "packageRoot=" << package_root;
00051 
00052   // check if it's a valid file by trying to load it's groups
00053   QStringList groups = groupNamesFromFile(archive_path);
00054   if (groups.isEmpty()) {
00055       kDebug() << "Invalid file format";
00056       return false;
00057   }
00058 
00059   QString file = archive_path.split("/", QString::SkipEmptyParts).last();
00060   QString package_name = file.split(".", QString::SkipEmptyParts).first();
00061 
00062   QString dir_name = QString("qedje_%1").arg(package_name);
00063   QString dest_dir = QString("%1/%2/contents/").arg(package_root).arg(dir_name);
00064 
00065   // Create the directory so we can copy the edje file inside it
00066   QDir contents(dest_dir);
00067   if (!contents.exists() && !contents.mkpath(dest_dir)) {
00068       kDebug() << "It was not possible to create the destination directory";
00069       return false;
00070   }
00071 
00072   // Copy the edje file to the package's directory
00073   if (!QFile::copy(archive_path, QString(dest_dir + "file.edj"))) {
00074       kDebug() << "It was not possible to copy " << archive_path << "to " << dest_dir;
00075       return false;
00076   }
00077 
00078   setPath(dest_dir);
00079 
00080   // Setup the metadata for this package
00081   Plasma::PackageMetadata data;
00082   data.setName(package_name);
00083   data.setType("Service");
00084   data.setPluginName(dir_name);
00085   data.setImplementationApi("qedjescript");
00086   data.setDescription(i18n("An Edje Object to be loaded using QEdje"));
00087   Plasma::Package::registerPackage(data, QString(""));
00088 
00089   return true;
00090 }

Plasma

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

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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