~ubuntu-branches/ubuntu/precise/folks/precise

« back to all changes in this revision

Viewing changes to tools/inspect/command-individuals.c

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis
  • Date: 2011-02-02 14:22:14 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110202142214-ngpuu3mhjxyl430f
Tags: 0.3.4-0ubuntu1
* New Upstream Release
  - libfolks-telepathy.so exports private symbols
  - Add a HACKING file that outlines development policies and coding style
  - Review coding conventions in folks
  - Add folks command line application
  - libfolks hard-codes backend names for debugging
  - Print stack traces for failed tests to improve remote debugging
  - Add static aggregation tests
  - Logger service unavailable in make check
  - Add tests for LinkedHashSet
  - Use better interface names
* debian/control
  -changed Maintainer to XSBC-Original-Maintainer
  -added Maintainer of Ubuntu Core Developers
  -changed libfolks19* > libfolks20*
* debian
  -changed .install and .symbols files from 19 > 20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* command-individuals.c generated by valac 0.11.5.3-fe751, the Vala compiler
 
2
 * generated from command-individuals.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2010 Collabora Ltd.
 
6
 *
 
7
 * This library is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU Lesser General Public License as published by
 
9
 * the Free Software Foundation, either version 2.1 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * Authors:
 
21
 *       Philip Withnall <philip.withnall@collabora.co.uk>
 
22
 */
 
23
 
 
24
#include <glib.h>
 
25
#include <glib-object.h>
 
26
#include <stdlib.h>
 
27
#include <string.h>
 
28
#include <folks.h>
 
29
#include <stdio.h>
 
30
#include <readline/readline.h>
 
31
 
 
32
 
 
33
#define FOLKS_INSPECT_TYPE_COMMAND (folks_inspect_command_get_type ())
 
34
#define FOLKS_INSPECT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommand))
 
35
#define FOLKS_INSPECT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
 
36
#define FOLKS_INSPECT_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_COMMAND))
 
37
#define FOLKS_INSPECT_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_COMMAND))
 
38
#define FOLKS_INSPECT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
 
39
 
 
40
typedef struct _FolksInspectCommand FolksInspectCommand;
 
41
typedef struct _FolksInspectCommandClass FolksInspectCommandClass;
 
42
typedef struct _FolksInspectCommandPrivate FolksInspectCommandPrivate;
 
43
 
 
44
#define FOLKS_INSPECT_TYPE_CLIENT (folks_inspect_client_get_type ())
 
45
#define FOLKS_INSPECT_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClient))
 
46
#define FOLKS_INSPECT_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
 
47
#define FOLKS_INSPECT_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_CLIENT))
 
48
#define FOLKS_INSPECT_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_CLIENT))
 
49
#define FOLKS_INSPECT_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
 
50
 
 
51
typedef struct _FolksInspectClient FolksInspectClient;
 
52
typedef struct _FolksInspectClientClass FolksInspectClientClass;
 
53
 
 
54
#define FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS (folks_inspect_commands_individuals_get_type ())
 
55
#define FOLKS_INSPECT_COMMANDS_INDIVIDUALS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS, FolksInspectCommandsIndividuals))
 
56
#define FOLKS_INSPECT_COMMANDS_INDIVIDUALS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS, FolksInspectCommandsIndividualsClass))
 
57
#define FOLKS_INSPECT_COMMANDS_IS_INDIVIDUALS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS))
 
58
#define FOLKS_INSPECT_COMMANDS_IS_INDIVIDUALS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS))
 
59
#define FOLKS_INSPECT_COMMANDS_INDIVIDUALS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS, FolksInspectCommandsIndividualsClass))
 
60
 
 
61
typedef struct _FolksInspectCommandsIndividuals FolksInspectCommandsIndividuals;
 
62
typedef struct _FolksInspectCommandsIndividualsClass FolksInspectCommandsIndividualsClass;
 
63
typedef struct _FolksInspectCommandsIndividualsPrivate FolksInspectCommandsIndividualsPrivate;
 
