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

« back to all changes in this revision

Viewing changes to tools/inspect/command-persona-stores.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-persona-stores.c generated by valac 0.11.5.3-fe751, the Vala compiler
 
2
 * generated from command-persona-stores.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 <gee.h>
 
30
#include <stdio.h>
 
31
#include <readline/readline.h>
 
32
 
 
33
 
 
34
#define FOLKS_INSPECT_TYPE_COMMAND (folks_inspect_command_get_type ())
 
35
#define FOLKS_INSPECT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommand))
 
36
#define FOLKS_INSPECT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
 
37
#define FOLKS_INSPECT_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_COMMAND))
 
38
#define FOLKS_INSPECT_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_COMMAND))
 
39
#define FOLKS_INSPECT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
 
40
 
 
41
typedef struct _FolksInspectCommand FolksInspectCommand;
 
42
typedef struct _FolksInspectCommandClass FolksInspectCommandClass;
 
43
typedef struct _FolksInspectCommandPrivate FolksInspectCommandPrivate;
 
44
 
 
45
#define FOLKS_INSPECT_TYPE_CLIENT (folks_inspect_client_get_type ())
 
46
#define FOLKS_INSPECT_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClient))
 
47
#define FOLKS_INSPECT_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
 
48
#define FOLKS_INSPECT_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_CLIENT))
 
49
#define FOLKS_INSPECT_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_CLIENT))
 
50
#define FOLKS_INSPECT_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
 
51
 
 
52
typedef struct _FolksInspectClient FolksInspectClient;
 
53
typedef struct _FolksInspectClientClass FolksInspectClientClass;
 
54
 
 
55
#define FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES (folks_inspect_commands_persona_stores_get_type ())
 
56
#define FOLKS_INSPECT_COMMANDS_PERSONA_STORES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES, FolksInspectCommandsPersonaStores))
 
57
#define FOLKS_INSPECT_COMMANDS_PERSONA_STORES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES, FolksInspectCommandsPersonaStoresClass))
 
58
#define FOLKS_INSPECT_COMMANDS_IS_PERSONA_STORES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES))
 
59
#define FOLKS_INSPECT_COMMANDS_IS_PERSONA_STORES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES))
 
60
#define FOLKS_INSPECT_COMMANDS_PERSONA_STORES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES, FolksInspectCommandsPersonaStoresClass))
 
61
 
 
62
typedef struct _FolksInspectCommandsPersonaStores FolksInspectCommandsPersonaStores;
 
63
typedef struct _FolksInspectCommandsPersonaStoresClass FolksInspectCommandsPersonaStoresClass;
 
64
typedef struct _FolksInspectCommandsPersonaStoresPrivate FolksInspectCommandsPersonaStoresPrivate;
 
65
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
 
66
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
67
 
 
68
struct _FolksInspectCommand {
 
69
        GTypeInstance parent_instance;
 
70
        volatile int ref_count;
 
71
        FolksInspectCommandPrivate * priv;
 
72
        FolksInspectClient* client;
 
73
};
 
74
 
 
75
struct _FolksInspectCommandClass {
 
76
        GTypeClass parent_class;
 
77
        void (*finalize) (FolksInspectCommand *self);
 
78
        void (*run) (FolksInspectCommand* self, const gchar* command_string);
 
79
        gchar** (*complete_subcommand) (FolksInspectCommand* self, const gchar* subcommand);
 
80
        const gchar* (*get_name) (FolksInspectCommand* self);
 
81
        const gchar* (*get_description) (FolksInspectCommand* self);
 
82
        const gchar* (*get_help) (FolksInspectCommand* self);
 
83
};
 
84
 
 
85
struct _FolksInspectCommandsPersonaStores {
 
86
        FolksInspectCommand parent_instance;
 
87
        FolksInspectCommandsPersonaStoresPrivate * priv;
 
88
};
 
89
 
 
90
struct _FolksInspectCommandsPersonaStoresClass {
 
91
        FolksInspectCommandClass parent_class;
 
92
};
 
93
 
 
94
 
 
95
static gpointer folks_inspect_commands_persona_stores_parent_class = NULL;
 
96
 
 
97
gpointer folks_inspect_command_ref (gpointer instance);
 
98
void folks_inspect_command_unref (gpointer instance);
 
