[tracker] Debug-mode option for tracker-extract



commit 183077da2408493e8d63e0b3cf3bc6fe3fa5f40f
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed May 6 16:42:54 2009 +0200

    Debug-mode option for tracker-extract
---
 src/tracker-extract/tracker-extract.c |   12 +++++++++---
 src/tracker-extract/tracker-main.c    |   16 ++++++++++++++--
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index e8c6746..37c0481 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -39,6 +39,8 @@
 #define MAX_EXTRACT_TIME 5
 #define TRACKER_EXTRACT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_EXTRACT, TrackerExtractPrivate))
 
+extern gboolean debug_mode;
+
 typedef struct {
 	GArray *specific_extractors;
 	GArray *generic_extractors;
@@ -464,7 +466,9 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 				    "  Resetting shutdown timeout");
 	
 	tracker_main_quit_timeout_reset ();
-	alarm (MAX_EXTRACT_TIME);
+	if (!debug_mode) {
+		alarm (MAX_EXTRACT_TIME);
+	}
 
 	statements = get_file_metadata (object, request_id, uri, mime);
 
@@ -487,6 +491,8 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 		g_error_free (actual_error);
 	}
 
-	/* Unset alarm so the extractor doesn't die when it's idle */
-	alarm (0);
+	if (!debug_mode) {
+		/* Unset alarm so the extractor doesn't die when it's idle */
+		alarm (0);
+	}
 }
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index c140ee6..9458fa3 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -71,6 +71,7 @@ static guint       quit_timeout_id = 0;
 static TrackerHal *hal;
 
 static gboolean    version;
+gboolean           debug_mode = FALSE;
 static gint        verbosity = -1;
 static gchar      *filename;
 static gchar      *mime_type;
@@ -93,6 +94,12 @@ static GOptionEntry  entries[] = {
 	  G_OPTION_ARG_STRING, &mime_type,
 	  N_("MIME type for file (if not provided, this will be guessed)"),
 	  N_("MIME") },
+	/* Debug run is used to avoid that the mainloop exits, so that
+	 * as a developer you can be relax when running the tool in gdb */
+	{ "debug-mode", 'd', 0,
+	  G_OPTION_ARG_NONE, &debug_mode,
+	  N_("Debug mode (default = off)"),
+	  NULL },
 
 	{ NULL }
 };
@@ -101,7 +108,12 @@ static gboolean
 quit_timeout_cb (gpointer user_data)
 {
 	quit_timeout_id = 0;
-	g_main_loop_quit (main_loop);
+	
+	if (!debug_mode) {
+		g_main_loop_quit (main_loop);
+	} else {
+		g_debug ("Would have quit the mainloop");
+	}
 
 	return FALSE;
 }
@@ -298,7 +310,7 @@ main (int argc, char *argv[])
 		return EXIT_SUCCESS;
 	}
 
-	g_print ("Initializing tracker-extract...\n");
+	g_print ("Initializing tracker-extract...%s\n", debug_mode ? "Running in debug mode" : "");
 
 	initialize_signal_handler ();
 



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