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



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

    core: Add synchronous version of grl_media_source_store() function

 src/grl-media-source.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/grl-media-source.h |    6 ++++-
 2 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index 5a33e4f..1a71f5c 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -850,6 +850,24 @@ metadata_result_async_cb (GrlMediaSource *source,
   oa->complete = TRUE;
 }
 
+static void
+store_async_cb (GrlMediaSource *source,
+                GrlMediaBox *parent,
+                GrlMedia *media,
+                gpointer user_data,
+                const GError *error)
+{
+  struct OperationAsyncCb *oa = (struct OperationAsyncCb *) user_data;
+
+  g_debug ("store_async_cb");
+
+  if (error) {
+    oa->error = g_error_copy (error);
+  }
+
+  oa->complete = TRUE;
+}
+
 static gint
 compare_sorted_results (gconstpointer a, gconstpointer b)
 {
@@ -2093,6 +2111,46 @@ grl_media_source_store (GrlMediaSource *source,
 }
 
 /**
+ * grl_media_source_store_sync:
+ * @source: a media source
+ * @parent: a parent to store the data transfer objects
+ * @media: a data transfer object
+ * @error: a #GError, or @NULL
+ *
+ * Store the @media into the @parent container.
+ *
+ * This method is synchronous.
+ */
+void
+grl_media_source_store_sync (GrlMediaSource *source,
+                             GrlMediaBox *parent,
+                             GrlMedia *media,
+                             GError **error)
+{
+  struct OperationAsyncCb *oa;
+
+  oa = g_slice_new0 (struct OperationAsyncCb);
+
+  grl_media_source_store (source,
+                          parent,
+                          media,
+                          store_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);
+}
+
+/**
  * grl_media_source_remove:
  * @source: a media source
  * @media: a data transfer object
diff --git a/src/grl-media-source.h b/src/grl-media-source.h
index 0bbc125..f0c8658 100644
--- a/src/grl-media-source.h
+++ b/src/grl-media-source.h
@@ -392,13 +392,17 @@ GrlMedia *grl_media_source_metadata_sync (GrlMediaSource *source,
                                           GrlMetadataResolutionFlags flags,
                                           GError **error);
 
-
 void grl_media_source_store (GrlMediaSource *source,
                              GrlMediaBox *parent,
                              GrlMedia *media,
                              GrlMediaSourceStoreCb callback,
                              gpointer user_data);
 
+void grl_media_source_store_sync (GrlMediaSource *source,
+                                  GrlMediaBox *parent,
+                                  GrlMedia *media,
+                                  GError **error);
+
 void grl_media_source_remove (GrlMediaSource *source,
                               GrlMedia *media,
                               GrlMediaSourceRemoveCb callback,



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