64
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
65
 
 
66
struct _FolksInspectCommand {
 
67
        GTypeInstance parent_instance;
 
68
        volatile int ref_count;
 
69
        FolksInspectCommandPrivate * priv;
 
70
        FolksInspectClient* client;
 
71
};
 
72
 
 
73
struct _FolksInspectCommandClass {
 
74
        GTypeClass parent_class;
 
75
        void (*finalize) (FolksInspectCommand *self);
 
76
        void (*run) (FolksInspectCommand* self, const gchar* command_string);
 
77
        gchar** (*complete_subcommand) (FolksInspectCommand* self, const gchar* subcommand);
 
78
        const gchar* (*get_name) (FolksInspectCommand* self);
 
79
        const gchar* (*get_description) (FolksInspectCommand* self);
 
80
        const gchar* (*get_help) (FolksInspectCommand* self);
 
81
};
 
82
 
 
83
struct _FolksInspectCommandsIndividuals {
 
84
        FolksInspectCommand parent_instance;
 
85
        FolksInspectCommandsIndividualsPrivate * priv;
 
86
};
 
87
 
 
88
struct _FolksInspectCommandsIndividualsClass {
 
89
        FolksInspectCommandClass parent_class;
 
90
};
 
91
 
 
92
 
 
93
static gpointer folks_inspect_commands_individuals_parent_class = NULL;
 
94
 
 
95
gpointer folks_inspect_command_ref (gpointer instance);
 
96
void folks_inspect_command_unref (gpointer instance);
 
97
GParamSpec* folks_inspect_param_spec_command (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
98
void folks_inspect_value_set_command (GValue* value, gpointer v_object);
 
99
void folks_inspect_value_take_command (GValue* value, gpointer v_object);
 
100
gpointer folks_inspect_value_get_command (const GValue* value);
 
101
GType folks_inspect_command_get_type (void) G_GNUC_CONST;
 
102
GType folks_inspect_client_get_type (void) G_GNUC_CONST;
 
103
GType folks_inspect_commands_individuals_get_type (void) G_GNUC_CONST;
 
104
enum  {
 
105
        FOLKS_INSPECT_COMMANDS_INDIVIDUALS_DUMMY_PROPERTY
 
106
};
 
107
FolksInspectCommandsIndividuals* folks_inspect_commands_individuals_new (FolksInspectClient* client);
 
108
FolksInspectCommandsIndividuals* folks_inspect_commands_individuals_construct (GType object_type, FolksInspectClient* client);
 
109
FolksInspectCommand* folks_inspect_command_construct (GType object_type, FolksInspectClient* client);
 
110
static void folks_inspect_commands_individuals_real_run (FolksInspectCommand* base, const gchar* command_string);
 
111
FolksIndividualAggregator* folks_inspect_client_get_aggregator (FolksInspectClient* self);
 
112
static void _lambda6_ (const gchar* k, FolksIndividual* v, FolksInspectCommandsIndividuals* self);
 
113
void folks_inspect_utils_print_individual (FolksIndividual* individual, gboolean show_personas);
 
114
void folks_inspect_utils_print_line (const gchar* format, ...);
 
115
static void __lambda6__gh_func (gconstpointer key, gconstpointer value, gpointer self);
 
116
static gchar** folks_inspect_commands_individuals_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1);
 
117
gchar* folks_inspect_utils_individual_id_completion_cb (const gchar* word, gint state);
 
118
static gchar* _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
 
119
static gchar** _vala_array_dup3 (gchar** self, int length);
 
120
static gint _vala_array_length (gpointer array);
 
121
 
 
122
 
 
123
FolksInspectCommandsIndividuals* folks_inspect_commands_individuals_construct (GType object_type, FolksInspectClient* client) {
 
124
        FolksInspectCommandsIndividuals* self = NULL;
 
125
        g_return_val_if_fail (client != NULL, NULL);
 
126
        self = (FolksInspectCommandsIndividuals*) folks_inspect_command_construct (object_type, client);
 
127
        return self;
 
128
}
 
