[PATCH] all: Use the new "content-changed" API



The new API to notify changes in source content requires to specify a list with
the changed medias, instead of just the changed media.

Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
 src/media/bookmarks/grl-bookmarks.c         |    5 ++++-
 src/media/filesystem/grl-filesystem.c       |   13 +++++++++----
 src/media/podcasts/grl-podcasts.c           |   21 ++++++++++++---------
 src/media/tracker/grl-tracker-media-notif.c |   15 ++++++++++++---
 src/media/upnp/grl-upnp.c                   |   14 +++++++++-----
 5 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/src/media/bookmarks/grl-bookmarks.c b/src/media/bookmarks/grl-bookmarks.c
index 1c7de10..b978f5a 100644
--- a/src/media/bookmarks/grl-bookmarks.c
+++ b/src/media/bookmarks/grl-bookmarks.c
@@ -588,6 +588,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
   const gchar *title;
   const gchar *url;
   const gchar *desc;
+  GList *changed_list = NULL;
   GTimeVal now;
   const gchar *parent_id;
   const gchar *mime;
@@ -679,10 +680,12 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
   g_free (id);
 
   if (bookmarks_source->priv->notify_changes) {
+    changed_list = g_list_append (NULL, GRL_MEDIA (parent));
     grl_media_source_notify_change (GRL_MEDIA_SOURCE (bookmarks_source),
-                                    GRL_MEDIA (parent),
+                                    changed_list,
                                     GRL_CONTENT_ADDED,
                                     FALSE);
+    g_list_free (changed_list);
   }
 }
 
diff --git a/src/media/filesystem/grl-filesystem.c b/src/media/filesystem/grl-filesystem.c
index 553e3e4..2b72d14 100644
--- a/src/media/filesystem/grl-filesystem.c
+++ b/src/media/filesystem/grl-filesystem.c
@@ -969,7 +969,7 @@ static void
 notify_parent_change (GrlMediaSource *source, GFile *child, GrlMediaSourceChangeType change)
 {
   GFile *parent;
-  GrlMedia *media;
+  GList *medialist = NULL;
   gchar *parent_path;
 
   parent = g_file_get_parent (child);
@@ -979,9 +979,14 @@ notify_parent_change (GrlMediaSource *source, GFile *child, GrlMediaSourceChange
     parent_path = g_strdup ("/");
   }
 
-  media = create_content (NULL, parent_path, GRL_RESOLVE_FAST_ONLY, parent == NULL);
-  grl_media_source_notify_change (source, media, change, FALSE);
-  g_object_unref (media);
+  medialist = g_list_append (medialist,
+                             create_content (NULL,
+                                             parent_path,
+                                             GRL_RESOLVE_FAST_ONLY,
+                                             parent == NULL));
+  grl_media_source_notify_change (source, medialist, change, FALSE);
+  g_object_unref (medialist->data);
+  g_list_free (medialist);
 
   if (parent) {
     g_object_unref (parent);
diff --git a/src/media/podcasts/grl-podcasts.c b/src/media/podcasts/grl-podcasts.c
index 759a36d..671cf18 100644
--- a/src/media/podcasts/grl-podcasts.c
+++ b/src/media/podcasts/grl-podcasts.c
@@ -973,6 +973,7 @@ parse_entry_idle (gpointer user_data)
   xmlNodeSetPtr nodes;
   guint remaining;
   GrlMedia *media;
+  GList *medialist;
 
   nodes = osp->xpathObj->nodesetval;
 
@@ -1030,13 +1031,14 @@ parse_entry_idle (gpointer user_data)
 		       NULL);
     /* Notify about changes */
     if (GRL_PODCASTS_SOURCE (osp->os->source)->priv->notify_changes) {
-      media = grl_media_box_new ();
-      grl_media_set_id (media, osp->os->media_id);
+      medialist = g_list_append (NULL, grl_media_box_new ());
+      grl_media_set_id (medialist->data, osp->os->media_id);
       grl_media_source_notify_change (osp->os->source,
-                                      media,
+                                      medialist,
                                       GRL_CONTENT_CHANGED,
                                       FALSE);
-      g_object_unref (media);
+      g_object_unref (medialist->data);
+      g_list_free (medialist);
     }
     g_slice_free (OperationSpec, osp->os);
     xmlXPathFreeObject (osp->xpathObj);
@@ -1051,7 +1053,7 @@ parse_entry_idle (gpointer user_data)
 static void
 parse_feed (OperationSpec *os, const gchar *str, GError **error)
 {
-  GrlMedia *podcast = NULL;
+  GList *podcast_list = NULL;
   xmlDocPtr doc = NULL;
   xmlXPathContextPtr xpathCtx = NULL;
   xmlXPathObjectPtr xpathObj = NULL;
@@ -1104,13 +1106,14 @@ parse_feed (OperationSpec *os, const gchar *str, GError **error)
   
   if (stream_count <= 0) {
     if (GRL_PODCASTS_SOURCE (os->source)->priv->notify_changes) {
-      podcast = grl_media_box_new ();
-      grl_media_set_id (podcast, os->media_id);
+      podcast_list = g_list_append (NULL, grl_media_box_new ());
+      grl_media_set_id (podcast_list->data, os->media_id);
       grl_media_source_notify_change (os->source,
-                                      podcast,
+                                      podcast_list,
                                       GRL_CONTENT_CHANGED,
                                       FALSE);
-      g_object_unref (podcast);
+      g_object_unref (podcast_list->data);
+      g_list_free (podcast_list);
     }
     os->callback (os->source,
 		  os->operation_id,
diff --git a/src/media/tracker/grl-tracker-media-notif.c b/src/media/tracker/grl-tracker-media-notif.c
index 615e299..632cc2f 100644
--- a/src/media/tracker/grl-tracker-media-notif.c
+++ b/src/media/tracker/grl-tracker-media-notif.c
@@ -234,10 +234,13 @@ tracker_evt_update_orphan_item_cb (GObject              *object,
         GRL_DEBUG ("\tNotify id=%u source=%s p=%p", id,
                    grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)),
                    source);
-        grl_media_source_notify_change (GRL_MEDIA_SOURCE (source), media,
+
+        GList *changed_medias = g_list_append (NULL, media);
+        grl_media_source_notify_change (GRL_MEDIA_SOURCE (source), changed_medias,
                                         change_type, FALSE);
 
         g_object_unref (media);
+        g_list_free (changed_medias);
       }
     }
   }
@@ -320,9 +323,11 @@ tracker_evt_update_orphans (tracker_evt_update_t *evt)
             grl_media_set_id (media, str_id);
             g_free (str_id);
 
+            GList *changed_medias = g_list_append (NULL, media);
             grl_media_source_notify_change (GRL_MEDIA_SOURCE (source->data),
-                                            media, GRL_CONTENT_REMOVED, FALSE);
+                                            changed_medias, GRL_CONTENT_REMOVED, FALSE);
             g_object_unref (media);
