Update dbus interface 52/237752/1
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 3 Jul 2020 16:28:23 +0000 (16:28 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 3 Jul 2020 16:46:40 +0000 (16:46 +0000)
- Add result method to dbus
- Check updatecontrol.admin privilige with dbus call

Change-Id: I597d1d713daac408c53411a77c0158806703b1ac
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
include/update-manager-dbus.c
include/update-manager-dbus.h
packaging/update-manager.conf
packaging/update-manager.xml

index 47c26e1f293ac6a61496fa0f52267eab156f0d1a..2dc9db8037f1cd079eef90feba381a4e2add498b 100644 (file)
@@ -194,9 +194,40 @@ static const _ExtendedGDBusMethodInfo _org_tizen_update_manager_method_info_inst
   FALSE
 };
 
+static const _ExtendedGDBusArgInfo _org_tizen_update_manager_method_info_result_OUT_ARG_status =
+{
+  {
+    -1,
+    (gchar *) "status",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _org_tizen_update_manager_method_info_result_OUT_ARG_pointers[] =
+{
+  &_org_tizen_update_manager_method_info_result_OUT_ARG_status,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _org_tizen_update_manager_method_info_result =
+{
+  {
+    -1,
+    (gchar *) "result",
+    NULL,
+    (GDBusArgInfo **) &_org_tizen_update_manager_method_info_result_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-result",
+  FALSE
+};
+
 static const _ExtendedGDBusMethodInfo * const _org_tizen_update_manager_method_info_pointers[] =
 {
   &_org_tizen_update_manager_method_info_install,
+  &_org_tizen_update_manager_method_info_result,
   NULL
 };
 
@@ -255,6 +286,7 @@ org_tizen_update_manager_override_properties (GObjectClass *klass, guint propert
  * OrgTizenUpdateManagerIface:
  * @parent_iface: The parent interface.
  * @handle_install: Handler for the #OrgTizenUpdateManager::handle-install signal.
+ * @handle_result: Handler for the #OrgTizenUpdateManager::handle-result signal.
  *
  * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-tizen-update-manager.top_of_page">org.tizen.update.manager</link>.
  */
@@ -288,6 +320,28 @@ org_tizen_update_manager_default_init (OrgTizenUpdateManagerIface *iface)
     1,
     G_TYPE_DBUS_METHOD_INVOCATION);
 
+  /**
+   * OrgTizenUpdateManager::handle-result:
+   * @object: A #OrgTizenUpdateManager.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-tizen-update-manager.result">result()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call org_tizen_update_manager_complete_result() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-result",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (OrgTizenUpdateManagerIface, handle_result),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
 }
 
 /**
@@ -388,6 +442,104 @@ _out:
   return _ret != NULL;
 }
 
+/**
+ * org_tizen_update_manager_call_result:
+ * @proxy: A #OrgTizenUpdateManagerProxy.
+ * @cancellable: (nullable): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-tizen-update-manager.result">result()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call org_tizen_update_manager_call_result_finish() to get the result of the operation.
+ *
+ * See org_tizen_update_manager_call_result_sync() for the synchronous, blocking version of this method.
+ */
+void
+org_tizen_update_manager_call_result (
+    OrgTizenUpdateManager *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "result",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * org_tizen_update_manager_call_result_finish:
+ * @proxy: A #OrgTizenUpdateManagerProxy.
+ * @out_status: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to org_tizen_update_manager_call_result().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with org_tizen_update_manager_call_result().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+org_tizen_update_manager_call_result_finish (
+    OrgTizenUpdateManager *proxy,
+    gint *out_status,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_status);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * org_tizen_update_manager_call_result_sync:
+ * @proxy: A #OrgTizenUpdateManagerProxy.
+ * @out_status: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (nullable): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-tizen-update-manager.result">result()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See org_tizen_update_manager_call_result() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+org_tizen_update_manager_call_result_sync (
+    OrgTizenUpdateManager *proxy,
+    gint *out_status,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "result",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_status);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
 /**
  * org_tizen_update_manager_complete_install:
  * @object: A #OrgTizenUpdateManager.
@@ -409,6 +561,27 @@ org_tizen_update_manager_complete_install (
                    status));
 }
 
+/**
+ * org_tizen_update_manager_complete_result:
+ * @object: A #OrgTizenUpdateManager.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @status: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-tizen-update-manager.result">result()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+org_tizen_update_manager_complete_result (
+    OrgTizenUpdateManager *object,
+    GDBusMethodInvocation *invocation,
+    gint status)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   status));
+}
+
 /* ------------------------------------------------------------------------ */
 
 /**
index 4f576646810ca03f7c0a45a7c9296489830f07a9..cb3fbc8bf6e9e88a01424d8e4d75320fcf6598f3 100644 (file)
@@ -33,6 +33,10 @@ struct _OrgTizenUpdateManagerIface
     OrgTizenUpdateManager *object,
     GDBusMethodInvocation *invocation);
 
+  gboolean (*handle_result) (
+    OrgTizenUpdateManager *object,
+    GDBusMethodInvocation *invocation);
+
 };
 
 GType org_tizen_update_manager_get_type (void) G_GNUC_CONST;
@@ -47,6 +51,11 @@ void org_tizen_update_manager_complete_install (
     GDBusMethodInvocation *invocation,
     gint status);
 
+void org_tizen_update_manager_complete_result (
+    OrgTizenUpdateManager *object,
+    GDBusMethodInvocation *invocation,
+    gint status);
+
 
 
 /* D-Bus method calls: */
@@ -68,6 +77,24 @@ gboolean org_tizen_update_manager_call_install_sync (
     GCancellable *cancellable,
     GError **error);
 
+void org_tizen_update_manager_call_result (
+    OrgTizenUpdateManager *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean org_tizen_update_manager_call_result_finish (
+    OrgTizenUpdateManager *proxy,
+    gint *out_status,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean org_tizen_update_manager_call_result_sync (
+    OrgTizenUpdateManager *proxy,
+    gint *out_status,
+    GCancellable *cancellable,
+    GError **error);
+
 
 
 /* ---- */
index 2eaf90b38c16fc50f5f43b29025c577294d4f273..d1728c34c60d6e27b848f6acab6068f2241aea2b 100644 (file)
@@ -8,7 +8,8 @@
   <policy context="default">
     <deny own="org.tizen.update.manager"/>
     <deny send_destination="org.tizen.update.manager" send_type="method_call"/>
-    <allow send_destination="org.tizen.update.manager" send_interface="org.tizen.update.manager" send_member="install" />
+    <check send_destination="org.tizen.update.manager" send_interface="org.tizen.update.manager" send_member="install" privilege="http://tizen.org/privilege/updatecontrol.admin" />
+    <check send_destination="org.tizen.update.manager" send_interface="org.tizen.update.manager" send_member="result" privilege="http://tizen.org/privilege/updatecontrol.admin" />
     <allow send_destination="org.tizen.update.manager" send_interface="org.freedesktop.DBus.Properties" send_member="GetAll" />
   </policy>
 </busconfig>
\ No newline at end of file
index d55d5c80783faa57aae0d64b62bda19bcc8bf19e..345d36785d09766354c4cfe1d0a6f8865044d372 100644 (file)
@@ -4,5 +4,8 @@
                <method name="install">
                        <arg name="status" direction="out" type="i" />
                </method>
+               <method name="result">
+                       <arg name="status" direction="out" type="i" />
+               </method>
        </interface>
 </node>
\ No newline at end of file