[PATCH] grl-inspect: Show information about a set of plugins



Shows information from the plugins specified at command line.
---
 tools/grilo-inspect/grl-inspect.c |   80 ++++++++++++++++++++++++++++++++-----
 1 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/tools/grilo-inspect/grl-inspect.c b/tools/grilo-inspect/grl-inspect.c
index 58a051b..77a8758 100644
--- a/tools/grilo-inspect/grl-inspect.c
+++ b/tools/grilo-inspect/grl-inspect.c
@@ -23,30 +23,91 @@
 #include <grilo.h>
 #include <glib.h>
 
-gint delay = 0;
-GMainLoop *mainloop = NULL;
+static gint delay = 0;
+static GMainLoop *mainloop = NULL;
+static gchar **introspect_plugins = NULL;
+static GrlPluginRegistry *registry = NULL;
 
 static GOptionEntry entries[] = {
   { "delay", 'd', 0,
     G_OPTION_ARG_INT, &delay,
     "Wait some seconds before showing results",
     NULL },
+  { G_OPTION_REMAINING, '\0', 0,
+    G_OPTION_ARG_STRING_ARRAY, &introspect_plugins,
+    "Plugins to introspect",
+    NULL },
   { NULL }
 };
 
-static gboolean
-list_all_sources (gpointer data)
+static void
+list_all_sources ()
 {
   GrlMediaPlugin **plugin;
   GrlMediaPlugin **plugins;
-  GrlPluginRegistry *registry;
-
-  registry = grl_plugin_registry_get_instance ();
 
   plugins = grl_plugin_registry_get_sources (registry, FALSE);
   for (plugin = plugins; *plugin; plugin++) {
     g_print ("%s\n", grl_media_plugin_get_id (*plugin));
   }
+}
+
+static void
+introspect_plugin (const gchar *plugin_id)
+{
+  GrlMediaPlugin *plugin;
+  const gchar *value;
+
+  plugin = grl_plugin_registry_lookup_source (registry, plugin_id);
+
+  if (plugin) {
+    g_print ("Plugin Details:\n");
+    g_print ("  Identifier:\t\t%s\n", grl_media_plugin_get_id (plugin));
+    g_print ("  Filename:\t\t%s\n", grl_media_plugin_get_filename (plugin));
+    g_print ("  Rank:\t\t\t%d\n", grl_media_plugin_get_rank (plugin));
+
+    value = grl_media_plugin_get_name (plugin);
+    if (value) {
+      g_print ("  Name:\t\t\t%s\n", value);
+    }
+    value = grl_media_plugin_get_description (plugin);
+    if (value) {
+      g_print ("  Description:\t\t%s\n", value);
+    }
+    value = grl_media_plugin_get_version (plugin);
+    if (value) {
+      g_print ("  Version:\t\t%s\n", value);
+    }
+    value = grl_media_plugin_get_license (plugin);
+    if (value) {
+      g_print ("  License:\t\t%s\n", value);
+    }
+    value = grl_media_plugin_get_author (plugin);
+    if (value) {
+      g_print ("  Author:\t\t%s\n", value);
+    }
+    value = grl_media_plugin_get_site (plugin);
+    if (value) {
+      g_print ("  Site:\t\t\t%s\n", value);
+    }
+    g_print ("\n");
+  } else {
+    g_printerr ("Plugin Not Found: %s\n\n", plugin_id);
+  }
+}
+
+static gboolean
+run (gpointer data)
+{
+  gchar **p;
+
+  if (introspect_plugins) {
+    for (p = introspect_plugins; *p; p++) {
+      introspect_plugin (*p);
+    }
+  } else {
+    list_all_sources ();
+  }
 
   g_main_loop_quit (mainloop);
 
@@ -58,7 +119,6 @@ main (int argc, char *argv[])
 {
   GError *error = NULL;
   GOptionContext *context;
-  GrlPluginRegistry *registry;
 
   context = g_option_context_new ("- introspect Grilo plugins");
   g_option_context_add_main_entries (context, entries, NULL);
@@ -81,9 +141,9 @@ main (int argc, char *argv[])
   grl_plugin_registry_load_all (registry);
 
   if (delay > 0) {
-    g_timeout_add_seconds ((guint) delay, list_all_sources, NULL);
+    g_timeout_add_seconds ((guint) delay, run, NULL);
   } else {
-    g_idle_add (list_all_sources, NULL);
+    g_idle_add (run, NULL);
   }
 
   g_main_loop_run (mainloop);
-- 
1.7.0.4



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