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