1 /*
2 * Generated by gdbus-codegen 2.58.1 from org.xfce.Power.Manager.xml. DO NOT EDIT.
3 *
4 * The license of this code is the same as for the D-Bus interface description
5 * it was derived from.
6 */
7
8 #ifdef HAVE_CONFIG_H
9 # include "config.h"
10 #endif
11
12 #include "xfce-power-manager-dbus.h"
13
14 #include <string.h>
15 #ifdef G_OS_UNIX
16 # include <gio/gunixfdlist.h>
17 #endif
18
19 typedef struct
20 {
21 GDBusArgInfo parent_struct;
22 gboolean use_gvariant;
23 } _ExtendedGDBusArgInfo;
24
25 typedef struct
26 {
27 GDBusMethodInfo parent_struct;
28 const gchar *signal_name;
29 gboolean pass_fdlist;
30 } _ExtendedGDBusMethodInfo;
31
32 typedef struct
33 {
34 GDBusSignalInfo parent_struct;
35 const gchar *signal_name;
36 } _ExtendedGDBusSignalInfo;
37
38 typedef struct
39 {
40 GDBusPropertyInfo parent_struct;
41 const gchar *hyphen_name;
42 gboolean use_gvariant;
43 } _ExtendedGDBusPropertyInfo;
44
45 typedef struct
46 {
47 GDBusInterfaceInfo parent_struct;
48 const gchar *hyphen_name;
49 } _ExtendedGDBusInterfaceInfo;
50
51 typedef struct
52 {
53 const _ExtendedGDBusPropertyInfo *info;
54 guint prop_id;
55 GValue orig_value; /* the value before the change */
56 } ChangedProperty;
57
58 static void
_changed_property_free(ChangedProperty * data)59 _changed_property_free (ChangedProperty *data)
60 {
61 g_value_unset (&data->orig_value);
62 g_free (data);
63 }
64
65 static gboolean
_g_strv_equal0(gchar ** a,gchar ** b)66 _g_strv_equal0 (gchar **a, gchar **b)
67 {
68 gboolean ret = FALSE;
69 guint n;
70 if (a == NULL && b == NULL)
71 {
72 ret = TRUE;
73 goto out;
74 }
75 if (a == NULL || b == NULL)
76 goto out;
77 if (g_strv_length (a) != g_strv_length (b))
78 goto out;
79 for (n = 0; a[n] != NULL; n++)
80 if (g_strcmp0 (a[n], b[n]) != 0)
81 goto out;
82 ret = TRUE;
83 out:
84 return ret;
85 }
86
87 static gboolean
_g_variant_equal0(GVariant * a,GVariant * b)88 _g_variant_equal0 (GVariant *a, GVariant *b)
89 {
90 gboolean ret = FALSE;
91 if (a == NULL && b == NULL)
92 {
93 ret = TRUE;
94 goto out;
95 }
96 if (a == NULL || b == NULL)
97 goto out;
98 ret = g_variant_equal (a, b);
99 out:
100 return ret;
101 }
102
103 G_GNUC_UNUSED static gboolean
_g_value_equal(const GValue * a,const GValue * b)104 _g_value_equal (const GValue *a, const GValue *b)
105 {
106 gboolean ret = FALSE;
107 g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
108 switch (G_VALUE_TYPE (a))
109 {
110 case G_TYPE_BOOLEAN:
111 ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
112 break;
113 case G_TYPE_UCHAR:
114 ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
115 break;
116 case G_TYPE_INT:
117 ret = (g_value_get_int (a) == g_value_get_int (b));
118 break;
119 case G_TYPE_UINT:
120 ret = (g_value_get_uint (a) == g_value_get_uint (b));
121 break;
122 case G_TYPE_INT64:
123 ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
124 break;
125 case G_TYPE_UINT64:
126 ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
127 break;
128 case G_TYPE_DOUBLE:
129 {
130 /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
131 gdouble da = g_value_get_double (a);
132 gdouble db = g_value_get_double (b);
133 ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
134 }
135 break;
136 case G_TYPE_STRING:
137 ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
138 break;
139 case G_TYPE_VARIANT:
140 ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
141 break;
142 default:
143 if (G_VALUE_TYPE (a) == G_TYPE_STRV)
144 ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
145 else
146 g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
147 break;
148 }
149 return ret;
150 }
151
152 /* ------------------------------------------------------------------------
153 * Code for interface org.xfce.Power.Manager
154 * ------------------------------------------------------------------------
155 */
156
157 /**
158 * SECTION:XfpmPowerManager
159 * @title: XfpmPowerManager
160 * @short_description: Generated C code for the org.xfce.Power.Manager D-Bus interface
161 *
162 * This section contains code for working with the <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link> D-Bus interface in C.
163 */
164
165 /* ---- Introspection data for org.xfce.Power.Manager ---- */
166
167 static const _ExtendedGDBusMethodInfo _xfpm_power_manager_method_info_quit =
168 {
169 {
170 -1,
171 (gchar *) "Quit",
172 NULL,
173 NULL,
174 NULL
175 },
176 "handle-quit",
177 FALSE
178 };
179
180 static const _ExtendedGDBusMethodInfo _xfpm_power_manager_method_info_restart =
181 {
182 {
183 -1,
184 (gchar *) "Restart",
185 NULL,
186 NULL,
187 NULL
188 },
189 "handle-restart",
190 FALSE
191 };
192
193 static const _ExtendedGDBusArgInfo _xfpm_power_manager_method_info_get_config_OUT_ARG_config =
194 {
195 {
196 -1,
197 (gchar *) "config",
198 (gchar *) "a{ss}",
199 NULL
200 },
201 FALSE
202 };
203
204 static const GDBusArgInfo * const _xfpm_power_manager_method_info_get_config_OUT_ARG_pointers[] =
205 {
206 &_xfpm_power_manager_method_info_get_config_OUT_ARG_config.parent_struct,
207 NULL
208 };
209
210 static const _ExtendedGDBusMethodInfo _xfpm_power_manager_method_info_get_config =
211 {
212 {
213 -1,
214 (gchar *) "GetConfig",
215 NULL,
216 (GDBusArgInfo **) &_xfpm_power_manager_method_info_get_config_OUT_ARG_pointers,
217 NULL
218 },
219 "handle-get-config",
220 FALSE
221 };
222
223 static const _ExtendedGDBusArgInfo _xfpm_power_manager_method_info_get_info_OUT_ARG_name =
224 {
225 {
226 -1,
227 (gchar *) "name",
228 (gchar *) "s",
229 NULL
230 },
231 FALSE
232 };
233
234 static const _ExtendedGDBusArgInfo _xfpm_power_manager_method_info_get_info_OUT_ARG_version =
235 {
236 {
237 -1,
238 (gchar *) "version",
239 (gchar *) "s",
240 NULL
241 },
242 FALSE
243 };
244
245 static const _ExtendedGDBusArgInfo _xfpm_power_manager_method_info_get_info_OUT_ARG_vendor =
246 {
247 {
248 -1,
249 (gchar *) "vendor",
250 (gchar *) "s",
251 NULL
252 },
253 FALSE
254 };
255
256 static const GDBusArgInfo * const _xfpm_power_manager_method_info_get_info_OUT_ARG_pointers[] =
257 {
258 &_xfpm_power_manager_method_info_get_info_OUT_ARG_name.parent_struct,
259 &_xfpm_power_manager_method_info_get_info_OUT_ARG_version.parent_struct,
260 &_xfpm_power_manager_method_info_get_info_OUT_ARG_vendor.parent_struct,
261 NULL
262 };
263
264 static const _ExtendedGDBusMethodInfo _xfpm_power_manager_method_info_get_info =
265 {
266 {
267 -1,
268 (gchar *) "GetInfo",
269 NULL,
270 (GDBusArgInfo **) &_xfpm_power_manager_method_info_get_info_OUT_ARG_pointers,
271 NULL
272 },
273 "handle-get-info",
274 FALSE
275 };
276
277 static const GDBusMethodInfo * const _xfpm_power_manager_method_info_pointers[] =
278 {
279 &_xfpm_power_manager_method_info_quit.parent_struct,
280 &_xfpm_power_manager_method_info_restart.parent_struct,
281 &_xfpm_power_manager_method_info_get_config.parent_struct,
282 &_xfpm_power_manager_method_info_get_info.parent_struct,
283 NULL
284 };
285
286 static const _ExtendedGDBusInterfaceInfo _xfpm_power_manager_interface_info =
287 {
288 {
289 -1,
290 (gchar *) "org.xfce.Power.Manager",
291 (GDBusMethodInfo **) &_xfpm_power_manager_method_info_pointers,
292 NULL,
293 NULL,
294 NULL
295 },
296 "power-manager",
297 };
298
299
300 /**
301 * xfpm_power_manager_interface_info:
302 *
303 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link> D-Bus interface.
304 *
305 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
306 */
307 GDBusInterfaceInfo *
xfpm_power_manager_interface_info(void)308 xfpm_power_manager_interface_info (void)
309 {
310 return (GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct;
311 }
312
313 /**
314 * xfpm_power_manager_override_properties:
315 * @klass: The class structure for a #GObject derived class.
316 * @property_id_begin: The property id to assign to the first overridden property.
317 *
318 * Overrides all #GObject properties in the #XfpmPowerManager interface for a concrete class.
319 * The properties are overridden in the order they are defined.
320 *
321 * Returns: The last property id.
322 */
323 guint
xfpm_power_manager_override_properties(GObjectClass * klass,guint property_id_begin)324 xfpm_power_manager_override_properties (GObjectClass *klass, guint property_id_begin)
325 {
326 return property_id_begin - 1;
327 }
328
329
330
331 /**
332 * XfpmPowerManager:
333 *
334 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link>.
335 */
336
337 /**
338 * XfpmPowerManagerIface:
339 * @parent_iface: The parent interface.
340 * @handle_get_config: Handler for the #XfpmPowerManager::handle-get-config signal.
341 * @handle_get_info: Handler for the #XfpmPowerManager::handle-get-info signal.
342 * @handle_quit: Handler for the #XfpmPowerManager::handle-quit signal.
343 * @handle_restart: Handler for the #XfpmPowerManager::handle-restart signal.
344 *
345 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link>.
346 */
347
348 typedef XfpmPowerManagerIface XfpmPowerManagerInterface;
G_DEFINE_INTERFACE(XfpmPowerManager,xfpm_power_manager,G_TYPE_OBJECT)349 G_DEFINE_INTERFACE (XfpmPowerManager, xfpm_power_manager, G_TYPE_OBJECT)
350
351 static void
352 xfpm_power_manager_default_init (XfpmPowerManagerIface *iface)
353 {
354 /* GObject signals for incoming D-Bus method calls: */
355 /**
356 * XfpmPowerManager::handle-quit:
357 * @object: A #XfpmPowerManager.
358 * @invocation: A #GDBusMethodInvocation.
359 *
360 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Power-Manager.Quit">Quit()</link> D-Bus method.
361 *
362 * 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 xfpm_power_manager_complete_quit() 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.
363 *
364 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
365 */
366 g_signal_new ("handle-quit",
367 G_TYPE_FROM_INTERFACE (iface),
368 G_SIGNAL_RUN_LAST,
369 G_STRUCT_OFFSET (XfpmPowerManagerIface, handle_quit),
370 g_signal_accumulator_true_handled,
371 NULL,
372 g_cclosure_marshal_generic,
373 G_TYPE_BOOLEAN,
374 1,
375 G_TYPE_DBUS_METHOD_INVOCATION);
376
377 /**
378 * XfpmPowerManager::handle-restart:
379 * @object: A #XfpmPowerManager.
380 * @invocation: A #GDBusMethodInvocation.
381 *
382 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Power-Manager.Restart">Restart()</link> D-Bus method.
383 *
384 * 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 xfpm_power_manager_complete_restart() 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.
385 *
386 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
387 */
388 g_signal_new ("handle-restart",
389 G_TYPE_FROM_INTERFACE (iface),
390 G_SIGNAL_RUN_LAST,
391 G_STRUCT_OFFSET (XfpmPowerManagerIface, handle_restart),
392 g_signal_accumulator_true_handled,
393 NULL,
394 g_cclosure_marshal_generic,
395 G_TYPE_BOOLEAN,
396 1,
397 G_TYPE_DBUS_METHOD_INVOCATION);
398
399 /**
400 * XfpmPowerManager::handle-get-config:
401 * @object: A #XfpmPowerManager.
402 * @invocation: A #GDBusMethodInvocation.
403 *
404 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Power-Manager.GetConfig">GetConfig()</link> D-Bus method.
405 *
406 * 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 xfpm_power_manager_complete_get_config() 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.
407 *
408 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
409 */
410 g_signal_new ("handle-get-config",
411 G_TYPE_FROM_INTERFACE (iface),
412 G_SIGNAL_RUN_LAST,
413 G_STRUCT_OFFSET (XfpmPowerManagerIface, handle_get_config),
414 g_signal_accumulator_true_handled,
415 NULL,
416 g_cclosure_marshal_generic,
417 G_TYPE_BOOLEAN,
418 1,
419 G_TYPE_DBUS_METHOD_INVOCATION);
420
421 /**
422 * XfpmPowerManager::handle-get-info:
423 * @object: A #XfpmPowerManager.
424 * @invocation: A #GDBusMethodInvocation.
425 *
426 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-xfce-Power-Manager.GetInfo">GetInfo()</link> D-Bus method.
427 *
428 * 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 xfpm_power_manager_complete_get_info() 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.
429 *
430 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
431 */
432 g_signal_new ("handle-get-info",
433 G_TYPE_FROM_INTERFACE (iface),
434 G_SIGNAL_RUN_LAST,
435 G_STRUCT_OFFSET (XfpmPowerManagerIface, handle_get_info),
436 g_signal_accumulator_true_handled,
437 NULL,
438 g_cclosure_marshal_generic,
439 G_TYPE_BOOLEAN,
440 1,
441 G_TYPE_DBUS_METHOD_INVOCATION);
442
443 }
444
445 /**
446 * xfpm_power_manager_call_quit:
447 * @proxy: A #XfpmPowerManagerProxy.
448 * @cancellable: (nullable): A #GCancellable or %NULL.
449 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
450 * @user_data: User data to pass to @callback.
451 *
452 * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.Quit">Quit()</link> D-Bus method on @proxy.
453 * 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.
454 * You can then call xfpm_power_manager_call_quit_finish() to get the result of the operation.
455 *
456 * See xfpm_power_manager_call_quit_sync() for the synchronous, blocking version of this method.
457 */
458 void
xfpm_power_manager_call_quit(XfpmPowerManager * proxy,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)459 xfpm_power_manager_call_quit (
460 XfpmPowerManager *proxy,
461 GCancellable *cancellable,
462 GAsyncReadyCallback callback,
463 gpointer user_data)
464 {
465 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
466 "Quit",
467 g_variant_new ("()"),
468 G_DBUS_CALL_FLAGS_NONE,
469 -1,
470 cancellable,
471 callback,
472 user_data);
473 }
474
475 /**
476 * xfpm_power_manager_call_quit_finish:
477 * @proxy: A #XfpmPowerManagerProxy.
478 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_call_quit().
479 * @error: Return location for error or %NULL.
480 *
481 * Finishes an operation started with xfpm_power_manager_call_quit().
482 *
483 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
484 */
485 gboolean
xfpm_power_manager_call_quit_finish(XfpmPowerManager * proxy,GAsyncResult * res,GError ** error)486 xfpm_power_manager_call_quit_finish (
487 XfpmPowerManager *proxy,
488 GAsyncResult *res,
489 GError **error)
490 {
491 GVariant *_ret;
492 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
493 if (_ret == NULL)
494 goto _out;
495 g_variant_get (_ret,
496 "()");
497 g_variant_unref (_ret);
498 _out:
499 return _ret != NULL;
500 }
501
502 /**
503 * xfpm_power_manager_call_quit_sync:
504 * @proxy: A #XfpmPowerManagerProxy.
505 * @cancellable: (nullable): A #GCancellable or %NULL.
506 * @error: Return location for error or %NULL.
507 *
508 * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.Quit">Quit()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
509 *
510 * See xfpm_power_manager_call_quit() for the asynchronous version of this method.
511 *
512 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
513 */
514 gboolean
xfpm_power_manager_call_quit_sync(XfpmPowerManager * proxy,GCancellable * cancellable,GError ** error)515 xfpm_power_manager_call_quit_sync (
516 XfpmPowerManager *proxy,
517 GCancellable *cancellable,
518 GError **error)
519 {
520 GVariant *_ret;
521 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
522 "Quit",
523 g_variant_new ("()"),
524 G_DBUS_CALL_FLAGS_NONE,
525 -1,
526 cancellable,
527 error);
528 if (_ret == NULL)
529 goto _out;
530 g_variant_get (_ret,
531 "()");
532 g_variant_unref (_ret);
533 _out:
534 return _ret != NULL;
535 }
536
537 /**
538 * xfpm_power_manager_call_restart:
539 * @proxy: A #XfpmPowerManagerProxy.
540 * @cancellable: (nullable): A #GCancellable or %NULL.
541 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
542 * @user_data: User data to pass to @callback.
543 *
544 * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.Restart">Restart()</link> D-Bus method on @proxy.
545 * 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.
546 * You can then call xfpm_power_manager_call_restart_finish() to get the result of the operation.
547 *
548 * See xfpm_power_manager_call_restart_sync() for the synchronous, blocking version of this method.
549 */
550 void
xfpm_power_manager_call_restart(XfpmPowerManager * proxy,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)551 xfpm_power_manager_call_restart (
552 XfpmPowerManager *proxy,
553 GCancellable *cancellable,
554 GAsyncReadyCallback callback,
555 gpointer user_data)
556 {
557 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
558 "Restart",
559 g_variant_new ("()"),
560 G_DBUS_CALL_FLAGS_NONE,
561 -1,
562 cancellable,
563 callback,
564 user_data);
565 }
566
567 /**
568 * xfpm_power_manager_call_restart_finish:
569 * @proxy: A #XfpmPowerManagerProxy.
570 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_call_restart().
571 * @error: Return location for error or %NULL.
572 *
573 * Finishes an operation started with xfpm_power_manager_call_restart().
574 *
575 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
576 */
577 gboolean
xfpm_power_manager_call_restart_finish(XfpmPowerManager * proxy,GAsyncResult * res,GError ** error)578 xfpm_power_manager_call_restart_finish (
579 XfpmPowerManager *proxy,
580 GAsyncResult *res,
581 GError **error)
582 {
583 GVariant *_ret;
584 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
585 if (_ret == NULL)
586 goto _out;
587 g_variant_get (_ret,
588 "()");
589 g_variant_unref (_ret);
590 _out:
591 return _ret != NULL;
592 }
593
594 /**
595 * xfpm_power_manager_call_restart_sync:
596 * @proxy: A #XfpmPowerManagerProxy.
597 * @cancellable: (nullable): A #GCancellable or %NULL.
598 * @error: Return location for error or %NULL.
599 *
600 * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.Restart">Restart()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
601 *
602 * See xfpm_power_manager_call_restart() for the asynchronous version of this method.
603 *
604 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
605 */
606 gboolean
xfpm_power_manager_call_restart_sync(XfpmPowerManager * proxy,GCancellable * cancellable,GError ** error)607 xfpm_power_manager_call_restart_sync (
608 XfpmPowerManager *proxy,
609 GCancellable *cancellable,
610 GError **error)
611 {
612 GVariant *_ret;
613 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
614 "Restart",
615 g_variant_new ("()"),
616 G_DBUS_CALL_FLAGS_NONE,
617 -1,
618 cancellable,
619 error);
620 if (_ret == NULL)
621 goto _out;
622 g_variant_get (_ret,
623 "()");
624 g_variant_unref (_ret);
625 _out:
626 return _ret != NULL;
627 }
628
629 /**
630 * xfpm_power_manager_call_get_config:
631 * @proxy: A #XfpmPowerManagerProxy.
632 * @cancellable: (nullable): A #GCancellable or %NULL.
633 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
634 * @user_data: User data to pass to @callback.
635 *
636 * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.GetConfig">GetConfig()</link> D-Bus method on @proxy.
637 * 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.
638 * You can then call xfpm_power_manager_call_get_config_finish() to get the result of the operation.
639 *
640 * See xfpm_power_manager_call_get_config_sync() for the synchronous, blocking version of this method.
641 */
642 void
xfpm_power_manager_call_get_config(XfpmPowerManager * proxy,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)643 xfpm_power_manager_call_get_config (
644 XfpmPowerManager *proxy,
645 GCancellable *cancellable,
646 GAsyncReadyCallback callback,
647 gpointer user_data)
648 {
649 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
650 "GetConfig",
651 g_variant_new ("()"),
652 G_DBUS_CALL_FLAGS_NONE,
653 -1,
654 cancellable,
655 callback,
656 user_data);
657 }
658
659 /**
660 * xfpm_power_manager_call_get_config_finish:
661 * @proxy: A #XfpmPowerManagerProxy.
662 * @out_config: (out): Return location for return parameter or %NULL to ignore.
663 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_call_get_config().
664 * @error: Return location for error or %NULL.
665 *
666 * Finishes an operation started with xfpm_power_manager_call_get_config().
667 *
668 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
669 */
670 gboolean
xfpm_power_manager_call_get_config_finish(XfpmPowerManager * proxy,GVariant ** out_config,GAsyncResult * res,GError ** error)671 xfpm_power_manager_call_get_config_finish (
672 XfpmPowerManager *proxy,
673 GVariant **out_config,
674 GAsyncResult *res,
675 GError **error)
676 {
677 GVariant *_ret;
678 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
679 if (_ret == NULL)
680 goto _out;
681 g_variant_get (_ret,
682 "(@a{ss})",
683 out_config);
684 g_variant_unref (_ret);
685 _out:
686 return _ret != NULL;
687 }
688
689 /**
690 * xfpm_power_manager_call_get_config_sync:
691 * @proxy: A #XfpmPowerManagerProxy.
692 * @out_config: (out): Return location for return parameter or %NULL to ignore.
693 * @cancellable: (nullable): A #GCancellable or %NULL.
694 * @error: Return location for error or %NULL.
695 *
696 * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.GetConfig">GetConfig()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
697 *
698 * See xfpm_power_manager_call_get_config() for the asynchronous version of this method.
699 *
700 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
701 */
702 gboolean
xfpm_power_manager_call_get_config_sync(XfpmPowerManager * proxy,GVariant ** out_config,GCancellable * cancellable,GError ** error)703 xfpm_power_manager_call_get_config_sync (
704 XfpmPowerManager *proxy,
705 GVariant **out_config,
706 GCancellable *cancellable,
707 GError **error)
708 {
709 GVariant *_ret;
710 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
711 "GetConfig",
712 g_variant_new ("()"),
713 G_DBUS_CALL_FLAGS_NONE,
714 -1,
715 cancellable,
716 error);
717 if (_ret == NULL)
718 goto _out;
719 g_variant_get (_ret,
720 "(@a{ss})",
721 out_config);
722 g_variant_unref (_ret);
723 _out:
724 return _ret != NULL;
725 }
726
727 /**
728 * xfpm_power_manager_call_get_info:
729 * @proxy: A #XfpmPowerManagerProxy.
730 * @cancellable: (nullable): A #GCancellable or %NULL.
731 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
732 * @user_data: User data to pass to @callback.
733 *
734 * Asynchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.GetInfo">GetInfo()</link> D-Bus method on @proxy.
735 * 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.
736 * You can then call xfpm_power_manager_call_get_info_finish() to get the result of the operation.
737 *
738 * See xfpm_power_manager_call_get_info_sync() for the synchronous, blocking version of this method.
739 */
740 void
xfpm_power_manager_call_get_info(XfpmPowerManager * proxy,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)741 xfpm_power_manager_call_get_info (
742 XfpmPowerManager *proxy,
743 GCancellable *cancellable,
744 GAsyncReadyCallback callback,
745 gpointer user_data)
746 {
747 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
748 "GetInfo",
749 g_variant_new ("()"),
750 G_DBUS_CALL_FLAGS_NONE,
751 -1,
752 cancellable,
753 callback,
754 user_data);
755 }
756
757 /**
758 * xfpm_power_manager_call_get_info_finish:
759 * @proxy: A #XfpmPowerManagerProxy.
760 * @out_name: (out): Return location for return parameter or %NULL to ignore.
761 * @out_version: (out): Return location for return parameter or %NULL to ignore.
762 * @out_vendor: (out): Return location for return parameter or %NULL to ignore.
763 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_call_get_info().
764 * @error: Return location for error or %NULL.
765 *
766 * Finishes an operation started with xfpm_power_manager_call_get_info().
767 *
768 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
769 */
770 gboolean
xfpm_power_manager_call_get_info_finish(XfpmPowerManager * proxy,gchar ** out_name,gchar ** out_version,gchar ** out_vendor,GAsyncResult * res,GError ** error)771 xfpm_power_manager_call_get_info_finish (
772 XfpmPowerManager *proxy,
773 gchar **out_name,
774 gchar **out_version,
775 gchar **out_vendor,
776 GAsyncResult *res,
777 GError **error)
778 {
779 GVariant *_ret;
780 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
781 if (_ret == NULL)
782 goto _out;
783 g_variant_get (_ret,
784 "(sss)",
785 out_name,
786 out_version,
787 out_vendor);
788 g_variant_unref (_ret);
789 _out:
790 return _ret != NULL;
791 }
792
793 /**
794 * xfpm_power_manager_call_get_info_sync:
795 * @proxy: A #XfpmPowerManagerProxy.
796 * @out_name: (out): Return location for return parameter or %NULL to ignore.
797 * @out_version: (out): Return location for return parameter or %NULL to ignore.
798 * @out_vendor: (out): Return location for return parameter or %NULL to ignore.
799 * @cancellable: (nullable): A #GCancellable or %NULL.
800 * @error: Return location for error or %NULL.
801 *
802 * Synchronously invokes the <link linkend="gdbus-method-org-xfce-Power-Manager.GetInfo">GetInfo()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
803 *
804 * See xfpm_power_manager_call_get_info() for the asynchronous version of this method.
805 *
806 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
807 */
808 gboolean
xfpm_power_manager_call_get_info_sync(XfpmPowerManager * proxy,gchar ** out_name,gchar ** out_version,gchar ** out_vendor,GCancellable * cancellable,GError ** error)809 xfpm_power_manager_call_get_info_sync (
810 XfpmPowerManager *proxy,
811 gchar **out_name,
812 gchar **out_version,
813 gchar **out_vendor,
814 GCancellable *cancellable,
815 GError **error)
816 {
817 GVariant *_ret;
818 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
819 "GetInfo",
820 g_variant_new ("()"),
821 G_DBUS_CALL_FLAGS_NONE,
822 -1,
823 cancellable,
824 error);
825 if (_ret == NULL)
826 goto _out;
827 g_variant_get (_ret,
828 "(sss)",
829 out_name,
830 out_version,
831 out_vendor);
832 g_variant_unref (_ret);
833 _out:
834 return _ret != NULL;
835 }
836
837 /**
838 * xfpm_power_manager_complete_quit:
839 * @object: A #XfpmPowerManager.
840 * @invocation: (transfer full): A #GDBusMethodInvocation.
841 *
842 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Power-Manager.Quit">Quit()</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.
843 *
844 * This method will free @invocation, you cannot use it afterwards.
845 */
846 void
xfpm_power_manager_complete_quit(XfpmPowerManager * object,GDBusMethodInvocation * invocation)847 xfpm_power_manager_complete_quit (
848 XfpmPowerManager *object,
849 GDBusMethodInvocation *invocation)
850 {
851 g_dbus_method_invocation_return_value (invocation,
852 g_variant_new ("()"));
853 }
854
855 /**
856 * xfpm_power_manager_complete_restart:
857 * @object: A #XfpmPowerManager.
858 * @invocation: (transfer full): A #GDBusMethodInvocation.
859 *
860 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Power-Manager.Restart">Restart()</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.
861 *
862 * This method will free @invocation, you cannot use it afterwards.
863 */
864 void
xfpm_power_manager_complete_restart(XfpmPowerManager * object,GDBusMethodInvocation * invocation)865 xfpm_power_manager_complete_restart (
866 XfpmPowerManager *object,
867 GDBusMethodInvocation *invocation)
868 {
869 g_dbus_method_invocation_return_value (invocation,
870 g_variant_new ("()"));
871 }
872
873 /**
874 * xfpm_power_manager_complete_get_config:
875 * @object: A #XfpmPowerManager.
876 * @invocation: (transfer full): A #GDBusMethodInvocation.
877 * @config: Parameter to return.
878 *
879 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Power-Manager.GetConfig">GetConfig()</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.
880 *
881 * This method will free @invocation, you cannot use it afterwards.
882 */
883 void
xfpm_power_manager_complete_get_config(XfpmPowerManager * object,GDBusMethodInvocation * invocation,GVariant * config)884 xfpm_power_manager_complete_get_config (
885 XfpmPowerManager *object,
886 GDBusMethodInvocation *invocation,
887 GVariant *config)
888 {
889 g_dbus_method_invocation_return_value (invocation,
890 g_variant_new ("(@a{ss})",
891 config));
892 }
893
894 /**
895 * xfpm_power_manager_complete_get_info:
896 * @object: A #XfpmPowerManager.
897 * @invocation: (transfer full): A #GDBusMethodInvocation.
898 * @name: Parameter to return.
899 * @version: Parameter to return.
900 * @vendor: Parameter to return.
901 *
902 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-xfce-Power-Manager.GetInfo">GetInfo()</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.
903 *
904 * This method will free @invocation, you cannot use it afterwards.
905 */
906 void
xfpm_power_manager_complete_get_info(XfpmPowerManager * object,GDBusMethodInvocation * invocation,const gchar * name,const gchar * version,const gchar * vendor)907 xfpm_power_manager_complete_get_info (
908 XfpmPowerManager *object,
909 GDBusMethodInvocation *invocation,
910 const gchar *name,
911 const gchar *version,
912 const gchar *vendor)
913 {
914 g_dbus_method_invocation_return_value (invocation,
915 g_variant_new ("(sss)",
916 name,
917 version,
918 vendor));
919 }
920
921 /* ------------------------------------------------------------------------ */
922
923 /**
924 * XfpmPowerManagerProxy:
925 *
926 * The #XfpmPowerManagerProxy structure contains only private data and should only be accessed using the provided API.
927 */
928
929 /**
930 * XfpmPowerManagerProxyClass:
931 * @parent_class: The parent class.
932 *
933 * Class structure for #XfpmPowerManagerProxy.
934 */
935
936 struct _XfpmPowerManagerProxyPrivate
937 {
938 GData *qdata;
939 };
940
941 static void xfpm_power_manager_proxy_iface_init (XfpmPowerManagerIface *iface);
942
943 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
G_DEFINE_TYPE_WITH_CODE(XfpmPowerManagerProxy,xfpm_power_manager_proxy,G_TYPE_DBUS_PROXY,G_ADD_PRIVATE (XfpmPowerManagerProxy)G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER,xfpm_power_manager_proxy_iface_init))944 G_DEFINE_TYPE_WITH_CODE (XfpmPowerManagerProxy, xfpm_power_manager_proxy, G_TYPE_DBUS_PROXY,
945 G_ADD_PRIVATE (XfpmPowerManagerProxy)
946 G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER, xfpm_power_manager_proxy_iface_init))
947
948 #else
949 G_DEFINE_TYPE_WITH_CODE (XfpmPowerManagerProxy, xfpm_power_manager_proxy, G_TYPE_DBUS_PROXY,
950 G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER, xfpm_power_manager_proxy_iface_init))
951
952 #endif
953 static void
954 xfpm_power_manager_proxy_finalize (GObject *object)
955 {
956 XfpmPowerManagerProxy *proxy = XFPM_POWER_MANAGER_PROXY (object);
957 g_datalist_clear (&proxy->priv->qdata);
958 G_OBJECT_CLASS (xfpm_power_manager_proxy_parent_class)->finalize (object);
959 }
960
961 static void
xfpm_power_manager_proxy_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec G_GNUC_UNUSED)962 xfpm_power_manager_proxy_get_property (GObject *object,
963 guint prop_id,
964 GValue *value,
965 GParamSpec *pspec G_GNUC_UNUSED)
966 {
967 }
968
969 static void
xfpm_power_manager_proxy_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec G_GNUC_UNUSED)970 xfpm_power_manager_proxy_set_property (GObject *object,
971 guint prop_id,
972 const GValue *value,
973 GParamSpec *pspec G_GNUC_UNUSED)
974 {
975 }
976
977 static void
xfpm_power_manager_proxy_g_signal(GDBusProxy * proxy,const gchar * sender_name G_GNUC_UNUSED,const gchar * signal_name,GVariant * parameters)978 xfpm_power_manager_proxy_g_signal (GDBusProxy *proxy,
979 const gchar *sender_name G_GNUC_UNUSED,
980 const gchar *signal_name,
981 GVariant *parameters)
982 {
983 _ExtendedGDBusSignalInfo *info;
984 GVariantIter iter;
985 GVariant *child;
986 GValue *paramv;
987 gsize num_params;
988 gsize n;
989 guint signal_id;
990 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct, signal_name);
991 if (info == NULL)
992 return;
993 num_params = g_variant_n_children (parameters);
994 paramv = g_new0 (GValue, num_params + 1);
995 g_value_init (¶mv[0], XFPM_TYPE_POWER_MANAGER);
996 g_value_set_object (¶mv[0], proxy);
997 g_variant_iter_init (&iter, parameters);
998 n = 1;
999 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1000 {
1001 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
1002 if (arg_info->use_gvariant)
1003 {
1004 g_value_init (¶mv[n], G_TYPE_VARIANT);
1005 g_value_set_variant (¶mv[n], child);
1006 n++;
1007 }
1008 else
1009 g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
1010 g_variant_unref (child);
1011 }
1012 signal_id = g_signal_lookup (info->signal_name, XFPM_TYPE_POWER_MANAGER);
1013 g_signal_emitv (paramv, signal_id, 0, NULL);
1014 for (n = 0; n < num_params + 1; n++)
1015 g_value_unset (¶mv[n]);
1016 g_free (paramv);
1017 }
1018
1019 static void
xfpm_power_manager_proxy_g_properties_changed(GDBusProxy * _proxy,GVariant * changed_properties,const gchar * const * invalidated_properties)1020 xfpm_power_manager_proxy_g_properties_changed (GDBusProxy *_proxy,
1021 GVariant *changed_properties,
1022 const gchar *const *invalidated_properties)
1023 {
1024 XfpmPowerManagerProxy *proxy = XFPM_POWER_MANAGER_PROXY (_proxy);
1025 guint n;
1026 const gchar *key;
1027 GVariantIter *iter;
1028 _ExtendedGDBusPropertyInfo *info;
1029 g_variant_get (changed_properties, "a{sv}", &iter);
1030 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
1031 {
1032 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct, key);
1033 g_datalist_remove_data (&proxy->priv->qdata, key);
1034 if (info != NULL)
1035 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
1036 }
1037 g_variant_iter_free (iter);
1038 for (n = 0; invalidated_properties[n] != NULL; n++)
1039 {
1040 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct, invalidated_properties[n]);
1041 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
1042 if (info != NULL)
1043 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
1044 }
1045 }
1046
1047 static void
xfpm_power_manager_proxy_init(XfpmPowerManagerProxy * proxy)1048 xfpm_power_manager_proxy_init (XfpmPowerManagerProxy *proxy)
1049 {
1050 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1051 proxy->priv = xfpm_power_manager_proxy_get_instance_private (proxy);
1052 #else
1053 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, XFPM_TYPE_POWER_MANAGER_PROXY, XfpmPowerManagerProxyPrivate);
1054 #endif
1055
1056 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), xfpm_power_manager_interface_info ());
1057 }
1058
1059 static void
xfpm_power_manager_proxy_class_init(XfpmPowerManagerProxyClass * klass)1060 xfpm_power_manager_proxy_class_init (XfpmPowerManagerProxyClass *klass)
1061 {
1062 GObjectClass *gobject_class;
1063 GDBusProxyClass *proxy_class;
1064
1065 gobject_class = G_OBJECT_CLASS (klass);
1066 gobject_class->finalize = xfpm_power_manager_proxy_finalize;
1067 gobject_class->get_property = xfpm_power_manager_proxy_get_property;
1068 gobject_class->set_property = xfpm_power_manager_proxy_set_property;
1069
1070 proxy_class = G_DBUS_PROXY_CLASS (klass);
1071 proxy_class->g_signal = xfpm_power_manager_proxy_g_signal;
1072 proxy_class->g_properties_changed = xfpm_power_manager_proxy_g_properties_changed;
1073
1074 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1075 g_type_class_add_private (klass, sizeof (XfpmPowerManagerProxyPrivate));
1076 #endif
1077 }
1078
1079 static void
xfpm_power_manager_proxy_iface_init(XfpmPowerManagerIface * iface)1080 xfpm_power_manager_proxy_iface_init (XfpmPowerManagerIface *iface)
1081 {
1082 }
1083
1084 /**
1085 * xfpm_power_manager_proxy_new:
1086 * @connection: A #GDBusConnection.
1087 * @flags: Flags from the #GDBusProxyFlags enumeration.
1088 * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1089 * @object_path: An object path.
1090 * @cancellable: (nullable): A #GCancellable or %NULL.
1091 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1092 * @user_data: User data to pass to @callback.
1093 *
1094 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link>. See g_dbus_proxy_new() for more details.
1095 *
1096 * 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.
1097 * You can then call xfpm_power_manager_proxy_new_finish() to get the result of the operation.
1098 *
1099 * See xfpm_power_manager_proxy_new_sync() for the synchronous, blocking version of this constructor.
1100 */
1101 void
xfpm_power_manager_proxy_new(GDBusConnection * connection,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)1102 xfpm_power_manager_proxy_new (
1103 GDBusConnection *connection,
1104 GDBusProxyFlags flags,
1105 const gchar *name,
1106 const gchar *object_path,
1107 GCancellable *cancellable,
1108 GAsyncReadyCallback callback,
1109 gpointer user_data)
1110 {
1111 g_async_initable_new_async (XFPM_TYPE_POWER_MANAGER_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.xfce.Power.Manager", NULL);
1112 }
1113
1114 /**
1115 * xfpm_power_manager_proxy_new_finish:
1116 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_proxy_new().
1117 * @error: Return location for error or %NULL
1118 *
1119 * Finishes an operation started with xfpm_power_manager_proxy_new().
1120 *
1121 * Returns: (transfer full) (type XfpmPowerManagerProxy): The constructed proxy object or %NULL if @error is set.
1122 */
1123 XfpmPowerManager *
xfpm_power_manager_proxy_new_finish(GAsyncResult * res,GError ** error)1124 xfpm_power_manager_proxy_new_finish (
1125 GAsyncResult *res,
1126 GError **error)
1127 {
1128 GObject *ret;
1129 GObject *source_object;
1130 source_object = g_async_result_get_source_object (res);
1131 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1132 g_object_unref (source_object);
1133 if (ret != NULL)
1134 return XFPM_POWER_MANAGER (ret);
1135 else
1136 return NULL;
1137 }
1138
1139 /**
1140 * xfpm_power_manager_proxy_new_sync:
1141 * @connection: A #GDBusConnection.
1142 * @flags: Flags from the #GDBusProxyFlags enumeration.
1143 * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1144 * @object_path: An object path.
1145 * @cancellable: (nullable): A #GCancellable or %NULL.
1146 * @error: Return location for error or %NULL
1147 *
1148 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link>. See g_dbus_proxy_new_sync() for more details.
1149 *
1150 * The calling thread is blocked until a reply is received.
1151 *
1152 * See xfpm_power_manager_proxy_new() for the asynchronous version of this constructor.
1153 *
1154 * Returns: (transfer full) (type XfpmPowerManagerProxy): The constructed proxy object or %NULL if @error is set.
1155 */
1156 XfpmPowerManager *
xfpm_power_manager_proxy_new_sync(GDBusConnection * connection,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GError ** error)1157 xfpm_power_manager_proxy_new_sync (
1158 GDBusConnection *connection,
1159 GDBusProxyFlags flags,
1160 const gchar *name,
1161 const gchar *object_path,
1162 GCancellable *cancellable,
1163 GError **error)
1164 {
1165 GInitable *ret;
1166 ret = g_initable_new (XFPM_TYPE_POWER_MANAGER_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.xfce.Power.Manager", NULL);
1167 if (ret != NULL)
1168 return XFPM_POWER_MANAGER (ret);
1169 else
1170 return NULL;
1171 }
1172
1173
1174 /**
1175 * xfpm_power_manager_proxy_new_for_bus:
1176 * @bus_type: A #GBusType.
1177 * @flags: Flags from the #GDBusProxyFlags enumeration.
1178 * @name: A bus name (well-known or unique).
1179 * @object_path: An object path.
1180 * @cancellable: (nullable): A #GCancellable or %NULL.
1181 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1182 * @user_data: User data to pass to @callback.
1183 *
1184 * Like xfpm_power_manager_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
1185 *
1186 * 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.
1187 * You can then call xfpm_power_manager_proxy_new_for_bus_finish() to get the result of the operation.
1188 *
1189 * See xfpm_power_manager_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
1190 */
1191 void
xfpm_power_manager_proxy_new_for_bus(GBusType bus_type,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)1192 xfpm_power_manager_proxy_new_for_bus (
1193 GBusType bus_type,
1194 GDBusProxyFlags flags,
1195 const gchar *name,
1196 const gchar *object_path,
1197 GCancellable *cancellable,
1198 GAsyncReadyCallback callback,
1199 gpointer user_data)
1200 {
1201 g_async_initable_new_async (XFPM_TYPE_POWER_MANAGER_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.xfce.Power.Manager", NULL);
1202 }
1203
1204 /**
1205 * xfpm_power_manager_proxy_new_for_bus_finish:
1206 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to xfpm_power_manager_proxy_new_for_bus().
1207 * @error: Return location for error or %NULL
1208 *
1209 * Finishes an operation started with xfpm_power_manager_proxy_new_for_bus().
1210 *
1211 * Returns: (transfer full) (type XfpmPowerManagerProxy): The constructed proxy object or %NULL if @error is set.
1212 */
1213 XfpmPowerManager *
xfpm_power_manager_proxy_new_for_bus_finish(GAsyncResult * res,GError ** error)1214 xfpm_power_manager_proxy_new_for_bus_finish (
1215 GAsyncResult *res,
1216 GError **error)
1217 {
1218 GObject *ret;
1219 GObject *source_object;
1220 source_object = g_async_result_get_source_object (res);
1221 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1222 g_object_unref (source_object);
1223 if (ret != NULL)
1224 return XFPM_POWER_MANAGER (ret);
1225 else
1226 return NULL;
1227 }
1228
1229 /**
1230 * xfpm_power_manager_proxy_new_for_bus_sync:
1231 * @bus_type: A #GBusType.
1232 * @flags: Flags from the #GDBusProxyFlags enumeration.
1233 * @name: A bus name (well-known or unique).
1234 * @object_path: An object path.
1235 * @cancellable: (nullable): A #GCancellable or %NULL.
1236 * @error: Return location for error or %NULL
1237 *
1238 * Like xfpm_power_manager_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
1239 *
1240 * The calling thread is blocked until a reply is received.
1241 *
1242 * See xfpm_power_manager_proxy_new_for_bus() for the asynchronous version of this constructor.
1243 *
1244 * Returns: (transfer full) (type XfpmPowerManagerProxy): The constructed proxy object or %NULL if @error is set.
1245 */
1246 XfpmPowerManager *
xfpm_power_manager_proxy_new_for_bus_sync(GBusType bus_type,GDBusProxyFlags flags,const gchar * name,const gchar * object_path,GCancellable * cancellable,GError ** error)1247 xfpm_power_manager_proxy_new_for_bus_sync (
1248 GBusType bus_type,
1249 GDBusProxyFlags flags,
1250 const gchar *name,
1251 const gchar *object_path,
1252 GCancellable *cancellable,
1253 GError **error)
1254 {
1255 GInitable *ret;
1256 ret = g_initable_new (XFPM_TYPE_POWER_MANAGER_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.xfce.Power.Manager", NULL);
1257 if (ret != NULL)
1258 return XFPM_POWER_MANAGER (ret);
1259 else
1260 return NULL;
1261 }
1262
1263
1264 /* ------------------------------------------------------------------------ */
1265
1266 /**
1267 * XfpmPowerManagerSkeleton:
1268 *
1269 * The #XfpmPowerManagerSkeleton structure contains only private data and should only be accessed using the provided API.
1270 */
1271
1272 /**
1273 * XfpmPowerManagerSkeletonClass:
1274 * @parent_class: The parent class.
1275 *
1276 * Class structure for #XfpmPowerManagerSkeleton.
1277 */
1278
1279 struct _XfpmPowerManagerSkeletonPrivate
1280 {
1281 GValue *properties;
1282 GList *changed_properties;
1283 GSource *changed_properties_idle_source;
1284 GMainContext *context;
1285 GMutex lock;
1286 };
1287
1288 static void
_xfpm_power_manager_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)1289 _xfpm_power_manager_skeleton_handle_method_call (
1290 GDBusConnection *connection G_GNUC_UNUSED,
1291 const gchar *sender G_GNUC_UNUSED,
1292 const gchar *object_path G_GNUC_UNUSED,
1293 const gchar *interface_name,
1294 const gchar *method_name,
1295 GVariant *parameters,
1296 GDBusMethodInvocation *invocation,
1297 gpointer user_data)
1298 {
1299 XfpmPowerManagerSkeleton *skeleton = XFPM_POWER_MANAGER_SKELETON (user_data);
1300 _ExtendedGDBusMethodInfo *info;
1301 GVariantIter iter;
1302 GVariant *child;
1303 GValue *paramv;
1304 gsize num_params;
1305 guint num_extra;
1306 gsize n;
1307 guint signal_id;
1308 GValue return_value = G_VALUE_INIT;
1309 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
1310 g_assert (info != NULL);
1311 num_params = g_variant_n_children (parameters);
1312 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
1313 n = 0;
1314 g_value_init (¶mv[n], XFPM_TYPE_POWER_MANAGER);
1315 g_value_set_object (¶mv[n++], skeleton);
1316 g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION);
1317 g_value_set_object (¶mv[n++], invocation);
1318 if (info->pass_fdlist)
1319 {
1320 #ifdef G_OS_UNIX
1321 g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST);
1322 g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
1323 #else
1324 g_assert_not_reached ();
1325 #endif
1326 }
1327 g_variant_iter_init (&iter, parameters);
1328 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1329 {
1330 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
1331 if (arg_info->use_gvariant)
1332 {
1333 g_value_init (¶mv[n], G_TYPE_VARIANT);
1334 g_value_set_variant (¶mv[n], child);
1335 n++;
1336 }
1337 else
1338 g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
1339 g_variant_unref (child);
1340 }
1341 signal_id = g_signal_lookup (info->signal_name, XFPM_TYPE_POWER_MANAGER);
1342 g_value_init (&return_value, G_TYPE_BOOLEAN);
1343 g_signal_emitv (paramv, signal_id, 0, &return_value);
1344 if (!g_value_get_boolean (&return_value))
1345 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);
1346 g_value_unset (&return_value);
1347 for (n = 0; n < num_params + num_extra; n++)
1348 g_value_unset (¶mv[n]);
1349 g_free (paramv);
1350 }
1351
1352 static GVariant *
_xfpm_power_manager_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)1353 _xfpm_power_manager_skeleton_handle_get_property (
1354 GDBusConnection *connection G_GNUC_UNUSED,
1355 const gchar *sender G_GNUC_UNUSED,
1356 const gchar *object_path G_GNUC_UNUSED,
1357 const gchar *interface_name G_GNUC_UNUSED,
1358 const gchar *property_name,
1359 GError **error,
1360 gpointer user_data)
1361 {
1362 XfpmPowerManagerSkeleton *skeleton = XFPM_POWER_MANAGER_SKELETON (user_data);
1363 GValue value = G_VALUE_INIT;
1364 GParamSpec *pspec;
1365 _ExtendedGDBusPropertyInfo *info;
1366 GVariant *ret;
1367 ret = NULL;
1368 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct, property_name);
1369 g_assert (info != NULL);
1370 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1371 if (pspec == NULL)
1372 {
1373 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1374 }
1375 else
1376 {
1377 g_value_init (&value, pspec->value_type);
1378 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1379 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
1380 g_value_unset (&value);
1381 }
1382 return ret;
1383 }
1384
1385 static gboolean
_xfpm_power_manager_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)1386 _xfpm_power_manager_skeleton_handle_set_property (
1387 GDBusConnection *connection G_GNUC_UNUSED,
1388 const gchar *sender G_GNUC_UNUSED,
1389 const gchar *object_path G_GNUC_UNUSED,
1390 const gchar *interface_name G_GNUC_UNUSED,
1391 const gchar *property_name,
1392 GVariant *variant,
1393 GError **error,
1394 gpointer user_data)
1395 {
1396 XfpmPowerManagerSkeleton *skeleton = XFPM_POWER_MANAGER_SKELETON (user_data);
1397 GValue value = G_VALUE_INIT;
1398 GParamSpec *pspec;
1399 _ExtendedGDBusPropertyInfo *info;
1400 gboolean ret;
1401 ret = FALSE;
1402 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_xfpm_power_manager_interface_info.parent_struct, property_name);
1403 g_assert (info != NULL);
1404 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1405 if (pspec == NULL)
1406 {
1407 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1408 }
1409 else
1410 {
1411 if (info->use_gvariant)
1412 g_value_set_variant (&value, variant);
1413 else
1414 g_dbus_gvariant_to_gvalue (variant, &value);
1415 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1416 g_value_unset (&value);
1417 ret = TRUE;
1418 }
1419 return ret;
1420 }
1421
1422 static const GDBusInterfaceVTable _xfpm_power_manager_skeleton_vtable =
1423 {
1424 _xfpm_power_manager_skeleton_handle_method_call,
1425 _xfpm_power_manager_skeleton_handle_get_property,
1426 _xfpm_power_manager_skeleton_handle_set_property,
1427 {NULL}
1428 };
1429
1430 static GDBusInterfaceInfo *
xfpm_power_manager_skeleton_dbus_interface_get_info(GDBusInterfaceSkeleton * skeleton G_GNUC_UNUSED)1431 xfpm_power_manager_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1432 {
1433 return xfpm_power_manager_interface_info ();
1434 }
1435
1436 static GDBusInterfaceVTable *
xfpm_power_manager_skeleton_dbus_interface_get_vtable(GDBusInterfaceSkeleton * skeleton G_GNUC_UNUSED)1437 xfpm_power_manager_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1438 {
1439 return (GDBusInterfaceVTable *) &_xfpm_power_manager_skeleton_vtable;
1440 }
1441
1442 static GVariant *
xfpm_power_manager_skeleton_dbus_interface_get_properties(GDBusInterfaceSkeleton * _skeleton)1443 xfpm_power_manager_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
1444 {
1445 XfpmPowerManagerSkeleton *skeleton = XFPM_POWER_MANAGER_SKELETON (_skeleton);
1446
1447 GVariantBuilder builder;
1448 guint n;
1449 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1450 if (_xfpm_power_manager_interface_info.parent_struct.properties == NULL)
1451 goto out;
1452 for (n = 0; _xfpm_power_manager_interface_info.parent_struct.properties[n] != NULL; n++)
1453 {
1454 GDBusPropertyInfo *info = _xfpm_power_manager_interface_info.parent_struct.properties[n];
1455 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
1456 {
1457 GVariant *value;
1458 value = _xfpm_power_manager_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.xfce.Power.Manager", info->name, NULL, skeleton);
1459 if (value != NULL)
1460 {
1461 g_variant_take_ref (value);
1462 g_variant_builder_add (&builder, "{sv}", info->name, value);
1463 g_variant_unref (value);
1464 }
1465 }
1466 }
1467 out:
1468 return g_variant_builder_end (&builder);
1469 }
1470
1471 static void
xfpm_power_manager_skeleton_dbus_interface_flush(GDBusInterfaceSkeleton * _skeleton)1472 xfpm_power_manager_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
1473 {
1474 }
1475
1476 static void xfpm_power_manager_skeleton_iface_init (XfpmPowerManagerIface *iface);
1477 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
G_DEFINE_TYPE_WITH_CODE(XfpmPowerManagerSkeleton,xfpm_power_manager_skeleton,G_TYPE_DBUS_INTERFACE_SKELETON,G_ADD_PRIVATE (XfpmPowerManagerSkeleton)G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER,xfpm_power_manager_skeleton_iface_init))1478 G_DEFINE_TYPE_WITH_CODE (XfpmPowerManagerSkeleton, xfpm_power_manager_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1479 G_ADD_PRIVATE (XfpmPowerManagerSkeleton)
1480 G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER, xfpm_power_manager_skeleton_iface_init))
1481
1482 #else
1483 G_DEFINE_TYPE_WITH_CODE (XfpmPowerManagerSkeleton, xfpm_power_manager_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1484 G_IMPLEMENT_INTERFACE (XFPM_TYPE_POWER_MANAGER, xfpm_power_manager_skeleton_iface_init))
1485
1486 #endif
1487 static void
1488 xfpm_power_manager_skeleton_finalize (GObject *object)
1489 {
1490 XfpmPowerManagerSkeleton *skeleton = XFPM_POWER_MANAGER_SKELETON (object);
1491 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1492 if (skeleton->priv->changed_properties_idle_source != NULL)
1493 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1494 g_main_context_unref (skeleton->priv->context);
1495 g_mutex_clear (&skeleton->priv->lock);
1496 G_OBJECT_CLASS (xfpm_power_manager_skeleton_parent_class)->finalize (object);
1497 }
1498
1499 static void
xfpm_power_manager_skeleton_init(XfpmPowerManagerSkeleton * skeleton)1500 xfpm_power_manager_skeleton_init (XfpmPowerManagerSkeleton *skeleton)
1501 {
1502 #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1503 skeleton->priv = xfpm_power_manager_skeleton_get_instance_private (skeleton);
1504 #else
1505 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, XFPM_TYPE_POWER_MANAGER_SKELETON, XfpmPowerManagerSkeletonPrivate);
1506 #endif
1507
1508 g_mutex_init (&skeleton->priv->lock);
1509 skeleton->priv->context = g_main_context_ref_thread_default ();
1510 }
1511
1512 static void
xfpm_power_manager_skeleton_class_init(XfpmPowerManagerSkeletonClass * klass)1513 xfpm_power_manager_skeleton_class_init (XfpmPowerManagerSkeletonClass *klass)
1514 {
1515 GObjectClass *gobject_class;
1516 GDBusInterfaceSkeletonClass *skeleton_class;
1517
1518 gobject_class = G_OBJECT_CLASS (klass);
1519 gobject_class->finalize = xfpm_power_manager_skeleton_finalize;
1520
1521 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
1522 skeleton_class->get_info = xfpm_power_manager_skeleton_dbus_interface_get_info;
1523 skeleton_class->get_properties = xfpm_power_manager_skeleton_dbus_interface_get_properties;
1524 skeleton_class->flush = xfpm_power_manager_skeleton_dbus_interface_flush;
1525 skeleton_class->get_vtable = xfpm_power_manager_skeleton_dbus_interface_get_vtable;
1526
1527 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1528 g_type_class_add_private (klass, sizeof (XfpmPowerManagerSkeletonPrivate));
1529 #endif
1530 }
1531
1532 static void
xfpm_power_manager_skeleton_iface_init(XfpmPowerManagerIface * iface)1533 xfpm_power_manager_skeleton_iface_init (XfpmPowerManagerIface *iface)
1534 {
1535 }
1536
1537 /**
1538 * xfpm_power_manager_skeleton_new:
1539 *
1540 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-xfce-Power-Manager.top_of_page">org.xfce.Power.Manager</link>.
1541 *
1542 * Returns: (transfer full) (type XfpmPowerManagerSkeleton): The skeleton object.
1543 */
1544 XfpmPowerManager *
xfpm_power_manager_skeleton_new(void)1545 xfpm_power_manager_skeleton_new (void)
1546 {
1547 return XFPM_POWER_MANAGER (g_object_new (XFPM_TYPE_POWER_MANAGER_SKELETON, NULL));
1548 }
1549
1550