[tracker] Add tracker-import utility to import turtle files
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] Add tracker-import utility to import turtle files
- Date: Thu, 16 Apr 2009 11:00:51 -0400 (EDT)
commit bbce4638c476fc524735ef0198c43ca373280c0a
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 15 12:32:59 2009 +0200
Add tracker-import utility to import turtle files
---
po/POTFILES.in | 1 +
src/tracker-utils/Makefile.am | 6 ++-
src/tracker-utils/tracker-import.c | 116 ++++++++++++++++++++++++++++++++++++
3 files changed, 122 insertions(+), 1 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 73db1d1..3871b85 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,7 @@ src/tracker-search-tool/tracker-search-tool-callbacks.c
src/tracker-search-tool/tracker-search-tool-support.c
src/tracker-search-tool/tracker-search-tool.c
src/tracker-search-tool/tracker-search-tool.desktop.in.in
+src/tracker-utils/tracker-import.c
src/tracker-utils/tracker-info.c
src/tracker-utils/tracker-meta-folder.c
src/tracker-utils/tracker-processes.c
diff --git a/src/tracker-utils/Makefile.am b/src/tracker-utils/Makefile.am
index b77f8a3..455ca47 100644
--- a/src/tracker-utils/Makefile.am
+++ b/src/tracker-utils/Makefile.am
@@ -26,7 +26,8 @@ bin_PROGRAMS = \
tracker-status \
tracker-info \
tracker-processes \
- tracker-sparql
+ tracker-sparql \
+ tracker-import
tracker_search_SOURCES = tracker-search.c
tracker_search_LDADD = $(libs)
@@ -49,3 +50,6 @@ tracker_processes_LDADD = $(libs)
tracker_sparql_SOURCES = tracker-sparql.c
tracker_sparql_LDADD = $(libs)
+tracker_import_SOURCES = tracker-import.c
+tracker_import_LDADD = $(libs)
+
diff --git a/src/tracker-utils/tracker-import.c b/src/tracker-utils/tracker-import.c
new file mode 100644
index 0000000..e4c06aa
--- /dev/null
+++ b/src/tracker-utils/tracker-import.c
@@ -0,0 +1,116 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008-2009, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <locale.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
+
+static gchar **filenames = NULL;
+
+static GOptionEntry entries[] = {
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
+ N_("FILE"),
+ N_("FILE")},
+ { NULL }
+};
+
+int
+main (int argc, char **argv)
+{
+ TrackerClient *client;
+ gchar *query;
+ GOptionContext *context;
+ GError *error = NULL;
+ GPtrArray *results;
+ GFile *file;
+ char *uri;
+
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ /* Translators: this messagge will apper immediately after the */
+ /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
+ context = g_option_context_new (_("- Import files"));
+
+ /* Translators: this message will appear after the usage string */
+ /* and before the list of options. */
+ g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_parse (context, &argc, &argv, NULL);
+
+ if (!filenames) {
+ gchar *help;
+
+ g_printerr ("%s\n\n",
+ _("File missing"));
+
+ help = g_option_context_get_help (context, TRUE, NULL);
+ g_option_context_free (context);
+ g_printerr ("%s", help);
+ g_free (help);
+
+ return EXIT_FAILURE;
+ }
+
+ g_option_context_free (context);
+
+ client = tracker_connect (FALSE);
+
+ if (!client) {
+ g_printerr ("%s\n",
+ _("Could not establish a DBus connection to Tracker"));
+ return EXIT_FAILURE;
+ }
+
+ file = g_file_new_for_commandline_arg (filenames[0]);
+ uri = g_file_get_uri (file);
+
+ tracker_resources_load (client, uri, &error);
+
+ g_object_unref (file);
+ g_free (uri);
+
+ if (error) {
+ g_printerr ("%s, %s\n",
+ _("Unable to import file"),
+ error->message);
+
+ g_error_free (error);
+ tracker_disconnect (client);
+
+ return EXIT_FAILURE;
+ }
+
+ tracker_disconnect (client);
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]