1
/* command-individuals.c generated by valac 0.11.5.3-fe751, the Vala compiler
2
* generated from command-individuals.vala, do not modify */
5
* Copyright (C) 2010 Collabora Ltd.
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.
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.
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/>.
21
* Philip Withnall <philip.withnall@collabora.co.uk>
25
#include <glib-object.h>
30
#include <readline/readline.h>
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))
40
typedef struct _FolksInspectCommand FolksInspectCommand;
41
typedef struct _FolksInspectCommandClass FolksInspectCommandClass;
42
typedef struct _FolksInspectCommandPrivate FolksInspectCommandPrivate;
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))
51
typedef struct _FolksInspectClient FolksInspectClient;
52
typedef struct _FolksInspectClientClass FolksInspectClientClass;
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))
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)))
66
struct _FolksInspectCommand {
67
GTypeInstance parent_instance;
68
volatile int ref_count;
69
FolksInspectCommandPrivate * priv;
70
FolksInspectClient* client;
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);
83
struct _FolksInspectCommandsIndividuals {
84
FolksInspectCommand parent_instance;
85
FolksInspectCommandsIndividualsPrivate * priv;
88
struct _FolksInspectCommandsIndividualsClass {
89
FolksInspectCommandClass parent_class;
93
static gpointer folks_inspect_commands_individuals_parent_class = NULL;
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;
105
FOLKS_INSPECT_COMMANDS_INDIVIDUALS_DUMMY_PROPERTY
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);
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);
131
FolksInspectCommandsIndividuals* folks_inspect_commands_individuals_new (FolksInspectClient* client) {
132
return folks_inspect_commands_individuals_construct (FOLKS_INSPECT_COMMANDS_TYPE_INDIVIDUALS, client);
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 ("");
144
static void __lambda6__gh_func (gconstpointer key, gconstpointer value, gpointer self) {
145
_lambda6_ (key, value, self);
149
static gpointer _g_object_ref0 (gpointer self) {
150
return self ? g_object_ref (self) : NULL;
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);
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_);
174
if (individual == NULL) {
175
folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", command_string);
176
_g_object_unref0 (individual);
179
folks_inspect_utils_print_individual (individual, TRUE);
180
_g_object_unref0 (individual);
185
static gchar* _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
187
result = folks_inspect_utils_individual_id_completion_cb (str, a);
192
static gchar** _vala_array_dup3 (gchar** self, int length) {
195
result = g_new0 (gchar*, length + 1);
196
for (i = 0; i < length; i++) {
197
result[i] = g_strdup (self[i]);
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;
207
gchar** _tmp1_ = NULL;
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_)));
216
*result_length1 = _vala_array_length (_tmp0_);
222
static const gchar* folks_inspect_commands_individuals_real_get_name (FolksInspectCommand* base) {
224
FolksInspectCommandsIndividuals* self;
225
self = (FolksInspectCommandsIndividuals*) base;
226
result = "individuals";
231
static const gchar* folks_inspect_commands_individuals_real_get_description (FolksInspectCommand* base) {
233
FolksInspectCommandsIndividuals* self;
234
self = (FolksInspectCommandsIndividuals*) base;
235
result = "Inspect the individuals currently present in the aggregator";
240
static const gchar* folks_inspect_commands_individuals_real_get_help (FolksInspectCommand* base) {
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.";
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;
259
static void folks_inspect_commands_individuals_instance_init (FolksInspectCommandsIndividuals * self) {
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);
271
return folks_inspect_commands_individuals_type_id__volatile;
275
static gint _vala_array_length (gpointer array) {
279
while (((gpointer*) array)[length]) {