99
GParamSpec* folks_inspect_param_spec_command (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
100
void folks_inspect_value_set_command (GValue* value, gpointer v_object);
 
101
void folks_inspect_value_take_command (GValue* value, gpointer v_object);
 
102
gpointer folks_inspect_value_get_command (const GValue* value);
 
103
GType folks_inspect_command_get_type (void) G_GNUC_CONST;
 
104
GType folks_inspect_client_get_type (void) G_GNUC_CONST;
 
105
GType folks_inspect_commands_persona_stores_get_type (void) G_GNUC_CONST;
 
106
enum  {
 
107
        FOLKS_INSPECT_COMMANDS_PERSONA_STORES_DUMMY_PROPERTY
 
108
};
 
109
FolksInspectCommandsPersonaStores* folks_inspect_commands_persona_stores_new (FolksInspectClient* client);
 
110
FolksInspectCommandsPersonaStores* folks_inspect_commands_persona_stores_construct (GType object_type, FolksInspectClient* client);
 
111
FolksInspectCommand* folks_inspect_command_construct (GType object_type, FolksInspectClient* client);
 
112
static void folks_inspect_commands_persona_stores_real_run (FolksInspectCommand* base, const gchar* command_string);
 
113
FolksBackendStore* folks_inspect_client_get_backend_store (FolksInspectClient* self);
 
114
static void _lambda8_ (const gchar* k, FolksPersonaStore* v, FolksInspectCommandsPersonaStores* self);
 
115
void folks_inspect_utils_print_persona_store (FolksPersonaStore* store, gboolean show_personas);
 
116
void folks_inspect_utils_print_line (const gchar* format, ...);
 
117
static void __lambda8__gh_func (gconstpointer key, gconstpointer value, gpointer self);
 
118
static gchar** folks_inspect_commands_persona_stores_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1);
 
119
gchar* folks_inspect_utils_persona_store_id_completion_cb (const gchar* word, gint state);
 
120
static gchar* _folks_inspect_utils_persona_store_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
 
121
static gchar** _vala_array_dup4 (gchar** self, int length);
 
122
static gint _vala_array_length (gpointer array);
 
123
 
 
124
 
 
125
FolksInspectCommandsPersonaStores* folks_inspect_commands_persona_stores_construct (GType object_type, FolksInspectClient* client) {
 
126
        FolksInspectCommandsPersonaStores* self = NULL;
 
127
        g_return_val_if_fail (client != NULL, NULL);
 
128
        self = (FolksInspectCommandsPersonaStores*) folks_inspect_command_construct (object_type, client);
 
129
        return self;
 
130
}
 
131
 
 
132
 
 
133
FolksInspectCommandsPersonaStores* folks_inspect_commands_persona_stores_new (FolksInspectClient* client) {
 
134
        return folks_inspect_commands_persona_stores_construct (FOLKS_INSPECT_COMMANDS_TYPE_PERSONA_STORES, client);
 
135
}
 
136
 
 
137
 
 
138
static gpointer _g_hash_table_ref0 (gpointer self) {
 
139
        return self ? g_hash_table_ref (self) : NULL;
 
140
}
 
141
 
 
142
 
 
143
static void _lambda8_ (const gchar* k, FolksPersonaStore* v, FolksInspectCommandsPersonaStores* self) {
 
144
        g_return_if_fail (k != NULL);
 
145
        g_return_if_fail (v != NULL);
 
146
        folks_inspect_utils_print_persona_store (FOLKS_PERSONA_STORE (v), FALSE);
 
147
        folks_inspect_utils_print_line ("");
 
148
}
 
149
 
 
150
 
 
151
static void __lambda8__gh_func (gconstpointer key, gconstpointer value, gpointer self) {
 
152
        _lambda8_ (key, value, self);
 
153
}
 
154
 
 
155
 
 
156
static gpointer _g_object_ref0 (gpointer self) {
 
157
        return self ? g_object_ref (self) : NULL;
 
158
}
 
