[grilo-plugins] tracker: don't rely on plugin registry to find tracker media sources
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tracker: don't rely on plugin registry to find tracker media sources
- Date: Thu, 17 Mar 2011 20:37:48 +0000 (UTC)
commit 07be7ab561251f400e30a8388aefd8382c441e74
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date: Wed Mar 16 10:25:41 2011 +0000
tracker: don't rely on plugin registry to find tracker media sources
Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
src/media/tracker/grl-tracker-media-notif.c | 68 +++++++++------------------
src/media/tracker/grl-tracker-media-priv.h | 2 +-
src/media/tracker/grl-tracker-media.c | 26 ++++++----
3 files changed, 40 insertions(+), 56 deletions(-)
---
diff --git a/src/media/tracker/grl-tracker-media-notif.c b/src/media/tracker/grl-tracker-media-notif.c
index 265d0ad..fbf9ee7 100644
--- a/src/media/tracker/grl-tracker-media-notif.c
+++ b/src/media/tracker/grl-tracker-media-notif.c
@@ -111,7 +111,7 @@ tracker_evt_update_media_add (tracker_evt_update_t *evt,
GrlTrackerMedia *source;
GrlTrackerMediaPriv *priv;
- source = g_hash_table_lookup (grl_tracker_modified_sources, id);
+ source = g_hash_table_lookup (grl_tracker_media_sources_modified, id);
if (!source) {
source = g_object_new (GRL_TRACKER_MEDIA_TYPE,
"source-id", id,
@@ -120,11 +120,12 @@ tracker_evt_update_media_add (tracker_evt_update_t *evt,
"tracker-connection", grl_tracker_connection,
"tracker-datasource", id,
NULL);
- g_hash_table_insert (grl_tracker_modified_sources,
+ g_hash_table_insert (grl_tracker_media_sources_modified,
(gpointer) grl_tracker_media_get_tracker_source (source),
source);
}
+ /* FIXME: something's wrong here... */
priv = GRL_TRACKER_MEDIA_GET_PRIVATE (source);
priv->state = GRL_TRACKER_MEDIA_STATE_INSERTING;
priv->notification_ref++;
@@ -277,6 +278,7 @@ tracker_evt_update_orphans (tracker_evt_update_t *evt)
{
guint id;
gchar *str_id;
+ gboolean first = TRUE;
GString *request_str;
GList *subject, *subjects;
GrlMedia *media;
@@ -299,9 +301,14 @@ tracker_evt_update_orphans (tracker_evt_update_t *evt)
while (subject != NULL) {
id = GPOINTER_TO_INT (subject->data);
if (GPOINTER_TO_INT (g_hash_table_lookup (evt->orphan_items,
- subject->data)) != GRL_CONTENT_REMOVED) {
- g_string_append_printf (request_str, "%u", id);
- break;
+ subject->data)) != GRL_CONTENT_REMOVED) {
+ if (first) {
+ g_string_append_printf (request_str, "%u", id);
+ first = FALSE;
+ }
+ else {
+ g_string_append_printf (request_str, ", %u", id);
+ }
} else {
/* Notify all sources that a been removed */
media = grl_media_new ();
@@ -311,62 +318,33 @@ tracker_evt_update_orphans (tracker_evt_update_t *evt)
source = sources;
while (source != NULL) {
- if (GRL_IS_TRACKER_MEDIA (source->data)) {
- GRL_DEBUG ("\tNotify id=%u source=%s p=%p", id,
+ if (GRL_IS_TRACKER_MEDIA (source->data)) {
+ GRL_DEBUG ("\tNotify id=%u source=%s p=%p", id,
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->data)),
source->data);
- if (grl_tracker_media_can_notify (GRL_TRACKER_MEDIA (source->data)))
- grl_media_source_notify_change (GRL_MEDIA_SOURCE (source->data),
+ if (grl_tracker_media_can_notify (GRL_TRACKER_MEDIA (source->data)))
+ grl_media_source_notify_change (GRL_MEDIA_SOURCE (source->data),
media, GRL_CONTENT_REMOVED, FALSE);
- }
- source = source->next;
+ }
+ source = source->next;
}
g_object_unref (media);
}
subject = subject->next;
}
- if (subject != NULL) {
- subject = subject->next;
- while (subject != NULL) {
- id = GPOINTER_TO_INT (subject->data);
- if (GPOINTER_TO_INT (g_hash_table_lookup (evt->orphan_items,
- subject->data)) != GRL_CONTENT_REMOVED) {
- g_string_append_printf (request_str, ", %u", id);
- } else {
- /* Notify all sources that a been removed */
- media = grl_media_new ();
- str_id = g_strdup_printf ("%u", id);
- grl_media_set_id (media, str_id);
- g_free (str_id);
-
- source = sources;
- while (source != NULL) {
- if (GRL_IS_TRACKER_MEDIA (source->data)) {
- GRL_DEBUG ("\tNotify id=%u source=%s p=%p", id,
- grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->data)),
- source->data);
- if (grl_tracker_media_can_notify (GRL_TRACKER_MEDIA (source->data)))
- grl_media_source_notify_change (GRL_MEDIA_SOURCE (source->data),
- media, GRL_CONTENT_REMOVED, FALSE);
- }
- source = source->next;
- }
- g_object_unref (media);
- }
- subject = subject->next;
- }
- g_list_free (subjects);
+ g_list_free (subjects);
+ if (request_str->len == 0) {
g_string_append (request_str, TRACKER_MEDIA_ITEM_END);
GRL_DEBUG ("\trequest : '%s'", request_str->str);
tracker_sparql_connection_query_async (grl_tracker_connection,
request_str->str,
- NULL,
+ NULL,
(GAsyncReadyCallback) tracker_evt_update_orphans_cb,
- evt);
+ evt);
} else {
tracker_evt_postupdate_sources (evt);
}
@@ -536,7 +514,7 @@ tracker_dbus_signal_cb (GDBusConnection *connection,
g_variant_get (parameters, "(&sa(iiii)a(iiii))", &class_name, &iter1, &iter2);
- GRL_DEBUG ("\tTracker update event for class=%s ins=%lu del=%lu evt=%p",
+ GRL_DEBUG ("Tracker update event for class=%s ins=%lu del=%lu evt=%p",
class_name,
(unsigned long) g_variant_iter_n_children (iter1),
(unsigned long) g_variant_iter_n_children (iter2),
diff --git a/src/media/tracker/grl-tracker-media-priv.h b/src/media/tracker/grl-tracker-media-priv.h
index 391ae0b..965c270 100644
--- a/src/media/tracker/grl-tracker-media-priv.h
+++ b/src/media/tracker/grl-tracker-media-priv.h
@@ -75,7 +75,7 @@ extern const GrlPluginInfo *grl_tracker_plugin;
/* shared data across */
extern GrlTrackerCache *grl_tracker_item_cache;
-extern GHashTable *grl_tracker_modified_sources;
+extern GHashTable *grl_tracker_media_sources_modified;
/* tracker plugin config */
extern gboolean grl_tracker_per_device_source;
diff --git a/src/media/tracker/grl-tracker-media.c b/src/media/tracker/grl-tracker-media.c
index 430fd27..03b222a 100644
--- a/src/media/tracker/grl-tracker-media.c
+++ b/src/media/tracker/grl-tracker-media.c
@@ -68,7 +68,8 @@ static void grl_tracker_media_finalize (GObject *object);
/* shared data across */
GrlTrackerCache *grl_tracker_item_cache;
-GHashTable *grl_tracker_modified_sources;
+GHashTable *grl_tracker_media_sources_modified;
+GHashTable *grl_tracker_media_sources;
/* ================== TrackerMedia GObject ================ */
@@ -206,8 +207,11 @@ grl_tracker_add_source (GrlTrackerMedia *source)
priv->notification_ref--;
}
if (priv->notification_ref == 0) {
- g_hash_table_remove (grl_tracker_modified_sources,
+ g_hash_table_remove (grl_tracker_media_sources_modified,
grl_tracker_media_get_tracker_source (source));
+ g_hash_table_insert (grl_tracker_media_sources,
+ (gpointer) grl_tracker_media_get_tracker_source (source),
+ source);
priv->state = GRL_TRACKER_MEDIA_STATE_RUNNING;
grl_plugin_registry_register_source (grl_plugin_registry_get_default (),
grl_tracker_plugin,
@@ -228,7 +232,9 @@ grl_tracker_del_source (GrlTrackerMedia *source)
priv->notification_ref--;
}
if (priv->notification_ref == 0) {
- g_hash_table_remove (grl_tracker_modified_sources,
+ g_hash_table_remove (grl_tracker_media_sources_modified,
+ grl_tracker_media_get_tracker_source (source));
+ g_hash_table_remove (grl_tracker_media_sources,
grl_tracker_media_get_tracker_source (source));
grl_tracker_media_cache_del_source (grl_tracker_item_cache, source);
priv->state = GRL_TRACKER_MEDIA_STATE_DELETED;
@@ -252,17 +258,15 @@ grl_tracker_media_can_notify (GrlTrackerMedia *source)
GrlTrackerMedia *
grl_tracker_media_find (const gchar *id)
{
- GrlMediaPlugin *source;
+ GrlTrackerMedia *source;
- source = grl_plugin_registry_lookup_source (grl_plugin_registry_get_default (),
- id);
+ source = g_hash_table_lookup (grl_tracker_media_sources, id);
- if (source && GRL_IS_TRACKER_MEDIA (source)) {
+ if (source)
return (GrlTrackerMedia *) source;
- }
return
- (GrlTrackerMedia *) g_hash_table_lookup (grl_tracker_modified_sources,
+ (GrlTrackerMedia *) g_hash_table_lookup (grl_tracker_media_sources_modified,
id);
}
@@ -353,7 +357,9 @@ grl_tracker_media_sources_init (void)
grl_tracker_item_cache =
grl_tracker_media_cache_new (TRACKER_ITEM_CACHE_SIZE);
- grl_tracker_modified_sources = g_hash_table_new (g_str_hash, g_str_equal);
+ grl_tracker_media_sources = g_hash_table_new (g_str_hash, g_str_equal);
+ grl_tracker_media_sources_modified = g_hash_table_new (g_str_hash,
+ g_str_equal);
if (grl_tracker_connection != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]