1
/* Generated by GOB (v2.0.15) (do not edit directly) */
3
/* End world hunger, donate to the World Food Programme, http://www.wfp.org */
5
#define GOB_VERSION_MAJOR 2
6
#define GOB_VERSION_MINOR 0
7
#define GOB_VERSION_PATCHLEVEL 15
9
#define selfp (self->_priv)
11
#include <string.h> /* memset() */
15
#include "lm-shell-private.h"
18
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
19
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
20
#else /* ! G_LIKELY */
21
#define ___GOB_LIKELY(expr) (expr)
22
#define ___GOB_UNLIKELY(expr) (expr)
25
#line 37 "src/lm-shell.gob"
30
#include <glib/gi18n.h>
31
#include "lm-applet.h"
41
LMShell *lm_shell = NULL;
44
/* self casting macros */
45
#define SELF(x) LM_SHELL(x)
46
#define SELF_CONST(x) LM_SHELL_CONST(x)
47
#define IS_SELF(x) LM_IS_SHELL(x)
48
#define TYPE_SELF LM_TYPE_SHELL
49
#define SELF_CLASS(x) LM_SHELL_CLASS(x)
51
#define SELF_GET_CLASS(x) LM_SHELL_GET_CLASS(x)
55
typedef LMShellClass SelfClass;
57
/* here are local prototypes */
58
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
59
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
60
#line 0 "src/lm-shell.gob"
61
static void lm_shell_init (LMShell * o);
63
#line 0 "src/lm-shell.gob"
64
static void lm_shell_class_init (LMShellClass * c);
66
#line 80 "src/lm-shell.gob"
67
static void lm_shell_constructor (LMShell * self);
69
#line 98 "src/lm-shell.gob"
70
static void lm_shell_init_socket (LMShell * self, LMSocket * sock);
72
#line 123 "src/lm-shell.gob"
73
static gboolean lm_shell_socket_watch_cb (GIOChannel * source, GIOCondition condition, gpointer data);
75
#line 146 "src/lm-shell.gob"
76
static LMHost * lm_shell_get_host (LMShell * self, int host_id);
85
/* pointer to the class of our parent */
86
static GObjectClass *parent_class = NULL;
88
/* Short form macros */
89
#define self_get_host_count lm_shell_get_host_count
90
#define self_init_socket lm_shell_init_socket
91
#define self_socket_watch_cb lm_shell_socket_watch_cb
92
#define self_get_host lm_shell_get_host
93
#define self_allocate_host_id lm_shell_allocate_host_id
94
#define self_deallocate_host_id lm_shell_deallocate_host_id
95
#define self_get_socket lm_shell_get_socket
96
#define self_new lm_shell_new
98
lm_shell_get_type (void)
100
static GType type = 0;
102
if ___GOB_UNLIKELY(type == 0) {
103
static const GTypeInfo info = {
104
sizeof (LMShellClass),
105
(GBaseInitFunc) NULL,
106
(GBaseFinalizeFunc) NULL,
107
(GClassInitFunc) lm_shell_class_init,
108
(GClassFinalizeFunc) NULL,
109
NULL /* class_data */,
112
(GInstanceInitFunc) lm_shell_init,
116
type = g_type_register_static (G_TYPE_OBJECT, "LMShell", &info, (GTypeFlags)0);
122
/* a macro for creating a new object of our type */
123
#define GET_NEW ((LMShell *)g_object_new(lm_shell_get_type(), NULL))
125
/* a function for creating a new object of our type */
127
static LMShell * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
129
GET_NEW_VARG (const char *first, ...)
133
va_start (ap, first);
134
ret = (LMShell *)g_object_new_valist (lm_shell_get_type (), first, ap);
141
___constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
143
#define __GOB_FUNCTION__ "LM:Shell::constructor"
146
obj_self = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_properties);
147
self = LM_SHELL (obj_self);
148
#line 80 "src/lm-shell.gob"
149
lm_shell_constructor (self);
150
#line 151 "lm-shell.c"
153
#undef __GOB_FUNCTION__
157
___finalize(GObject *obj_self)
159
#define __GOB_FUNCTION__ "LM:Shell::finalize"
160
LMShell *self G_GNUC_UNUSED = LM_SHELL (obj_self);
161
gpointer priv G_GNUC_UNUSED = self->_priv;
162
if(G_OBJECT_CLASS(parent_class)->finalize) \
163
(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
165
#undef __GOB_FUNCTION__
168
lm_shell_init (LMShell * o G_GNUC_UNUSED)
170
#define __GOB_FUNCTION__ "LM:Shell::init"
171
o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,LM_TYPE_SHELL,LMShellPrivate);
173
#undef __GOB_FUNCTION__
175
lm_shell_class_init (LMShellClass * c G_GNUC_UNUSED)
177
#define __GOB_FUNCTION__ "LM:Shell::class_init"
178
GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
180
g_type_class_add_private(c,sizeof(LMShellPrivate));
182
parent_class = g_type_class_ref (G_TYPE_OBJECT);
184
g_object_class->constructor = ___constructor;
185
g_object_class->finalize = ___finalize;
186
g_object_class->get_property = ___object_get_property;
187
g_object_class->set_property = ___object_set_property;
189
GParamSpec *param_spec;
191
param_spec = g_param_spec_pointer
192
("sockets" /* name */,
195
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
196
g_object_class_install_property (g_object_class,
199
param_spec = g_param_spec_int
200
("host_count" /* name */,
203
G_MININT /* minimum */,
204
G_MAXINT /* maximum */,
205
0 /* default_value */,
206
(GParamFlags)(G_PARAM_READABLE));
207
g_object_class_install_property (g_object_class,
212
#undef __GOB_FUNCTION__
215
___object_set_property (GObject *object,
217
const GValue *VAL G_GNUC_UNUSED,
218
GParamSpec *pspec G_GNUC_UNUSED)
219
#define __GOB_FUNCTION__ "LM:Shell::set_property"
221
LMShell *self G_GNUC_UNUSED;
223
self = LM_SHELL (object);
225
switch (property_id) {
228
#line 60 "src/lm-shell.gob"
229
self->_priv->sockets = g_value_get_pointer (VAL);
230
#line 231 "lm-shell.c"
234
/* Apparently in g++ this is needed, glib is b0rk */
235
#ifndef __PRETTY_FUNCTION__
237
# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
239
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
243
#undef __GOB_FUNCTION__
246
___object_get_property (GObject *object,
248
GValue *VAL G_GNUC_UNUSED,
249
GParamSpec *pspec G_GNUC_UNUSED)
250
#define __GOB_FUNCTION__ "LM:Shell::get_property"
252
LMShell *self G_GNUC_UNUSED;
254
self = LM_SHELL (object);
256
switch (property_id) {
259
#line 60 "src/lm-shell.gob"
260
g_value_set_pointer (VAL, self->_priv->sockets);
261
#line 262 "lm-shell.c"
264
case PROP_HOST_COUNT:
266
#line 69 "src/lm-shell.gob"
271
for (i = 0; i < G_N_ELEMENTS(selfp->hosts); i++)
275
g_value_set_int(VAL, count);
277
#line 278 "lm-shell.c"
281
/* Apparently in g++ this is needed, glib is b0rk */
282
#ifndef __PRETTY_FUNCTION__
284
# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
286
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
290
#undef __GOB_FUNCTION__
294
#line 69 "src/lm-shell.gob"
296
lm_shell_get_host_count (LMShell * self)
298
#line 299 "lm-shell.c"
299
#define __GOB_FUNCTION__ "LM:Shell::get_host_count"
301
#line 67 "src/lm-shell.gob"
302
gint val; g_object_get (G_OBJECT (self), "host_count", &val, NULL); return val;
304
#line 305 "lm-shell.c"
305
#undef __GOB_FUNCTION__
307
#line 80 "src/lm-shell.gob"
309
lm_shell_constructor (LMShell * self)
311
#line 312 "lm-shell.c"
312
#define __GOB_FUNCTION__ "LM:Shell::constructor"
314
#line 81 "src/lm-shell.gob"
318
g_assert(lm_shell == NULL);
321
lm_add_weak_pointer(&lm_shell);
323
/* unique identifier for our ICMP packets */
324
self->icmp_ident = getpid() & 0xffff;
326
LM_LIST_FOREACH(l, selfp->sockets)
327
self_init_socket(self, l->data);
329
self->tooltips = lm_tooltips_new();
331
#line 332 "lm-shell.c"
332
#undef __GOB_FUNCTION__
334
#line 98 "src/lm-shell.gob"
336
lm_shell_init_socket (LMShell * self, LMSocket * sock)
338
#line 339 "lm-shell.c"
339
#define __GOB_FUNCTION__ "LM:Shell::init_socket"
340
#line 98 "src/lm-shell.gob"
341
g_return_if_fail (self != NULL);
342
#line 98 "src/lm-shell.gob"
343
g_return_if_fail (LM_IS_SHELL (self));
344
#line 98 "src/lm-shell.gob"
345
g_return_if_fail (sock != NULL);
346
#line 347 "lm-shell.c"
348
#line 100 "src/lm-shell.gob"
350
if (! sock->init_error)
354
flags = fcntl(sock->desc, F_GETFL, 0);
355
if (fcntl(sock->desc, F_SETFL, flags | O_NONBLOCK) < 0)
356
sock->init_error = g_strdup_printf(_("unable to set O_NONBLOCK flag: %s"), g_strerror(errno));
362
info = g_new0(WatchInfo, 1);
366
channel = g_io_channel_unix_new(sock->desc);
367
g_io_add_watch_full(channel, G_PRIORITY_HIGH, G_IO_IN, self_socket_watch_cb, info, NULL);
371
#line 372 "lm-shell.c"
372
#undef __GOB_FUNCTION__
374
#line 123 "src/lm-shell.gob"
376
lm_shell_socket_watch_cb (GIOChannel * source, GIOCondition condition, gpointer data)
378
#line 379 "lm-shell.c"
379
#define __GOB_FUNCTION__ "LM:Shell::socket_watch_cb"
381
#line 125 "src/lm-shell.gob"
383
WatchInfo *info = data;
384
Self *self = info->self;
387
if (lm_icmp_reply_get(info->sock, &reply))
391
host = self_get_host(self, reply.host_id);
395
lm_host_reply_received(host, &reply);
400
return TRUE; /* keep source */
402
#line 403 "lm-shell.c"
403
#undef __GOB_FUNCTION__
405
#line 146 "src/lm-shell.gob"
407
lm_shell_get_host (LMShell * self, int host_id)
409
#line 410 "lm-shell.c"
410
#define __GOB_FUNCTION__ "LM:Shell::get_host"
411
#line 146 "src/lm-shell.gob"
412
g_return_val_if_fail (self != NULL, (LMHost * )0);
413
#line 146 "src/lm-shell.gob"
414
g_return_val_if_fail (LM_IS_SHELL (self), (LMHost * )0);
415
#line 146 "src/lm-shell.gob"
416
g_return_val_if_fail (host_id >= 0, (LMHost * )0);
417
#line 146 "src/lm-shell.gob"
418
g_return_val_if_fail (host_id < LM_MAX_HOSTS, (LMHost * )0);
419
#line 420 "lm-shell.c"
421
#line 148 "src/lm-shell.gob"
423
return selfp->hosts[host_id];
425
#line 426 "lm-shell.c"
426
#undef __GOB_FUNCTION__
428
#line 152 "src/lm-shell.gob"
430
lm_shell_allocate_host_id (LMShell * self, LMHost * host)
432
#line 433 "lm-shell.c"
433
#define __GOB_FUNCTION__ "LM:Shell::allocate_host_id"
434
#line 152 "src/lm-shell.gob"
435
g_return_val_if_fail (self != NULL, (int )0);
436
#line 152 "src/lm-shell.gob"
437
g_return_val_if_fail (LM_IS_SHELL (self), (int )0);
438
#line 152 "src/lm-shell.gob"
439
g_return_val_if_fail (host != NULL, (int )0);
440
#line 152 "src/lm-shell.gob"
441
g_return_val_if_fail (LM_IS_HOST (host), (int )0);
442
#line 443 "lm-shell.c"
444
#line 154 "src/lm-shell.gob"
448
for (host_id = 0; host_id < G_N_ELEMENTS(selfp->hosts); host_id++)
449
if (! selfp->hosts[host_id])
451
selfp->hosts[host_id] = host;
452
g_object_notify(G_OBJECT(self), "host-count");
456
g_assert_not_reached();
459
#line 460 "lm-shell.c"
460
#undef __GOB_FUNCTION__
462
#line 169 "src/lm-shell.gob"
464
lm_shell_deallocate_host_id (LMShell * self, int host_id)
466
#line 467 "lm-shell.c"
467
#define __GOB_FUNCTION__ "LM:Shell::deallocate_host_id"
468
#line 169 "src/lm-shell.gob"
469
g_return_if_fail (self != NULL);
470
#line 169 "src/lm-shell.gob"
471
g_return_if_fail (LM_IS_SHELL (self));
472
#line 473 "lm-shell.c"
474
#line 171 "src/lm-shell.gob"
476
g_return_if_fail(selfp->hosts[host_id] != NULL);
478
selfp->hosts[host_id] = NULL;
479
g_object_notify(G_OBJECT(self), "host-count");
481
#line 482 "lm-shell.c"
482
#undef __GOB_FUNCTION__
484
#line 178 "src/lm-shell.gob"
486
lm_shell_get_socket (LMShell * self, int domain)
488
#line 489 "lm-shell.c"
489
#define __GOB_FUNCTION__ "LM:Shell::get_socket"
490
#line 178 "src/lm-shell.gob"
491
g_return_val_if_fail (self != NULL, (const LMSocket * )0);
492
#line 178 "src/lm-shell.gob"
493
g_return_val_if_fail (LM_IS_SHELL (self), (const LMSocket * )0);
494
#line 495 "lm-shell.c"
496
#line 180 "src/lm-shell.gob"
500
LM_LIST_FOREACH(l, selfp->sockets)
502
const LMSocket *sock = l->data;
504
if (sock->domain == domain)
510
#line 511 "lm-shell.c"
511
#undef __GOB_FUNCTION__
513
#line 194 "src/lm-shell.gob"
515
lm_shell_new (GSList * sockets)
517
#line 518 "lm-shell.c"
518
#define __GOB_FUNCTION__ "LM:Shell::new"
520
#line 196 "src/lm-shell.gob"
522
return GET_NEW_VARG(LM_SHELL_PROP_SOCKETS(sockets), NULL);
524
#line 525 "lm-shell.c"
525
#undef __GOB_FUNCTION__