129
 
 
130
 
 
131
FolksInspectCommandsIndividuals* folks_inspect_commands_individuals_new (FolksInspectClient* client) {
 
132
        return folks_inspect_commands_individuals_construct (FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS, client);
 
133
}
 
134
 
 
135
 
 
136
static void _lambda6_ (const gchar* k, FolksIndividual* v, FolksInspectCommandsIndividuals* self) {
 
137
        g_return_if_fail (k != NULL);
 
138
        g_return_if_fail (v != NULL);
 
139
        folks_inspect_utils_print_individual (FOLKS_INDIVIDUAL (v), FALSE);
 
140
        folks_inspect_utils_print_line ("");
 
141
}
 
142
 
 
143
 
 
144
static void __lambda6__gh_func (gconstpointer key, gconstpointer value, gpointer self) {
 
145
        _lambda6_ (key, value, self);
 
146
}
 
147
 
 
148
 
 
149
static gpointer _g_object_ref0 (gpointer self) {
 
150
        return self ? g_object_ref (self) : NULL;
 
151
}
 
152
 
 
153
 
 
154
static void folks_inspect_commands_individuals_real_run (FolksInspectCommand* base, const gchar* command_string) {
 
155
        FolksInspectCommandsIndividuals * self;
 
156
        self = (FolksInspectCommandsIndividuals*) base;
 
157
        if (command_string == NULL) {
 
158
                FolksIndividualAggregator* _tmp0_ = NULL;
 
159
                GHashTable* _tmp1_ = NULL;
 
160
                _tmp0_ = folks_inspect_client_get_aggregator (((FolksInspectCommand*) self)->client);
 
161
                _tmp1_ = folks_individual_aggregator_get_individuals (_tmp0_);
 
162
                g_hash_table_foreach (_tmp1_, __lambda6__gh_func, self);
 
163
        } else {
 
164
                FolksIndividualAggregator* _tmp2_ = NULL;
 
165
                GHashTable* _tmp3_ = NULL;
 
166
                gconstpointer _tmp4_ = NULL;
 
167
                FolksIndividual* _tmp5_;
 
168
                FolksIndividual* individual;
 
169
                _tmp2_ = folks_inspect_client_get_aggregator (((FolksInspectCommand*) self)->client);
 
170
                _tmp3_ = folks_individual_aggregator_get_individuals (_tmp2_);
 
171
                _tmp4_ = g_hash_table_lookup (_tmp3_, command_string);
 
172
                _tmp5_ = _g_object_ref0 ((FolksIndividual*) _tmp4_);
 
173
                individual = _tmp5_;
 
174
                if (individual == NULL) {
 
175
                        folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", command_string);
 
176
                        _g_object_unref0 (individual);
 
177
                        return;
 
178
                }
 
179
                folks_inspect_utils_print_individual (individual, TRUE);
 
180
                _g_object_unref0 (individual);
 
181
        }
 
182
}
 
183
 
 
184
 
 
185
static gchar* _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
 
186
        gchar* result;
 
187
        result = folks_inspect_utils_individual_id_completion_cb (str, a);
 
188
        return result;
 
189
}
 
190
 
 
191
 
 
192
static gchar** _vala_array_dup3 (gchar** self, int length) {
 
193
        gchar** result;
 
194
        int i;
 
195
        result = g_new0 (gchar*, length + 1);
 
196
        for (i = 0; i < length; i++) {
 
197
                result[i] = g_strdup (self[i]);
 
198
        }
 
199
        return result;
 
200
}
 
