[tracker/libtracker-miner] Added tracker-status command line options to list running/available miners
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-miner] Added tracker-status command line options to list running/available miners
- Date: Fri, 21 Aug 2009 10:45:19 +0000 (UTC)
commit 62b4baefef5a275172c611f0c2b58ed529961413
Author: Martyn Russell <martyn lanedo com>
Date: Fri Aug 21 11:45:05 2009 +0100
Added tracker-status command line options to list running/available miners
src/libtracker-miner/tracker-miner-discover.c | 17 +++++--
src/libtracker-miner/tracker-miner-discover.h | 2 +-
src/tracker-utils/tracker-status.c | 57 +++++++++++++++++++++----
3 files changed, 61 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-discover.c b/src/libtracker-miner/tracker-miner-discover.c
index 8d5aba5..bcd3238 100644
--- a/src/libtracker-miner/tracker-miner-discover.c
+++ b/src/libtracker-miner/tracker-miner-discover.c
@@ -28,7 +28,7 @@
#include "tracker-miner-discover.h"
GSList *
-tracker_miner_discover_get_available (void)
+tracker_miner_discover_get_running (void)
{
DBusGConnection *connection;
DBusGProxy *gproxy;
@@ -98,11 +98,18 @@ crawler_process_file_cb (TrackerCrawler *crawler,
basename = g_file_get_basename (file);
if (g_str_has_prefix (basename, TRACKER_MINER_DBUS_NAME_PREFIX)) {
- GSList **list = user_data;
+ gchar *p;
- *list = g_slist_prepend (*list, g_file_get_path (file));
+ p = strstr (basename, ".service");
+
+ if (p) {
+ GSList **list = user_data;
- g_free (basename);
+ *p = '\0';
+ *list = g_slist_prepend (*list, basename);
+ } else {
+ g_free (basename);
+ }
return TRUE;
}
@@ -125,7 +132,7 @@ crawler_finished_cb (TrackerCrawler *crawler,
}
GSList *
-tracker_miner_discover_get_all (void)
+tracker_miner_discover_get_available (void)
{
GSList *list = NULL;
GMainLoop *main_loop;
diff --git a/src/libtracker-miner/tracker-miner-discover.h b/src/libtracker-miner/tracker-miner-discover.h
index 8695dc4..e0a41e7 100644
--- a/src/libtracker-miner/tracker-miner-discover.h
+++ b/src/libtracker-miner/tracker-miner-discover.h
@@ -25,8 +25,8 @@
G_BEGIN_DECLS
+GSList *tracker_miner_discover_get_running (void);
GSList *tracker_miner_discover_get_available (void);
-GSList *tracker_miner_discover_get_all (void);
G_END_DECLS
diff --git a/src/tracker-utils/tracker-status.c b/src/tracker-utils/tracker-status.c
index 52e804d..c07cf46 100644
--- a/src/tracker-utils/tracker-status.c
+++ b/src/tracker-utils/tracker-status.c
@@ -42,6 +42,8 @@
static GMainLoop *main_loop;
+static gboolean list_miners_running;
+static gboolean list_miners_available;
static gboolean follow;
static gboolean detailed;
@@ -54,6 +56,14 @@ static GOptionEntry entries[] = {
N_("Include details with state updates (only applies to --follow)"),
NULL
},
+ { "list-miners-running", 'r', 0, G_OPTION_ARG_NONE, &list_miners_running,
+ N_("List all miners installed"),
+ NULL
+ },
+ { "list-miners-available", 'a', 0, G_OPTION_ARG_NONE, &list_miners_available,
+ N_("List all miners installed"),
+ NULL
+ },
{ NULL }
};
@@ -133,17 +143,46 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
- GSList *list;
- list = tracker_miner_discover_get_available ();
- g_print ("Found %d names\n", g_slist_length (list));
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ if (list_miners_available) {
+ GSList *list, *l;
+ gchar *str;
+
+ list = tracker_miner_discover_get_available ();
+
+ str = g_strdup_printf (_("Found %d miners installed"), g_slist_length (list));
+ g_print ("%s%s\n", str, g_slist_length (list) > 0 ? ":" : "");
+ g_free (str);
+
+ for (l = list; l; l = l->next) {
+ g_print (" %s\n", (gchar*) l->data);
+ g_free (l->data);
+ }
+
+ g_slist_free (list);
+
+ return EXIT_SUCCESS;
+ }
+
+ if (list_miners_running) {
+ GSList *list, *l;
+ gchar *str;
+
+ list = tracker_miner_discover_get_running ();
- list = tracker_miner_discover_get_all ();
- g_print ("Found %d total\n", g_slist_length (list));
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ str = g_strdup_printf (_("Found %d miners running"), g_slist_length (list));
+ g_print ("%s%s\n", str, g_slist_length (list) > 0 ? ":" : "");
+ g_free (str);
+ for (l = list; l; l = l->next) {
+ g_print (" %s\n", (gchar*) l->data);
+ g_free (l->data);
+ }
+
+ g_slist_free (list);
+
+ return EXIT_SUCCESS;
+ }
+
if (!follow) {
GError *error = NULL;
gchar *state;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]