[gnome-builder/wip/chergert/git-oop: 15/34] add synchronous update variant



commit b48ea738203439870ea3234de4b5bc6aa6488939
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 20 17:00:22 2019 -0700

    add synchronous update variant

 src/plugins/git/gbp-git-client.c | 52 ++++++++++++++++++++++++++++++++++++++++
 src/plugins/git/gbp-git-client.h |  6 +++++
 2 files changed, 58 insertions(+)
---
diff --git a/src/plugins/git/gbp-git-client.c b/src/plugins/git/gbp-git-client.c
index ba80d9c1a..945b643e7 100644
--- a/src/plugins/git/gbp-git-client.c
+++ b/src/plugins/git/gbp-git-client.c
@@ -518,6 +518,30 @@ gbp_git_client_call_cancelled (GCancellable *cancellable,
                              NULL, NULL, NULL);
 }
 
+static gboolean
+gbp_git_client_call (GbpGitClient  *self,
+                     const gchar   *method,
+                     GVariant      *params,
+                     GCancellable  *cancellable,
+                     GVariant     **reply,
+                     GError       **error)
+{
+  g_return_val_if_fail (GBP_IS_GIT_CLIENT (self), FALSE);
+  g_return_val_if_fail (method != NULL, FALSE);
+  g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
+
+  if (self->rpc_client == NULL)
+    {
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_NOT_CONNECTED,
+                   "Cannot call synchronously without connection");
+      return FALSE;
+    }
+
+  return jsonrpc_client_call (self->rpc_client, method, params, cancellable, reply, error);
+}
+
 void
 gbp_git_client_call_async (GbpGitClient        *self,
                            const gchar         *method,
@@ -839,6 +863,34 @@ gbp_git_client_update_config_cb (GObject      *object,
     ide_task_return_boolean (task, TRUE);
 }
 
+gboolean
+gbp_git_client_update_config (GbpGitClient  *self,
+                              gboolean       global,
+                              const gchar   *key,
+                              GVariant      *value,
+                              GCancellable  *cancellable,
+                              GError       **error)
+{
+  g_autoptr(GVariant) reply = NULL;
+  GVariantDict dict;
+
+  g_return_val_if_fail (GBP_IS_GIT_CLIENT (self), FALSE);
+  g_return_val_if_fail (key != NULL, FALSE);
+  g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
+
+  g_variant_dict_init (&dict, NULL);
+  g_variant_dict_insert (&dict, "global", "b", global);
+  g_variant_dict_insert (&dict, "key", "s", key);
+  g_variant_dict_insert_value (&dict, "value", value);
+
+  return gbp_git_client_call (self,
+                              "git/updateConfig",
+                              g_variant_dict_end (&dict),
+                              cancellable,
+                              &reply,
+                              error);
+}
+
 void
 gbp_git_client_update_config_async (GbpGitClient        *self,
                                     gboolean             global,
diff --git a/src/plugins/git/gbp-git-client.h b/src/plugins/git/gbp-git-client.h
index 410ab7818..6fe777d6f 100644
--- a/src/plugins/git/gbp-git-client.h
+++ b/src/plugins/git/gbp-git-client.h
@@ -99,6 +99,12 @@ void          gbp_git_client_update_submodules_async  (GbpGitClient           *s
 gboolean      gbp_git_client_update_submodules_finish (GbpGitClient           *self,
                                                        GAsyncResult           *result,
                                                        GError                **error);
+gboolean      gbp_git_client_update_config            (GbpGitClient           *self,
+                                                       gboolean                global,
+                                                       const gchar            *key,
+                                                       GVariant               *value,
+                                                       GCancellable           *cancellable,
+                                                       GError                **error);
 void          gbp_git_client_update_config_async      (GbpGitClient           *self,
                                                        gboolean                global,
                                                        const gchar            *key,


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