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