[grilo] core: Add synchronous version of grl_media_source_remove() function



commit 8f485574b04901c7c4ddcad2544e4efed5eee476
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Jul 15 13:42:43 2010 +0200

    core: Add synchronous version of grl_media_source_remove() function

 src/grl-media-source.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/grl-media-source.h |    5 ++++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index 1a71f5c..bca0eb4 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -868,6 +868,23 @@ store_async_cb (GrlMediaSource *source,
   oa->complete = TRUE;
 }
 
+static void
+remove_async_cb (GrlMediaSource *source,
+                 GrlMedia *media,
+                 gpointer user_data,
+                 const GError *error)
+{
+  struct OperationAsyncCb *oa = (struct OperationAsyncCb *) user_data;
+
+  g_debug ("remove_async_cb");
+
+  if (error) {
+    oa->error = g_error_copy (error);
+  }
+
+  oa->complete = TRUE;
+}
+
 static gint
 compare_sorted_results (gconstpointer a, gconstpointer b)
 {
@@ -2204,3 +2221,39 @@ grl_media_source_remove (GrlMediaSource *source,
   }
 }
 
+/**
+ * grl_media_source_remove_sync:
+ * @source: a media source
+ * @media: a data transfer object
+ * @error: a #GError, or @NULL
+ *
+ * Remove a @media from the @source repository.
+ *
+ * This method is synchronous.
+ */
+void
+grl_media_source_remove_sync (GrlMediaSource *source,
+                              GrlMedia *media,
+                              GError **error)
+{
+  struct OperationAsyncCb *oa;
+
+  oa = g_slice_new0 (struct OperationAsyncCb);
+
+  grl_media_source_remove (source,
+                           media,
+                           remove_async_cb,
+                           oa);
+
+  wait_for_async_operation_complete (oa);
+
+  if (oa->error) {
+    if (error) {
+      *error = oa->error;
+    } else {
+      g_error_free (oa->error);
+    }
+  }
+
+  g_slice_free (struct OperationAsyncCb, oa);
+}
diff --git a/src/grl-media-source.h b/src/grl-media-source.h
index f0c8658..dc1b6d4 100644
--- a/src/grl-media-source.h
+++ b/src/grl-media-source.h
@@ -408,6 +408,11 @@ void grl_media_source_remove (GrlMediaSource *source,
                               GrlMediaSourceRemoveCb callback,
                               gpointer user_data);
 
+void grl_media_source_remove_sync (GrlMediaSource *source,
+                                   GrlMedia *media,
+                                   GError **error);
+
+
 void grl_media_source_cancel (GrlMediaSource *source, guint operation_id);
 
 void grl_media_source_set_operation_data (GrlMediaSource *source,



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