static void handle_new_source_plugin (MexTrackerPlugin *self, GrlMediaPlugin *plugin) { GrlSupportedOps ops; GrlMetadataSource *meta = GRL_METADATA_SOURCE (plugin); const char *id; id = grl_media_plugin_get_id (plugin); if (g_strcmp0 (id,"grl-tracker") != 0) { MEX_DEBUG ("Attempting to use the media explorer tracker plugin " "but grilo tracker plugin not loaded. " "You may not see any content!"); return; } ops = grl_metadata_source_supported_operations (meta); if ((ops & GRL_OP_QUERY) == 0) return; grl_media_source_notify_change_start (GRL_MEDIA_SOURCE (plugin), NULL); add_model (self, plugin, MEX_TRACKER_CATEGORY_VIDEO); add_model (self, plugin, MEX_TRACKER_CATEGORY_IMAGE); add_model (self, plugin, MEX_TRACKER_CATEGORY_MUSIC); }
static void grilo_source_added_cb (GrlPluginRegistry *registry, GrlMediaPlugin *grilo_plugin, RBGriloPlugin *plugin) { RBSource *grilo_source; RBShell *shell; int i; if (GRL_IS_MEDIA_SOURCE (grilo_plugin) == FALSE) { /* TODO use metadata sources for album art and lyrics */ rb_debug ("grilo source %s is not interesting", grl_media_plugin_get_name (grilo_plugin)); return; } for (i = 0; i < G_N_ELEMENTS (ignored_plugins); i++) { if (g_str_equal (ignored_plugins[i], grl_media_plugin_get_id (grilo_plugin))) { rb_debug ("grilo source %s is blacklisted", grl_media_plugin_get_name (grilo_plugin)); return; } } rb_debug ("new grilo source: %s", grl_media_plugin_get_name (grilo_plugin)); grilo_source = rb_grilo_source_new (G_OBJECT (plugin), GRL_MEDIA_SOURCE (grilo_plugin)); g_hash_table_insert (plugin->sources, grilo_plugin, grilo_source); /* probably put some sources under 'shared', some under 'stores'? */ g_object_get (plugin, "object", &shell, NULL); rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (grilo_source), RB_DISPLAY_PAGE_GROUP_SHARED); g_object_unref (shell); }
static void mex_search_plugin_search (MexSearchPlugin *self, const gchar *search) { GList *s, *sources; MexSearchPluginPrivate *priv = self->priv; /* Kill the last search */ if (priv->search_model) { g_object_unref (priv->search_model); priv->search_model = NULL; } /* Create search model */ priv->search_model = mex_aggregate_model_new (); g_object_set (G_OBJECT (priv->search_model), "title", "Search results", NULL); /* Iterate over searchable Grilo sources */ sources = grl_plugin_registry_get_sources (grl_plugin_registry_get_default (), FALSE); /* find the local files source and place it first */ for (s = sources; s; s = s->next) { GrlMetadataSource *meta_src = s->data; const gchar *name = grl_metadata_source_get_name (meta_src); if (!GRL_IS_METADATA_SOURCE (meta_src)) continue; if (name && !strcmp (name, "Local files")) { sources = g_list_remove_link (sources, s); sources = g_list_concat (sources, s); break; } } for (s = sources; s; s = s->next) { const gchar *source_id; GrlSupportedOps supported; GrlMetadataSource *meta_src = s->data; if (!GRL_IS_METADATA_SOURCE (meta_src)) continue; /* only search upnp and tracker sources */ source_id = grl_media_plugin_get_id (GRL_MEDIA_PLUGIN (meta_src)); supported = grl_metadata_source_supported_operations (meta_src); if ((supported & GRL_OP_SEARCH) || (supported & GRL_OP_QUERY)) { MexFeed *feed; if (g_str_equal (source_id, "grl-tracker")) feed = mex_grilo_tracker_feed_new (GRL_MEDIA_SOURCE (meta_src), NULL, NULL, NULL, NULL); else feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (meta_src), NULL, NULL, NULL); g_object_set (G_OBJECT (feed), "placeholder-text", _("No videos found"), NULL); GController *controller = mex_model_get_controller (MEX_MODEL (feed)); /* Attach to the changed signal so that we can alter the * mime-type of content if necessary. */ g_signal_connect (controller, "changed", G_CALLBACK (mex_search_plugin_model_changed_cb), feed); mex_aggregate_model_add_model ( MEX_AGGREGATE_MODEL (priv->search_model), MEX_MODEL (feed)); /* FIXME: Arbitrary 50 item limit... */ mex_grilo_feed_search (MEX_GRILO_FEED (feed), search, 0, 50); } } g_list_free (sources); }
static void mex_search_plugin_search (MexSearchPlugin *self, const gchar *search) { GList *l, *list; MexSearchPluginPrivate *priv = self->priv; MexModelManager *manager = mex_model_manager_get_default (); gboolean have_tracker = FALSE; if (!priv->search_model) { /* Create search model */ priv->search_model = mex_aggregate_model_new (); g_object_set (G_OBJECT (priv->search_model), "title", _("Search results"), NULL); } /* Kill the last search */ list = (GList *) mex_aggregate_model_get_models ( MEX_AGGREGATE_MODEL (priv->search_model)); for (l = list; l; l = l->next) mex_model_manager_remove_model (manager, l->data); mex_aggregate_model_clear (MEX_AGGREGATE_MODEL (priv->search_model)); /* Iterate over searchable Grilo sources */ list = grl_plugin_registry_get_sources (grl_plugin_registry_get_default (), FALSE); /* find the local files source and place it first */ for (l = list; l; l = l->next) { GrlMetadataSource *meta_src = l->data; const gchar *name = grl_metadata_source_get_name (meta_src); const gchar *source_id; if (!GRL_IS_METADATA_SOURCE (meta_src)) continue; source_id = grl_media_plugin_get_id (GRL_MEDIA_PLUGIN (meta_src)); if (source_id && g_str_equal (source_id, "grl-tracker")) have_tracker = TRUE; if (name && !strcmp (name, "Local files")) { list = g_list_remove_link (list, l); list = g_list_concat (list, l); break; } } /* prefer tracker over the filesystem plugin by removing it from the list if * tracker is available */ if (have_tracker) { for (l = list; l; l = l->next) { GrlMetadataSource *meta_src = l->data; const gchar *source_id; if (!GRL_IS_METADATA_SOURCE (meta_src)) continue; source_id = grl_media_plugin_get_id (GRL_MEDIA_PLUGIN (meta_src)); if (source_id && g_str_equal (source_id, "grl-filesystem")) { list = g_list_delete_link (list, l); break; } } } for (l = list; l; l = l->next) { const gchar *source_id; GrlSupportedOps supported; GrlMetadataSource *meta_src = l->data; if (!GRL_IS_METADATA_SOURCE (meta_src)) continue; /* only search upnp and tracker sources */ source_id = grl_media_plugin_get_id (GRL_MEDIA_PLUGIN (meta_src)); supported = grl_metadata_source_supported_operations (meta_src); if ((supported & GRL_OP_SEARCH) || (supported & GRL_OP_QUERY)) { MexFeed *feed; GController *controller; if (g_str_equal (source_id, "grl-tracker")) feed = mex_grilo_tracker_feed_new (GRL_MEDIA_SOURCE (meta_src), NULL, NULL, NULL, NULL); else feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (meta_src), NULL, NULL, NULL); mex_model_set_sort_func (MEX_MODEL (feed), mex_model_sort_time_cb, GINT_TO_POINTER (TRUE)); g_object_set (G_OBJECT (feed), "category", "search-results", "placeholder-text", _("No videos found"), NULL); mex_model_manager_add_model (manager, MEX_MODEL (feed)); controller = mex_model_get_controller (MEX_MODEL (feed)); /* Attach to the changed signal so that we can alter the * mime-type of content if necessary. */ g_signal_connect (controller, "changed", G_CALLBACK (mex_search_plugin_model_changed_cb), feed); mex_aggregate_model_add_model ( MEX_AGGREGATE_MODEL (priv->search_model), MEX_MODEL (feed)); /* FIXME: Arbitrary 50 item limit... */ mex_grilo_feed_search (MEX_GRILO_FEED (feed), search, 0, 50); g_object_unref (G_OBJECT (feed)); } } g_list_free (list); }