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