[gnome-software/wip/kalev/codecs: 12/12] PK session service: Add a new version of the Modify interface



commit 24c4a16989bfbfedadf41d680eabd86632047956
Author: Kalev Lember <kalevlember gmail com>
Date:   Tue Feb 10 12:27:03 2015 +0100

    PK session service: Add a new version of the Modify interface
    
    The new org.freedesktop.PackageKit.Modify2 interface is equivalent with
    the older org.freedesktop.PackageKit.Modify, the only changes are the
    removal of the XID parameter in all methods and the addition of
    desktop_id and timestamp parameters.
    
    XXX: is there anything else we need to change in the interface? Now
    would be the time.
    
    XXX: copy-paste the boilerplate to support all methods

 src/Makefile.am                            |   11 +
 src/gs-dbus-helper.c                       |   55 ++++
 src/org.freedesktop.PackageKit.Modify2.xml |  487 ++++++++++++++++++++++++++++
 3 files changed, 553 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 662efd1..4b88263 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,7 @@ bin_PROGRAMS =                                                \
 
 gnome_software_SOURCES =                               \
        $(packagekit_built_sources)                     \
+       $(packagekit_modify2_built_sources)             \
        gs-cleanup.h                                    \
        gs-resources.c                                  \
        gs-resources.h                                  \
@@ -197,6 +198,14 @@ $(packagekit_built_sources): Makefile.am org.freedesktop.PackageKit.xml
                --generate-c-code gs-packagekit-generated       \
                $(srcdir)/org.freedesktop.PackageKit.xml
 
+packagekit_modify2_built_sources = gs-packagekit-modify2-generated.c gs-packagekit-modify2-generated.h
+$(packagekit_modify2_built_sources): Makefile.am org.freedesktop.PackageKit.Modify2.xml
+       $(AM_V_GEN) gdbus-codegen                                       \
+               --interface-prefix org.freedesktop.                     \
+               --c-namespace Gs                                        \
+               --generate-c-code gs-packagekit-modify2-generated       \
+               $(srcdir)/org.freedesktop.PackageKit.Modify2.xml
+
 gs-shell-search-provider-generated.h gs-shell-search-provider-generated.c: Makefile.am 
$(srcdir)/shell-search-provider-dbus-interfaces.xml
        $(AM_V_GEN) gdbus-codegen \
                --interface-prefix org.gnome. \
@@ -212,6 +221,7 @@ gs-resources.h: gnome-software.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) -
 
 BUILT_SOURCES =                                                \
        $(packagekit_built_sources)                     \
+       $(packagekit_modify2_built_sources)             \
        gs-shell-search-provider-generated.c            \
        gs-shell-search-provider-generated.h            \
        gs-resources.c                                  \
@@ -249,6 +259,7 @@ TESTS = gs-self-test
 EXTRA_DIST =                                           \
        shell-search-provider-dbus-interfaces.xml       \
        org.freedesktop.PackageKit.xml                  \
+       org.freedesktop.PackageKit.Modify2.xml          \
        gnome-software.gresource.xml                    \
        gnome-software.xml                              \
        gtk-style.css                                   \
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index f6da06a..7b6111a 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -30,6 +30,7 @@
 #include "gs-cleanup.h"
 #include "gs-dbus-helper.h"
 #include "gs-packagekit-generated.h"
