[calls] sip: Make save_to_disk() public and use it when updating accounts



commit 0bfa55473ebfc6a49f11d29133e95adb30737547
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Aug 27 10:10:23 2021 +0200

    sip: Make save_to_disk() public and use it when updating accounts
    
    Account credentials will not get updated at all otherwise.

 plugins/sip/calls-sip-account-widget.c |  1 +
 plugins/sip/calls-sip-provider.c       | 37 +++++++++++++++++++---------------
 plugins/sip/calls-sip-provider.h       |  1 +
 3 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/plugins/sip/calls-sip-account-widget.c b/plugins/sip/calls-sip-account-widget.c
index a2330879..dbd31152 100644
--- a/plugins/sip/calls-sip-account-widget.c
+++ b/plugins/sip/calls-sip-account-widget.c
@@ -400,6 +400,7 @@ on_apply_clicked (CallsSipAccountWidget *self)
                                     TRUE);
 
   update_header (self);
+  calls_sip_provider_save_accounts_to_disk (self->provider);
   g_signal_emit_by_name (self->provider, "widget-edit-done");
 }
 
diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c
index 03b2d2e2..82075416 100644
--- a/plugins/sip/calls-sip-provider.c
+++ b/plugins/sip/calls-sip-provider.c
@@ -303,20 +303,6 @@ origin_to_keyfile (CallsSipOrigin *origin,
 }
 
 
-static void
-save_to_disk (CallsSipProvider *self)
-{
-  g_autoptr (GKeyFile) key_file = g_key_file_new ();
-  g_autoptr (GError) error = NULL;
-
-  g_assert (CALLS_IS_SIP_PROVIDER (self));
-
-  calls_sip_provider_save_accounts (self, key_file);
-
-  if (!g_key_file_save_to_file (key_file, self->filename, &error))
-    g_warning ("Error saving keyfile to file %s: %s", self->filename, error->message);
-}
-
 static const char *
 calls_sip_provider_get_name (CallsProvider *provider)
 {
@@ -718,7 +704,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
   g_list_store_append (self->origins, origin);
 
   if (store_credentials && !self->use_memory_backend)
-    save_to_disk (self);
+    calls_sip_provider_save_accounts_to_disk (self);
 
   return origin;
 }
@@ -739,7 +725,7 @@ calls_sip_provider_remove_origin (CallsSipProvider *self,
 
     if (!self->use_memory_backend) {
       origin_pw_delete_secret (origin);
-      save_to_disk (self);
+      calls_sip_provider_save_accounts_to_disk (self);
     }
     g_object_unref (origin);
     return TRUE;
@@ -793,6 +779,25 @@ calls_sip_provider_save_accounts (CallsSipProvider *self,
 }
 
 
+gboolean
+calls_sip_provider_save_accounts_to_disk (CallsSipProvider *self)
+{
+  g_autoptr (GKeyFile) key_file = g_key_file_new ();
+  g_autoptr (GError) error = NULL;
+  gboolean saved = FALSE;
+
+  g_assert (CALLS_IS_SIP_PROVIDER (self));
+
+  calls_sip_provider_save_accounts (self, key_file);
+
+  if (!(saved = g_key_file_save_to_file (key_file, self->filename, &error)))
+    g_warning ("Error saving keyfile to file %s: %s", self->filename, error->message);
+
+  return saved;
+}
+
+
+
 G_MODULE_EXPORT void
 peas_register_types (PeasObjectModule *module)
 {
diff --git a/plugins/sip/calls-sip-provider.h b/plugins/sip/calls-sip-provider.h
index 8317bf6e..2d540331 100644
--- a/plugins/sip/calls-sip-provider.h
+++ b/plugins/sip/calls-sip-provider.h
@@ -62,6 +62,7 @@ void              calls_sip_provider_load_accounts          (CallsSipProvider *s
                                                              GKeyFile         *key_file);
 void              calls_sip_provider_save_accounts          (CallsSipProvider *self,
                                                              GKeyFile         *key_file);
+gboolean          calls_sip_provider_save_accounts_to_disk  (CallsSipProvider *self);
 void              peas_register_types                       (PeasObjectModule *module);
 
 G_END_DECLS


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