daemon: delete_later() support added to disposable object which can be used for kill...
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Fri, 1 Mar 2013 16:45:52 +0000 (18:45 +0200)
committerJussi Laako <jussi.laako@linux.intel.com>
Tue, 19 Mar 2013 14:17:58 +0000 (16:17 +0200)
src/daemon/gsignond-daemon.c
src/daemon/gsignond-disposable.c
src/daemon/gsignond-disposable.h
src/daemon/gsignond-identity.c

index 614b65a..bec252e 100644 (file)
@@ -327,22 +327,6 @@ gsignond_daemon_class_init (GSignondDaemonClass *klass)
     object_class->finalize = _finalize;
 }
 
-static gboolean
-_on_remove_identity (GSignondIdentity *identity, gpointer data)
-{
-    GSignondDaemon *daemon = GSIGNOND_DAEMON (data);
-
-    if (gsignond_db_credentials_database_remove_identity (daemon->priv->db, 
-          gsignond_identity_get_id (identity)) == TRUE) {
-
-        g_object_unref (G_OBJECT (identity));
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
 static void
 _on_identity_disposed (gpointer data, GObject *object)
 {
@@ -369,9 +353,9 @@ _catch_identity (GSignondDaemon *daemon, GSignondIdentity *identity)
 
     g_signal_connect_swapped (identity, "store", 
         G_CALLBACK (gsignond_db_credentials_database_update_identity), daemon->priv->db);
+    g_signal_connect_swapped (identity, "remove", 
+        G_CALLBACK(gsignond_db_credentials_database_remove_identity), daemon->priv->db);
     
-    g_signal_connect (identity, "remove",
-         G_CALLBACK (_on_remove_identity), daemon);
 }
 
 static const gchar * 
index 26d7e77..b190266 100644 (file)
@@ -265,3 +265,13 @@ gsignond_disposable_set_keep_in_use (GSignondDisposable *self)
                                                   _auto_dispose, self);
 }
 
+void
+gsignond_disposable_delete_later (GSignondDisposable *self)
+{
+    if (self->priv->timer_id)
+            g_source_remove (self->priv->timer_id);
+
+    INFO ("Object '%s' about to dispose...", G_OBJECT_TYPE_NAME (self));
+    self->priv->timer_id = g_idle_add (_auto_dispose, self);
+}
+
index 7abc268..2f15e50 100644 (file)
@@ -68,6 +68,9 @@ void
 gsignond_disposable_set_timeout (GSignondDisposable *self,
                                  guint timeout);
 
+void
+gsignond_disposable_delete_later (GSignondDisposable *self);
+
 G_END_DECLS
 
 #endif /* __GSIGNOND_DISPOSABLE_H_ */
index e9b6da3..8579045 100644 (file)
@@ -641,7 +641,7 @@ _remove (GSignondIdentityIface *iface, const GSignondSecurityContext *ctx, GErro
     else if (error)
         *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_REMOVE_FAILED, "failed to remove identity");
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (identity));
+    gsignond_disposable_delete_later (GSIGNOND_DISPOSABLE (identity));
 
     return is_removed;
 }