static void add_model (MexBliptvPlugin *self, GrlSource *source) { MexFeed *feed; GrlMedia *box; box = grl_media_video_new (); grl_media_set_id (GRL_MEDIA (box), NULL); feed = mex_grilo_feed_new (source, self->priv->query_keys, self->priv->video_keys, box); g_object_set (feed, "icon-name", "icon-panelheader-computer", "placeholder-text", "No videos found", "category", "videos", NULL); mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, 100); g_hash_table_insert (self->priv->video_models, source, feed); mex_model_manager_add_model (self->priv->manager, MEX_MODEL (feed)); }
/* When the MexContent set on the queue button is a directory we * try to add the children of the directory and mark the directory * as queued. When the child items are added to the queue model they * are marked as queued via the controller */ static void _add_from_directory (MexQueueButton *q_button, gboolean add) { MexQueueButtonPrivate *priv = q_button->priv; MexFeed *feed; GrlSource *source; GList *metadata_keys; GList *query_keys; const gchar *filter; const gchar *stream_uri; /* check if this content is a group */ if (MEX_IS_GROUP_ITEM (priv->content)) { MexModel *model; model = mex_group_item_get_model (MEX_GROUP_ITEM (priv->content)); _add_remove_recursive (priv->queue_model, g_object_ref (model), add); /* _add_remove_recursive will unref feed */ mex_content_set_metadata (priv->content, MEX_CONTENT_METADATA_QUEUED, (add) ? "yes" : NULL); return; } if (!MEX_IS_GRILO_PROGRAM (priv->content)) return; g_object_get (priv->content, "feed", &feed, NULL); if (MEX_IS_GRILO_FEED (feed)) { g_object_get (feed, "grilo-source", &source, "grilo-query-keys", &query_keys, "grilo-metadata-keys", &metadata_keys, NULL); stream_uri = mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_STREAM); /* tracker filesystem feed */ if (MEX_IS_GRILO_TRACKER_FEED (feed)) { gchar *orig_filter; g_object_get (feed, "tracker-filter", &orig_filter, NULL); filter = g_strdup_printf("FILTER(fn:starts-with(nie:url(?urn), '%s'))", stream_uri); feed = mex_grilo_tracker_feed_new (source, query_keys, metadata_keys, filter, NULL); mex_grilo_feed_query (MEX_GRILO_FEED (feed), orig_filter, 0, G_MAXINT); if (orig_filter) g_free (orig_filter); } /* We already know that the content is ia MexGriloProgram * box provides the root Grlio media content. * filesystem grilo feed */ else { GrlMedia *box; g_object_get (priv->content, "grilo-media", &box, NULL); feed = mex_grilo_feed_new (source, query_keys, metadata_keys, box); mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT); g_object_unref (box); } /* unref/free the stuff we g_object_get'ed */ if (source) g_object_unref (source); if (query_keys) g_list_free (query_keys); if (metadata_keys) g_list_free (metadata_keys); /* we don't actually want to add the priv->content into the queue model, * only it's children, which is where the QUEUED flag is usually set */ if (add) { g_signal_connect (feed, "notify::completed", G_CALLBACK (_add_directory_query_complete_cb), q_button); mex_content_set_metadata (priv->content, MEX_CONTENT_METADATA_QUEUED, "yes"); } else { g_signal_connect (feed, "notify::completed", G_CALLBACK (_remove_directory_query_complete_cb), q_button); mex_content_set_metadata (priv->content, MEX_CONTENT_METADATA_QUEUED, NULL); } } else { /* We're not working with a grilo feed therefore we can't help :( */ return; } }
static void mex_library_plugin_init (MexLibraryPlugin *self) { GrlMediaPlugin *plugin; GrlPluginRegistry *registry; MexLibraryPluginPrivate *priv = self->priv = LIBRARY_PLUGIN_PRIVATE (self); registry = grl_plugin_registry_get_default (); plugin = grl_plugin_registry_lookup_source (registry, "grl-filesystem"); if (plugin) { GList *query_keys; MexFeed *feed; GrlMedia *box; const gchar *path; MexModelInfo *video_info, *photo_info, *music_info; query_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID, GRL_METADATA_KEY_TITLE, GRL_METADATA_KEY_MIME, GRL_METADATA_KEY_URL, GRL_METADATA_KEY_DATE, NULL); /* Add the videos model */ path = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS); box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin), query_keys, path); if (box) { GList *metadata_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID, GRL_METADATA_KEY_DESCRIPTION, GRL_METADATA_KEY_DURATION, GRL_METADATA_KEY_THUMBNAIL, GRL_METADATA_KEY_WIDTH, GRL_METADATA_KEY_HEIGHT, NULL); feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin), query_keys, metadata_keys, box); g_object_set (feed, "icon-name", "icon-library", "placeholder-text", "No videos found", NULL); mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT); video_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed), "videos", 0); priv->models = g_list_append (priv->models, video_info); g_object_unref (feed); g_list_free (metadata_keys); } /* Add the photos model */ path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin), query_keys, path); if (box) { GList *metadata_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID, GRL_METADATA_KEY_DESCRIPTION, GRL_METADATA_KEY_THUMBNAIL, GRL_METADATA_KEY_WIDTH, GRL_METADATA_KEY_HEIGHT, NULL); feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin), query_keys, metadata_keys, box); g_object_set (feed, "icon-name", "icon-library", "placeholder-text", "No pictures found", NULL); mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT); photo_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed), "pictures", 0); priv->models = g_list_append (priv->models, photo_info); g_object_unref (feed); g_list_free (metadata_keys); } /* Add the music model */ path = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC); box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin), query_keys, path); if (box) { GList *metadata_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID, GRL_METADATA_KEY_DESCRIPTION, GRL_METADATA_KEY_THUMBNAIL, GRL_METADATA_KEY_WIDTH, GRL_METADATA_KEY_HEIGHT, GRL_METADATA_KEY_ARTIST, GRL_METADATA_KEY_ALBUM, NULL); feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin), query_keys, metadata_keys, box); g_object_set (feed, "icon-name", "icon-library", "placeholder-text", "No music found", NULL); mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT); music_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed), "music", 0); priv->models = g_list_append (priv->models, music_info); g_object_unref (feed); g_list_free (metadata_keys); } g_list_free (query_keys); } else g_warning ("Filesystem plugin not found"); }
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); }