2
* Copyright (C) 2006, Jamie McCracken <jamiemcc@gnome.org>
3
* Copyright (C) 2008-2009, Nokia <ivan.frade@nokia.com>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
30
#include <glib/gi18n.h>
32
#include <libtracker-sparql/tracker-sparql.h>
35
"Tracker " PACKAGE_VERSION "\n"
38
"This program is free software and comes without any warranty.\n" \
39
"It is licensed under version 2 or later of the General Public " \
40
"License which can be viewed at:\n" \
42
" http://www.gnu.org/licenses/gpl.txt\n"
45
static gchar **filenames = NULL;
46
static gboolean print_version;
48
static GOptionEntry entries[] = {
49
{ "version", 'V', 0, G_OPTION_ARG_NONE, &print_version,
53
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
60
main (int argc, char **argv)
62
TrackerSparqlConnection *connection;
63
GOptionContext *context;
67
setlocale (LC_ALL, "");
69
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
70
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
71
textdomain (GETTEXT_PACKAGE);
73
/* Translators: this messagge will apper immediately after the */
74
/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
75
context = g_option_context_new (_("- Import data using Turtle files"));
77
/* Translators: this message will appear after the usage string */
78
/* and before the list of options. */
79
g_option_context_add_main_entries (context, entries, NULL);
80
g_option_context_parse (context, &argc, &argv, NULL);
83
g_print ("\n" ABOUT "\n" LICENSE "\n");
84
g_option_context_free (context);
93
_("One or more files have not been specified"));
95
help = g_option_context_get_help (context, TRUE, NULL);
96
g_option_context_free (context);
97
g_printerr ("%s", help);
103
g_option_context_free (context);
107
if (!g_thread_supported ()) {
108
g_thread_init (NULL);
111
connection = tracker_sparql_connection_get (NULL, &error);
114
g_printerr ("%s: %s\n",
115
_("Could not establish a connection to Tracker"),
116
error ? error->message : _("No error given"));
117
g_clear_error (&error);
121
for (p = filenames; *p; p++) {
122
GError *error = NULL;
125
g_print ("%s:'%s'\n",
126
_("Importing Turtle file"),
129
file = g_file_new_for_commandline_arg (*p);
130
tracker_sparql_connection_load (connection, file, NULL, &error);
131
g_object_unref (file);
134
g_printerr (" %s, %s\n",
135
_("Unable to import Turtle file"),
138
g_error_free (error);
142
g_print (" %s\n", _("Done"));
146
g_object_unref (connection);