Back to index

indicator-session  12.10.0
dbus-upower.c
Go to the documentation of this file.
00001 /*
00002  * Generated by gdbus-codegen 2.33.3. DO NOT EDIT.
00003  *
00004  * The license of this code is the same as for the source it was derived from.
00005  */
00006 
00007 #ifdef HAVE_CONFIG_H
00008 #  include "config.h"
00009 #endif
00010 
00011 #include "dbus-upower.h"
00012 
00013 #include <string.h>
00014 #ifdef G_OS_UNIX
00015 #  include <gio/gunixfdlist.h>
00016 #endif
00017 
00018 typedef struct
00019 {
00020   GDBusArgInfo parent_struct;
00021   gboolean use_gvariant;
00022 } _ExtendedGDBusArgInfo;
00023 
00024 typedef struct
00025 {
00026   GDBusMethodInfo parent_struct;
00027   const gchar *signal_name;
00028   gboolean pass_fdlist;
00029 } _ExtendedGDBusMethodInfo;
00030 
00031 typedef struct
00032 {
00033   GDBusSignalInfo parent_struct;
00034   const gchar *signal_name;
00035 } _ExtendedGDBusSignalInfo;
00036 
00037 typedef struct
00038 {
00039   GDBusPropertyInfo parent_struct;
00040   const gchar *hyphen_name;
00041   gboolean use_gvariant;
00042 } _ExtendedGDBusPropertyInfo;
00043 
00044 typedef struct
00045 {
00046   GDBusInterfaceInfo parent_struct;
00047   const gchar *hyphen_name;
00048 } _ExtendedGDBusInterfaceInfo;
00049 
00050 typedef struct
00051 {
00052   const _ExtendedGDBusPropertyInfo *info;
00053   guint prop_id;
00054   GValue orig_value; /* the value before the change */
00055 } ChangedProperty;
00056 
00057 static void
00058 _changed_property_free (ChangedProperty *data)
00059 {
00060   g_value_unset (&data->orig_value);
00061   g_free (data);
00062 }
00063 
00064 static gboolean
00065 _g_strv_equal0 (gchar **a, gchar **b)
00066 {
00067   gboolean ret = FALSE;
00068   guint n;
00069   if (a == NULL && b == NULL)
00070     {
00071       ret = TRUE;
00072       goto out;
00073     }
00074   if (a == NULL || b == NULL)
00075     goto out;
00076   if (g_strv_length (a) != g_strv_length (b))
00077     goto out;
00078   for (n = 0; a[n] != NULL; n++)
00079     if (g_strcmp0 (a[n], b[n]) != 0)
00080       goto out;
00081   ret = TRUE;
00082 out:
00083   return ret;
00084 }
00085 
00086 static gboolean
00087 _g_variant_equal0 (GVariant *a, GVariant *b)
00088 {
00089   gboolean ret = FALSE;
00090   if (a == NULL && b == NULL)
00091     {
00092       ret = TRUE;
00093       goto out;
00094     }
00095   if (a == NULL || b == NULL)
00096     goto out;
00097   ret = g_variant_equal (a, b);
00098 out:
00099   return ret;
00100 }
00101 
00102 G_GNUC_UNUSED static gboolean
00103 _g_value_equal (const GValue *a, const GValue *b)
00104 {
00105   gboolean ret = FALSE;
00106   g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
00107   switch (G_VALUE_TYPE (a))
00108     {
00109       case G_TYPE_BOOLEAN:
00110         ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
00111         break;
00112       case G_TYPE_UCHAR:
00113         ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
00114         break;
00115       case G_TYPE_INT:
00116         ret = (g_value_get_int (a) == g_value_get_int (b));
00117         break;
00118       case G_TYPE_UINT:
00119         ret = (g_value_get_uint (a) == g_value_get_uint (b));
00120         break;
00121       case G_TYPE_INT64:
00122         ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
00123         break;
00124       case G_TYPE_UINT64:
00125         ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
00126         break;
00127       case G_TYPE_DOUBLE:
00128         {
00129           /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
00130           gdouble da = g_value_get_double (a);
00131           gdouble db = g_value_get_double (b);
00132           ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
00133         }
00134         break;
00135       case G_TYPE_STRING:
00136         ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
00137         break;
00138       case G_TYPE_VARIANT:
00139         ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
00140         break;
00141       default:
00142         if (G_VALUE_TYPE (a) == G_TYPE_STRV)
00143           ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
00144         else
00145           g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
00146         break;
00147     }
00148   return ret;
00149 }
00150 
00151 /* ------------------------------------------------------------------------
00152  * Code for interface org.freedesktop.UPower
00153  * ------------------------------------------------------------------------
00154  */
00155 
00164 /* ---- Introspection data for org.freedesktop.UPower ---- */
00165 
00166 static const _ExtendedGDBusArgInfo _dbus_upower_method_info_enumerate_devices_OUT_ARG_devices =
00167 {
00168   {
00169     -1,
00170     (gchar *) "devices",
00171     (gchar *) "ao",
00172     NULL
00173   },
00174   FALSE
00175 };
00176 
00177 static const _ExtendedGDBusArgInfo * const _dbus_upower_method_info_enumerate_devices_OUT_ARG_pointers[] =
00178 {
00179   &_dbus_upower_method_info_enumerate_devices_OUT_ARG_devices,
00180   NULL
00181 };
00182 
00183 static const GDBusAnnotationInfo _dbus_upower_method_enumerate_devices_annotation_info_0 =
00184 {
00185   -1,
00186   (gchar *) "org.freedesktop.DBus.GLib.Async",
00187   (gchar *) "",
00188   NULL
00189 };
00190 
00191 static const GDBusAnnotationInfo * const _dbus_upower_method_enumerate_devices_annotation_info_pointers[] =
00192 {
00193   &_dbus_upower_method_enumerate_devices_annotation_info_0,
00194   NULL
00195 };
00196 
00197 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_enumerate_devices =
00198 {
00199   {
00200     -1,
00201     (gchar *) "EnumerateDevices",
00202     NULL,
00203     (GDBusArgInfo **) &_dbus_upower_method_info_enumerate_devices_OUT_ARG_pointers,
00204     (GDBusAnnotationInfo **) &_dbus_upower_method_enumerate_devices_annotation_info_pointers
00205   },
00206   "handle-enumerate-devices",
00207   FALSE
00208 };
00209 
00210 static const GDBusAnnotationInfo _dbus_upower_method_about_to_sleep_annotation_info_0 =
00211 {
00212   -1,
00213   (gchar *) "org.freedesktop.DBus.GLib.Async",
00214   (gchar *) "",
00215   NULL
00216 };
00217 
00218 static const GDBusAnnotationInfo * const _dbus_upower_method_about_to_sleep_annotation_info_pointers[] =
00219 {
00220   &_dbus_upower_method_about_to_sleep_annotation_info_0,
00221   NULL
00222 };
00223 
00224 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_about_to_sleep =
00225 {
00226   {
00227     -1,
00228     (gchar *) "AboutToSleep",
00229     NULL,
00230     NULL,
00231     (GDBusAnnotationInfo **) &_dbus_upower_method_about_to_sleep_annotation_info_pointers
00232   },
00233   "handle-about-to-sleep",
00234   FALSE
00235 };
00236 
00237 static const GDBusAnnotationInfo _dbus_upower_method_suspend_annotation_info_0 =
00238 {
00239   -1,
00240   (gchar *) "org.freedesktop.DBus.GLib.Async",
00241   (gchar *) "",
00242   NULL
00243 };
00244 
00245 static const GDBusAnnotationInfo * const _dbus_upower_method_suspend_annotation_info_pointers[] =
00246 {
00247   &_dbus_upower_method_suspend_annotation_info_0,
00248   NULL
00249 };
00250 
00251 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_suspend =
00252 {
00253   {
00254     -1,
00255     (gchar *) "Suspend",
00256     NULL,
00257     NULL,
00258     (GDBusAnnotationInfo **) &_dbus_upower_method_suspend_annotation_info_pointers
00259   },
00260   "handle-suspend",
00261   FALSE
00262 };
00263 
00264 static const _ExtendedGDBusArgInfo _dbus_upower_method_info_suspend_allowed_OUT_ARG_allowed =
00265 {
00266   {
00267     -1,
00268     (gchar *) "allowed",
00269     (gchar *) "b",
00270     NULL
00271   },
00272   FALSE
00273 };
00274 
00275 static const _ExtendedGDBusArgInfo * const _dbus_upower_method_info_suspend_allowed_OUT_ARG_pointers[] =
00276 {
00277   &_dbus_upower_method_info_suspend_allowed_OUT_ARG_allowed,
00278   NULL
00279 };
00280 
00281 static const GDBusAnnotationInfo _dbus_upower_method_suspend_allowed_annotation_info_0 =
00282 {
00283   -1,
00284   (gchar *) "org.freedesktop.DBus.GLib.Async",
00285   (gchar *) "",
00286   NULL
00287 };
00288 
00289 static const GDBusAnnotationInfo * const _dbus_upower_method_suspend_allowed_annotation_info_pointers[] =
00290 {
00291   &_dbus_upower_method_suspend_allowed_annotation_info_0,
00292   NULL
00293 };
00294 
00295 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_suspend_allowed =
00296 {
00297   {
00298     -1,
00299     (gchar *) "SuspendAllowed",
00300     NULL,
00301     (GDBusArgInfo **) &_dbus_upower_method_info_suspend_allowed_OUT_ARG_pointers,
00302     (GDBusAnnotationInfo **) &_dbus_upower_method_suspend_allowed_annotation_info_pointers
00303   },
00304   "handle-suspend-allowed",
00305   FALSE
00306 };
00307 
00308 static const GDBusAnnotationInfo _dbus_upower_method_hibernate_annotation_info_0 =
00309 {
00310   -1,
00311   (gchar *) "org.freedesktop.DBus.GLib.Async",
00312   (gchar *) "",
00313   NULL
00314 };
00315 
00316 static const GDBusAnnotationInfo * const _dbus_upower_method_hibernate_annotation_info_pointers[] =
00317 {
00318   &_dbus_upower_method_hibernate_annotation_info_0,
00319   NULL
00320 };
00321 
00322 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_hibernate =
00323 {
00324   {
00325     -1,
00326     (gchar *) "Hibernate",
00327     NULL,
00328     NULL,
00329     (GDBusAnnotationInfo **) &_dbus_upower_method_hibernate_annotation_info_pointers
00330   },
00331   "handle-hibernate",
00332   FALSE
00333 };
00334 
00335 static const _ExtendedGDBusArgInfo _dbus_upower_method_info_hibernate_allowed_OUT_ARG_allowed =
00336 {
00337   {
00338     -1,
00339     (gchar *) "allowed",
00340     (gchar *) "b",
00341     NULL
00342   },
00343   FALSE
00344 };
00345 
00346 static const _ExtendedGDBusArgInfo * const _dbus_upower_method_info_hibernate_allowed_OUT_ARG_pointers[] =
00347 {
00348   &_dbus_upower_method_info_hibernate_allowed_OUT_ARG_allowed,
00349   NULL
00350 };
00351 
00352 static const GDBusAnnotationInfo _dbus_upower_method_hibernate_allowed_annotation_info_0 =
00353 {
00354   -1,
00355   (gchar *) "org.freedesktop.DBus.GLib.Async",
00356   (gchar *) "",
00357   NULL
00358 };
00359 
00360 static const GDBusAnnotationInfo * const _dbus_upower_method_hibernate_allowed_annotation_info_pointers[] =
00361 {
00362   &_dbus_upower_method_hibernate_allowed_annotation_info_0,
00363   NULL
00364 };
00365 
00366 static const _ExtendedGDBusMethodInfo _dbus_upower_method_info_hibernate_allowed =
00367 {
00368   {
00369     -1,
00370     (gchar *) "HibernateAllowed",
00371     NULL,
00372     (GDBusArgInfo **) &_dbus_upower_method_info_hibernate_allowed_OUT_ARG_pointers,
00373     (GDBusAnnotationInfo **) &_dbus_upower_method_hibernate_allowed_annotation_info_pointers
00374   },
00375   "handle-hibernate-allowed",
00376   FALSE
00377 };
00378 
00379 static const _ExtendedGDBusMethodInfo * const _dbus_upower_method_info_pointers[] =
00380 {
00381   &_dbus_upower_method_info_enumerate_devices,
00382   &_dbus_upower_method_info_about_to_sleep,
00383   &_dbus_upower_method_info_suspend,
00384   &_dbus_upower_method_info_suspend_allowed,
00385   &_dbus_upower_method_info_hibernate,
00386   &_dbus_upower_method_info_hibernate_allowed,
00387   NULL
00388 };
00389 
00390 static const _ExtendedGDBusArgInfo _dbus_upower_signal_info_device_added_ARG_device =
00391 {
00392   {
00393     -1,
00394     (gchar *) "device",
00395     (gchar *) "o",
00396     NULL
00397   },
00398   FALSE
00399 };
00400 
00401 static const _ExtendedGDBusArgInfo * const _dbus_upower_signal_info_device_added_ARG_pointers[] =
00402 {
00403   &_dbus_upower_signal_info_device_added_ARG_device,
00404   NULL
00405 };
00406 
00407 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_device_added =
00408 {
00409   {
00410     -1,
00411     (gchar *) "DeviceAdded",
00412     (GDBusArgInfo **) &_dbus_upower_signal_info_device_added_ARG_pointers,
00413     NULL
00414   },
00415   "device-added"
00416 };
00417 
00418 static const _ExtendedGDBusArgInfo _dbus_upower_signal_info_device_removed_ARG_device =
00419 {
00420   {
00421     -1,
00422     (gchar *) "device",
00423     (gchar *) "o",
00424     NULL
00425   },
00426   FALSE
00427 };
00428 
00429 static const _ExtendedGDBusArgInfo * const _dbus_upower_signal_info_device_removed_ARG_pointers[] =
00430 {
00431   &_dbus_upower_signal_info_device_removed_ARG_device,
00432   NULL
00433 };
00434 
00435 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_device_removed =
00436 {
00437   {
00438     -1,
00439     (gchar *) "DeviceRemoved",
00440     (GDBusArgInfo **) &_dbus_upower_signal_info_device_removed_ARG_pointers,
00441     NULL
00442   },
00443   "device-removed"
00444 };
00445 
00446 static const _ExtendedGDBusArgInfo _dbus_upower_signal_info_device_changed_ARG_device =
00447 {
00448   {
00449     -1,
00450     (gchar *) "device",
00451     (gchar *) "s",
00452     NULL
00453   },
00454   FALSE
00455 };
00456 
00457 static const _ExtendedGDBusArgInfo * const _dbus_upower_signal_info_device_changed_ARG_pointers[] =
00458 {
00459   &_dbus_upower_signal_info_device_changed_ARG_device,
00460   NULL
00461 };
00462 
00463 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_device_changed =
00464 {
00465   {
00466     -1,
00467     (gchar *) "DeviceChanged",
00468     (GDBusArgInfo **) &_dbus_upower_signal_info_device_changed_ARG_pointers,
00469     NULL
00470   },
00471   "device-changed"
00472 };
00473 
00474 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_changed =
00475 {
00476   {
00477     -1,
00478     (gchar *) "Changed",
00479     NULL,
00480     NULL
00481   },
00482   "changed"
00483 };
00484 
00485 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_sleeping =
00486 {
00487   {
00488     -1,
00489     (gchar *) "Sleeping",
00490     NULL,
00491     NULL
00492   },
00493   "sleeping"
00494 };
00495 
00496 static const _ExtendedGDBusSignalInfo _dbus_upower_signal_info_resuming =
00497 {
00498   {
00499     -1,
00500     (gchar *) "Resuming",
00501     NULL,
00502     NULL
00503   },
00504   "resuming"
00505 };
00506 
00507 static const _ExtendedGDBusSignalInfo * const _dbus_upower_signal_info_pointers[] =
00508 {
00509   &_dbus_upower_signal_info_device_added,
00510   &_dbus_upower_signal_info_device_removed,
00511   &_dbus_upower_signal_info_device_changed,
00512   &_dbus_upower_signal_info_changed,
00513   &_dbus_upower_signal_info_sleeping,
00514   &_dbus_upower_signal_info_resuming,
00515   NULL
00516 };
00517 
00518 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_daemon_version =
00519 {
00520   {
00521     -1,
00522     (gchar *) "DaemonVersion",
00523     (gchar *) "s",
00524     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00525     NULL
00526   },
00527   "daemon-version",
00528   FALSE
00529 };
00530 
00531 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_can_suspend =
00532 {
00533   {
00534     -1,
00535     (gchar *) "CanSuspend",
00536     (gchar *) "b",
00537     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00538     NULL
00539   },
00540   "can-suspend",
00541   FALSE
00542 };
00543 
00544 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_can_hibernate =
00545 {
00546   {
00547     -1,
00548     (gchar *) "CanHibernate",
00549     (gchar *) "b",
00550     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00551     NULL
00552   },
00553   "can-hibernate",
00554   FALSE
00555 };
00556 
00557 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_on_battery =
00558 {
00559   {
00560     -1,
00561     (gchar *) "OnBattery",
00562     (gchar *) "b",
00563     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00564     NULL
00565   },
00566   "on-battery",
00567   FALSE
00568 };
00569 
00570 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_on_low_battery =
00571 {
00572   {
00573     -1,
00574     (gchar *) "OnLowBattery",
00575     (gchar *) "b",
00576     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00577     NULL
00578   },
00579   "on-low-battery",
00580   FALSE
00581 };
00582 
00583 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_lid_is_closed =
00584 {
00585   {
00586     -1,
00587     (gchar *) "LidIsClosed",
00588     (gchar *) "b",
00589     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00590     NULL
00591   },
00592   "lid-is-closed",
00593   FALSE
00594 };
00595 
00596 static const _ExtendedGDBusPropertyInfo _dbus_upower_property_info_lid_is_present =
00597 {
00598   {
00599     -1,
00600     (gchar *) "LidIsPresent",
00601     (gchar *) "b",
00602     G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
00603     NULL
00604   },
00605   "lid-is-present",
00606   FALSE
00607 };
00608 
00609 static const _ExtendedGDBusPropertyInfo * const _dbus_upower_property_info_pointers[] =
00610 {
00611   &_dbus_upower_property_info_daemon_version,
00612   &_dbus_upower_property_info_can_suspend,
00613   &_dbus_upower_property_info_can_hibernate,
00614   &_dbus_upower_property_info_on_battery,
00615   &_dbus_upower_property_info_on_low_battery,
00616   &_dbus_upower_property_info_lid_is_closed,
00617   &_dbus_upower_property_info_lid_is_present,
00618   NULL
00619 };
00620 
00621 static const _ExtendedGDBusInterfaceInfo _dbus_upower_interface_info =
00622 {
00623   {
00624     -1,
00625     (gchar *) "org.freedesktop.UPower",
00626     (GDBusMethodInfo **) &_dbus_upower_method_info_pointers,
00627     (GDBusSignalInfo **) &_dbus_upower_signal_info_pointers,
00628     (GDBusPropertyInfo **) &_dbus_upower_property_info_pointers,
00629     NULL
00630   },
00631   "upower",
00632 };
00633 
00634 
00642 GDBusInterfaceInfo *
00643 dbus_upower_interface_info (void)
00644 {
00645   return (GDBusInterfaceInfo *) &_dbus_upower_interface_info;
00646 }
00647 
00658 guint
00659 dbus_upower_override_properties (GObjectClass *klass, guint property_id_begin)
00660 {
00661   g_object_class_override_property (klass, property_id_begin++, "daemon-version");
00662   g_object_class_override_property (klass, property_id_begin++, "can-suspend");
00663   g_object_class_override_property (klass, property_id_begin++, "can-hibernate");
00664   g_object_class_override_property (klass, property_id_begin++, "on-battery");
00665   g_object_class_override_property (klass, property_id_begin++, "on-low-battery");
00666   g_object_class_override_property (klass, property_id_begin++, "lid-is-closed");
00667   g_object_class_override_property (klass, property_id_begin++, "lid-is-present");
00668   return property_id_begin - 1;
00669 }
00670 
00671 
00672 
00705 static void
00706 dbus_upower_default_init (DBusUPowerIface *iface)
00707 {
00708   /* GObject signals for incoming D-Bus method calls: */
00720   g_signal_new ("handle-enumerate-devices",
00721     G_TYPE_FROM_INTERFACE (iface),
00722     G_SIGNAL_RUN_LAST,
00723     G_STRUCT_OFFSET (DBusUPowerIface, handle_enumerate_devices),
00724     g_signal_accumulator_true_handled,
00725     NULL,
00726     g_cclosure_marshal_generic,
00727     G_TYPE_BOOLEAN,
00728     1,
00729     G_TYPE_DBUS_METHOD_INVOCATION);
00730 
00742   g_signal_new ("handle-about-to-sleep",
00743     G_TYPE_FROM_INTERFACE (iface),
00744     G_SIGNAL_RUN_LAST,
00745     G_STRUCT_OFFSET (DBusUPowerIface, handle_about_to_sleep),
00746     g_signal_accumulator_true_handled,
00747     NULL,
00748     g_cclosure_marshal_generic,
00749     G_TYPE_BOOLEAN,
00750     1,
00751     G_TYPE_DBUS_METHOD_INVOCATION);
00752 
00764   g_signal_new ("handle-suspend",
00765     G_TYPE_FROM_INTERFACE (iface),
00766     G_SIGNAL_RUN_LAST,
00767     G_STRUCT_OFFSET (DBusUPowerIface, handle_suspend),
00768     g_signal_accumulator_true_handled,
00769     NULL,
00770     g_cclosure_marshal_generic,
00771     G_TYPE_BOOLEAN,
00772     1,
00773     G_TYPE_DBUS_METHOD_INVOCATION);
00774 
00786   g_signal_new ("handle-suspend-allowed",
00787     G_TYPE_FROM_INTERFACE (iface),
00788     G_SIGNAL_RUN_LAST,
00789     G_STRUCT_OFFSET (DBusUPowerIface, handle_suspend_allowed),
00790     g_signal_accumulator_true_handled,
00791     NULL,
00792     g_cclosure_marshal_generic,
00793     G_TYPE_BOOLEAN,
00794     1,
00795     G_TYPE_DBUS_METHOD_INVOCATION);
00796 
00808   g_signal_new ("handle-hibernate",
00809     G_TYPE_FROM_INTERFACE (iface),
00810     G_SIGNAL_RUN_LAST,
00811     G_STRUCT_OFFSET (DBusUPowerIface, handle_hibernate),
00812     g_signal_accumulator_true_handled,
00813     NULL,
00814     g_cclosure_marshal_generic,
00815     G_TYPE_BOOLEAN,
00816     1,
00817     G_TYPE_DBUS_METHOD_INVOCATION);
00818 
00830   g_signal_new ("handle-hibernate-allowed",
00831     G_TYPE_FROM_INTERFACE (iface),
00832     G_SIGNAL_RUN_LAST,
00833     G_STRUCT_OFFSET (DBusUPowerIface, handle_hibernate_allowed),
00834     g_signal_accumulator_true_handled,
00835     NULL,
00836     g_cclosure_marshal_generic,
00837     G_TYPE_BOOLEAN,
00838     1,
00839     G_TYPE_DBUS_METHOD_INVOCATION);
00840 
00841   /* GObject signals for received D-Bus signals: */
00851   g_signal_new ("device-added",
00852     G_TYPE_FROM_INTERFACE (iface),
00853     G_SIGNAL_RUN_LAST,
00854     G_STRUCT_OFFSET (DBusUPowerIface, device_added),
00855     NULL,
00856     NULL,
00857     g_cclosure_marshal_generic,
00858     G_TYPE_NONE,
00859     1, G_TYPE_STRING);
00860 
00870   g_signal_new ("device-removed",
00871     G_TYPE_FROM_INTERFACE (iface),
00872     G_SIGNAL_RUN_LAST,
00873     G_STRUCT_OFFSET (DBusUPowerIface, device_removed),
00874     NULL,
00875     NULL,
00876     g_cclosure_marshal_generic,
00877     G_TYPE_NONE,
00878     1, G_TYPE_STRING);
00879 
00889   g_signal_new ("device-changed",
00890     G_TYPE_FROM_INTERFACE (iface),
00891     G_SIGNAL_RUN_LAST,
00892     G_STRUCT_OFFSET (DBusUPowerIface, device_changed),
00893     NULL,
00894     NULL,
00895     g_cclosure_marshal_generic,
00896     G_TYPE_NONE,
00897     1, G_TYPE_STRING);
00898 
00907   g_signal_new ("changed",
00908     G_TYPE_FROM_INTERFACE (iface),
00909     G_SIGNAL_RUN_LAST,
00910     G_STRUCT_OFFSET (DBusUPowerIface, changed),
00911     NULL,
00912     NULL,
00913     g_cclosure_marshal_generic,
00914     G_TYPE_NONE,
00915     0);
00916 
00925   g_signal_new ("sleeping",
00926     G_TYPE_FROM_INTERFACE (iface),
00927     G_SIGNAL_RUN_LAST,
00928     G_STRUCT_OFFSET (DBusUPowerIface, sleeping),
00929     NULL,
00930     NULL,
00931     g_cclosure_marshal_generic,
00932     G_TYPE_NONE,
00933     0);
00934 
00943   g_signal_new ("resuming",
00944     G_TYPE_FROM_INTERFACE (iface),
00945     G_SIGNAL_RUN_LAST,
00946     G_STRUCT_OFFSET (DBusUPowerIface, resuming),
00947     NULL,
00948     NULL,
00949     g_cclosure_marshal_generic,
00950     G_TYPE_NONE,
00951     0);
00952 
00953   /* GObject properties for D-Bus properties: */
00961   g_object_interface_install_property (iface,
00962     g_param_spec_string ("daemon-version", "DaemonVersion", "DaemonVersion", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
00970   g_object_interface_install_property (iface,
00971     g_param_spec_boolean ("can-suspend", "CanSuspend", "CanSuspend", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
00979   g_object_interface_install_property (iface,
00980     g_param_spec_boolean ("can-hibernate", "CanHibernate", "CanHibernate", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
00988   g_object_interface_install_property (iface,
00989     g_param_spec_boolean ("on-battery", "OnBattery", "OnBattery", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
00997   g_object_interface_install_property (iface,
00998     g_param_spec_boolean ("on-low-battery", "OnLowBattery", "OnLowBattery", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
01006   g_object_interface_install_property (iface,
01007     g_param_spec_boolean ("lid-is-closed", "LidIsClosed", "LidIsClosed", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
01015   g_object_interface_install_property (iface,
01016     g_param_spec_boolean ("lid-is-present", "LidIsPresent", "LidIsPresent", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
01017 }
01018 
01019 typedef DBusUPowerIface DBusUPowerInterface;
01020 G_DEFINE_INTERFACE (DBusUPower, dbus_upower, G_TYPE_OBJECT);
01021 
01034 const gchar *
01035 dbus_upower_get_daemon_version (DBusUPower *object)
01036 {
01037   return DBUS_UPOWER_GET_IFACE (object)->get_daemon_version (object);
01038 }
01039 
01050 gchar *
01051 dbus_upower_dup_daemon_version (DBusUPower *object)
01052 {
01053   gchar *value;
01054   g_object_get (G_OBJECT (object), "daemon-version", &value, NULL);
01055   return value;
01056 }
01057 
01067 void
01068 dbus_upower_set_daemon_version (DBusUPower *object, const gchar *value)
01069 {
01070   g_object_set (G_OBJECT (object), "daemon-version", value, NULL);
01071 }
01072 
01083 gboolean 
01084 dbus_upower_get_can_suspend (DBusUPower *object)
01085 {
01086   return DBUS_UPOWER_GET_IFACE (object)->get_can_suspend (object);
01087 }
01088 
01098 void
01099 dbus_upower_set_can_suspend (DBusUPower *object, gboolean value)
01100 {
01101   g_object_set (G_OBJECT (object), "can-suspend", value, NULL);
01102 }
01103 
01114 gboolean 
01115 dbus_upower_get_can_hibernate (DBusUPower *object)
01116 {
01117   return DBUS_UPOWER_GET_IFACE (object)->get_can_hibernate (object);
01118 }
01119 
01129 void
01130 dbus_upower_set_can_hibernate (DBusUPower *object, gboolean value)
01131 {
01132   g_object_set (G_OBJECT (object), "can-hibernate", value, NULL);
01133 }
01134 
01145 gboolean 
01146 dbus_upower_get_on_battery (DBusUPower *object)
01147 {
01148   return DBUS_UPOWER_GET_IFACE (object)->get_on_battery (object);
01149 }
01150 
01160 void
01161 dbus_upower_set_on_battery (DBusUPower *object, gboolean value)
01162 {
01163   g_object_set (G_OBJECT (object), "on-battery", value, NULL);
01164 }
01165 
01176 gboolean 
01177 dbus_upower_get_on_low_battery (DBusUPower *object)
01178 {
01179   return DBUS_UPOWER_GET_IFACE (object)->get_on_low_battery (object);
01180 }
01181 
01191 void
01192 dbus_upower_set_on_low_battery (DBusUPower *object, gboolean value)
01193 {
01194   g_object_set (G_OBJECT (object), "on-low-battery", value, NULL);
01195 }
01196 
01207 gboolean 
01208 dbus_upower_get_lid_is_closed (DBusUPower *object)
01209 {
01210   return DBUS_UPOWER_GET_IFACE (object)->get_lid_is_closed (object);
01211 }
01212 
01222 void
01223 dbus_upower_set_lid_is_closed (DBusUPower *object, gboolean value)
01224 {
01225   g_object_set (G_OBJECT (object), "lid-is-closed", value, NULL);
01226 }
01227 
01238 gboolean 
01239 dbus_upower_get_lid_is_present (DBusUPower *object)
01240 {
01241   return DBUS_UPOWER_GET_IFACE (object)->get_lid_is_present (object);
01242 }
01243 
01253 void
01254 dbus_upower_set_lid_is_present (DBusUPower *object, gboolean value)
01255 {
01256   g_object_set (G_OBJECT (object), "lid-is-present", value, NULL);
01257 }
01258 
01266 void
01267 dbus_upower_emit_device_added (
01268     DBusUPower *object,
01269     const gchar *arg_device)
01270 {
01271   g_signal_emit_by_name (object, "device-added", arg_device);
01272 }
01273 
01281 void
01282 dbus_upower_emit_device_removed (
01283     DBusUPower *object,
01284     const gchar *arg_device)
01285 {
01286   g_signal_emit_by_name (object, "device-removed", arg_device);
01287 }
01288 
01296 void
01297 dbus_upower_emit_device_changed (
01298     DBusUPower *object,
01299     const gchar *arg_device)
01300 {
01301   g_signal_emit_by_name (object, "device-changed", arg_device);
01302 }
01303 
01310 void
01311 dbus_upower_emit_changed (
01312     DBusUPower *object)
01313 {
01314   g_signal_emit_by_name (object, "changed");
01315 }
01316 
01323 void
01324 dbus_upower_emit_sleeping (
01325     DBusUPower *object)
01326 {
01327   g_signal_emit_by_name (object, "sleeping");
01328 }
01329 
01336 void
01337 dbus_upower_emit_resuming (
01338     DBusUPower *object)
01339 {
01340   g_signal_emit_by_name (object, "resuming");
01341 }
01342 
01356 void
01357 dbus_upower_call_enumerate_devices (
01358     DBusUPower *proxy,
01359     GCancellable *cancellable,
01360     GAsyncReadyCallback callback,
01361     gpointer user_data)
01362 {
01363   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01364     "EnumerateDevices",
01365     g_variant_new ("()"),
01366     G_DBUS_CALL_FLAGS_NONE,
01367     -1,
01368     cancellable,
01369     callback,
01370     user_data);
01371 }
01372 
01384 gboolean
01385 dbus_upower_call_enumerate_devices_finish (
01386     DBusUPower *proxy,
01387     gchar ***out_devices,
01388     GAsyncResult *res,
01389     GError **error)
01390 {
01391   GVariant *_ret;
01392   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01393   if (_ret == NULL)
01394     goto _out;
01395   g_variant_get (_ret,
01396                  "(^ao)",
01397                  out_devices);
01398   g_variant_unref (_ret);
01399 _out:
01400   return _ret != NULL;
01401 }
01402 
01416 gboolean
01417 dbus_upower_call_enumerate_devices_sync (
01418     DBusUPower *proxy,
01419     gchar ***out_devices,
01420     GCancellable *cancellable,
01421     GError **error)
01422 {
01423   GVariant *_ret;
01424   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01425     "EnumerateDevices",
01426     g_variant_new ("()"),
01427     G_DBUS_CALL_FLAGS_NONE,
01428     -1,
01429     cancellable,
01430     error);
01431   if (_ret == NULL)
01432     goto _out;
01433   g_variant_get (_ret,
01434                  "(^ao)",
01435                  out_devices);
01436   g_variant_unref (_ret);
01437 _out:
01438   return _ret != NULL;
01439 }
01440 
01454 void
01455 dbus_upower_call_about_to_sleep (
01456     DBusUPower *proxy,
01457     GCancellable *cancellable,
01458     GAsyncReadyCallback callback,
01459     gpointer user_data)
01460 {
01461   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01462     "AboutToSleep",
01463     g_variant_new ("()"),
01464     G_DBUS_CALL_FLAGS_NONE,
01465     -1,
01466     cancellable,
01467     callback,
01468     user_data);
01469 }
01470 
01481 gboolean
01482 dbus_upower_call_about_to_sleep_finish (
01483     DBusUPower *proxy,
01484     GAsyncResult *res,
01485     GError **error)
01486 {
01487   GVariant *_ret;
01488   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01489   if (_ret == NULL)
01490     goto _out;
01491   g_variant_get (_ret,
01492                  "()");
01493   g_variant_unref (_ret);
01494 _out:
01495   return _ret != NULL;
01496 }
01497 
01510 gboolean
01511 dbus_upower_call_about_to_sleep_sync (
01512     DBusUPower *proxy,
01513     GCancellable *cancellable,
01514     GError **error)
01515 {
01516   GVariant *_ret;
01517   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01518     "AboutToSleep",
01519     g_variant_new ("()"),
01520     G_DBUS_CALL_FLAGS_NONE,
01521     -1,
01522     cancellable,
01523     error);
01524   if (_ret == NULL)
01525     goto _out;
01526   g_variant_get (_ret,
01527                  "()");
01528   g_variant_unref (_ret);
01529 _out:
01530   return _ret != NULL;
01531 }
01532 
01546 void
01547 dbus_upower_call_suspend (
01548     DBusUPower *proxy,
01549     GCancellable *cancellable,
01550     GAsyncReadyCallback callback,
01551     gpointer user_data)
01552 {
01553   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01554     "Suspend",
01555     g_variant_new ("()"),
01556     G_DBUS_CALL_FLAGS_NONE,
01557     -1,
01558     cancellable,
01559     callback,
01560     user_data);
01561 }
01562 
01573 gboolean
01574 dbus_upower_call_suspend_finish (
01575     DBusUPower *proxy,
01576     GAsyncResult *res,
01577     GError **error)
01578 {
01579   GVariant *_ret;
01580   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01581   if (_ret == NULL)
01582     goto _out;
01583   g_variant_get (_ret,
01584                  "()");
01585   g_variant_unref (_ret);
01586 _out:
01587   return _ret != NULL;
01588 }
01589 
01602 gboolean
01603 dbus_upower_call_suspend_sync (
01604     DBusUPower *proxy,
01605     GCancellable *cancellable,
01606     GError **error)
01607 {
01608   GVariant *_ret;
01609   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01610     "Suspend",
01611     g_variant_new ("()"),
01612     G_DBUS_CALL_FLAGS_NONE,
01613     -1,
01614     cancellable,
01615     error);
01616   if (_ret == NULL)
01617     goto _out;
01618   g_variant_get (_ret,
01619                  "()");
01620   g_variant_unref (_ret);
01621 _out:
01622   return _ret != NULL;
01623 }
01624 
01638 void
01639 dbus_upower_call_suspend_allowed (
01640     DBusUPower *proxy,
01641     GCancellable *cancellable,
01642     GAsyncReadyCallback callback,
01643     gpointer user_data)
01644 {
01645   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01646     "SuspendAllowed",
01647     g_variant_new ("()"),
01648     G_DBUS_CALL_FLAGS_NONE,
01649     -1,
01650     cancellable,
01651     callback,
01652     user_data);
01653 }
01654 
01666 gboolean
01667 dbus_upower_call_suspend_allowed_finish (
01668     DBusUPower *proxy,
01669     gboolean *out_allowed,
01670     GAsyncResult *res,
01671     GError **error)
01672 {
01673   GVariant *_ret;
01674   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01675   if (_ret == NULL)
01676     goto _out;
01677   g_variant_get (_ret,
01678                  "(b)",
01679                  out_allowed);
01680   g_variant_unref (_ret);
01681 _out:
01682   return _ret != NULL;
01683 }
01684 
01698 gboolean
01699 dbus_upower_call_suspend_allowed_sync (
01700     DBusUPower *proxy,
01701     gboolean *out_allowed,
01702     GCancellable *cancellable,
01703     GError **error)
01704 {
01705   GVariant *_ret;
01706   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01707     "SuspendAllowed",
01708     g_variant_new ("()"),
01709     G_DBUS_CALL_FLAGS_NONE,
01710     -1,
01711     cancellable,
01712     error);
01713   if (_ret == NULL)
01714     goto _out;
01715   g_variant_get (_ret,
01716                  "(b)",
01717                  out_allowed);
01718   g_variant_unref (_ret);
01719 _out:
01720   return _ret != NULL;
01721 }
01722 
01736 void
01737 dbus_upower_call_hibernate (
01738     DBusUPower *proxy,
01739     GCancellable *cancellable,
01740     GAsyncReadyCallback callback,
01741     gpointer user_data)
01742 {
01743   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01744     "Hibernate",
01745     g_variant_new ("()"),
01746     G_DBUS_CALL_FLAGS_NONE,
01747     -1,
01748     cancellable,
01749     callback,
01750     user_data);
01751 }
01752 
01763 gboolean
01764 dbus_upower_call_hibernate_finish (
01765     DBusUPower *proxy,
01766     GAsyncResult *res,
01767     GError **error)
01768 {
01769   GVariant *_ret;
01770   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01771   if (_ret == NULL)
01772     goto _out;
01773   g_variant_get (_ret,
01774                  "()");
01775   g_variant_unref (_ret);
01776 _out:
01777   return _ret != NULL;
01778 }
01779 
01792 gboolean
01793 dbus_upower_call_hibernate_sync (
01794     DBusUPower *proxy,
01795     GCancellable *cancellable,
01796     GError **error)
01797 {
01798   GVariant *_ret;
01799   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01800     "Hibernate",
01801     g_variant_new ("()"),
01802     G_DBUS_CALL_FLAGS_NONE,
01803     -1,
01804     cancellable,
01805     error);
01806   if (_ret == NULL)
01807     goto _out;
01808   g_variant_get (_ret,
01809                  "()");
01810   g_variant_unref (_ret);
01811 _out:
01812   return _ret != NULL;
01813 }
01814 
01828 void
01829 dbus_upower_call_hibernate_allowed (
01830     DBusUPower *proxy,
01831     GCancellable *cancellable,
01832     GAsyncReadyCallback callback,
01833     gpointer user_data)
01834 {
01835   g_dbus_proxy_call (G_DBUS_PROXY (proxy),
01836     "HibernateAllowed",
01837     g_variant_new ("()"),
01838     G_DBUS_CALL_FLAGS_NONE,
01839     -1,
01840     cancellable,
01841     callback,
01842     user_data);
01843 }
01844 
01856 gboolean
01857 dbus_upower_call_hibernate_allowed_finish (
01858     DBusUPower *proxy,
01859     gboolean *out_allowed,
01860     GAsyncResult *res,
01861     GError **error)
01862 {
01863   GVariant *_ret;
01864   _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
01865   if (_ret == NULL)
01866     goto _out;
01867   g_variant_get (_ret,
01868                  "(b)",
01869                  out_allowed);
01870   g_variant_unref (_ret);
01871 _out:
01872   return _ret != NULL;
01873 }
01874 
01888 gboolean
01889 dbus_upower_call_hibernate_allowed_sync (
01890     DBusUPower *proxy,
01891     gboolean *out_allowed,
01892     GCancellable *cancellable,
01893     GError **error)
01894 {
01895   GVariant *_ret;
01896   _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
01897     "HibernateAllowed",
01898     g_variant_new ("()"),
01899     G_DBUS_CALL_FLAGS_NONE,
01900     -1,
01901     cancellable,
01902     error);
01903   if (_ret == NULL)
01904     goto _out;
01905   g_variant_get (_ret,
01906                  "(b)",
01907                  out_allowed);
01908   g_variant_unref (_ret);
01909 _out:
01910   return _ret != NULL;
01911 }
01912 
01923 void
01924 dbus_upower_complete_enumerate_devices (
01925     DBusUPower *object,
01926     GDBusMethodInvocation *invocation,
01927     const gchar *const *devices)
01928 {
01929   g_dbus_method_invocation_return_value (invocation,
01930     g_variant_new ("(^ao)",
01931                    devices));
01932 }
01933 
01943 void
01944 dbus_upower_complete_about_to_sleep (
01945     DBusUPower *object,
01946     GDBusMethodInvocation *invocation)
01947 {
01948   g_dbus_method_invocation_return_value (invocation,
01949     g_variant_new ("()"));
01950 }
01951 
01961 void
01962 dbus_upower_complete_suspend (
01963     DBusUPower *object,
01964     GDBusMethodInvocation *invocation)
01965 {
01966   g_dbus_method_invocation_return_value (invocation,
01967     g_variant_new ("()"));
01968 }
01969 
01980 void
01981 dbus_upower_complete_suspend_allowed (
01982     DBusUPower *object,
01983     GDBusMethodInvocation *invocation,
01984     gboolean allowed)
01985 {
01986   g_dbus_method_invocation_return_value (invocation,
01987     g_variant_new ("(b)",
01988                    allowed));
01989 }
01990 
02000 void
02001 dbus_upower_complete_hibernate (
02002     DBusUPower *object,
02003     GDBusMethodInvocation *invocation)
02004 {
02005   g_dbus_method_invocation_return_value (invocation,
02006     g_variant_new ("()"));
02007 }
02008 
02019 void
02020 dbus_upower_complete_hibernate_allowed (
02021     DBusUPower *object,
02022     GDBusMethodInvocation *invocation,
02023     gboolean allowed)
02024 {
02025   g_dbus_method_invocation_return_value (invocation,
02026     g_variant_new ("(b)",
02027                    allowed));
02028 }
02029 
02030 /* ------------------------------------------------------------------------ */
02031 
02045 struct _DBusUPowerProxyPrivate
02046 {
02047   GData *qdata;
02048 };
02049 
02050 static void dbus_upower_proxy_iface_init (DBusUPowerIface *iface);
02051 
02052 G_DEFINE_TYPE_WITH_CODE (DBusUPowerProxy, dbus_upower_proxy, G_TYPE_DBUS_PROXY,
02053                          G_IMPLEMENT_INTERFACE (DBUS_TYPE_UPOWER, dbus_upower_proxy_iface_init));
02054 
02055 static void
02056 dbus_upower_proxy_finalize (GObject *object)
02057 {
02058   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02059   g_datalist_clear (&proxy->priv->qdata);
02060   G_OBJECT_CLASS (dbus_upower_proxy_parent_class)->finalize (object);
02061 }
02062 
02063 static void
02064 dbus_upower_proxy_get_property (GObject      *object,
02065   guint         prop_id,
02066   GValue       *value,
02067   GParamSpec   *pspec)
02068 {
02069   const _ExtendedGDBusPropertyInfo *info;
02070   GVariant *variant;
02071   g_assert (prop_id != 0 && prop_id - 1 < 7);
02072   info = _dbus_upower_property_info_pointers[prop_id - 1];
02073   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
02074   if (info->use_gvariant)
02075     {
02076       g_value_set_variant (value, variant);
02077     }
02078   else
02079     {
02080       if (variant != NULL)
02081         g_dbus_gvariant_to_gvalue (variant, value);
02082     }
02083   if (variant != NULL)
02084     g_variant_unref (variant);
02085 }
02086 
02087 static void
02088 dbus_upower_proxy_set_property_cb (GDBusProxy *proxy,
02089   GAsyncResult *res,
02090   gpointer      user_data)
02091 {
02092   const _ExtendedGDBusPropertyInfo *info = user_data;
02093   GError *error;
02094   error = NULL;
02095   if (!g_dbus_proxy_call_finish (proxy, res, &error))
02096     {
02097       g_warning ("Error setting property `%s' on interface org.freedesktop.UPower: %s (%s, %d)",
02098                  info->parent_struct.name, 
02099                  error->message, g_quark_to_string (error->domain), error->code);
02100       g_error_free (error);
02101     }
02102 }
02103 
02104 static void
02105 dbus_upower_proxy_set_property (GObject      *object,
02106   guint         prop_id,
02107   const GValue *value,
02108   GParamSpec   *pspec)
02109 {
02110   const _ExtendedGDBusPropertyInfo *info;
02111   GVariant *variant;
02112   g_assert (prop_id != 0 && prop_id - 1 < 7);
02113   info = _dbus_upower_property_info_pointers[prop_id - 1];
02114   variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
02115   g_dbus_proxy_call (G_DBUS_PROXY (object),
02116     "org.freedesktop.DBus.Properties.Set",
02117     g_variant_new ("(ssv)", "org.freedesktop.UPower", info->parent_struct.name, variant),
02118     G_DBUS_CALL_FLAGS_NONE,
02119     -1,
02120     NULL, (GAsyncReadyCallback) dbus_upower_proxy_set_property_cb, (gpointer) info);
02121   g_variant_unref (variant);
02122 }
02123 
02124 static void
02125 dbus_upower_proxy_g_signal (GDBusProxy *proxy,
02126   const gchar *sender_name,
02127   const gchar *signal_name,
02128   GVariant *parameters)
02129 {
02130   _ExtendedGDBusSignalInfo *info;
02131   GVariantIter iter;
02132   GVariant *child;
02133   GValue *paramv;
02134   guint num_params;
02135   guint n;
02136   guint signal_id;
02137   info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_dbus_upower_interface_info, signal_name);
02138   if (info == NULL)
02139     return;
02140   num_params = g_variant_n_children (parameters);
02141   paramv = g_new0 (GValue, num_params + 1);
02142   g_value_init (&paramv[0], DBUS_TYPE_UPOWER);
02143   g_value_set_object (&paramv[0], proxy);
02144   g_variant_iter_init (&iter, parameters);
02145   n = 1;
02146   while ((child = g_variant_iter_next_value (&iter)) != NULL)
02147     {
02148       _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
02149       if (arg_info->use_gvariant)
02150         {
02151           g_value_init (&paramv[n], G_TYPE_VARIANT);
02152           g_value_set_variant (&paramv[n], child);
02153           n++;
02154         }
02155       else
02156         g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
02157       g_variant_unref (child);
02158     }
02159   signal_id = g_signal_lookup (info->signal_name, DBUS_TYPE_UPOWER);
02160   g_signal_emitv (paramv, signal_id, 0, NULL);
02161   for (n = 0; n < num_params + 1; n++)
02162     g_value_unset (&paramv[n]);
02163   g_free (paramv);
02164 }
02165 
02166 static void
02167 dbus_upower_proxy_g_properties_changed (GDBusProxy *_proxy,
02168   GVariant *changed_properties,
02169   const gchar *const *invalidated_properties)
02170 {
02171   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (_proxy);
02172   guint n;
02173   const gchar *key;
02174   GVariantIter *iter;
02175   _ExtendedGDBusPropertyInfo *info;
02176   g_variant_get (changed_properties, "a{sv}", &iter);
02177   while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
02178     {
02179       info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_dbus_upower_interface_info, key);
02180       g_datalist_remove_data (&proxy->priv->qdata, key);
02181       if (info != NULL)
02182         g_object_notify (G_OBJECT (proxy), info->hyphen_name);
02183     }
02184   g_variant_iter_free (iter);
02185   for (n = 0; invalidated_properties[n] != NULL; n++)
02186     {
02187       info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_dbus_upower_interface_info, invalidated_properties[n]);
02188       g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
02189       if (info != NULL)
02190         g_object_notify (G_OBJECT (proxy), info->hyphen_name);
02191     }
02192 }
02193 
02194 static const gchar *
02195 dbus_upower_proxy_get_daemon_version (DBusUPower *object)
02196 {
02197   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02198   GVariant *variant;
02199   const gchar *value = NULL;
02200   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "DaemonVersion");
02201   if (variant != NULL)
02202     {
02203       value = g_variant_get_string (variant, NULL);
02204       g_variant_unref (variant);
02205     }
02206   return value;
02207 }
02208 
02209 static gboolean 
02210 dbus_upower_proxy_get_can_suspend (DBusUPower *object)
02211 {
02212   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02213   GVariant *variant;
02214   gboolean value = 0;
02215   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "CanSuspend");
02216   if (variant != NULL)
02217     {
02218       value = g_variant_get_boolean (variant);
02219       g_variant_unref (variant);
02220     }
02221   return value;
02222 }
02223 
02224 static gboolean 
02225 dbus_upower_proxy_get_can_hibernate (DBusUPower *object)
02226 {
02227   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02228   GVariant *variant;
02229   gboolean value = 0;
02230   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "CanHibernate");
02231   if (variant != NULL)
02232     {
02233       value = g_variant_get_boolean (variant);
02234       g_variant_unref (variant);
02235     }
02236   return value;
02237 }
02238 
02239 static gboolean 
02240 dbus_upower_proxy_get_on_battery (DBusUPower *object)
02241 {
02242   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02243   GVariant *variant;
02244   gboolean value = 0;
02245   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "OnBattery");
02246   if (variant != NULL)
02247     {
02248       value = g_variant_get_boolean (variant);
02249       g_variant_unref (variant);
02250     }
02251   return value;
02252 }
02253 
02254 static gboolean 
02255 dbus_upower_proxy_get_on_low_battery (DBusUPower *object)
02256 {
02257   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02258   GVariant *variant;
02259   gboolean value = 0;
02260   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "OnLowBattery");
02261   if (variant != NULL)
02262     {
02263       value = g_variant_get_boolean (variant);
02264       g_variant_unref (variant);
02265     }
02266   return value;
02267 }
02268 
02269 static gboolean 
02270 dbus_upower_proxy_get_lid_is_closed (DBusUPower *object)
02271 {
02272   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02273   GVariant *variant;
02274   gboolean value = 0;
02275   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "LidIsClosed");
02276   if (variant != NULL)
02277     {
02278       value = g_variant_get_boolean (variant);
02279       g_variant_unref (variant);
02280     }
02281   return value;
02282 }
02283 
02284 static gboolean 
02285 dbus_upower_proxy_get_lid_is_present (DBusUPower *object)
02286 {
02287   DBusUPowerProxy *proxy = DBUS_UPOWER_PROXY (object);
02288   GVariant *variant;
02289   gboolean value = 0;
02290   variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "LidIsPresent");
02291   if (variant != NULL)
02292     {
02293       value = g_variant_get_boolean (variant);
02294       g_variant_unref (variant);
02295     }
02296   return value;
02297 }
02298 
02299 static void
02300 dbus_upower_proxy_init (DBusUPowerProxy *proxy)
02301 {
02302   proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, DBUS_TYPE_UPOWER_PROXY, DBusUPowerProxyPrivate);
02303   g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), dbus_upower_interface_info ());
02304 }
02305 
02306 static void
02307 dbus_upower_proxy_class_init (DBusUPowerProxyClass *klass)
02308 {
02309   GObjectClass *gobject_class;
02310   GDBusProxyClass *proxy_class;
02311 
02312   g_type_class_add_private (klass, sizeof (DBusUPowerProxyPrivate));
02313 
02314   gobject_class = G_OBJECT_CLASS (klass);
02315   gobject_class->finalize     = dbus_upower_proxy_finalize;
02316   gobject_class->get_property = dbus_upower_proxy_get_property;
02317   gobject_class->set_property = dbus_upower_proxy_set_property;
02318 
02319   proxy_class = G_DBUS_PROXY_CLASS (klass);
02320   proxy_class->g_signal = dbus_upower_proxy_g_signal;
02321   proxy_class->g_properties_changed = dbus_upower_proxy_g_properties_changed;
02322 
02323 
02324   dbus_upower_override_properties (gobject_class, 1);
02325 }
02326 
02327 static void
02328 dbus_upower_proxy_iface_init (DBusUPowerIface *iface)
02329 {
02330   iface->get_daemon_version = dbus_upower_proxy_get_daemon_version;
02331   iface->get_can_suspend = dbus_upower_proxy_get_can_suspend;
02332   iface->get_can_hibernate = dbus_upower_proxy_get_can_hibernate;
02333   iface->get_on_battery = dbus_upower_proxy_get_on_battery;
02334   iface->get_on_low_battery = dbus_upower_proxy_get_on_low_battery;
02335   iface->get_lid_is_closed = dbus_upower_proxy_get_lid_is_closed;
02336   iface->get_lid_is_present = dbus_upower_proxy_get_lid_is_present;
02337 }
02338 
02356 void
02357 dbus_upower_proxy_new (
02358     GDBusConnection     *connection,
02359     GDBusProxyFlags      flags,
02360     const gchar         *name,
02361     const gchar         *object_path,
02362     GCancellable        *cancellable,
02363     GAsyncReadyCallback  callback,
02364     gpointer             user_data)
02365 {
02366   g_async_initable_new_async (DBUS_TYPE_UPOWER_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);
02367 }
02368 
02378 DBusUPower *
02379 dbus_upower_proxy_new_finish (
02380     GAsyncResult        *res,
02381     GError             **error)
02382 {
02383   GObject *ret;
02384   GObject *source_object;
02385   source_object = g_async_result_get_source_object (res);
02386   ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
02387   g_object_unref (source_object);
02388   if (ret != NULL)
02389     return DBUS_UPOWER (ret);
02390   else
02391     return NULL;
02392 }
02393 
02411 DBusUPower *
02412 dbus_upower_proxy_new_sync (
02413     GDBusConnection     *connection,
02414     GDBusProxyFlags      flags,
02415     const gchar         *name,
02416     const gchar         *object_path,
02417     GCancellable        *cancellable,
02418     GError             **error)
02419 {
02420   GInitable *ret;
02421   ret = g_initable_new (DBUS_TYPE_UPOWER_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.freedesktop.UPower", NULL);
02422   if (ret != NULL)
02423     return DBUS_UPOWER (ret);
02424   else
02425     return NULL;
02426 }
02427 
02428 
02446 void
02447 dbus_upower_proxy_new_for_bus (
02448     GBusType             bus_type,
02449     GDBusProxyFlags      flags,
02450     const gchar         *name,
02451     const gchar         *object_path,
02452     GCancellable        *cancellable,
02453     GAsyncReadyCallback  callback,
02454     gpointer             user_data)
02455 {
02456   g_async_initable_new_async (DBUS_TYPE_UPOWER_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);
02457 }
02458 
02468 DBusUPower *
02469 dbus_upower_proxy_new_for_bus_finish (
02470     GAsyncResult        *res,
02471     GError             **error)
02472 {
02473   GObject *ret;
02474   GObject *source_object;
02475   source_object = g_async_result_get_source_object (res);
02476   ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
02477   g_object_unref (source_object);
02478   if (ret != NULL)
02479     return DBUS_UPOWER (ret);
02480   else
02481     return NULL;
02482 }
02483 
02501 DBusUPower *
02502 dbus_upower_proxy_new_for_bus_sync (
02503     GBusType             bus_type,
02504     GDBusProxyFlags      flags,
02505     const gchar         *name,
02506     const gchar         *object_path,
02507     GCancellable        *cancellable,
02508     GError             **error)
02509 {
02510   GInitable *ret;
02511   ret = g_initable_new (DBUS_TYPE_UPOWER_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);
02512   if (ret != NULL)
02513     return DBUS_UPOWER (ret);
02514   else
02515     return NULL;
02516 }
02517 
02518 
02519 /* ------------------------------------------------------------------------ */
02520 
02534 struct _DBusUPowerSkeletonPrivate
02535 {
02536   GValue *properties;
02537   GList *changed_properties;
02538   GSource *changed_properties_idle_source;
02539   GMainContext *context;
02540   GMutex lock;
02541 };
02542 
02543 static void
02544 _dbus_upower_skeleton_handle_method_call (
02545   GDBusConnection *connection,
02546   const gchar *sender,
02547   const gchar *object_path,
02548   const gchar *interface_name,
02549   const gchar *method_name,
02550   GVariant *parameters,
02551   GDBusMethodInvocation *invocation,
02552   gpointer user_data)
02553 {
02554   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (user_data);
02555   _ExtendedGDBusMethodInfo *info;
02556   GVariantIter iter;
02557   GVariant *child;
02558   GValue *paramv;
02559   guint num_params;
02560   guint num_extra;
02561   guint n;
02562   guint signal_id;
02563   GValue return_value = G_VALUE_INIT;
02564   info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
02565   g_assert (info != NULL);
02566   num_params = g_variant_n_children (parameters);
02567   num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
02568   n = 0;
02569   g_value_init (&paramv[n], DBUS_TYPE_UPOWER);
02570   g_value_set_object (&paramv[n++], skeleton);
02571   g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
02572   g_value_set_object (&paramv[n++], invocation);
02573   if (info->pass_fdlist)
02574     {
02575 #ifdef G_OS_UNIX
02576       g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
02577       g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
02578 #else
02579       g_assert_not_reached ();
02580 #endif
02581     }
02582   g_variant_iter_init (&iter, parameters);
02583   while ((child = g_variant_iter_next_value (&iter)) != NULL)
02584     {
02585       _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
02586       if (arg_info->use_gvariant)
02587         {
02588           g_value_init (&paramv[n], G_TYPE_VARIANT);
02589           g_value_set_variant (&paramv[n], child);
02590           n++;
02591         }
02592       else
02593         g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
02594       g_variant_unref (child);
02595     }
02596   signal_id = g_signal_lookup (info->signal_name, DBUS_TYPE_UPOWER);
02597   g_value_init (&return_value, G_TYPE_BOOLEAN);
02598   g_signal_emitv (paramv, signal_id, 0, &return_value);
02599   if (!g_value_get_boolean (&return_value))
02600     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);
02601   g_value_unset (&return_value);
02602   for (n = 0; n < num_params + num_extra; n++)
02603     g_value_unset (&paramv[n]);
02604   g_free (paramv);
02605 }
02606 
02607 static GVariant *
02608 _dbus_upower_skeleton_handle_get_property (
02609   GDBusConnection *connection,
02610   const gchar *sender,
02611   const gchar *object_path,
02612   const gchar *interface_name,
02613   const gchar *property_name,
02614   GError **error,
02615   gpointer user_data)
02616 {
02617   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (user_data);
02618   GValue value = G_VALUE_INIT;
02619   GParamSpec *pspec;
02620   _ExtendedGDBusPropertyInfo *info;
02621   GVariant *ret;
02622   ret = NULL;
02623   info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_dbus_upower_interface_info, property_name);
02624   g_assert (info != NULL);
02625   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
02626   if (pspec == NULL)
02627     {
02628       g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
02629     }
02630   else
02631     {
02632       g_value_init (&value, pspec->value_type);
02633       g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
02634       ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
02635       g_value_unset (&value);
02636     }
02637   return ret;
02638 }
02639 
02640 static gboolean
02641 _dbus_upower_skeleton_handle_set_property (
02642   GDBusConnection *connection,
02643   const gchar *sender,
02644   const gchar *object_path,
02645   const gchar *interface_name,
02646   const gchar *property_name,
02647   GVariant *variant,
02648   GError **error,
02649   gpointer user_data)
02650 {
02651   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (user_data);
02652   GValue value = G_VALUE_INIT;
02653   GParamSpec *pspec;
02654   _ExtendedGDBusPropertyInfo *info;
02655   gboolean ret;
02656   ret = FALSE;
02657   info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_dbus_upower_interface_info, property_name);
02658   g_assert (info != NULL);
02659   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
02660   if (pspec == NULL)
02661     {
02662       g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
02663     }
02664   else
02665     {
02666       if (info->use_gvariant)
02667         g_value_set_variant (&value, variant);
02668       else
02669         g_dbus_gvariant_to_gvalue (variant, &value);
02670       g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
02671       g_value_unset (&value);
02672       ret = TRUE;
02673     }
02674   return ret;
02675 }
02676 
02677 static const GDBusInterfaceVTable _dbus_upower_skeleton_vtable =
02678 {
02679   _dbus_upower_skeleton_handle_method_call,
02680   _dbus_upower_skeleton_handle_get_property,
02681   _dbus_upower_skeleton_handle_set_property
02682 };
02683 
02684 static GDBusInterfaceInfo *
02685 dbus_upower_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton)
02686 {
02687   return dbus_upower_interface_info ();
02688 }
02689 
02690 static GDBusInterfaceVTable *
02691 dbus_upower_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton)
02692 {
02693   return (GDBusInterfaceVTable *) &_dbus_upower_skeleton_vtable;
02694 }
02695 
02696 static GVariant *
02697 dbus_upower_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
02698 {
02699   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (_skeleton);
02700 
02701   GVariantBuilder builder;
02702   guint n;
02703   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
02704   if (_dbus_upower_interface_info.parent_struct.properties == NULL)
02705     goto out;
02706   for (n = 0; _dbus_upower_interface_info.parent_struct.properties[n] != NULL; n++)
02707     {
02708       GDBusPropertyInfo *info = _dbus_upower_interface_info.parent_struct.properties[n];
02709       if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
02710         {
02711           GVariant *value;
02712           value = _dbus_upower_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);
02713           if (value != NULL)
02714             {
02715               g_variant_take_ref (value);
02716               g_variant_builder_add (&builder, "{sv}", info->name, value);
02717               g_variant_unref (value);
02718             }
02719         }
02720     }
02721 out:
02722   return g_variant_builder_end (&builder);
02723 }
02724 
02725 static gboolean _dbus_upower_emit_changed (gpointer user_data);
02726 
02727 static void
02728 dbus_upower_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
02729 {
02730   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (_skeleton);
02731   gboolean emit_changed = FALSE;
02732 
02733   g_mutex_lock (&skeleton->priv->lock);
02734   if (skeleton->priv->changed_properties_idle_source != NULL)
02735     {
02736       g_source_destroy (skeleton->priv->changed_properties_idle_source);
02737       skeleton->priv->changed_properties_idle_source = NULL;
02738       emit_changed = TRUE;
02739     }
02740   g_mutex_unlock (&skeleton->priv->lock);
02741 
02742   if (emit_changed)
02743     _dbus_upower_emit_changed (skeleton);
02744 }
02745 
02746 static void
02747 _dbus_upower_on_signal_device_added (
02748     DBusUPower *object,
02749     const gchar *arg_device)
02750 {
02751   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02752 
02753   GList      *connections, *l;
02754   GVariant   *signal_variant;
02755   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02756 
02757   signal_variant = g_variant_ref_sink (g_variant_new ("(o)",
02758                    arg_device));
02759   for (l = connections; l != NULL; l = l->next)
02760     {
02761       GDBusConnection *connection = l->data;
02762       g_dbus_connection_emit_signal (connection,
02763         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "DeviceAdded",
02764         signal_variant, NULL);
02765     }
02766   g_variant_unref (signal_variant);
02767   g_list_free_full (connections, g_object_unref);
02768 }
02769 
02770 static void
02771 _dbus_upower_on_signal_device_removed (
02772     DBusUPower *object,
02773     const gchar *arg_device)
02774 {
02775   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02776 
02777   GList      *connections, *l;
02778   GVariant   *signal_variant;
02779   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02780 
02781   signal_variant = g_variant_ref_sink (g_variant_new ("(o)",
02782                    arg_device));
02783   for (l = connections; l != NULL; l = l->next)
02784     {
02785       GDBusConnection *connection = l->data;
02786       g_dbus_connection_emit_signal (connection,
02787         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "DeviceRemoved",
02788         signal_variant, NULL);
02789     }
02790   g_variant_unref (signal_variant);
02791   g_list_free_full (connections, g_object_unref);
02792 }
02793 
02794 static void
02795 _dbus_upower_on_signal_device_changed (
02796     DBusUPower *object,
02797     const gchar *arg_device)
02798 {
02799   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02800 
02801   GList      *connections, *l;
02802   GVariant   *signal_variant;
02803   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02804 
02805   signal_variant = g_variant_ref_sink (g_variant_new ("(s)",
02806                    arg_device));
02807   for (l = connections; l != NULL; l = l->next)
02808     {
02809       GDBusConnection *connection = l->data;
02810       g_dbus_connection_emit_signal (connection,
02811         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "DeviceChanged",
02812         signal_variant, NULL);
02813     }
02814   g_variant_unref (signal_variant);
02815   g_list_free_full (connections, g_object_unref);
02816 }
02817 
02818 static void
02819 _dbus_upower_on_signal_changed (
02820     DBusUPower *object)
02821 {
02822   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02823 
02824   GList      *connections, *l;
02825   GVariant   *signal_variant;
02826   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02827 
02828   signal_variant = g_variant_ref_sink (g_variant_new ("()"));
02829   for (l = connections; l != NULL; l = l->next)
02830     {
02831       GDBusConnection *connection = l->data;
02832       g_dbus_connection_emit_signal (connection,
02833         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "Changed",
02834         signal_variant, NULL);
02835     }
02836   g_variant_unref (signal_variant);
02837   g_list_free_full (connections, g_object_unref);
02838 }
02839 
02840 static void
02841 _dbus_upower_on_signal_sleeping (
02842     DBusUPower *object)
02843 {
02844   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02845 
02846   GList      *connections, *l;
02847   GVariant   *signal_variant;
02848   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02849 
02850   signal_variant = g_variant_ref_sink (g_variant_new ("()"));
02851   for (l = connections; l != NULL; l = l->next)
02852     {
02853       GDBusConnection *connection = l->data;
02854       g_dbus_connection_emit_signal (connection,
02855         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "Sleeping",
02856         signal_variant, NULL);
02857     }
02858   g_variant_unref (signal_variant);
02859   g_list_free_full (connections, g_object_unref);
02860 }
02861 
02862 static void
02863 _dbus_upower_on_signal_resuming (
02864     DBusUPower *object)
02865 {
02866   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02867 
02868   GList      *connections, *l;
02869   GVariant   *signal_variant;
02870   connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02871 
02872   signal_variant = g_variant_ref_sink (g_variant_new ("()"));
02873   for (l = connections; l != NULL; l = l->next)
02874     {
02875       GDBusConnection *connection = l->data;
02876       g_dbus_connection_emit_signal (connection,
02877         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.UPower", "Resuming",
02878         signal_variant, NULL);
02879     }
02880   g_variant_unref (signal_variant);
02881   g_list_free_full (connections, g_object_unref);
02882 }
02883 
02884 static void dbus_upower_skeleton_iface_init (DBusUPowerIface *iface);
02885 G_DEFINE_TYPE_WITH_CODE (DBusUPowerSkeleton, dbus_upower_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
02886                          G_IMPLEMENT_INTERFACE (DBUS_TYPE_UPOWER, dbus_upower_skeleton_iface_init));
02887 
02888 static void
02889 dbus_upower_skeleton_finalize (GObject *object)
02890 {
02891   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02892   guint n;
02893   for (n = 0; n < 7; n++)
02894     g_value_unset (&skeleton->priv->properties[n]);
02895   g_free (skeleton->priv->properties);
02896   g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
02897   if (skeleton->priv->changed_properties_idle_source != NULL)
02898     g_source_destroy (skeleton->priv->changed_properties_idle_source);
02899   g_main_context_unref (skeleton->priv->context);
02900   g_mutex_clear (&skeleton->priv->lock);
02901   G_OBJECT_CLASS (dbus_upower_skeleton_parent_class)->finalize (object);
02902 }
02903 
02904 static void
02905 dbus_upower_skeleton_get_property (GObject      *object,
02906   guint         prop_id,
02907   GValue       *value,
02908   GParamSpec   *pspec)
02909 {
02910   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
02911   g_assert (prop_id != 0 && prop_id - 1 < 7);
02912   g_mutex_lock (&skeleton->priv->lock);
02913   g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
02914   g_mutex_unlock (&skeleton->priv->lock);
02915 }
02916 
02917 static gboolean
02918 _dbus_upower_emit_changed (gpointer user_data)
02919 {
02920   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (user_data);
02921   GList *l;
02922   GVariantBuilder builder;
02923   GVariantBuilder invalidated_builder;
02924   guint num_changes;
02925 
02926   g_mutex_lock (&skeleton->priv->lock);
02927   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
02928   g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
02929   for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
02930     {
02931       ChangedProperty *cp = l->data;
02932       GVariant *variant;
02933       const GValue *cur_value;
02934 
02935       cur_value = &skeleton->priv->properties[cp->prop_id - 1];
02936       if (!_g_value_equal (cur_value, &cp->orig_value))
02937         {
02938           variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
02939           g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
02940           g_variant_unref (variant);
02941           num_changes++;
02942         }
02943     }
02944   if (num_changes > 0)
02945     {
02946       GList *connections, *l;
02947       GVariant *signal_variant;
02948       signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.freedesktop.UPower",
02949                                            &builder, &invalidated_builder));
02950       connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
02951       for (l = connections; l != NULL; l = l->next)
02952         {
02953           GDBusConnection *connection = l->data;
02954 
02955           g_dbus_connection_emit_signal (connection,
02956                                          NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
02957                                          "org.freedesktop.DBus.Properties",
02958                                          "PropertiesChanged",
02959                                          signal_variant,
02960                                          NULL);
02961         }
02962       g_variant_unref (signal_variant);
02963       g_list_free_full (connections, g_object_unref);
02964     }
02965   else
02966     {
02967       g_variant_builder_clear (&builder);
02968       g_variant_builder_clear (&invalidated_builder);
02969     }
02970   g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
02971   skeleton->priv->changed_properties = NULL;
02972   skeleton->priv->changed_properties_idle_source = NULL;
02973   g_mutex_unlock (&skeleton->priv->lock);
02974   return FALSE;
02975 }
02976 
02977 static void
02978 _dbus_upower_schedule_emit_changed (DBusUPowerSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
02979 {
02980   ChangedProperty *cp;
02981   GList *l;
02982   cp = NULL;
02983   for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
02984     {
02985       ChangedProperty *i_cp = l->data;
02986       if (i_cp->info == info)
02987         {
02988           cp = i_cp;
02989           break;
02990         }
02991     }
02992   if (cp == NULL)
02993     {
02994       cp = g_new0 (ChangedProperty, 1);
02995       cp->prop_id = prop_id;
02996       cp->info = info;
02997       skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
02998       g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
02999       g_value_copy (orig_value, &cp->orig_value);
03000     }
03001 }
03002 
03003 static void
03004 dbus_upower_skeleton_notify (GObject      *object,
03005   GParamSpec *pspec)
03006 {
03007   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03008   g_mutex_lock (&skeleton->priv->lock);
03009   if (skeleton->priv->changed_properties != NULL &&
03010       skeleton->priv->changed_properties_idle_source == NULL)
03011     {
03012       skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
03013       g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
03014       g_source_set_callback (skeleton->priv->changed_properties_idle_source, _dbus_upower_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
03015       g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
03016       g_source_unref (skeleton->priv->changed_properties_idle_source);
03017     }
03018   g_mutex_unlock (&skeleton->priv->lock);
03019 }
03020 
03021 static void
03022 dbus_upower_skeleton_set_property (GObject      *object,
03023   guint         prop_id,
03024   const GValue *value,
03025   GParamSpec   *pspec)
03026 {
03027   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03028   g_assert (prop_id != 0 && prop_id - 1 < 7);
03029   g_mutex_lock (&skeleton->priv->lock);
03030   g_object_freeze_notify (object);
03031   if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
03032     {
03033       if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
03034         _dbus_upower_schedule_emit_changed (skeleton, _dbus_upower_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
03035       g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
03036       g_object_notify_by_pspec (object, pspec);
03037     }
03038   g_mutex_unlock (&skeleton->priv->lock);
03039   g_object_thaw_notify (object);
03040 }
03041 
03042 static void
03043 dbus_upower_skeleton_init (DBusUPowerSkeleton *skeleton)
03044 {
03045   skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, DBUS_TYPE_UPOWER_SKELETON, DBusUPowerSkeletonPrivate);
03046   g_mutex_init (&skeleton->priv->lock);
03047   skeleton->priv->context = g_main_context_ref_thread_default ();
03048   skeleton->priv->properties = g_new0 (GValue, 7);
03049   g_value_init (&skeleton->priv->properties[0], G_TYPE_STRING);
03050   g_value_init (&skeleton->priv->properties[1], G_TYPE_BOOLEAN);
03051   g_value_init (&skeleton->priv->properties[2], G_TYPE_BOOLEAN);
03052   g_value_init (&skeleton->priv->properties[3], G_TYPE_BOOLEAN);
03053   g_value_init (&skeleton->priv->properties[4], G_TYPE_BOOLEAN);
03054   g_value_init (&skeleton->priv->properties[5], G_TYPE_BOOLEAN);
03055   g_value_init (&skeleton->priv->properties[6], G_TYPE_BOOLEAN);
03056 }
03057 
03058 static const gchar *
03059 dbus_upower_skeleton_get_daemon_version (DBusUPower *object)
03060 {
03061   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03062   const gchar *value;
03063   g_mutex_lock (&skeleton->priv->lock);
03064   value = g_value_get_string (&(skeleton->priv->properties[0]));
03065   g_mutex_unlock (&skeleton->priv->lock);
03066   return value;
03067 }
03068 
03069 static gboolean 
03070 dbus_upower_skeleton_get_can_suspend (DBusUPower *object)
03071 {
03072   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03073   gboolean value;
03074   g_mutex_lock (&skeleton->priv->lock);
03075   value = g_value_get_boolean (&(skeleton->priv->properties[1]));
03076   g_mutex_unlock (&skeleton->priv->lock);
03077   return value;
03078 }
03079 
03080 static gboolean 
03081 dbus_upower_skeleton_get_can_hibernate (DBusUPower *object)
03082 {
03083   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03084   gboolean value;
03085   g_mutex_lock (&skeleton->priv->lock);
03086   value = g_value_get_boolean (&(skeleton->priv->properties[2]));
03087   g_mutex_unlock (&skeleton->priv->lock);
03088   return value;
03089 }
03090 
03091 static gboolean 
03092 dbus_upower_skeleton_get_on_battery (DBusUPower *object)
03093 {
03094   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03095   gboolean value;
03096   g_mutex_lock (&skeleton->priv->lock);
03097   value = g_value_get_boolean (&(skeleton->priv->properties[3]));
03098   g_mutex_unlock (&skeleton->priv->lock);
03099   return value;
03100 }
03101 
03102 static gboolean 
03103 dbus_upower_skeleton_get_on_low_battery (DBusUPower *object)
03104 {
03105   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03106   gboolean value;
03107   g_mutex_lock (&skeleton->priv->lock);
03108   value = g_value_get_boolean (&(skeleton->priv->properties[4]));
03109   g_mutex_unlock (&skeleton->priv->lock);
03110   return value;
03111 }
03112 
03113 static gboolean 
03114 dbus_upower_skeleton_get_lid_is_closed (DBusUPower *object)
03115 {
03116   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03117   gboolean value;
03118   g_mutex_lock (&skeleton->priv->lock);
03119   value = g_value_get_boolean (&(skeleton->priv->properties[5]));
03120   g_mutex_unlock (&skeleton->priv->lock);
03121   return value;
03122 }
03123 
03124 static gboolean 
03125 dbus_upower_skeleton_get_lid_is_present (DBusUPower *object)
03126 {
03127   DBusUPowerSkeleton *skeleton = DBUS_UPOWER_SKELETON (object);
03128   gboolean value;
03129   g_mutex_lock (&skeleton->priv->lock);
03130   value = g_value_get_boolean (&(skeleton->priv->properties[6]));
03131   g_mutex_unlock (&skeleton->priv->lock);
03132   return value;
03133 }
03134 
03135 static void
03136 dbus_upower_skeleton_class_init (DBusUPowerSkeletonClass *klass)
03137 {
03138   GObjectClass *gobject_class;
03139   GDBusInterfaceSkeletonClass *skeleton_class;
03140 
03141   g_type_class_add_private (klass, sizeof (DBusUPowerSkeletonPrivate));
03142 
03143   gobject_class = G_OBJECT_CLASS (klass);
03144   gobject_class->finalize = dbus_upower_skeleton_finalize;
03145   gobject_class->get_property = dbus_upower_skeleton_get_property;
03146   gobject_class->set_property = dbus_upower_skeleton_set_property;
03147   gobject_class->notify       = dbus_upower_skeleton_notify;
03148 
03149 
03150   dbus_upower_override_properties (gobject_class, 1);
03151 
03152   skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
03153   skeleton_class->get_info = dbus_upower_skeleton_dbus_interface_get_info;
03154   skeleton_class->get_properties = dbus_upower_skeleton_dbus_interface_get_properties;
03155   skeleton_class->flush = dbus_upower_skeleton_dbus_interface_flush;
03156   skeleton_class->get_vtable = dbus_upower_skeleton_dbus_interface_get_vtable;
03157 }
03158 
03159 static void
03160 dbus_upower_skeleton_iface_init (DBusUPowerIface *iface)
03161 {
03162   iface->device_added = _dbus_upower_on_signal_device_added;
03163   iface->device_removed = _dbus_upower_on_signal_device_removed;
03164   iface->device_changed = _dbus_upower_on_signal_device_changed;
03165   iface->changed = _dbus_upower_on_signal_changed;
03166   iface->sleeping = _dbus_upower_on_signal_sleeping;
03167   iface->resuming = _dbus_upower_on_signal_resuming;
03168   iface->get_daemon_version = dbus_upower_skeleton_get_daemon_version;
03169   iface->get_can_suspend = dbus_upower_skeleton_get_can_suspend;
03170   iface->get_can_hibernate = dbus_upower_skeleton_get_can_hibernate;
03171   iface->get_on_battery = dbus_upower_skeleton_get_on_battery;
03172   iface->get_on_low_battery = dbus_upower_skeleton_get_on_low_battery;
03173   iface->get_lid_is_closed = dbus_upower_skeleton_get_lid_is_closed;
03174   iface->get_lid_is_present = dbus_upower_skeleton_get_lid_is_present;
03175 }
03176 
03184 DBusUPower *
03185 dbus_upower_skeleton_new (void)
03186 {
03187   return DBUS_UPOWER (g_object_new (DBUS_TYPE_UPOWER_SKELETON, NULL));
03188 }
03189