[tracker] utils: tracker-sql: Fixed --query command line option not working
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] utils: tracker-sql: Fixed --query command line option not working
- Date: Thu, 11 Nov 2010 12:20:48 +0000 (UTC)
commit b4fceae29692f60e80d4973785ebc2c41681a60b
Author: Martyn Russell <martyn lanedo com>
Date: Thu Nov 11 12:04:03 2010 +0000
utils: tracker-sql: Fixed --query command line option not working
Also cleaned up Makefile.am and made errors/messages translatable
utils/tracker-sql/Makefile.am | 18 ++++-------
utils/tracker-sql/tracker-sql.c | 63 ++++++++++++++++++++++----------------
2 files changed, 43 insertions(+), 38 deletions(-)
---
diff --git a/utils/tracker-sql/Makefile.am b/utils/tracker-sql/Makefile.am
index 4e897c9..430303d 100644
--- a/utils/tracker-sql/Makefile.am
+++ b/utils/tracker-sql/Makefile.am
@@ -2,19 +2,15 @@ include $(top_srcdir)/Makefile.decl
noinst_PROGRAMS = tracker-sql
-INCLUDES = \
- -DTRACKER_COMPILATION \
- -DTOP_SRCDIR=\"$(top_srcdir)\" \
- -DTOP_BUILDDIR=\"$(top_builddir)\" \
- -DG_LOG_DOMAIN=\"Tracker\" \
- -I$(top_srcdir)/src \
- $(WARN_CFLAGS) \
+INCLUDES = \
+ $(BUILD_CFLAGS) \
+ -DLOCALEDIR=\""$(localedir)"\" \
+ -I$(top_srcdir)/src \
$(TRACKER_UTILS_CFLAGS)
-tracker_sql_SOURCES = \
- tracker-sql.c
-
-tracker_sql_LDADD = \
+LDADD = \
$(top_builddir)/src/libtracker-data/libtracker-data.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(TRACKER_UTILS_LIBS)
+
+tracker_sql_SOURCES = tracker-sql.c
diff --git a/utils/tracker-sql/tracker-sql.c b/utils/tracker-sql/tracker-sql.c
index 27488ae..17613ae 100644
--- a/utils/tracker-sql/tracker-sql.c
+++ b/utils/tracker-sql/tracker-sql.c
@@ -25,6 +25,7 @@
#include <locale.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-data/tracker-data-manager.h>
@@ -50,30 +51,27 @@ static GOptionEntry entries[] = {
int
main (int argc, char **argv)
{
- GOptionContext *context = NULL;
- GError *error = NULL;
- const gchar *error_message;
-
- gchar *query = NULL;
+ GOptionContext *context;
+ GError *error = NULL;
+ const gchar *error_message;
TrackerDBResultSet *result_set;
TrackerDBInterface *iface;
- gboolean first_time = FALSE;
setlocale (LC_ALL, "");
- g_type_init ();
- if (!g_thread_supported ()) {
- g_thread_init (NULL);
- }
-
- context = g_option_context_new ("- Query or update using SQL");
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ context = g_option_context_new (_("- Query or update using SQL"));
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
if (!file && !query) {
- error_message = "An argument must be supplied";
+ error_message = _("An argument must be supplied");
} else if (file && query) {
- error_message = "File and query can not be used together";
+ error_message = _("File and query can not be used together");
} else {
error_message = NULL;
}
@@ -90,8 +88,13 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
+
g_option_context_free (context);
-
+
+ g_type_init ();
+ if (!g_thread_supported ()) {
+ g_thread_init (NULL);
+ }
if (file) {
gchar *path_in_utf8;
@@ -100,7 +103,7 @@ main (int argc, char **argv)
path_in_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, &error);
if (error) {
g_printerr ("%s:'%s', %s\n",
- "Could not get UTF-8 path from path",
+ _("Could not get UTF-8 path from path"),
file,
error->message);
g_error_free (error);
@@ -111,7 +114,7 @@ main (int argc, char **argv)
g_file_get_contents (path_in_utf8, &query, &size, &error);
if (error) {
g_printerr ("%s:'%s', %s\n",
- "Could not read file",
+ _("Could not read file"),
path_in_utf8,
error->message);
g_error_free (error);
@@ -124,7 +127,8 @@ main (int argc, char **argv)
}
if (query) {
-
+ gboolean first_time = FALSE;
+
if (!tracker_data_manager_init (0,
NULL,
&first_time,
@@ -134,18 +138,20 @@ main (int argc, char **argv)
NULL,
NULL,
NULL)) {
- g_printerr ("Failed to initialize data manager\n");
+ g_printerr ("%s\n",
+ _("Failed to initialize data manager"));
return EXIT_FAILURE;
-
}
-
- iface = tracker_db_manager_get_db_interface ();
-
+
+ g_print ("--------------------------------------------------\n");
+ g_print ("\n\n");
+
+ iface = tracker_db_manager_get_db_interface ();
result_set = tracker_db_interface_execute_query (iface, &error, "%s", query);
if (error) {
- g_printerr ("%s, %s\n",
- "Could not run query",
+ g_printerr ("%s: %s\n",
+ _("Could not run query"),
error->message);
g_error_free (error);
@@ -155,6 +161,8 @@ main (int argc, char **argv)
if (result_set) {
gboolean valid = TRUE;
guint columns;
+
+ g_print ("%s:\n", _("Results"));
columns = tracker_db_result_set_get_n_columns (result_set);
@@ -187,11 +195,12 @@ main (int argc, char **argv)
valid = tracker_db_result_set_iter_next (result_set);
}
} else {
- g_print ("Empty result set");
+ g_print ("%s\n", _("Empty result set"));
}
-
}
+ g_print ("\n");
+
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]