~ubuntu-branches/ubuntu/raring/tracker/raring

« back to all changes in this revision

Viewing changes to .pc/90-remove-gthread-init.patch/src/tracker-utils/tracker-import.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2011-12-19 15:20:01 UTC
  • Revision ID: package-import@ubuntu.com-20111219152001-ecj0pbq5u838v099
Tags: 0.12.9-1ubuntu1
* 90-remove-gthread-init.patch
  - Git patch to fix FTBFS with glib 2.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006, Jamie McCracken <jamiemcc@gnome.org>
 
3
 * Copyright (C) 2008-2009, Nokia <ivan.frade@nokia.com>
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
#include <time.h>
 
26
#include <locale.h>
 
27
#include <stdint.h>
 
28
 
 
29
#include <glib.h>
 
30
#include <glib/gi18n.h>
 
31
 
 
32
#include <libtracker-sparql/tracker-sparql.h>
 
33
 
 
34
#define ABOUT \
 
35
        "Tracker " PACKAGE_VERSION "\n"
 
36
 
 
37
#define LICENSE \
 
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" \
 
41
        "\n" \
 
42
        "  http://www.gnu.org/licenses/gpl.txt\n"
 
43
 
 
44
 
 
45
static gchar        **filenames = NULL;
 
46
static gboolean       print_version;
 
47
 
 
48
static GOptionEntry   entries[] = {
 
49
        { "version", 'V', 0, G_OPTION_ARG_NONE, &print_version,
 
50
          N_("Print version"),
 
51
          NULL,
 
52
        },
 
53
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
 
54
          N_("FILE"),
 
55
          N_("FILE")},
 
56
        { NULL }
 
57
};
 
58
 
 
59
int
 
60
main (int argc, char **argv)
 
61
{
 
62
        TrackerSparqlConnection *connection;
 
63
        GOptionContext *context;
 
64
        GError *error = NULL;
 
65
        gchar **p;
 
66
 
 
67
        setlocale (LC_ALL, "");
 
68
 
 
69
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 
70
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
71
        textdomain (GETTEXT_PACKAGE);
 
72
 
 
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"));
 
76
 
 
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);
 
81
 
 
82
        if (print_version) {
 
83
                g_print ("\n" ABOUT "\n" LICENSE "\n");
 
84
                g_option_context_free (context);
 
85
 
 
86
                return EXIT_SUCCESS;
 
87
        }
 
88
 
 
89
        if (!filenames) {
 
90
                gchar *help;
 
91
 
 
92
                g_printerr ("%s\n\n",
 
93
                            _("One or more files have not been specified"));
 
94
 
 
95
                help = g_option_context_get_help (context, TRUE, NULL);
 
96
                g_option_context_free (context);
 
97
                g_printerr ("%s", help);
 
98
                g_free (help);
 
99
 
 
100
                return EXIT_FAILURE;
 
101
        }
 
102
 
 
103
        g_option_context_free (context);
 
104
 
 
105
        g_type_init ();
 
106
 
 
107
        if (!g_thread_supported ()) {
 
108
                g_thread_init (NULL);
 
109
        }
 
110
 
 
111
        connection = tracker_sparql_connection_get (NULL, &error);
 
112
 
 
113
        if (!connection) {
 
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);
 
118
                return EXIT_FAILURE;
 
119
        }
 
120
 
 
121
        for (p = filenames; *p; p++) {
 
122
                GError *error = NULL;
 
123
                GFile *file;
 
124
 
 
125
                g_print ("%s:'%s'\n",
 
126
                         _("Importing Turtle file"),
 
127
                         *p);
 
128
 
 
129
                file = g_file_new_for_commandline_arg (*p);
 
130
                tracker_sparql_connection_load (connection, file, NULL, &error);
 
131
                g_object_unref (file);
 
132
 
 
133
                if (error) {
 
134
                        g_printerr ("  %s, %s\n",
 
135
                                    _("Unable to import Turtle file"),
 
136
                                    error->message);
 
137
 
 
138
                        g_error_free (error);
 
139
                        continue;
 
140
                }
 
141
 
 
142
                g_print ("  %s\n", _("Done"));
 
143
                g_print ("\n");
 
144
        }
 
145
 
 
146
        g_object_unref (connection);
 
147
 
 
148
        return EXIT_SUCCESS;
 
149
}