~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-stats.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, 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
 
 
28
#include <glib.h>
 
29
#include <glib/gi18n.h>
 
30
 
 
31
#include <libtracker-sparql/tracker-sparql.h>
 
32
 
 
33
#define ABOUT \
 
34
        "Tracker " PACKAGE_VERSION "\n"
 
35
 
 
36
#define LICENSE \
 
37
        "This program is free software and comes without any warranty.\n" \
 
38
        "It is licensed under version 2 or later of the General Public " \
 
39
        "License which can be viewed at:\n" \
 
40
        "\n" \
 
41
        "  http://www.gnu.org/licenses/gpl.txt\n"
 
42
 
 
43
static gboolean print_version;
 
44
 
 
45
static GOptionEntry entries[] = {
 
46
        { "version", 'V', 0, G_OPTION_ARG_NONE, &print_version,
 
47
          N_("Print version"),
 
48
          NULL
 
49
        },
 
50
        { NULL }
 
51
};
 
52
 
 
53
int
 
54
main (int argc, char **argv)
 
55
{
 
56
        TrackerSparqlConnection *connection;
 
57
        TrackerSparqlCursor *cursor;
 
58
        GOptionContext *context;
 
59
        GError *error = NULL;
 
60
 
 
61
        setlocale (LC_ALL, "");
 
62
 
 
63
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 
64
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
65
        textdomain (GETTEXT_PACKAGE);
 
66
 
 
67
        /* Translators: this messagge will apper immediately after the  */
 
68
        /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>     */
 
69
        context = g_option_context_new (_(" - Show statistics for all Nepomuk defined ontology classes"));
 
70
        g_option_context_add_main_entries (context, entries, NULL);
 
71
        g_option_context_parse (context, &argc, &argv, NULL);
 
72
 
 
73
        if (print_version) {
 
74
                g_print ("\n" ABOUT "\n" LICENSE "\n");
 
75
                g_option_context_free (context);
 
76
 
 
77
                return EXIT_SUCCESS;
 
78
        }
 
79
 
 
80
        g_option_context_free (context);
 
81
 
 
82
        g_type_init ();
 
83
 
 
84
        if (!g_thread_supported ()) {
 
85
                g_thread_init (NULL);
 
86
        }
 
87
 
 
88
        connection = tracker_sparql_connection_get (NULL, &error);
 
89
 
 
90
        if (!connection) {
 
91
                g_printerr ("%s: %s\n",
 
92
                            _("Could not establish a connection to Tracker"),
 
93
                            error ? error->message : _("No error given"));
 
94
                g_clear_error (&error);
 
95
                return EXIT_FAILURE;
 
96
        }
 
97
 
 
98
        cursor = tracker_sparql_connection_statistics (connection, NULL, &error);
 
99
 
 
100
        if (error) {
 
101
                g_printerr ("%s, %s\n",
 
102
                            _("Could not get Tracker statistics"),
 
103
                            error->message);
 
104
                g_error_free (error);
 
105
                return EXIT_FAILURE;
 
106
        }
 
107
 
 
108
        if (!cursor) {
 
109
                g_print ("%s\n", _("No statistics available"));
 
110
        } else {
 
111
                gint count = 0;
 
112
 
 
113
                g_print ("%s\n", _("Statistics:"));
 
114
 
 
115
                while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 
116
                        g_print ("  %s = %s\n",
 
117
                                 tracker_sparql_cursor_get_string (cursor, 0, NULL),
 
118
                                 tracker_sparql_cursor_get_string (cursor, 1, NULL));
 
119
                        count++;
 
120
                }
 
121
 
 
122
                if (count == 0) {
 
123
                        g_print ("  %s\n", _("None"));
 
124
                }
 
125
 
 
126
                g_print ("\n");
 
127
 
 
128
                g_object_unref (cursor);
 
129
        }
 
130
 
 
131
        g_object_unref (connection);
 
132
 
 
133
        return EXIT_SUCCESS;
 
134
}