[calls] sip: provider: Delete password from keyring when deleting account



commit 8ca63828dfff4f147cd91a4763c244358f15bd99
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Fri Jul 9 17:22:56 2021 +0200

    sip: provider: Delete password from keyring when deleting account

 plugins/sip/calls-sip-provider.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c
index 3a523f26..2a3c4862 100644
--- a/plugins/sip/calls-sip-provider.c
+++ b/plugins/sip/calls-sip-provider.c
@@ -154,6 +154,39 @@ new_origin_from_keyfile (CallsSipProvider *self,
 }
 
 
+static void
+on_origin_pw_cleared (GObject      *source,
+                      GAsyncResult *result,
+                      gpointer      user_data)
+{
+  g_autoptr (GError) error = NULL;
+
+  if (!secret_password_clear_finish (result, &error))
+    g_warning ("Could not delete the password in the keyring: %s", error->message);
+}
+
+
+static void
+origin_pw_delete_secret (CallsSipOrigin *origin)
+{
+  g_autofree char *host = NULL;
+  g_autofree char *user = NULL;
+
+  g_assert (CALLS_IS_SIP_ORIGIN (origin));
+
+  g_object_get (origin,
+                "host", &host,
+                "user", &user,
+                NULL);
+
+  secret_password_clear (calls_secret_get_schema (), NULL, on_origin_pw_cleared, NULL,
+                         CALLS_SERVER_ATTRIBUTE, host,
+                         CALLS_USERNAME_ATTRIBUTE, user,
+                         CALLS_PROTOCOL_ATTRIBUTE, CALLS_PROTOCOL_SIP_STR,
+                         NULL);
+}
+
+
 static void
 on_origin_pw_saved (GObject      *source,
                     GAsyncResult *result,
@@ -643,12 +676,14 @@ calls_sip_provider_remove_origin (CallsSipProvider *self,
   g_return_val_if_fail (CALLS_IS_SIP_ORIGIN (origin), FALSE);
 
   if (g_list_store_find (self->origins, origin, &position)) {
+    g_object_ref (origin);
     g_list_store_remove (self->origins, position);
 
     if (!self->use_memory_backend) {
-      /* TODO need to delete credentials from the keyring as well */
+      origin_pw_delete_secret (origin);
       save_to_disk (self);
     }
+    g_object_unref (origin);
     return TRUE;
   }
   return FALSE;


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