159
 
 
160
 
 
161
static void folks_inspect_commands_persona_stores_real_run (FolksInspectCommand* base, const gchar* command_string) {
 
162
        FolksInspectCommandsPersonaStores * self;
 
163
        self = (FolksInspectCommandsPersonaStores*) base;
 
164
        if (command_string == NULL) {
 
165
                FolksBackendStore* _tmp0_ = NULL;
 
166
                GeeCollection* _tmp1_ = NULL;
 
167
                GeeCollection* backends;
 
168
                _tmp0_ = folks_inspect_client_get_backend_store (((FolksInspectCommand*) self)->client);
 
169
                _tmp1_ = folks_backend_store_list_backends (_tmp0_);
 
170
                backends = _tmp1_;
 
171
                {
 
172
                        GeeIterator* _tmp2_ = NULL;
 
173
                        GeeIterator* _backend_it;
 
174
                        _tmp2_ = gee_iterable_iterator ((GeeIterable*) backends);
 
175
                        _backend_it = _tmp2_;
 
176
                        while (TRUE) {
 
177
                                gboolean _tmp3_;
 
178
                                gpointer _tmp4_ = NULL;
 
179
                                FolksBackend* backend;
 
180
                                GHashTable* _tmp5_ = NULL;
 
181
                                GHashTable* _tmp6_;
 
182
                                GHashTable* stores;
 
183
                                _tmp3_ = gee_iterator_next (_backend_it);
 
184
                                if (!_tmp3_) {
 
185
                                        break;
 
186
                                }
 
187
                                _tmp4_ = gee_iterator_get (_backend_it);
 
188
                                backend = (FolksBackend*) _tmp4_;
 
189
                                _tmp5_ = folks_backend_get_persona_stores (backend);
 
190
                                _tmp6_ = _g_hash_table_ref0 (_tmp5_);
 
191
                                stores = _tmp6_;
 
192
                                g_hash_table_foreach (stores, __lambda8__gh_func, self);
 
193
                                _g_hash_table_unref0 (stores);
 
194
                                _g_object_unref0 (backend);
 
195
                        }
 
196
                        _g_object_unref0 (_backend_it);
 
197
                }
 
198
                _g_object_unref0 (backends);
 
199
        } else {
 
200
                FolksBackendStore* _tmp7_ = NULL;
 
201
                GeeCollection* _tmp8_ = NULL;
 
202
                GeeCollection* backends;
 
203
                FolksPersonaStore* store;
 
204
                _tmp7_ = folks_inspect_client_get_backend_store (((FolksInspectCommand*) self)->client);
 
205
                _tmp8_ = folks_backend_store_list_backends (_tmp7_);
 
206
                backends = _tmp8_;
 
207
                store = NULL;
 
208
                {
 
209
                        GeeIterator* _tmp9_ = NULL;
 
210
                        GeeIterator* _backend_it;
 
211
                        _tmp9_ = gee_iterable_iterator ((GeeIterable*) backends);
 
212
                        _backend_it = _tmp9_;
 
213
                        while (TRUE) {
 
214
                                gboolean _tmp10_;
 
215
                                gpointer _tmp11_ = NULL;
 
216
                                FolksBackend* backend;
 
217
                                GHashTable* _tmp12_ = NULL;
 
218
                                GHashTable* _tmp13_;
 
219
                                GHashTable* stores;
 
220
                                gconstpointer _tmp14_ = NULL;
 
221
                                FolksPersonaStore* _tmp15_;
 
222
                                FolksPersonaStore* _tmp16_;
 
223
                                _tmp10_ = gee_iterator_next (_backend_it);
 
224
                                if (!_tmp10_) {
 
225
                                        break;
 
226
                                }
 
227
                                _tmp11_ = gee_iterator_get (_backend_it);
 
228
                                backend = (FolksBackend*) _tmp11_;
 
229
                                _tmp12_ = folks_backend_get_persona_stores (backend);
 
230
                                _tmp13_ = _g_hash_table_ref0 (_tmp12_);
 
231
                                stores = _tmp13_;
 
232
                                _tmp14_ = g_hash_table_lookup (stores, command_string);
 
233
                                _tmp15_ = _g_object_ref0 ((FolksPersonaStore*) _tmp14_);
 
234
                                _tmp16_ = _tmp15_;
 
235
                                _g_object_unref0 (store);
 
236
                                store = _tmp16_;
 
237
                                if (store != NULL) {
 
238
                                        _g_hash_table_unref0 (stores);
 
239
                                        _g_object_unref0 (backend);
 
240
                                        break;
 
241
                                }
 
242
                                _g_hash_table_unref0 (stores);
 
243
                                _g_object_unref0 (backend);
 
244
                        }
 
245
                        _g_object_unref0 (_backend_it);
 
246
                }
 
247
                if (store == NULL) {
 
248
                        folks_inspect_utils_print_line ("Unrecognised persona store ID '%s'.", command_string);
 
249
                        _g_object_unref0 (store);
 
250
                        _g_object_unref0 (backends);
 
251
                        return;
 
252
                }
 
253
                folks_inspect_utils_print_persona_store (store, TRUE);
 
254
                _g_object_unref0 (store);
 
255
                _g_object_unref0 (backends);
 
256
        }
 
257
}
 
258
 
 
259
 
 
260
static gchar* _folks_inspect_utils_persona_store_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
 
261
        gchar* result;
 
262
        result = folks_inspect_utils_persona_store_id_completion_cb (str, a);
 
263
        return result;
 
264
}
 
265
 
 
266
 
 
267
static gchar** _vala_array_dup4 (gchar** self, int length) {
 
268
        gchar** result;
 
269
        int i;
 
270
        result = g_new0 (gchar*, length + 1);
 
271
        for (i = 0; i < length; i++) {
 
272
                result[i] = g_strdup (self[i]);
 
273
        }
 
274
        return result;
 
275
}
 
