|
|
92cace |
diff -up kdelibs-4.7.80/plasma/CMakeLists.txt.libplasma-pk-0001 kdelibs-4.7.80/plasma/CMakeLists.txt
|
|
|
92cace |
--- kdelibs-4.7.80/plasma/CMakeLists.txt.libplasma-pk-0001 2011-11-17 21:54:56.000000000 +0100
|
|
|
92cace |
+++ kdelibs-4.7.80/plasma/CMakeLists.txt 2011-11-18 13:16:23.243039344 +0100
|
|
|
92cace |
@@ -6,10 +6,15 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBL
|
|
|
92cace |
set(PLASMA_NO_KNEWSTUFF TRUE)
|
|
|
92cace |
set(PLASMA_NO_SOLID TRUE)
|
|
|
92cace |
set(PLASMA_NO_KIO TRUE)
|
|
|
92cace |
+ set(PLASMA_NO_PACKAGEKIT TRUE)
|
|
|
92cace |
set(PLASMA_NO_KUTILS TRUE)
|
|
|
92cace |
set(PLASMA_NO_GLOBAL_SHORTCUTS TRUE)
|
|
|
92cace |
endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
|
|
|
92cace |
|
|
|
92cace |
+if(NOT Q_WS_X11)
|
|
|
92cace |
+ set(PLASMA_NO_PACKAGEKIT TRUE)
|
|
|
92cace |
+endif(NOT Q_WS_X11)
|
|
|
92cace |
+
|
|
|
92cace |
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
92cace |
${KDE4_KDECORE_INCLUDES}
|
|
|
92cace |
${KDE4_KDEUI_INCLUDES}
|
|
|
92cace |
@@ -44,6 +49,11 @@ if(NOT PLASMA_NO_SOLID)
|
|
|
92cace |
set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${KDE4_SOLID_LIBS})
|
|
|
92cace |
endif(NOT PLASMA_NO_SOLID)
|
|
|
92cace |
|
|
|
92cace |
+if(NOT PLASMA_NO_PACKAGEKIT)
|
|
|
92cace |
+ add_definitions(-DPLASMA_ENABLE_PACKAGEKIT_SUPPORT=1)
|
|
|
92cace |
+ set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${QT_QTDBUS_LIBRARY})
|
|
|
92cace |
+endif(NOT PLASMA_NO_PACKAGEKIT)
|
|
|
92cace |
+
|
|
|
92cace |
if (NOT PLASMA_NO_KUTILS)
|
|
|
92cace |
include_directories(${CMAKE_SOURCE_DIR}/kutils)
|
|
|
92cace |
set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${KDE4_KUTILS_LIBS})
|
|
|
92cace |
@@ -117,6 +127,7 @@ set(plasma_LIB_SRCS
|
|
|
92cace |
private/animablegraphicswebview.cpp
|
|
|
92cace |
private/applethandle.cpp
|
|
|
92cace |
private/associatedapplicationmanager.cpp
|
|
|
92cace |
+ private/componentinstaller.cpp
|
|
|
92cace |
private/datacontainer_p.cpp
|
|
|
92cace |
private/dataenginebindings.cpp
|
|
|
92cace |
private/dataengineconsumer.cpp
|
|
|
92cace |
diff -up kdelibs-4.7.80/plasma/dataenginemanager.cpp.libplasma-pk-0001 kdelibs-4.7.80/plasma/dataenginemanager.cpp
|
|
|
92cace |
--- kdelibs-4.7.80/plasma/dataenginemanager.cpp.libplasma-pk-0001 2011-08-22 15:13:55.000000000 +0200
|
|
|
92cace |
+++ kdelibs-4.7.80/plasma/dataenginemanager.cpp 2011-11-18 12:48:37.513008572 +0100
|
|
|
92cace |
@@ -29,6 +29,7 @@
|
|
|
92cace |
|
|
|
92cace |
#include "datacontainer.h"
|
|
|
92cace |
#include "pluginloader.h"
|
|
|
92cace |
+#include "private/componentinstaller_p.h"
|
|
|
92cace |
#include "private/dataengine_p.h"
|
|
|
92cace |
#include "private/datacontainer_p.h"
|
|
|
92cace |
#include "scripting/scriptengine.h"
|
|
|
92cace |
@@ -130,6 +131,9 @@ Plasma::DataEngine *DataEngineManager::l
|
|
|
92cace |
|
|
|
92cace |
DataEngine *engine = PluginLoader::pluginLoader()->loadDataEngine(name);
|
|
|
92cace |
if (!engine) {
|
|
|
92cace |
+ // Try installing the engine. However, it's too late for this request.
|
|
|
92cace |
+ ComponentInstaller::self()->installMissingComponent("dataengine", name);
|
|
|
92cace |
+
|
|
|
92cace |
return d->nullEngine();
|
|
|
92cace |
}
|
|
|
92cace |
|
|
|
92cace |
diff -up kdelibs-4.7.80/plasma/private/componentinstaller.cpp.libplasma-pk-0001 kdelibs-4.7.80/plasma/private/componentinstaller.cpp
|
|
|
92cace |
--- kdelibs-4.7.80/plasma/private/componentinstaller.cpp.libplasma-pk-0001 2011-11-18 12:48:37.513008572 +0100
|
|
|
92cace |
+++ kdelibs-4.7.80/plasma/private/componentinstaller.cpp 2011-11-18 12:48:37.513008572 +0100
|
|
|
92cace |
@@ -0,0 +1,103 @@
|
|
|
92cace |
+/*
|
|
|
92cace |
+ * Copyright 2011 Kevin Kofler <kevin.kofler@chello.at>
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
92cace |
+ * it under the terms of the GNU Library General Public License as
|
|
|
92cace |
+ * published by the Free Software Foundation; either version 2, or
|
|
|
92cace |
+ * (at your option) any later version.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * This program is distributed in the hope that it will be useful,
|
|
|
92cace |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
92cace |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
92cace |
+ * GNU General Public License for more details
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * You should have received a copy of the GNU Library General Public
|
|
|
92cace |
+ * License along with this program; if not, write to the
|
|
|
92cace |
+ * Free Software Foundation, Inc.,
|
|
|
92cace |
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
92cace |
+ */
|
|
|
92cace |
+
|
|
|
92cace |
+#include "private/componentinstaller_p.h"
|
|
|
92cace |
+
|
|
|
92cace |
+#include <kglobal.h>
|
|
|
92cace |
+
|
|
|
92cace |
+#ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT
|
|
|
92cace |
+#include <QSet>
|
|
|
92cace |
+#include <QDBusInterface>
|
|
|
92cace |
+#include <QDBusPendingCall>
|
|
|
92cace |
+#include <QWidget>
|
|
|
92cace |
+#include <QLatin1String>
|
|
|
92cace |
+#include <QStringList>
|
|
|
92cace |
+#endif
|
|
|
92cace |
+
|
|
|
92cace |
+namespace Plasma
|
|
|
92cace |
+{
|
|
|
92cace |
+
|
|
|
92cace |
+class ComponentInstallerPrivate
|
|
|
92cace |
+{
|
|
|
92cace |
+ public:
|
|
|
92cace |
+#ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT
|
|
|
92cace |
+ QSet<QString> alreadyPrompted;
|
|
|
92cace |
+#endif
|
|
|
92cace |
+};
|
|
|
92cace |
+
|
|
|
92cace |
+class ComponentInstallerSingleton
|
|
|
92cace |
+{
|
|
|
92cace |
+ public:
|
|
|
92cace |
+ ComponentInstaller self;
|
|
|
92cace |
+};
|
|
|
92cace |
+
|
|
|
92cace |
+K_GLOBAL_STATIC(ComponentInstallerSingleton, privateComponentInstallerSelf)
|
|
|
92cace |
+
|
|
|
92cace |
+ComponentInstaller *ComponentInstaller::self()
|
|
|
92cace |
+{
|
|
|
92cace |
+ return &privateComponentInstallerSelf->self;
|
|
|
92cace |
+}
|
|
|
92cace |
+
|
|
|
92cace |
+ComponentInstaller::ComponentInstaller()
|
|
|
92cace |
+ : d(new ComponentInstallerPrivate)
|
|
|
92cace |
+{
|
|
|
92cace |
+}
|
|
|
92cace |
+
|
|
|
92cace |
+ComponentInstaller::~ComponentInstaller()
|
|
|
92cace |
+{
|
|
|
92cace |
+ delete d;
|
|
|
92cace |
+}
|
|
|
92cace |
+
|
|
|
92cace |
+void ComponentInstaller::installMissingComponent(const QString &type,
|
|
|
92cace |
+ const QString &name,
|
|
|
92cace |
+ QWidget *parent, bool force)
|
|
|
92cace |
+{
|
|
|
92cace |
+#ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT
|
|
|
92cace |
+ QString searchString = type + '-' + name;
|
|
|
92cace |
+
|
|
|
92cace |
+ if (!force) {
|
|
|
92cace |
+ if (d->alreadyPrompted.contains(searchString)) {
|
|
|
92cace |
+ return;
|
|
|
92cace |
+ }
|
|
|
92cace |
+ }
|
|
|
92cace |
+
|
|
|
92cace |
+ d->alreadyPrompted.insert(searchString);
|
|
|
92cace |
+
|
|
|
92cace |
+ QDBusInterface packageKit(QLatin1String("org.freedesktop.PackageKit"),
|
|
|
92cace |
+ QLatin1String("/org/freedesktop/PackageKit"),
|
|
|
92cace |
+ QLatin1String("org.freedesktop.PackageKit.Modify"));
|
|
|
92cace |
+ // We don't check packageKit.isValid() because the service is activated on
|
|
|
92cace |
+ // demand, so it will show up as "not valid".
|
|
|
92cace |
+ WId wid = 0;
|
|
|
92cace |
+ if (parent) {
|
|
|
92cace |
+ wid = parent->winId();
|
|
|
92cace |
+ }
|
|
|
92cace |
+ QStringList resources;
|
|
|
92cace |
+ resources.append(searchString);
|
|
|
92cace |
+ packageKit.asyncCall(QLatin1String("InstallResources"), (unsigned int) wid,
|
|
|
92cace |
+ QLatin1String("plasma-service"), resources, QString());
|
|
|
92cace |
+#else
|
|
|
92cace |
+ Q_UNUSED(type);
|
|
|
92cace |
+ Q_UNUSED(name);
|
|
|
92cace |
+ Q_UNUSED(parent);
|
|
|
92cace |
+ Q_UNUSED(force);
|
|
|
92cace |
+#endif
|
|
|
92cace |
+}
|
|
|
92cace |
+
|
|
|
92cace |
+} // namespace Plasma
|
|
|
92cace |
diff -up kdelibs-4.7.80/plasma/private/componentinstaller_p.h.libplasma-pk-0001 kdelibs-4.7.80/plasma/private/componentinstaller_p.h
|
|
|
92cace |
--- kdelibs-4.7.80/plasma/private/componentinstaller_p.h.libplasma-pk-0001 2011-11-18 12:48:37.514008574 +0100
|
|
|
92cace |
+++ kdelibs-4.7.80/plasma/private/componentinstaller_p.h 2011-11-18 12:48:37.514008574 +0100
|
|
|
92cace |
@@ -0,0 +1,94 @@
|
|
|
92cace |
+/*
|
|
|
92cace |
+ * Copyright 2011 Kevin Kofler <kevin.kofler@chello.at>
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
92cace |
+ * it under the terms of the GNU Library General Public License as
|
|
|
92cace |
+ * published by the Free Software Foundation; either version 2, or
|
|
|
92cace |
+ * (at your option) any later version.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * This program is distributed in the hope that it will be useful,
|
|
|
92cace |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
92cace |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
92cace |
+ * GNU General Public License for more details
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * You should have received a copy of the GNU Library General Public
|
|
|
92cace |
+ * License along with this program; if not, write to the
|
|
|
92cace |
+ * Free Software Foundation, Inc.,
|
|
|
92cace |
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
92cace |
+ */
|
|
|
92cace |
+
|
|
|
92cace |
+#ifndef PLASMA_COMPONENTINSTALLER_H
|
|
|
92cace |
+#define PLASMA_COMPONENTINSTALLER_H
|
|
|
92cace |
+
|
|
|
92cace |
+class QString;
|
|
|
92cace |
+class QWidget;
|
|
|
92cace |
+
|
|
|
92cace |
+namespace Plasma
|
|
|
92cace |
+{
|
|
|
92cace |
+
|
|
|
92cace |
+class ComponentInstallerPrivate;
|
|
|
92cace |
+
|
|
|
92cace |
+/**
|
|
|
92cace |
+ * @class ComponentInstaller plasma/private/componentinstaller_p.h
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * @short This class provides a generic API for installation of components.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * @internal
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * Plasma::ComponentInstaller allows searching for a missing data or script
|
|
|
92cace |
+ * engine by name, and allowing the user to install the missing service.
|
|
|
92cace |
+ * Currently, PackageKit is supported as the mechanism to install components,
|
|
|
92cace |
+ * but more mechanisms could be supported in the future through the same API.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * @since 4.8
|
|
|
92cace |
+ */
|
|
|
92cace |
+class ComponentInstaller
|
|
|
92cace |
+{
|
|
|
92cace |
+ public:
|
|
|
92cace |
+ /**
|
|
|
92cace |
+ * Singleton pattern accessor.
|
|
|
92cace |
+ */
|
|
|
92cace |
+ static ComponentInstaller *self();
|
|
|
92cace |
+
|
|
|
92cace |
+ /**
|
|
|
92cace |
+ * Installs a missing component asynchronously.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * By default, this method will cache requested components and not
|
|
|
92cace |
+ * prompt again for the same engine in the same session. The force
|
|
|
92cace |
+ * parameter can be used to disable this mechanism, e.g. when the user
|
|
|
92cace |
+ * just installed a new widget written in a scripting language, and so
|
|
|
92cace |
+ * is likely to want the script engine installed after all.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * In the case of on-demand installation, this will unfortunately not
|
|
|
92cace |
+ * allow the call which triggered the missing component lookup to
|
|
|
92cace |
+ * succeed, but we cannot afford to block all of Plasma until the
|
|
|
92cace |
+ * mechanism is done installing the service.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * This function does nothing if PackageKit integration was disabled at
|
|
|
92cace |
+ * compile time.
|
|
|
92cace |
+ *
|
|
|
92cace |
+ * @param type the type of the component, should be "scriptengine" or
|
|
|
92cace |
+ * "dataengine"
|
|
|
92cace |
+ * @param name the name of the component
|
|
|
92cace |
+ * @param parent a parent widget, used to set the wid for PackageKit
|
|
|
92cace |
+ * @param force whether to always prompt, even if recently prompted
|
|
|
92cace |
+ */
|
|
|
92cace |
+ void installMissingComponent(const QString &type, const QString &name,
|
|
|
92cace |
+ QWidget *parent = 0, bool force = false);
|
|
|
92cace |
+
|
|
|
92cace |
+ private:
|
|
|
92cace |
+ /**
|
|
|
92cace |
+ * Default constructor. The singleton method self() is the
|
|
|
92cace |
+ * preferred access mechanism.
|
|
|
92cace |
+ */
|
|
|
92cace |
+ ComponentInstaller();
|
|
|
92cace |
+ ~ComponentInstaller();
|
|
|
92cace |
+
|
|
|
92cace |
+ ComponentInstallerPrivate *const d;
|
|
|
92cace |
+
|
|
|
92cace |
+ friend class ComponentInstallerSingleton;
|
|
|
92cace |
+};
|
|
|
92cace |
+
|
|
|
92cace |
+} // namespace Plasma
|
|
|
92cace |
+
|
|
|
92cace |
+#endif // multiple inclusion guard
|
|
|
92cace |
diff -up kdelibs-4.7.80/plasma/scripting/scriptengine.cpp.libplasma-pk-0001 kdelibs-4.7.80/plasma/scripting/scriptengine.cpp
|
|
|
92cace |
--- kdelibs-4.7.80/plasma/scripting/scriptengine.cpp.libplasma-pk-0001 2011-09-26 11:41:11.000000000 +0200
|
|
|
92cace |
+++ kdelibs-4.7.80/plasma/scripting/scriptengine.cpp 2011-11-18 12:48:37.514008574 +0100
|
|
|
92cace |
@@ -27,6 +27,7 @@
|
|
|
92cace |
#include "applet.h"
|
|
|
92cace |
#include "dataengine.h"
|
|
|
92cace |
#include "package.h"
|
|
|
92cace |
+#include "private/componentinstaller_p.h"
|
|
|
92cace |
#include "scripting/appletscript.h"
|
|
|
92cace |
#include "scripting/dataenginescript.h"
|
|
|
92cace |
#include "scripting/runnerscript.h"
|
|
|
92cace |
@@ -196,6 +197,9 @@ ScriptEngine *loadEngine(const QString &
|
|
|
92cace |
<< "! error reported: " << error;
|
|
|
92cace |
}
|
|
|
92cace |
|
|
|
92cace |
+ // Try installing the engine. However, it's too late for this request.
|
|
|
92cace |
+ ComponentInstaller::self()->installMissingComponent("scriptengine", language);
|
|
|
92cace |
+
|
|
|
92cace |
return 0;
|
|
|
92cace |
}
|
|
|
92cace |
|