201
 
 
202
 
 
203
static gchar** folks_inspect_commands_individuals_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1) {
 
204
        FolksInspectCommandsIndividuals * self;
 
205
        gchar** result = NULL;
 
206
        gchar** _tmp0_;
 
207
        gchar** _tmp1_ = NULL;
 
208
        gchar** _tmp2_;
 
209
        gchar** _tmp3_;
 
210
        gchar** _tmp4_;
 
211
        self = (FolksInspectCommandsIndividuals*) base;
 
212
        g_return_val_if_fail (subcommand != NULL, NULL);
 
213
        _tmp1_ = _tmp0_ = rl_completion_matches (subcommand, _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t);
 
214
        _tmp2_ = (_tmp3_ = _tmp1_, (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup3 (_tmp3_, _vala_array_length (_tmp0_)));
 
215
        _tmp4_ = _tmp2_;
 
216
        *result_length1 = _vala_array_length (_tmp0_);
 
217
        result = _tmp4_;
 
218
        return result;
 
219
}
 
220
 
 
221
 
 
222
static const gchar* folks_inspect_commands_individuals_real_get_name (FolksInspectCommand* base) {
 
223
        const gchar* result;
 
224
        FolksInspectCommandsIndividuals* self;
 
225
        self = (FolksInspectCommandsIndividuals*) base;
 
226
        result = "individuals";
 
227
        return result;
 
228
}
 
229
 
 
230
 
 
231
static const gchar* folks_inspect_commands_individuals_real_get_description (FolksInspectCommand* base) {
 
232
        const gchar* result;
 
233
        FolksInspectCommandsIndividuals* self;
 
234
        self = (FolksInspectCommandsIndividuals*) base;
 
235
        result = "Inspect the individuals currently present in the aggregator";
 
236
        return result;
 
237
}
 
238
 
 
239
 
 
240
static const gchar* folks_inspect_commands_individuals_real_get_help (FolksInspectCommand* base) {
 
241
        const gchar* result;
 
242
        FolksInspectCommandsIndividuals* self;
 
243
        self = (FolksInspectCommandsIndividuals*) base;
 
244
        result = "individuals                    List all known " "individuals.\n" "individuals [individual ID]    Display the details of the " "specified individual and list its personas.";
 
245
        return result;
 
246
}
 
247
 
 
248
 
 
249
static void folks_inspect_commands_individuals_class_init (FolksInspectCommandsIndividualsClass * klass) {
 
250
        folks_inspect_commands_individuals_parent_class = g_type_class_peek_parent (klass);
 
251
        FOLKS_INSPECT_COMMAND_CLASS (klass)->run = folks_inspect_commands_individuals_real_run;
 
252
        FOLKS_INSPECT_COMMAND_CLASS (klass)->complete_subcommand = folks_inspect_commands_individuals_real_complete_subcommand;
 
253
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_name = folks_inspect_commands_individuals_real_get_name;
 
254
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_description = folks_inspect_commands_individuals_real_get_description;
 
255
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_help = folks_inspect_commands_individuals_real_get_help;
 
256
}
 
257
 
 
258
 
 
259
static void folks_inspect_commands_individuals_instance_init (FolksInspectCommandsIndividuals * self) {
 
260
}
 
261
 
 
262
 
 
263
GType folks_inspect_commands_individuals_get_type (void) {
 
264
        static volatile gsize folks_inspect_commands_individuals_type_id__volatile = 0;
 
265
        if (g_once_init_enter (&folks_inspect_commands_individuals_type_id__volatile)) {
 
266
                static const GTypeInfo g_define_type_info = { sizeof (FolksInspectCommandsIndividualsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_inspect_commands_individuals_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksInspectCommandsIndividuals), 0, (GInstanceInitFunc) folks_inspect_commands_individuals_instance_init, NULL };
 
267
                GType folks_inspect_commands_individuals_type_id;
 
268
                folks_inspect_commands_individuals_type_id = g_type_register_static (FOLKS_INSPECT_TYPE_COMMAND, "FolksInspectCommandsIndividuals", &g_define_type_info, 0);
 
269
                g_once_init_leave (&folks_inspect_commands_individuals_type_id__volatile, folks_inspect_commands_individuals_type_id);
 
270
        }
 
271
        return folks_inspect_commands_individuals_type_id__volatile;
 
272
}
 
273
 
 
274
 
 
275
static gint _vala_array_length (gpointer array) {
 
276
        int length;
 
277
        length = 0;
 
278
        if (array) {
 
279
                while (((gpointer*) array)[length]) {
 
280
                        length++;
 
281
                }
 
282
        }
 
283
        return length;
 
284
}
 
285
 
 
286
 
 
287