276
 
 
277
 
 
278
static gchar** folks_inspect_commands_persona_stores_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1) {
 
279
        FolksInspectCommandsPersonaStores * self;
 
280
        gchar** result = NULL;
 
281
        gchar** _tmp0_;
 
282
        gchar** _tmp1_ = NULL;
 
283
        gchar** _tmp2_;
 
284
        gchar** _tmp3_;
 
285
        gchar** _tmp4_;
 
286
        self = (FolksInspectCommandsPersonaStores*) base;
 
287
        g_return_val_if_fail (subcommand != NULL, NULL);
 
288
        _tmp1_ = _tmp0_ = rl_completion_matches (subcommand, _folks_inspect_utils_persona_store_id_completion_cb_rl_compentry_func_t);
 
289
        _tmp2_ = (_tmp3_ = _tmp1_, (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup4 (_tmp3_, _vala_array_length (_tmp0_)));
 
290
        _tmp4_ = _tmp2_;
 
291
        *result_length1 = _vala_array_length (_tmp0_);
 
292
        result = _tmp4_;
 
293
        return result;
 
294
}
 
295
 
 
296
 
 
297
static const gchar* folks_inspect_commands_persona_stores_real_get_name (FolksInspectCommand* base) {
 
298
        const gchar* result;
 
299
        FolksInspectCommandsPersonaStores* self;
 
300
        self = (FolksInspectCommandsPersonaStores*) base;
 
301
        result = "persona-stores";
 
302
        return result;
 
303
}
 
304
 
 
305
 
 
306
static const gchar* folks_inspect_commands_persona_stores_real_get_description (FolksInspectCommand* base) {
 
307
        const gchar* result;
 
308
        FolksInspectCommandsPersonaStores* self;
 
309
        self = (FolksInspectCommandsPersonaStores*) base;
 
310
        result = "Inspect the persona stores loaded by the aggregator";
 
311
        return result;
 
312
}
 
313
 
 
314
 
 
315
static const gchar* folks_inspect_commands_persona_stores_real_get_help (FolksInspectCommand* base) {
 
316
        const gchar* result;
 
317
        FolksInspectCommandsPersonaStores* self;
 
318
        self = (FolksInspectCommandsPersonaStores*) base;
 
319
        result = "persona-stores                       List all known " "persona stores.\n" "persona-stores [persona store ID]    Display the details of " "the specified persona store and list its personas.";
 
320
        return result;
 
321
}
 
322
 
 
323
 
 
324
static void folks_inspect_commands_persona_stores_class_init (FolksInspectCommandsPersonaStoresClass * klass) {
 
325
        folks_inspect_commands_persona_stores_parent_class = g_type_class_peek_parent (klass);
 
326
        FOLKS_INSPECT_COMMAND_CLASS (klass)->run = folks_inspect_commands_persona_stores_real_run;
 
327
        FOLKS_INSPECT_COMMAND_CLASS (klass)->complete_subcommand = folks_inspect_commands_persona_stores_real_complete_subcommand;
 
328
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_name = folks_inspect_commands_persona_stores_real_get_name;
 
329
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_description = folks_inspect_commands_persona_stores_real_get_description;
 
330
        FOLKS_INSPECT_COMMAND_CLASS (klass)->get_help = folks_inspect_commands_persona_stores_real_get_help;
 
331
}
 
332
 
 
333
 
 
334
static void folks_inspect_commands_persona_stores_instance_init (FolksInspectCommandsPersonaStores * self) {
 
335
}
 
336
 
 
337
 
 
338
GType folks_inspect_commands_persona_stores_get_type (void) {
 
339
        static volatile gsize folks_inspect_commands_persona_stores_type_id__volatile = 0;
 
340
        if (g_once_init_enter (&folks_inspect_commands_persona_stores_type_id__volatile)) {
 
341
                static const GTypeInfo g_define_type_info = { sizeof (FolksInspectCommandsPersonaStoresClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_inspect_commands_persona_stores_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksInspectCommandsPersonaStores), 0, (GInstanceInitFunc) folks_inspect_commands_persona_stores_instance_init, NULL };
 
342
                GType folks_inspect_commands_persona_stores_type_id;
 
343
                folks_inspect_commands_persona_stores_type_id = g_type_register_static (FOLKS_INSPECT_TYPE_COMMAND, "FolksInspectCommandsPersonaStores", &g_define_type_info, 0);
 
344
                g_once_init_leave (&folks_inspect_commands_persona_stores_type_id__volatile, folks_inspect_commands_persona_stores_type_id);
 
345
        }
 
346
        return folks_inspect_commands_persona_stores_type_id__volatile;
 
347
}
 
348
 
 
349
 
 
350
static gint _vala_array_length (gpointer array) {
 
351
        int length;
 
352
        length = 0;
 
353
        if (array) {
 
354
                while (((gpointer*) array)[length]) {
 
355
                        length++;
 
356
                }
 
357
        }
 
358
        return length;
 
359
}
 
360
 
 
361
 
 
362