+#include "gs-packagekit-modify2-generated.h"
 #include "gs-resources.h"
 
 struct _GsDbusHelper {
@@ -37,6 +38,7 @@ struct _GsDbusHelper {
        GCancellable            *cancellable;
        GDBusInterfaceSkeleton  *query_interface;
        GDBusInterfaceSkeleton  *modify_interface;
+       GDBusInterfaceSkeleton  *modify2_interface;
        PkTask                  *task;
        guint                    dbus_own_name_id;
 };
@@ -271,6 +273,21 @@ handle_query_is_installed (GsPackageKitQuery        *skeleton,
        return TRUE;
 }
 
+static gboolean
+interaction_is_show_confirm_search_set (const gchar *interaction)
+{
+       GsDbusHelperTask *dtask;
+       gboolean ret;
+
+       dtask = g_new0 (GsDbusHelperTask, 1);
+       dtask->show_confirm_search = TRUE;
+       gs_dbus_helper_task_set_interaction (dtask, interaction);
+       ret = dtask->show_confirm_search;
+       gs_dbus_helper_task_free (dtask);
+
+       return ret;
+}
+
 static void
 notify_find_package_files (const gchar  *desktop_id,
                            gchar       **files)
@@ -559,6 +576,30 @@ handle_modify_install_gstreamer_resources (GsPackageKitModify       *object,
        return TRUE;
 }
 
+static gboolean
+handle_modify2_install_gstreamer_resources (GsPackageKitModify2                 *object,
+                                            GDBusMethodInvocation       *invocation,
+                                            gchar                      **resources,
+                                            const gchar                         *interaction,
+                                            const gchar                         *desktop_id,
+                                            guint                        timestamp,
+                                            gpointer                     user_data)
+{
+       g_debug ("****** Modify2.InstallGStreamerResources");
+
+       if (interaction_is_show_confirm_search_set (interaction)) {
+               notify_find_gstreamer_resources (desktop_id, resources);
+       } else {
+               GApplication *app = g_application_get_default ();
+               g_action_group_activate_action (G_ACTION_GROUP (app), "install-gstreamer-resources",
+                                               g_variant_new ("(^asu)", resources, timestamp));
+       }
+
+       gs_package_kit_modify2_complete_install_gstreamer_resources (object, invocation);
+
+       return TRUE;
+}
+
 static void
 notify_find_plasma_resources (const gchar       *desktop_id,
                               gchar            **resources)
@@ -739,6 +780,20 @@ bus_gotten_cb (GObject      *source_object,
                return;
        }
 
+       /* Modify2 interface */
+       dbus_helper->modify2_interface = G_DBUS_INTERFACE_SKELETON (gs_package_kit_modify2_skeleton_new ());
+
+       g_signal_connect (dbus_helper->modify2_interface, "handle-install-gstreamer-resources",
+                         G_CALLBACK (handle_modify2_install_gstreamer_resources), dbus_helper);
+
+       if (!g_dbus_interface_skeleton_export (dbus_helper->modify2_interface,
+                                              connection,
+                                              "/org/freedesktop/PackageKit",
+                                              &error)) {
+               g_warning ("Could not export dbus interface: %s", error->message);
+               return;
+       }
+
        dbus_helper->dbus_own_name_id = g_bus_own_name_on_connection (connection,
                                                                      "org.freedesktop.PackageKit2",
                                                                      G_BUS_NAME_OWNER_FLAGS_NONE,
diff --git a/src/org.freedesktop.PackageKit.Modify2.xml b/src/org.freedesktop.PackageKit.Modify2.xml
new file mode 100644
index 0000000..c1b7996
--- /dev/null
+++ b/src/org.freedesktop.PackageKit.Modify2.xml
@@ -0,0 +1,487 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"; [
+  <!ENTITY ERROR_GENERAL "org.freedesktop.PackageKit.Denied">
+]>
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd";>
+
+  <interface name="org.freedesktop.PackageKit.Modify2">
+    <doc:doc>
+      <doc:description>
+        <doc:para>
+          The interface used for modifying the package database (version 2).
+        </doc:para>
+      </doc:description>
+    </doc:doc>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallPackageFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs local package files or service packs.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An interaction mode that specifies which UI elements should be shown
+              or hidden different from the user default, e.g.
+              <doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,show-progress</doc:tt>.
+              The show options are:
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>.
+              The hide options are:
+              
<doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,hide-progress,hide-finished,hide-warning</doc:tt>.
+              Convenience options such as:
+              <doc:tt>never</doc:tt>, <doc:tt>defaults</doc:tt> or <doc:tt>always</doc:tt>.
+              are also available.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallProvideFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs packages to provide files.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallPackageNames">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs packages from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="packages" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of package names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallMimeTypes">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs mimetype handlers from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="mime_types" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of mime types, e.g. <doc:tt>text/plain</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallFontconfigResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs fontconfig resources (usually fonts) from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of font descriptors from fontconfig, e.g. <doc:tt>:lang=mn</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallGStreamerResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs GStreamer fontconfig resources (usually codecs) from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of codecs descriptors from <doc:tt>pk-gstreamer-install</doc:tt>, e.g.
+              <doc:tt>Advanced Streaming Format (ASF) demuxer|decoder-video/x-ms-asf</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs resources of a given type from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="s" name="type" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The type of resource to request, e.g. <doc:tt>plasma-service</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of resource descriptors
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="RemovePackageByFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Removes packages that provide the given local files.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An interaction mode that specifies which UI elements should be shown
+              or hidden different from the user default, e.g.
+              <doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,show-progress</doc:tt>.
+              The show options are:
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>.
+              The hide options are:
+              
<doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,hide-progress,hide-finished,hide-warning</doc:tt>.
+              Convenience options such as:
+              <doc:tt>never</doc:tt>, <doc:tt>defaults</doc:tt> or <doc:tt>always</doc:tt>.
+              are also available.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <method name="InstallPrinterDrivers">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs printer drivers from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of printer model descriptors in IEEE 1284
+              Device ID format,
+              e.g. <doc:tt>MFG:Hewlett-Packard;MDL:HP LaserJet
+              6MP;</doc:tt>.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="desktop_id" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The desktop file ID of the calling application.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="u" name="timestamp" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The timestamp of the user interaction that triggered this call.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+  </interface>
+</node>
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]