+            g_list_free (changed_medias);
           }
         }
         source = source->next;
@@ -361,6 +366,7 @@ tracker_evt_update_items_cb (gpointer              key,
   gchar *str_id;
   GrlTrackerMedia *source = (GrlTrackerMedia *) value;
   GrlMedia *media;
+  GList *changed_medias = NULL;
 
   GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
 
@@ -382,10 +388,13 @@ tracker_evt_update_items_cb (gpointer              key,
 
   GRL_DEBUG ("\tNotify id=%u source=%s", id,
              grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)));
-  grl_media_source_notify_change (GRL_MEDIA_SOURCE (source), media,
+
+  changed_medias = g_list_append (NULL, media);
+  grl_media_source_notify_change (GRL_MEDIA_SOURCE (source), changed_medias,
                                   evt->change_type, FALSE);
 
   g_object_unref (media);
+  g_list_free (changed_medias);
 }
 
 static void
diff --git a/src/media/upnp/grl-upnp.c b/src/media/upnp/grl-upnp.c
index 424e900..7618028 100644
--- a/src/media/upnp/grl-upnp.c
+++ b/src/media/upnp/grl-upnp.c
@@ -286,6 +286,7 @@ container_changed_cb (GUPnPServiceProxy *proxy,
 {
   GrlMedia *container;
   GrlMediaSource *source = GRL_MEDIA_SOURCE (user_data);
+  GList *changed_list = NULL;
   gchar **tokens;
   gint i = 0;
 
@@ -296,13 +297,16 @@ container_changed_cb (GUPnPServiceProxy *proxy,
   while (tokens[i]) {
     container = grl_media_box_new ();
     grl_media_set_id (container, tokens[i]);
-    grl_media_source_notify_change (source,
-                                    container,
-                                    GRL_CONTENT_CHANGED,
-                                    FALSE);
-    g_object_unref (container);
+    changed_list = g_list_append (changed_list, container);
     i += 2;
   }
+
+  grl_media_source_notify_change (source,
+                                  changed_list,
+                                  GRL_CONTENT_CHANGED,
+                                  FALSE);
+  g_list_foreach (changed_list, (GFunc) g_object_unref, NULL);
+  g_list_free (changed_list);
   g_strfreev (tokens);
 }
 
-- 
1.7.1



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