blob: ea1ce08d67a3e90e9936b177f20be12c0beb5895 [file] [log] [blame]
Norman Jamese2765102015-08-19 22:00:55 -05001/*
2 * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
3 *
4 * The license of this code is the same as for the source it was derived from.
5 */
6
7#ifdef HAVE_CONFIG_H
8# include "config.h"
9#endif
10
11#include "interfaces/power_control.h"
12
13#include <string.h>
14#ifdef G_OS_UNIX
15# include <gio/gunixfdlist.h>
16#endif
17
18typedef struct
19{
20 GDBusArgInfo parent_struct;
21 gboolean use_gvariant;
22} _ExtendedGDBusArgInfo;
23
24typedef struct
25{
26 GDBusMethodInfo parent_struct;
27 const gchar *signal_name;
28 gboolean pass_fdlist;
29} _ExtendedGDBusMethodInfo;
30
31typedef struct
32{
33 GDBusSignalInfo parent_struct;
34 const gchar *signal_name;
35} _ExtendedGDBusSignalInfo;
36
37typedef struct
38{
39 GDBusPropertyInfo parent_struct;
40 const gchar *hyphen_name;
41 gboolean use_gvariant;
42} _ExtendedGDBusPropertyInfo;
43
44typedef struct
45{
46 GDBusInterfaceInfo parent_struct;
47 const gchar *hyphen_name;
48} _ExtendedGDBusInterfaceInfo;
49
50typedef struct
51{
52 const _ExtendedGDBusPropertyInfo *info;
53 guint prop_id;
54 GValue orig_value; /* the value before the change */
55} ChangedProperty;
56
57static void
58_changed_property_free (ChangedProperty *data)
59{
60 g_value_unset (&data->orig_value);
61 g_free (data);
62}
63
64static gboolean
65_g_strv_equal0 (gchar **a, gchar **b)
66{
67 gboolean ret = FALSE;
68 guint n;
69 if (a == NULL && b == NULL)
70 {
71 ret = TRUE;
72 goto out;
73 }
74 if (a == NULL || b == NULL)
75 goto out;
76 if (g_strv_length (a) != g_strv_length (b))
77 goto out;
78 for (n = 0; a[n] != NULL; n++)
79 if (g_strcmp0 (a[n], b[n]) != 0)
80 goto out;
81 ret = TRUE;
82out:
83 return ret;
84}
85
86static gboolean
87_g_variant_equal0 (GVariant *a, GVariant *b)
88{
89 gboolean ret = FALSE;
90 if (a == NULL && b == NULL)
91 {
92 ret = TRUE;
93 goto out;
94 }
95 if (a == NULL || b == NULL)
96 goto out;
97 ret = g_variant_equal (a, b);
98out:
99 return ret;
100}
101
102G_GNUC_UNUSED static gboolean
103_g_value_equal (const GValue *a, const GValue *b)
104{
105 gboolean ret = FALSE;
106 g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
107 switch (G_VALUE_TYPE (a))
108 {
109 case G_TYPE_BOOLEAN:
110 ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
111 break;
112 case G_TYPE_UCHAR:
113 ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
114 break;
115 case G_TYPE_INT:
116 ret = (g_value_get_int (a) == g_value_get_int (b));
117 break;
118 case G_TYPE_UINT:
119 ret = (g_value_get_uint (a) == g_value_get_uint (b));
120 break;
121 case G_TYPE_INT64:
122 ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
123 break;
124 case G_TYPE_UINT64:
125 ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
126 break;
127 case G_TYPE_DOUBLE:
128 {
129 /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
130 gdouble da = g_value_get_double (a);
131 gdouble db = g_value_get_double (b);
132 ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
133 }
134 break;
135 case G_TYPE_STRING:
136 ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
137 break;
138 case G_TYPE_VARIANT:
139 ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
140 break;
141 default:
142 if (G_VALUE_TYPE (a) == G_TYPE_STRV)
143 ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
144 else
145 g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
146 break;
147 }
148 return ret;
149}
150
151/* ------------------------------------------------------------------------
152 * Code for interface org.openbmc.PowerControl
153 * ------------------------------------------------------------------------
154 */
155
156/**
157 * SECTION:PowerControl
158 * @title: PowerControl
159 * @short_description: Generated C code for the org.openbmc.PowerControl D-Bus interface
160 *
161 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link> D-Bus interface in C.
162 */
163
164/* ---- Introspection data for org.openbmc.PowerControl ---- */
165
166static const _ExtendedGDBusArgInfo _power_control_method_info_set_power_state_IN_ARG_state =
167{
168 {
169 -1,
170 (gchar *) "state",
171 (gchar *) "i",
172 NULL
173 },
174 FALSE
175};
176
177static const _ExtendedGDBusArgInfo * const _power_control_method_info_set_power_state_IN_ARG_pointers[] =
178{
179 &_power_control_method_info_set_power_state_IN_ARG_state,
180 NULL
181};
182
183static const _ExtendedGDBusMethodInfo _power_control_method_info_set_power_state =
184{
185 {
186 -1,
187 (gchar *) "setPowerState",
188 (GDBusArgInfo **) &_power_control_method_info_set_power_state_IN_ARG_pointers,
189 NULL,
190 NULL
191 },
192 "handle-set-power-state",
193 FALSE
194};
195
196static const _ExtendedGDBusArgInfo _power_control_method_info_get_power_state_OUT_ARG_state =
197{
198 {
199 -1,
200 (gchar *) "state",
201 (gchar *) "i",
202 NULL
203 },
204 FALSE
205};
206
207static const _ExtendedGDBusArgInfo * const _power_control_method_info_get_power_state_OUT_ARG_pointers[] =
208{
209 &_power_control_method_info_get_power_state_OUT_ARG_state,
210 NULL
211};
212
213static const _ExtendedGDBusMethodInfo _power_control_method_info_get_power_state =
214{
215 {
216 -1,
217 (gchar *) "getPowerState",
218 NULL,
219 (GDBusArgInfo **) &_power_control_method_info_get_power_state_OUT_ARG_pointers,
220 NULL
221 },
222 "handle-get-power-state",
223 FALSE
224};
225
226static const _ExtendedGDBusMethodInfo * const _power_control_method_info_pointers[] =
227{
228 &_power_control_method_info_set_power_state,
229 &_power_control_method_info_get_power_state,
230 NULL
231};
232
233static const _ExtendedGDBusSignalInfo _power_control_signal_info_power_good =
234{
235 {
236 -1,
237 (gchar *) "PowerGood",
238 NULL,
239 NULL
240 },
241 "power-good"
242};
243
244static const _ExtendedGDBusSignalInfo _power_control_signal_info_power_lost =
245{
246 {
247 -1,
248 (gchar *) "PowerLost",
249 NULL,
250 NULL
251 },
252 "power-lost"
253};
254
255static const _ExtendedGDBusSignalInfo * const _power_control_signal_info_pointers[] =
256{
257 &_power_control_signal_info_power_good,
258 &_power_control_signal_info_power_lost,
259 NULL
260};
261
262static const _ExtendedGDBusPropertyInfo _power_control_property_info_pgood =
263{
264 {
265 -1,
266 (gchar *) "pgood",
267 (gchar *) "i",
268 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
269 NULL
270 },
271 "pgood",
272 FALSE
273};
274
275static const _ExtendedGDBusPropertyInfo _power_control_property_info_state =
276{
277 {
278 -1,
279 (gchar *) "state",
280 (gchar *) "i",
281 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
282 NULL
283 },
284 "state",
285 FALSE
286};
287
288static const _ExtendedGDBusPropertyInfo * const _power_control_property_info_pointers[] =
289{
290 &_power_control_property_info_pgood,
291 &_power_control_property_info_state,
292 NULL
293};
294
295static const _ExtendedGDBusInterfaceInfo _power_control_interface_info =
296{
297 {
298 -1,
299 (gchar *) "org.openbmc.PowerControl",
300 (GDBusMethodInfo **) &_power_control_method_info_pointers,
301 (GDBusSignalInfo **) &_power_control_signal_info_pointers,
302 (GDBusPropertyInfo **) &_power_control_property_info_pointers,
303 NULL
304 },
305 "power-control",
306};
307
308
309/**
310 * power_control_interface_info:
311 *
312 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link> D-Bus interface.
313 *
314 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
315 */
316GDBusInterfaceInfo *
317power_control_interface_info (void)
318{
319 return (GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct;
320}
321
322/**
323 * power_control_override_properties:
324 * @klass: The class structure for a #GObject<!-- -->-derived class.
325 * @property_id_begin: The property id to assign to the first overridden property.
326 *
327 * Overrides all #GObject properties in the #PowerControl interface for a concrete class.
328 * The properties are overridden in the order they are defined.
329 *
330 * Returns: The last property id.
331 */
332guint
333power_control_override_properties (GObjectClass *klass, guint property_id_begin)
334{
335 g_object_class_override_property (klass, property_id_begin++, "pgood");
336 g_object_class_override_property (klass, property_id_begin++, "state");
337 return property_id_begin - 1;
338}
339
340
341
342/**
343 * PowerControl:
344 *
345 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>.
346 */
347
348/**
349 * PowerControlIface:
350 * @parent_iface: The parent interface.
351 * @handle_get_power_state: Handler for the #PowerControl::handle-get-power-state signal.
352 * @handle_set_power_state: Handler for the #PowerControl::handle-set-power-state signal.
353 * @get_pgood: Getter for the #PowerControl:pgood property.
354 * @get_state: Getter for the #PowerControl:state property.
355 * @power_good: Handler for the #PowerControl::power-good signal.
356 * @power_lost: Handler for the #PowerControl::power-lost signal.
357 *
358 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>.
359 */
360
361typedef PowerControlIface PowerControlInterface;
362G_DEFINE_INTERFACE (PowerControl, power_control, G_TYPE_OBJECT);
363
364static void
365power_control_default_init (PowerControlIface *iface)
366{
367 /* GObject signals for incoming D-Bus method calls: */
368 /**
369 * PowerControl::handle-set-power-state:
370 * @object: A #PowerControl.
371 * @invocation: A #GDBusMethodInvocation.
372 * @arg_state: Argument passed by remote caller.
373 *
374 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-PowerControl.setPowerState">setPowerState()</link> D-Bus method.
375 *
376 * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call power_control_complete_set_power_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
377 *
378 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
379 */
380 g_signal_new ("handle-set-power-state",
381 G_TYPE_FROM_INTERFACE (iface),
382 G_SIGNAL_RUN_LAST,
383 G_STRUCT_OFFSET (PowerControlIface, handle_set_power_state),
384 g_signal_accumulator_true_handled,
385 NULL,
386 g_cclosure_marshal_generic,
387 G_TYPE_BOOLEAN,
388 2,
389 G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT);
390
391 /**
392 * PowerControl::handle-get-power-state:
393 * @object: A #PowerControl.
394 * @invocation: A #GDBusMethodInvocation.
395 *
396 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-PowerControl.getPowerState">getPowerState()</link> D-Bus method.
397 *
398 * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call power_control_complete_get_power_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
399 *
400 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
401 */
402 g_signal_new ("handle-get-power-state",
403 G_TYPE_FROM_INTERFACE (iface),
404 G_SIGNAL_RUN_LAST,
405 G_STRUCT_OFFSET (PowerControlIface, handle_get_power_state),
406 g_signal_accumulator_true_handled,
407 NULL,
408 g_cclosure_marshal_generic,
409 G_TYPE_BOOLEAN,
410 1,
411 G_TYPE_DBUS_METHOD_INVOCATION);
412
413 /* GObject signals for received D-Bus signals: */
414 /**
415 * PowerControl::power-good:
416 * @object: A #PowerControl.
417 *
418 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-PowerControl.PowerGood">"PowerGood"</link> is received.
419 *
420 * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
421 */
422 g_signal_new ("power-good",
423 G_TYPE_FROM_INTERFACE (iface),
424 G_SIGNAL_RUN_LAST,
425 G_STRUCT_OFFSET (PowerControlIface, power_good),
426 NULL,
427 NULL,
428 g_cclosure_marshal_generic,
429 G_TYPE_NONE,
430 0);
431
432 /**
433 * PowerControl::power-lost:
434 * @object: A #PowerControl.
435 *
436 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-PowerControl.PowerLost">"PowerLost"</link> is received.
437 *
438 * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
439 */
440 g_signal_new ("power-lost",
441 G_TYPE_FROM_INTERFACE (iface),
442 G_SIGNAL_RUN_LAST,
443 G_STRUCT_OFFSET (PowerControlIface, power_lost),
444 NULL,
445 NULL,
446 g_cclosure_marshal_generic,
447 G_TYPE_NONE,
448 0);
449
450 /* GObject properties for D-Bus properties: */
451 /**
452 * PowerControl:pgood:
453 *
454 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-PowerControl.pgood">"pgood"</link>.
455 *
456 * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
457 */
458 g_object_interface_install_property (iface,
459 g_param_spec_int ("pgood", "pgood", "pgood", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
460 /**
461 * PowerControl:state:
462 *
463 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-PowerControl.state">"state"</link>.
464 *
465 * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
466 */
467 g_object_interface_install_property (iface,
468 g_param_spec_int ("state", "state", "state", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
469}
470
471/**
472 * power_control_get_pgood: (skip)
473 * @object: A #PowerControl.
474 *
475 * Gets the value of the <link linkend="gdbus-property-org-openbmc-PowerControl.pgood">"pgood"</link> D-Bus property.
476 *
477 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
478 *
479 * Returns: The property value.
480 */
481gint
482power_control_get_pgood (PowerControl *object)
483{
484 return POWER_CONTROL_GET_IFACE (object)->get_pgood (object);
485}
486
487/**
488 * power_control_set_pgood: (skip)
489 * @object: A #PowerControl.
490 * @value: The value to set.
491 *
492 * Sets the <link linkend="gdbus-property-org-openbmc-PowerControl.pgood">"pgood"</link> D-Bus property to @value.
493 *
494 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
495 */
496void
497power_control_set_pgood (PowerControl *object, gint value)
498{
499 g_object_set (G_OBJECT (object), "pgood", value, NULL);
500}
501
502/**
503 * power_control_get_state: (skip)
504 * @object: A #PowerControl.
505 *
506 * Gets the value of the <link linkend="gdbus-property-org-openbmc-PowerControl.state">"state"</link> D-Bus property.
507 *
508 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
509 *
510 * Returns: The property value.
511 */
512gint
513power_control_get_state (PowerControl *object)
514{
515 return POWER_CONTROL_GET_IFACE (object)->get_state (object);
516}
517
518/**
519 * power_control_set_state: (skip)
520 * @object: A #PowerControl.
521 * @value: The value to set.
522 *
523 * Sets the <link linkend="gdbus-property-org-openbmc-PowerControl.state">"state"</link> D-Bus property to @value.
524 *
525 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
526 */
527void
528power_control_set_state (PowerControl *object, gint value)
529{
530 g_object_set (G_OBJECT (object), "state", value, NULL);
531}
532
533/**
534 * power_control_emit_power_good:
535 * @object: A #PowerControl.
536 *
537 * Emits the <link linkend="gdbus-signal-org-openbmc-PowerControl.PowerGood">"PowerGood"</link> D-Bus signal.
538 */
539void
540power_control_emit_power_good (
541 PowerControl *object)
542{
543 g_signal_emit_by_name (object, "power-good");
544}
545
546/**
547 * power_control_emit_power_lost:
548 * @object: A #PowerControl.
549 *
550 * Emits the <link linkend="gdbus-signal-org-openbmc-PowerControl.PowerLost">"PowerLost"</link> D-Bus signal.
551 */
552void
553power_control_emit_power_lost (
554 PowerControl *object)
555{
556 g_signal_emit_by_name (object, "power-lost");
557}
558
559/**
560 * power_control_call_set_power_state:
561 * @proxy: A #PowerControlProxy.
562 * @arg_state: Argument to pass with the method invocation.
563 * @cancellable: (allow-none): A #GCancellable or %NULL.
564 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
565 * @user_data: User data to pass to @callback.
566 *
567 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-PowerControl.setPowerState">setPowerState()</link> D-Bus method on @proxy.
568 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
569 * You can then call power_control_call_set_power_state_finish() to get the result of the operation.
570 *
571 * See power_control_call_set_power_state_sync() for the synchronous, blocking version of this method.
572 */
573void
574power_control_call_set_power_state (
575 PowerControl *proxy,
576 gint arg_state,
577 GCancellable *cancellable,
578 GAsyncReadyCallback callback,
579 gpointer user_data)
580{
581 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
582 "setPowerState",
583 g_variant_new ("(i)",
584 arg_state),
585 G_DBUS_CALL_FLAGS_NONE,
586 -1,
587 cancellable,
588 callback,
589 user_data);
590}
591
592/**
593 * power_control_call_set_power_state_finish:
594 * @proxy: A #PowerControlProxy.
595 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to power_control_call_set_power_state().
596 * @error: Return location for error or %NULL.
597 *
598 * Finishes an operation started with power_control_call_set_power_state().
599 *
600 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
601 */
602gboolean
603power_control_call_set_power_state_finish (
604 PowerControl *proxy,
605 GAsyncResult *res,
606 GError **error)
607{
608 GVariant *_ret;
609 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
610 if (_ret == NULL)
611 goto _out;
612 g_variant_get (_ret,
613 "()");
614 g_variant_unref (_ret);
615_out:
616 return _ret != NULL;
617}
618
619/**
620 * power_control_call_set_power_state_sync:
621 * @proxy: A #PowerControlProxy.
622 * @arg_state: Argument to pass with the method invocation.
623 * @cancellable: (allow-none): A #GCancellable or %NULL.
624 * @error: Return location for error or %NULL.
625 *
626 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-PowerControl.setPowerState">setPowerState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
627 *
628 * See power_control_call_set_power_state() for the asynchronous version of this method.
629 *
630 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
631 */
632gboolean
633power_control_call_set_power_state_sync (
634 PowerControl *proxy,
635 gint arg_state,
636 GCancellable *cancellable,
637 GError **error)
638{
639 GVariant *_ret;
640 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
641 "setPowerState",
642 g_variant_new ("(i)",
643 arg_state),
644 G_DBUS_CALL_FLAGS_NONE,
645 -1,
646 cancellable,
647 error);
648 if (_ret == NULL)
649 goto _out;
650 g_variant_get (_ret,
651 "()");
652 g_variant_unref (_ret);
653_out:
654 return _ret != NULL;
655}
656
657/**
658 * power_control_call_get_power_state:
659 * @proxy: A #PowerControlProxy.
660 * @cancellable: (allow-none): A #GCancellable or %NULL.
661 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
662 * @user_data: User data to pass to @callback.
663 *
664 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-PowerControl.getPowerState">getPowerState()</link> D-Bus method on @proxy.
665 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
666 * You can then call power_control_call_get_power_state_finish() to get the result of the operation.
667 *
668 * See power_control_call_get_power_state_sync() for the synchronous, blocking version of this method.
669 */
670void
671power_control_call_get_power_state (
672 PowerControl *proxy,
673 GCancellable *cancellable,
674 GAsyncReadyCallback callback,
675 gpointer user_data)
676{
677 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
678 "getPowerState",
679 g_variant_new ("()"),
680 G_DBUS_CALL_FLAGS_NONE,
681 -1,
682 cancellable,
683 callback,
684 user_data);
685}
686
687/**
688 * power_control_call_get_power_state_finish:
689 * @proxy: A #PowerControlProxy.
690 * @out_state: (out): Return location for return parameter or %NULL to ignore.
691 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to power_control_call_get_power_state().
692 * @error: Return location for error or %NULL.
693 *
694 * Finishes an operation started with power_control_call_get_power_state().
695 *
696 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
697 */
698gboolean
699power_control_call_get_power_state_finish (
700 PowerControl *proxy,
701 gint *out_state,
702 GAsyncResult *res,
703 GError **error)
704{
705 GVariant *_ret;
706 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
707 if (_ret == NULL)
708 goto _out;
709 g_variant_get (_ret,
710 "(i)",
711 out_state);
712 g_variant_unref (_ret);
713_out:
714 return _ret != NULL;
715}
716
717/**
718 * power_control_call_get_power_state_sync:
719 * @proxy: A #PowerControlProxy.
720 * @out_state: (out): Return location for return parameter or %NULL to ignore.
721 * @cancellable: (allow-none): A #GCancellable or %NULL.
722 * @error: Return location for error or %NULL.
723 *
724 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-PowerControl.getPowerState">getPowerState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
725 *
726 * See power_control_call_get_power_state() for the asynchronous version of this method.
727 *
728 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
729 */
730gboolean
731power_control_call_get_power_state_sync (
732 PowerControl *proxy,
733 gint *out_state,
734 GCancellable *cancellable,
735 GError **error)
736{
737 GVariant *_ret;
738 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
739 "getPowerState",
740 g_variant_new ("()"),
741 G_DBUS_CALL_FLAGS_NONE,
742 -1,
743 cancellable,
744 error);
745 if (_ret == NULL)
746 goto _out;
747 g_variant_get (_ret,
748 "(i)",
749 out_state);
750 g_variant_unref (_ret);
751_out:
752 return _ret != NULL;
753}
754
755/**
756 * power_control_complete_set_power_state:
757 * @object: A #PowerControl.
758 * @invocation: (transfer full): A #GDBusMethodInvocation.
759 *
760 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-PowerControl.setPowerState">setPowerState()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
761 *
762 * This method will free @invocation, you cannot use it afterwards.
763 */
764void
765power_control_complete_set_power_state (
766 PowerControl *object,
767 GDBusMethodInvocation *invocation)
768{
769 g_dbus_method_invocation_return_value (invocation,
770 g_variant_new ("()"));
771}
772
773/**
774 * power_control_complete_get_power_state:
775 * @object: A #PowerControl.
776 * @invocation: (transfer full): A #GDBusMethodInvocation.
777 * @state: Parameter to return.
778 *
779 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-PowerControl.getPowerState">getPowerState()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
780 *
781 * This method will free @invocation, you cannot use it afterwards.
782 */
783void
784power_control_complete_get_power_state (
785 PowerControl *object,
786 GDBusMethodInvocation *invocation,
787 gint state)
788{
789 g_dbus_method_invocation_return_value (invocation,
790 g_variant_new ("(i)",
791 state));
792}
793
794/* ------------------------------------------------------------------------ */
795
796/**
797 * PowerControlProxy:
798 *
799 * The #PowerControlProxy structure contains only private data and should only be accessed using the provided API.
800 */
801
802/**
803 * PowerControlProxyClass:
804 * @parent_class: The parent class.
805 *
806 * Class structure for #PowerControlProxy.
807 */
808
809struct _PowerControlProxyPrivate
810{
811 GData *qdata;
812};
813
814static void power_control_proxy_iface_init (PowerControlIface *iface);
815
816#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
817G_DEFINE_TYPE_WITH_CODE (PowerControlProxy, power_control_proxy, G_TYPE_DBUS_PROXY,
818 G_ADD_PRIVATE (PowerControlProxy)
819 G_IMPLEMENT_INTERFACE (TYPE_POWER_CONTROL, power_control_proxy_iface_init));
820
821#else
822G_DEFINE_TYPE_WITH_CODE (PowerControlProxy, power_control_proxy, G_TYPE_DBUS_PROXY,
823 G_IMPLEMENT_INTERFACE (TYPE_POWER_CONTROL, power_control_proxy_iface_init));
824
825#endif
826static void
827power_control_proxy_finalize (GObject *object)
828{
829 PowerControlProxy *proxy = POWER_CONTROL_PROXY (object);
830 g_datalist_clear (&proxy->priv->qdata);
831 G_OBJECT_CLASS (power_control_proxy_parent_class)->finalize (object);
832}
833
834static void
835power_control_proxy_get_property (GObject *object,
836 guint prop_id,
837 GValue *value,
838 GParamSpec *pspec G_GNUC_UNUSED)
839{
840 const _ExtendedGDBusPropertyInfo *info;
841 GVariant *variant;
842 g_assert (prop_id != 0 && prop_id - 1 < 2);
843 info = _power_control_property_info_pointers[prop_id - 1];
844 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
845 if (info->use_gvariant)
846 {
847 g_value_set_variant (value, variant);
848 }
849 else
850 {
851 if (variant != NULL)
852 g_dbus_gvariant_to_gvalue (variant, value);
853 }
854 if (variant != NULL)
855 g_variant_unref (variant);
856}
857
858static void
859power_control_proxy_set_property_cb (GDBusProxy *proxy,
860 GAsyncResult *res,
861 gpointer user_data)
862{
863 const _ExtendedGDBusPropertyInfo *info = user_data;
864 GError *error;
865 GVariant *_ret;
866 error = NULL;
867 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
868 if (!_ret)
869 {
870 g_warning ("Error setting property '%s' on interface org.openbmc.PowerControl: %s (%s, %d)",
871 info->parent_struct.name,
872 error->message, g_quark_to_string (error->domain), error->code);
873 g_error_free (error);
874 }
875 else
876 {
877 g_variant_unref (_ret);
878 }
879}
880
881static void
882power_control_proxy_set_property (GObject *object,
883 guint prop_id,
884 const GValue *value,
885 GParamSpec *pspec G_GNUC_UNUSED)
886{
887 const _ExtendedGDBusPropertyInfo *info;
888 GVariant *variant;
889 g_assert (prop_id != 0 && prop_id - 1 < 2);
890 info = _power_control_property_info_pointers[prop_id - 1];
891 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
892 g_dbus_proxy_call (G_DBUS_PROXY (object),
893 "org.freedesktop.DBus.Properties.Set",
894 g_variant_new ("(ssv)", "org.openbmc.PowerControl", info->parent_struct.name, variant),
895 G_DBUS_CALL_FLAGS_NONE,
896 -1,
897 NULL, (GAsyncReadyCallback) power_control_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
898 g_variant_unref (variant);
899}
900
901static void
902power_control_proxy_g_signal (GDBusProxy *proxy,
903 const gchar *sender_name G_GNUC_UNUSED,
904 const gchar *signal_name,
905 GVariant *parameters)
906{
907 _ExtendedGDBusSignalInfo *info;
908 GVariantIter iter;
909 GVariant *child;
910 GValue *paramv;
911 guint num_params;
912 guint n;
913 guint signal_id;
914 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct, signal_name);
915 if (info == NULL)
916 return;
917 num_params = g_variant_n_children (parameters);
918 paramv = g_new0 (GValue, num_params + 1);
919 g_value_init (&paramv[0], TYPE_POWER_CONTROL);
920 g_value_set_object (&paramv[0], proxy);
921 g_variant_iter_init (&iter, parameters);
922 n = 1;
923 while ((child = g_variant_iter_next_value (&iter)) != NULL)
924 {
925 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
926 if (arg_info->use_gvariant)
927 {
928 g_value_init (&paramv[n], G_TYPE_VARIANT);
929 g_value_set_variant (&paramv[n], child);
930 n++;
931 }
932 else
933 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
934 g_variant_unref (child);
935 }
936 signal_id = g_signal_lookup (info->signal_name, TYPE_POWER_CONTROL);
937 g_signal_emitv (paramv, signal_id, 0, NULL);
938 for (n = 0; n < num_params + 1; n++)
939 g_value_unset (&paramv[n]);
940 g_free (paramv);
941}
942
943static void
944power_control_proxy_g_properties_changed (GDBusProxy *_proxy,
945 GVariant *changed_properties,
946 const gchar *const *invalidated_properties)
947{
948 PowerControlProxy *proxy = POWER_CONTROL_PROXY (_proxy);
949 guint n;
950 const gchar *key;
951 GVariantIter *iter;
952 _ExtendedGDBusPropertyInfo *info;
953 g_variant_get (changed_properties, "a{sv}", &iter);
954 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
955 {
956 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct, key);
957 g_datalist_remove_data (&proxy->priv->qdata, key);
958 if (info != NULL)
959 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
960 }
961 g_variant_iter_free (iter);
962 for (n = 0; invalidated_properties[n] != NULL; n++)
963 {
964 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct, invalidated_properties[n]);
965 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
966 if (info != NULL)
967 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
968 }
969}
970
971static gint
972power_control_proxy_get_pgood (PowerControl *object)
973{
974 PowerControlProxy *proxy = POWER_CONTROL_PROXY (object);
975 GVariant *variant;
976 gint value = 0;
977 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "pgood");
978 if (variant != NULL)
979 {
980 value = g_variant_get_int32 (variant);
981 g_variant_unref (variant);
982 }
983 return value;
984}
985
986static gint
987power_control_proxy_get_state (PowerControl *object)
988{
989 PowerControlProxy *proxy = POWER_CONTROL_PROXY (object);
990 GVariant *variant;
991 gint value = 0;
992 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "state");
993 if (variant != NULL)
994 {
995 value = g_variant_get_int32 (variant);
996 g_variant_unref (variant);
997 }
998 return value;
999}
1000
1001static void
1002power_control_proxy_init (PowerControlProxy *proxy)
1003{
1004#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1005 proxy->priv = power_control_proxy_get_instance_private (proxy);
1006#else
1007 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_POWER_CONTROL_PROXY, PowerControlProxyPrivate);
1008#endif
1009
1010 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), power_control_interface_info ());
1011}
1012
1013static void
1014power_control_proxy_class_init (PowerControlProxyClass *klass)
1015{
1016 GObjectClass *gobject_class;
1017 GDBusProxyClass *proxy_class;
1018
1019 gobject_class = G_OBJECT_CLASS (klass);
1020 gobject_class->finalize = power_control_proxy_finalize;
1021 gobject_class->get_property = power_control_proxy_get_property;
1022 gobject_class->set_property = power_control_proxy_set_property;
1023
1024 proxy_class = G_DBUS_PROXY_CLASS (klass);
1025 proxy_class->g_signal = power_control_proxy_g_signal;
1026 proxy_class->g_properties_changed = power_control_proxy_g_properties_changed;
1027
1028 power_control_override_properties (gobject_class, 1);
1029
1030#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1031 g_type_class_add_private (klass, sizeof (PowerControlProxyPrivate));
1032#endif
1033}
1034
1035static void
1036power_control_proxy_iface_init (PowerControlIface *iface)
1037{
1038 iface->get_pgood = power_control_proxy_get_pgood;
1039 iface->get_state = power_control_proxy_get_state;
1040}
1041
1042/**
1043 * power_control_proxy_new:
1044 * @connection: A #GDBusConnection.
1045 * @flags: Flags from the #GDBusProxyFlags enumeration.
1046 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1047 * @object_path: An object path.
1048 * @cancellable: (allow-none): A #GCancellable or %NULL.
1049 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1050 * @user_data: User data to pass to @callback.
1051 *
1052 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>. See g_dbus_proxy_new() for more details.
1053 *
1054 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
1055 * You can then call power_control_proxy_new_finish() to get the result of the operation.
1056 *
1057 * See power_control_proxy_new_sync() for the synchronous, blocking version of this constructor.
1058 */
1059void
1060power_control_proxy_new (
1061 GDBusConnection *connection,
1062 GDBusProxyFlags flags,
1063 const gchar *name,
1064 const gchar *object_path,
1065 GCancellable *cancellable,
1066 GAsyncReadyCallback callback,
1067 gpointer user_data)
1068{
1069 g_async_initable_new_async (TYPE_POWER_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.PowerControl", NULL);
1070}
1071
1072/**
1073 * power_control_proxy_new_finish:
1074 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to power_control_proxy_new().
1075 * @error: Return location for error or %NULL
1076 *
1077 * Finishes an operation started with power_control_proxy_new().
1078 *
1079 * Returns: (transfer full) (type PowerControlProxy): The constructed proxy object or %NULL if @error is set.
1080 */
1081PowerControl *
1082power_control_proxy_new_finish (
1083 GAsyncResult *res,
1084 GError **error)
1085{
1086 GObject *ret;
1087 GObject *source_object;
1088 source_object = g_async_result_get_source_object (res);
1089 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1090 g_object_unref (source_object);
1091 if (ret != NULL)
1092 return POWER_CONTROL (ret);
1093 else
1094 return NULL;
1095}
1096
1097/**
1098 * power_control_proxy_new_sync:
1099 * @connection: A #GDBusConnection.
1100 * @flags: Flags from the #GDBusProxyFlags enumeration.
1101 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1102 * @object_path: An object path.
1103 * @cancellable: (allow-none): A #GCancellable or %NULL.
1104 * @error: Return location for error or %NULL
1105 *
1106 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>. See g_dbus_proxy_new_sync() for more details.
1107 *
1108 * The calling thread is blocked until a reply is received.
1109 *
1110 * See power_control_proxy_new() for the asynchronous version of this constructor.
1111 *
1112 * Returns: (transfer full) (type PowerControlProxy): The constructed proxy object or %NULL if @error is set.
1113 */
1114PowerControl *
1115power_control_proxy_new_sync (
1116 GDBusConnection *connection,
1117 GDBusProxyFlags flags,
1118 const gchar *name,
1119 const gchar *object_path,
1120 GCancellable *cancellable,
1121 GError **error)
1122{
1123 GInitable *ret;
1124 ret = g_initable_new (TYPE_POWER_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.PowerControl", NULL);
1125 if (ret != NULL)
1126 return POWER_CONTROL (ret);
1127 else
1128 return NULL;
1129}
1130
1131
1132/**
1133 * power_control_proxy_new_for_bus:
1134 * @bus_type: A #GBusType.
1135 * @flags: Flags from the #GDBusProxyFlags enumeration.
1136 * @name: A bus name (well-known or unique).
1137 * @object_path: An object path.
1138 * @cancellable: (allow-none): A #GCancellable or %NULL.
1139 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1140 * @user_data: User data to pass to @callback.
1141 *
1142 * Like power_control_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
1143 *
1144 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
1145 * You can then call power_control_proxy_new_for_bus_finish() to get the result of the operation.
1146 *
1147 * See power_control_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
1148 */
1149void
1150power_control_proxy_new_for_bus (
1151 GBusType bus_type,
1152 GDBusProxyFlags flags,
1153 const gchar *name,
1154 const gchar *object_path,
1155 GCancellable *cancellable,
1156 GAsyncReadyCallback callback,
1157 gpointer user_data)
1158{
1159 g_async_initable_new_async (TYPE_POWER_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.PowerControl", NULL);
1160}
1161
1162/**
1163 * power_control_proxy_new_for_bus_finish:
1164 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to power_control_proxy_new_for_bus().
1165 * @error: Return location for error or %NULL
1166 *
1167 * Finishes an operation started with power_control_proxy_new_for_bus().
1168 *
1169 * Returns: (transfer full) (type PowerControlProxy): The constructed proxy object or %NULL if @error is set.
1170 */
1171PowerControl *
1172power_control_proxy_new_for_bus_finish (
1173 GAsyncResult *res,
1174 GError **error)
1175{
1176 GObject *ret;
1177 GObject *source_object;
1178 source_object = g_async_result_get_source_object (res);
1179 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1180 g_object_unref (source_object);
1181 if (ret != NULL)
1182 return POWER_CONTROL (ret);
1183 else
1184 return NULL;
1185}
1186
1187/**
1188 * power_control_proxy_new_for_bus_sync:
1189 * @bus_type: A #GBusType.
1190 * @flags: Flags from the #GDBusProxyFlags enumeration.
1191 * @name: A bus name (well-known or unique).
1192 * @object_path: An object path.
1193 * @cancellable: (allow-none): A #GCancellable or %NULL.
1194 * @error: Return location for error or %NULL
1195 *
1196 * Like power_control_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
1197 *
1198 * The calling thread is blocked until a reply is received.
1199 *
1200 * See power_control_proxy_new_for_bus() for the asynchronous version of this constructor.
1201 *
1202 * Returns: (transfer full) (type PowerControlProxy): The constructed proxy object or %NULL if @error is set.
1203 */
1204PowerControl *
1205power_control_proxy_new_for_bus_sync (
1206 GBusType bus_type,
1207 GDBusProxyFlags flags,
1208 const gchar *name,
1209 const gchar *object_path,
1210 GCancellable *cancellable,
1211 GError **error)
1212{
1213 GInitable *ret;
1214 ret = g_initable_new (TYPE_POWER_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.PowerControl", NULL);
1215 if (ret != NULL)
1216 return POWER_CONTROL (ret);
1217 else
1218 return NULL;
1219}
1220
1221
1222/* ------------------------------------------------------------------------ */
1223
1224/**
1225 * PowerControlSkeleton:
1226 *
1227 * The #PowerControlSkeleton structure contains only private data and should only be accessed using the provided API.
1228 */
1229
1230/**
1231 * PowerControlSkeletonClass:
1232 * @parent_class: The parent class.
1233 *
1234 * Class structure for #PowerControlSkeleton.
1235 */
1236
1237struct _PowerControlSkeletonPrivate
1238{
1239 GValue *properties;
1240 GList *changed_properties;
1241 GSource *changed_properties_idle_source;
1242 GMainContext *context;
1243 GMutex lock;
1244};
1245
1246static void
1247_power_control_skeleton_handle_method_call (
1248 GDBusConnection *connection G_GNUC_UNUSED,
1249 const gchar *sender G_GNUC_UNUSED,
1250 const gchar *object_path G_GNUC_UNUSED,
1251 const gchar *interface_name,
1252 const gchar *method_name,
1253 GVariant *parameters,
1254 GDBusMethodInvocation *invocation,
1255 gpointer user_data)
1256{
1257 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (user_data);
1258 _ExtendedGDBusMethodInfo *info;
1259 GVariantIter iter;
1260 GVariant *child;
1261 GValue *paramv;
1262 guint num_params;
1263 guint num_extra;
1264 guint n;
1265 guint signal_id;
1266 GValue return_value = G_VALUE_INIT;
1267 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
1268 g_assert (info != NULL);
1269 num_params = g_variant_n_children (parameters);
1270 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
1271 n = 0;
1272 g_value_init (&paramv[n], TYPE_POWER_CONTROL);
1273 g_value_set_object (&paramv[n++], skeleton);
1274 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
1275 g_value_set_object (&paramv[n++], invocation);
1276 if (info->pass_fdlist)
1277 {
1278#ifdef G_OS_UNIX
1279 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
1280 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
1281#else
1282 g_assert_not_reached ();
1283#endif
1284 }
1285 g_variant_iter_init (&iter, parameters);
1286 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1287 {
1288 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
1289 if (arg_info->use_gvariant)
1290 {
1291 g_value_init (&paramv[n], G_TYPE_VARIANT);
1292 g_value_set_variant (&paramv[n], child);
1293 n++;
1294 }
1295 else
1296 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
1297 g_variant_unref (child);
1298 }
1299 signal_id = g_signal_lookup (info->signal_name, TYPE_POWER_CONTROL);
1300 g_value_init (&return_value, G_TYPE_BOOLEAN);
1301 g_signal_emitv (paramv, signal_id, 0, &return_value);
1302 if (!g_value_get_boolean (&return_value))
1303 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
1304 g_value_unset (&return_value);
1305 for (n = 0; n < num_params + num_extra; n++)
1306 g_value_unset (&paramv[n]);
1307 g_free (paramv);
1308}
1309
1310static GVariant *
1311_power_control_skeleton_handle_get_property (
1312 GDBusConnection *connection G_GNUC_UNUSED,
1313 const gchar *sender G_GNUC_UNUSED,
1314 const gchar *object_path G_GNUC_UNUSED,
1315 const gchar *interface_name G_GNUC_UNUSED,
1316 const gchar *property_name,
1317 GError **error,
1318 gpointer user_data)
1319{
1320 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (user_data);
1321 GValue value = G_VALUE_INIT;
1322 GParamSpec *pspec;
1323 _ExtendedGDBusPropertyInfo *info;
1324 GVariant *ret;
1325 ret = NULL;
1326 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct, property_name);
1327 g_assert (info != NULL);
1328 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1329 if (pspec == NULL)
1330 {
1331 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1332 }
1333 else
1334 {
1335 g_value_init (&value, pspec->value_type);
1336 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1337 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
1338 g_value_unset (&value);
1339 }
1340 return ret;
1341}
1342
1343static gboolean
1344_power_control_skeleton_handle_set_property (
1345 GDBusConnection *connection G_GNUC_UNUSED,
1346 const gchar *sender G_GNUC_UNUSED,
1347 const gchar *object_path G_GNUC_UNUSED,
1348 const gchar *interface_name G_GNUC_UNUSED,
1349 const gchar *property_name,
1350 GVariant *variant,
1351 GError **error,
1352 gpointer user_data)
1353{
1354 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (user_data);
1355 GValue value = G_VALUE_INIT;
1356 GParamSpec *pspec;
1357 _ExtendedGDBusPropertyInfo *info;
1358 gboolean ret;
1359 ret = FALSE;
1360 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_power_control_interface_info.parent_struct, property_name);
1361 g_assert (info != NULL);
1362 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1363 if (pspec == NULL)
1364 {
1365 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1366 }
1367 else
1368 {
1369 if (info->use_gvariant)
1370 g_value_set_variant (&value, variant);
1371 else
1372 g_dbus_gvariant_to_gvalue (variant, &value);
1373 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1374 g_value_unset (&value);
1375 ret = TRUE;
1376 }
1377 return ret;
1378}
1379
1380static const GDBusInterfaceVTable _power_control_skeleton_vtable =
1381{
1382 _power_control_skeleton_handle_method_call,
1383 _power_control_skeleton_handle_get_property,
1384 _power_control_skeleton_handle_set_property,
1385 {NULL}
1386};
1387
1388static GDBusInterfaceInfo *
1389power_control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1390{
1391 return power_control_interface_info ();
1392}
1393
1394static GDBusInterfaceVTable *
1395power_control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1396{
1397 return (GDBusInterfaceVTable *) &_power_control_skeleton_vtable;
1398}
1399
1400static GVariant *
1401power_control_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
1402{
1403 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (_skeleton);
1404
1405 GVariantBuilder builder;
1406 guint n;
1407 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1408 if (_power_control_interface_info.parent_struct.properties == NULL)
1409 goto out;
1410 for (n = 0; _power_control_interface_info.parent_struct.properties[n] != NULL; n++)
1411 {
1412 GDBusPropertyInfo *info = _power_control_interface_info.parent_struct.properties[n];
1413 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
1414 {
1415 GVariant *value;
1416 value = _power_control_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.PowerControl", info->name, NULL, skeleton);
1417 if (value != NULL)
1418 {
1419 g_variant_take_ref (value);
1420 g_variant_builder_add (&builder, "{sv}", info->name, value);
1421 g_variant_unref (value);
1422 }
1423 }
1424 }
1425out:
1426 return g_variant_builder_end (&builder);
1427}
1428
1429static gboolean _power_control_emit_changed (gpointer user_data);
1430
1431static void
1432power_control_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
1433{
1434 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (_skeleton);
1435 gboolean emit_changed = FALSE;
1436
1437 g_mutex_lock (&skeleton->priv->lock);
1438 if (skeleton->priv->changed_properties_idle_source != NULL)
1439 {
1440 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1441 skeleton->priv->changed_properties_idle_source = NULL;
1442 emit_changed = TRUE;
1443 }
1444 g_mutex_unlock (&skeleton->priv->lock);
1445
1446 if (emit_changed)
1447 _power_control_emit_changed (skeleton);
1448}
1449
1450static void
1451_power_control_on_signal_power_good (
1452 PowerControl *object)
1453{
1454 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1455
1456 GList *connections, *l;
1457 GVariant *signal_variant;
1458 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1459
1460 signal_variant = g_variant_ref_sink (g_variant_new ("()"));
1461 for (l = connections; l != NULL; l = l->next)
1462 {
1463 GDBusConnection *connection = l->data;
1464 g_dbus_connection_emit_signal (connection,
1465 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.PowerControl", "PowerGood",
1466 signal_variant, NULL);
1467 }
1468 g_variant_unref (signal_variant);
1469 g_list_free_full (connections, g_object_unref);
1470}
1471
1472static void
1473_power_control_on_signal_power_lost (
1474 PowerControl *object)
1475{
1476 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1477
1478 GList *connections, *l;
1479 GVariant *signal_variant;
1480 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1481
1482 signal_variant = g_variant_ref_sink (g_variant_new ("()"));
1483 for (l = connections; l != NULL; l = l->next)
1484 {
1485 GDBusConnection *connection = l->data;
1486 g_dbus_connection_emit_signal (connection,
1487 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.PowerControl", "PowerLost",
1488 signal_variant, NULL);
1489 }
1490 g_variant_unref (signal_variant);
1491 g_list_free_full (connections, g_object_unref);
1492}
1493
1494static void power_control_skeleton_iface_init (PowerControlIface *iface);
1495#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1496G_DEFINE_TYPE_WITH_CODE (PowerControlSkeleton, power_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1497 G_ADD_PRIVATE (PowerControlSkeleton)
1498 G_IMPLEMENT_INTERFACE (TYPE_POWER_CONTROL, power_control_skeleton_iface_init));
1499
1500#else
1501G_DEFINE_TYPE_WITH_CODE (PowerControlSkeleton, power_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1502 G_IMPLEMENT_INTERFACE (TYPE_POWER_CONTROL, power_control_skeleton_iface_init));
1503
1504#endif
1505static void
1506power_control_skeleton_finalize (GObject *object)
1507{
1508 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1509 guint n;
1510 for (n = 0; n < 2; n++)
1511 g_value_unset (&skeleton->priv->properties[n]);
1512 g_free (skeleton->priv->properties);
1513 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1514 if (skeleton->priv->changed_properties_idle_source != NULL)
1515 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1516 g_main_context_unref (skeleton->priv->context);
1517 g_mutex_clear (&skeleton->priv->lock);
1518 G_OBJECT_CLASS (power_control_skeleton_parent_class)->finalize (object);
1519}
1520
1521static void
1522power_control_skeleton_get_property (GObject *object,
1523 guint prop_id,
1524 GValue *value,
1525 GParamSpec *pspec G_GNUC_UNUSED)
1526{
1527 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1528 g_assert (prop_id != 0 && prop_id - 1 < 2);
1529 g_mutex_lock (&skeleton->priv->lock);
1530 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
1531 g_mutex_unlock (&skeleton->priv->lock);
1532}
1533
1534static gboolean
1535_power_control_emit_changed (gpointer user_data)
1536{
1537 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (user_data);
1538 GList *l;
1539 GVariantBuilder builder;
1540 GVariantBuilder invalidated_builder;
1541 guint num_changes;
1542
1543 g_mutex_lock (&skeleton->priv->lock);
1544 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1545 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
1546 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
1547 {
1548 ChangedProperty *cp = l->data;
1549 GVariant *variant;
1550 const GValue *cur_value;
1551
1552 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
1553 if (!_g_value_equal (cur_value, &cp->orig_value))
1554 {
1555 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
1556 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
1557 g_variant_unref (variant);
1558 num_changes++;
1559 }
1560 }
1561 if (num_changes > 0)
1562 {
1563 GList *connections, *ll;
1564 GVariant *signal_variant;
1565 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.PowerControl",
1566 &builder, &invalidated_builder));
1567 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1568 for (ll = connections; ll != NULL; ll = ll->next)
1569 {
1570 GDBusConnection *connection = ll->data;
1571
1572 g_dbus_connection_emit_signal (connection,
1573 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
1574 "org.freedesktop.DBus.Properties",
1575 "PropertiesChanged",
1576 signal_variant,
1577 NULL);
1578 }
1579 g_variant_unref (signal_variant);
1580 g_list_free_full (connections, g_object_unref);
1581 }
1582 else
1583 {
1584 g_variant_builder_clear (&builder);
1585 g_variant_builder_clear (&invalidated_builder);
1586 }
1587 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1588 skeleton->priv->changed_properties = NULL;
1589 skeleton->priv->changed_properties_idle_source = NULL;
1590 g_mutex_unlock (&skeleton->priv->lock);
1591 return FALSE;
1592}
1593
1594static void
1595_power_control_schedule_emit_changed (PowerControlSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
1596{
1597 ChangedProperty *cp;
1598 GList *l;
1599 cp = NULL;
1600 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
1601 {
1602 ChangedProperty *i_cp = l->data;
1603 if (i_cp->info == info)
1604 {
1605 cp = i_cp;
1606 break;
1607 }
1608 }
1609 if (cp == NULL)
1610 {
1611 cp = g_new0 (ChangedProperty, 1);
1612 cp->prop_id = prop_id;
1613 cp->info = info;
1614 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
1615 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
1616 g_value_copy (orig_value, &cp->orig_value);
1617 }
1618}
1619
1620static void
1621power_control_skeleton_notify (GObject *object,
1622 GParamSpec *pspec G_GNUC_UNUSED)
1623{
1624 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1625 g_mutex_lock (&skeleton->priv->lock);
1626 if (skeleton->priv->changed_properties != NULL &&
1627 skeleton->priv->changed_properties_idle_source == NULL)
1628 {
1629 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
1630 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
1631 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _power_control_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
1632 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
1633 g_source_unref (skeleton->priv->changed_properties_idle_source);
1634 }
1635 g_mutex_unlock (&skeleton->priv->lock);
1636}
1637
1638static void
1639power_control_skeleton_set_property (GObject *object,
1640 guint prop_id,
1641 const GValue *value,
1642 GParamSpec *pspec)
1643{
1644 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1645 g_assert (prop_id != 0 && prop_id - 1 < 2);
1646 g_mutex_lock (&skeleton->priv->lock);
1647 g_object_freeze_notify (object);
1648 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
1649 {
1650 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
1651 _power_control_schedule_emit_changed (skeleton, _power_control_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
1652 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
1653 g_object_notify_by_pspec (object, pspec);
1654 }
1655 g_mutex_unlock (&skeleton->priv->lock);
1656 g_object_thaw_notify (object);
1657}
1658
1659static void
1660power_control_skeleton_init (PowerControlSkeleton *skeleton)
1661{
1662#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1663 skeleton->priv = power_control_skeleton_get_instance_private (skeleton);
1664#else
1665 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_POWER_CONTROL_SKELETON, PowerControlSkeletonPrivate);
1666#endif
1667
1668 g_mutex_init (&skeleton->priv->lock);
1669 skeleton->priv->context = g_main_context_ref_thread_default ();
1670 skeleton->priv->properties = g_new0 (GValue, 2);
1671 g_value_init (&skeleton->priv->properties[0], G_TYPE_INT);
1672 g_value_init (&skeleton->priv->properties[1], G_TYPE_INT);
1673}
1674
1675static gint
1676power_control_skeleton_get_pgood (PowerControl *object)
1677{
1678 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1679 gint value;
1680 g_mutex_lock (&skeleton->priv->lock);
1681 value = g_value_get_int (&(skeleton->priv->properties[0]));
1682 g_mutex_unlock (&skeleton->priv->lock);
1683 return value;
1684}
1685
1686static gint
1687power_control_skeleton_get_state (PowerControl *object)
1688{
1689 PowerControlSkeleton *skeleton = POWER_CONTROL_SKELETON (object);
1690 gint value;
1691 g_mutex_lock (&skeleton->priv->lock);
1692 value = g_value_get_int (&(skeleton->priv->properties[1]));
1693 g_mutex_unlock (&skeleton->priv->lock);
1694 return value;
1695}
1696
1697static void
1698power_control_skeleton_class_init (PowerControlSkeletonClass *klass)
1699{
1700 GObjectClass *gobject_class;
1701 GDBusInterfaceSkeletonClass *skeleton_class;
1702
1703 gobject_class = G_OBJECT_CLASS (klass);
1704 gobject_class->finalize = power_control_skeleton_finalize;
1705 gobject_class->get_property = power_control_skeleton_get_property;
1706 gobject_class->set_property = power_control_skeleton_set_property;
1707 gobject_class->notify = power_control_skeleton_notify;
1708
1709
1710 power_control_override_properties (gobject_class, 1);
1711
1712 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
1713 skeleton_class->get_info = power_control_skeleton_dbus_interface_get_info;
1714 skeleton_class->get_properties = power_control_skeleton_dbus_interface_get_properties;
1715 skeleton_class->flush = power_control_skeleton_dbus_interface_flush;
1716 skeleton_class->get_vtable = power_control_skeleton_dbus_interface_get_vtable;
1717
1718#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1719 g_type_class_add_private (klass, sizeof (PowerControlSkeletonPrivate));
1720#endif
1721}
1722
1723static void
1724power_control_skeleton_iface_init (PowerControlIface *iface)
1725{
1726 iface->power_good = _power_control_on_signal_power_good;
1727 iface->power_lost = _power_control_on_signal_power_lost;
1728 iface->get_pgood = power_control_skeleton_get_pgood;
1729 iface->get_state = power_control_skeleton_get_state;
1730}
1731
1732/**
1733 * power_control_skeleton_new:
1734 *
1735 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>.
1736 *
1737 * Returns: (transfer full) (type PowerControlSkeleton): The skeleton object.
1738 */
1739PowerControl *
1740power_control_skeleton_new (void)
1741{
1742 return POWER_CONTROL (g_object_new (TYPE_POWER_CONTROL_SKELETON, NULL));
1743}
1744
1745/* ------------------------------------------------------------------------
1746 * Code for Object, ObjectProxy and ObjectSkeleton
1747 * ------------------------------------------------------------------------
1748 */
1749
1750/**
1751 * SECTION:Object
1752 * @title: Object
1753 * @short_description: Specialized GDBusObject types
1754 *
1755 * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
1756 */
1757
1758/**
1759 * Object:
1760 *
1761 * The #Object type is a specialized container of interfaces.
1762 */
1763
1764/**
1765 * ObjectIface:
1766 * @parent_iface: The parent interface.
1767 *
1768 * Virtual table for the #Object interface.
1769 */
1770
1771typedef ObjectIface ObjectInterface;
1772G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
1773
1774static void
1775object_default_init (ObjectIface *iface)
1776{
1777 /**
1778 * Object:power-control:
1779 *
1780 * The #PowerControl instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link>, if any.
1781 *
1782 * Connect to the #GObject::notify signal to get informed of property changes.
1783 */
1784 g_object_interface_install_property (iface, g_param_spec_object ("power-control", "power-control", "power-control", TYPE_POWER_CONTROL, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
1785
1786}
1787
1788/**
1789 * object_get_power_control:
1790 * @object: A #Object.
1791 *
1792 * Gets the #PowerControl instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link> on @object, if any.
1793 *
1794 * Returns: (transfer full): A #PowerControl that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
1795 */
1796PowerControl *object_get_power_control (Object *object)
1797{
1798 GDBusInterface *ret;
1799 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.PowerControl");
1800 if (ret == NULL)
1801 return NULL;
1802 return POWER_CONTROL (ret);
1803}
1804
1805
1806/**
1807 * object_peek_power_control: (skip)
1808 * @object: A #Object.
1809 *
1810 * Like object_get_power_control() but doesn't increase the reference count on the returned object.
1811 *
1812 * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
1813 *
1814 * Returns: (transfer none): A #PowerControl or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
1815 */
1816PowerControl *object_peek_power_control (Object *object)
1817{
1818 GDBusInterface *ret;
1819 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.PowerControl");
1820 if (ret == NULL)
1821 return NULL;
1822 g_object_unref (ret);
1823 return POWER_CONTROL (ret);
1824}
1825
1826
1827static void
1828object_notify (GDBusObject *object, GDBusInterface *interface)
1829{
1830 _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
1831 /* info can be NULL if the other end is using a D-Bus interface we don't know
1832 * anything about, for example old generated code in this process talking to
1833 * newer generated code in the other process. */
1834 if (info != NULL)
1835 g_object_notify (G_OBJECT (object), info->hyphen_name);
1836}
1837
1838/**
1839 * ObjectProxy:
1840 *
1841 * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
1842 */
1843
1844/**
1845 * ObjectProxyClass:
1846 * @parent_class: The parent class.
1847 *
1848 * Class structure for #ObjectProxy.
1849 */
1850
1851static void
1852object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
1853{
1854}
1855
1856static void
1857object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
1858{
1859 iface->interface_added = object_notify;
1860 iface->interface_removed = object_notify;
1861}
1862
1863
1864G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
1865 G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
1866 G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
1867
1868static void
1869object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
1870{
1871}
1872
1873static void
1874object_proxy_set_property (GObject *gobject,
1875 guint prop_id,
1876 const GValue *value G_GNUC_UNUSED,
1877 GParamSpec *pspec)
1878{
1879 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
1880}
1881
1882static void
1883object_proxy_get_property (GObject *gobject,
1884 guint prop_id,
1885 GValue *value,
1886 GParamSpec *pspec)
1887{
1888 ObjectProxy *object = OBJECT_PROXY (gobject);
1889 GDBusInterface *interface;
1890
1891 switch (prop_id)
1892 {
1893 case 1:
1894 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.PowerControl");
1895 g_value_take_object (value, interface);
1896 break;
1897
1898 default:
1899 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
1900 break;
1901 }
1902}
1903
1904static void
1905object_proxy_class_init (ObjectProxyClass *klass)
1906{
1907 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1908
1909 gobject_class->set_property = object_proxy_set_property;
1910 gobject_class->get_property = object_proxy_get_property;
1911
1912 g_object_class_override_property (gobject_class, 1, "power-control");
1913}
1914
1915/**
1916 * object_proxy_new:
1917 * @connection: A #GDBusConnection.
1918 * @object_path: An object path.
1919 *
1920 * Creates a new proxy object.
1921 *
1922 * Returns: (transfer full): The proxy object.
1923 */
1924ObjectProxy *
1925object_proxy_new (GDBusConnection *connection,
1926 const gchar *object_path)
1927{
1928 g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
1929 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
1930 return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
1931}
1932
1933/**
1934 * ObjectSkeleton:
1935 *
1936 * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
1937 */
1938
1939/**
1940 * ObjectSkeletonClass:
1941 * @parent_class: The parent class.
1942 *
1943 * Class structure for #ObjectSkeleton.
1944 */
1945
1946static void
1947object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
1948{
1949}
1950
1951
1952static void
1953object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
1954{
1955 iface->interface_added = object_notify;
1956 iface->interface_removed = object_notify;
1957}
1958
1959G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
1960 G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
1961 G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
1962
1963static void
1964object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
1965{
1966}
1967
1968static void
1969object_skeleton_set_property (GObject *gobject,
1970 guint prop_id,
1971 const GValue *value,
1972 GParamSpec *pspec)
1973{
1974 ObjectSkeleton *object = OBJECT_SKELETON (gobject);
1975 GDBusInterfaceSkeleton *interface;
1976
1977 switch (prop_id)
1978 {
1979 case 1:
1980 interface = g_value_get_object (value);
1981 if (interface != NULL)
1982 {
1983 g_warn_if_fail (IS_POWER_CONTROL (interface));
1984 g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
1985 }
1986 else
1987 {
1988 g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.PowerControl");
1989 }
1990 break;
1991
1992 default:
1993 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
1994 break;
1995 }
1996}
1997
1998static void
1999object_skeleton_get_property (GObject *gobject,
2000 guint prop_id,
2001 GValue *value,
2002 GParamSpec *pspec)
2003{
2004 ObjectSkeleton *object = OBJECT_SKELETON (gobject);
2005 GDBusInterface *interface;
2006
2007 switch (prop_id)
2008 {
2009 case 1:
2010 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.PowerControl");
2011 g_value_take_object (value, interface);
2012 break;
2013
2014 default:
2015 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
2016 break;
2017 }
2018}
2019
2020static void
2021object_skeleton_class_init (ObjectSkeletonClass *klass)
2022{
2023 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
2024
2025 gobject_class->set_property = object_skeleton_set_property;
2026 gobject_class->get_property = object_skeleton_get_property;
2027
2028 g_object_class_override_property (gobject_class, 1, "power-control");
2029}
2030
2031/**
2032 * object_skeleton_new:
2033 * @object_path: An object path.
2034 *
2035 * Creates a new skeleton object.
2036 *
2037 * Returns: (transfer full): The skeleton object.
2038 */
2039ObjectSkeleton *
2040object_skeleton_new (const gchar *object_path)
2041{
2042 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
2043 return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
2044}
2045
2046/**
2047 * object_skeleton_set_power_control:
2048 * @object: A #ObjectSkeleton.
2049 * @interface_: (allow-none): A #PowerControl or %NULL to clear the interface.
2050 *
2051 * Sets the #PowerControl instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-PowerControl.top_of_page">org.openbmc.PowerControl</link> on @object.
2052 */
2053void object_skeleton_set_power_control (ObjectSkeleton *object, PowerControl *interface_)
2054{
2055 g_object_set (G_OBJECT (object), "power-control", interface_, NULL);
2056}
2057
2058
2059/* ------------------------------------------------------------------------
2060 * Code for ObjectManager client
2061 * ------------------------------------------------------------------------
2062 */
2063
2064/**
2065 * SECTION:ObjectManagerClient
2066 * @title: ObjectManagerClient
2067 * @short_description: Generated GDBusObjectManagerClient type
2068 *
2069 * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
2070 */
2071
2072/**
2073 * ObjectManagerClient:
2074 *
2075 * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
2076 */
2077
2078/**
2079 * ObjectManagerClientClass:
2080 * @parent_class: The parent class.
2081 *
2082 * Class structure for #ObjectManagerClient.
2083 */
2084
2085G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
2086
2087static void
2088object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
2089{
2090}
2091
2092static void
2093object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
2094{
2095}
2096
2097/**
2098 * object_manager_client_get_proxy_type:
2099 * @manager: A #GDBusObjectManagerClient.
2100 * @object_path: The object path of the remote object (unused).
2101 * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
2102 * @user_data: User data (unused).
2103 *
2104 * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
2105 *
2106 * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
2107 */
2108GType
2109object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, gpointer user_data G_GNUC_UNUSED)
2110{
2111 static gsize once_init_value = 0;
2112 static GHashTable *lookup_hash;
2113 GType ret;
2114
2115 if (interface_name == NULL)
2116 return TYPE_OBJECT_PROXY;
2117 if (g_once_init_enter (&once_init_value))
2118 {
2119 lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
2120 g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.PowerControl", GSIZE_TO_POINTER (TYPE_POWER_CONTROL_PROXY));
2121 g_once_init_leave (&once_init_value, 1);
2122 }
2123 ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
2124 if (ret == (GType) 0)
2125 ret = G_TYPE_DBUS_PROXY;
2126 return ret;
2127}
2128
2129/**
2130 * object_manager_client_new:
2131 * @connection: A #GDBusConnection.
2132 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
2133 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
2134 * @object_path: An object path.
2135 * @cancellable: (allow-none): A #GCancellable or %NULL.
2136 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
2137 * @user_data: User data to pass to @callback.
2138 *
2139 * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
2140 *
2141 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
2142 * You can then call object_manager_client_new_finish() to get the result of the operation.
2143 *
2144 * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
2145 */
2146void
2147object_manager_client_new (
2148 GDBusConnection *connection,
2149 GDBusObjectManagerClientFlags flags,
2150 const gchar *name,
2151 const gchar *object_path,
2152 GCancellable *cancellable,
2153 GAsyncReadyCallback callback,
2154 gpointer user_data)
2155{
2156 g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
2157}
2158
2159/**
2160 * object_manager_client_new_finish:
2161 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
2162 * @error: Return location for error or %NULL
2163 *
2164 * Finishes an operation started with object_manager_client_new().
2165 *
2166 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
2167 */
2168GDBusObjectManager *
2169object_manager_client_new_finish (
2170 GAsyncResult *res,
2171 GError **error)
2172{
2173 GObject *ret;
2174 GObject *source_object;
2175 source_object = g_async_result_get_source_object (res);
2176 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
2177 g_object_unref (source_object);
2178 if (ret != NULL)
2179 return G_DBUS_OBJECT_MANAGER (ret);
2180 else
2181 return NULL;
2182}
2183
2184/**
2185 * object_manager_client_new_sync:
2186 * @connection: A #GDBusConnection.
2187 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
2188 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
2189 * @object_path: An object path.
2190 * @cancellable: (allow-none): A #GCancellable or %NULL.
2191 * @error: Return location for error or %NULL
2192 *
2193 * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
2194 *
2195 * The calling thread is blocked until a reply is received.
2196 *
2197 * See object_manager_client_new() for the asynchronous version of this constructor.
2198 *
2199 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
2200 */
2201GDBusObjectManager *
2202object_manager_client_new_sync (
2203 GDBusConnection *connection,
2204 GDBusObjectManagerClientFlags flags,
2205 const gchar *name,
2206 const gchar *object_path,
2207 GCancellable *cancellable,
2208 GError **error)
2209{
2210 GInitable *ret;
2211 ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
2212 if (ret != NULL)
2213 return G_DBUS_OBJECT_MANAGER (ret);
2214 else
2215 return NULL;
2216}
2217
2218
2219/**
2220 * object_manager_client_new_for_bus:
2221 * @bus_type: A #GBusType.
2222 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
2223 * @name: A bus name (well-known or unique).
2224 * @object_path: An object path.
2225 * @cancellable: (allow-none): A #GCancellable or %NULL.
2226 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
2227 * @user_data: User data to pass to @callback.
2228 *
2229 * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
2230 *
2231 * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
2232 * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
2233 *
2234 * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
2235 */
2236void
2237object_manager_client_new_for_bus (
2238 GBusType bus_type,
2239 GDBusObjectManagerClientFlags flags,
2240 const gchar *name,
2241 const gchar *object_path,
2242 GCancellable *cancellable,
2243 GAsyncReadyCallback callback,
2244 gpointer user_data)
2245{
2246 g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
2247}
2248
2249/**
2250 * object_manager_client_new_for_bus_finish:
2251 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
2252 * @error: Return location for error or %NULL
2253 *
2254 * Finishes an operation started with object_manager_client_new_for_bus().
2255 *
2256 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
2257 */
2258GDBusObjectManager *
2259object_manager_client_new_for_bus_finish (
2260 GAsyncResult *res,
2261 GError **error)
2262{
2263 GObject *ret;
2264 GObject *source_object;
2265 source_object = g_async_result_get_source_object (res);
2266 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
2267 g_object_unref (source_object);
2268 if (ret != NULL)
2269 return G_DBUS_OBJECT_MANAGER (ret);
2270 else
2271 return NULL;
2272}
2273
2274/**
2275 * object_manager_client_new_for_bus_sync:
2276 * @bus_type: A #GBusType.
2277 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
2278 * @name: A bus name (well-known or unique).
2279 * @object_path: An object path.
2280 * @cancellable: (allow-none): A #GCancellable or %NULL.
2281 * @error: Return location for error or %NULL
2282 *
2283 * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
2284 *
2285 * The calling thread is blocked until a reply is received.
2286 *
2287 * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
2288 *
2289 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
2290 */
2291GDBusObjectManager *
2292object_manager_client_new_for_bus_sync (
2293 GBusType bus_type,
2294 GDBusObjectManagerClientFlags flags,
2295 const gchar *name,
2296 const gchar *object_path,
2297 GCancellable *cancellable,
2298 GError **error)
2299{
2300 GInitable *ret;
2301 ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
2302 if (ret != NULL)
2303 return G_DBUS_OBJECT_MANAGER (ret);
2304 else
2305 return NULL;
2306}
2307
2308