Norman James | ce46e3e | 2015-08-30 22:25:55 -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/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 |
| 153 | * ------------------------------------------------------------------------ |
| 154 | */ |
| 155 | |
| 156 | /** |
| 157 | * SECTION:Control |
| 158 | * @title: Control |
| 159 | * @short_description: Generated C code for the org.openbmc.Control D-Bus interface |
| 160 | * |
| 161 | * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link> D-Bus interface in C. |
| 162 | */ |
| 163 | |
| 164 | /* ---- Introspection data for org.openbmc.Control ---- */ |
| 165 | |
| 166 | static const _ExtendedGDBusArgInfo _control_method_info_set_poll_interval_IN_ARG_poll_interval = |
| 167 | { |
| 168 | { |
| 169 | -1, |
| 170 | (gchar *) "poll_interval", |
| 171 | (gchar *) "i", |
| 172 | NULL |
| 173 | }, |
| 174 | FALSE |
| 175 | }; |
| 176 | |
| 177 | static const _ExtendedGDBusArgInfo * const _control_method_info_set_poll_interval_IN_ARG_pointers[] = |
| 178 | { |
| 179 | &_control_method_info_set_poll_interval_IN_ARG_poll_interval, |
| 180 | NULL |
| 181 | }; |
| 182 | |
| 183 | static const _ExtendedGDBusMethodInfo _control_method_info_set_poll_interval = |
| 184 | { |
| 185 | { |
| 186 | -1, |
| 187 | (gchar *) "setPollInterval", |
| 188 | (GDBusArgInfo **) &_control_method_info_set_poll_interval_IN_ARG_pointers, |
| 189 | NULL, |
| 190 | NULL |
| 191 | }, |
| 192 | "handle-set-poll-interval", |
| 193 | FALSE |
| 194 | }; |
| 195 | |
| 196 | static const _ExtendedGDBusMethodInfo * const _control_method_info_pointers[] = |
| 197 | { |
| 198 | &_control_method_info_set_poll_interval, |
| 199 | NULL |
| 200 | }; |
| 201 | |
| 202 | static const _ExtendedGDBusArgInfo _control_signal_info_heartbeat_ARG_bus_name = |
| 203 | { |
| 204 | { |
| 205 | -1, |
| 206 | (gchar *) "bus_name", |
| 207 | (gchar *) "s", |
| 208 | NULL |
| 209 | }, |
| 210 | FALSE |
| 211 | }; |
| 212 | |
| 213 | static const _ExtendedGDBusArgInfo * const _control_signal_info_heartbeat_ARG_pointers[] = |
| 214 | { |
| 215 | &_control_signal_info_heartbeat_ARG_bus_name, |
| 216 | NULL |
| 217 | }; |
| 218 | |
| 219 | static const _ExtendedGDBusSignalInfo _control_signal_info_heartbeat = |
| 220 | { |
| 221 | { |
| 222 | -1, |
| 223 | (gchar *) "Heartbeat", |
| 224 | (GDBusArgInfo **) &_control_signal_info_heartbeat_ARG_pointers, |
| 225 | NULL |
| 226 | }, |
| 227 | "heartbeat" |
| 228 | }; |
| 229 | |
| 230 | static const _ExtendedGDBusSignalInfo * const _control_signal_info_pointers[] = |
| 231 | { |
| 232 | &_control_signal_info_heartbeat, |
| 233 | NULL |
| 234 | }; |
| 235 | |
| 236 | static const _ExtendedGDBusPropertyInfo _control_property_info_poll_interval = |
| 237 | { |
| 238 | { |
| 239 | -1, |
| 240 | (gchar *) "poll_interval", |
| 241 | (gchar *) "i", |
| 242 | G_DBUS_PROPERTY_INFO_FLAGS_READABLE, |
| 243 | NULL |
| 244 | }, |
| 245 | "poll-interval", |
| 246 | FALSE |
| 247 | }; |
| 248 | |
| 249 | static const _ExtendedGDBusPropertyInfo _control_property_info_heatbeat = |
| 250 | { |
| 251 | { |
| 252 | -1, |
| 253 | (gchar *) "heatbeat", |
| 254 | (gchar *) "i", |
| 255 | G_DBUS_PROPERTY_INFO_FLAGS_READABLE, |
| 256 | NULL |
| 257 | }, |
| 258 | "heatbeat", |
| 259 | FALSE |
| 260 | }; |
| 261 | |
| 262 | static const _ExtendedGDBusPropertyInfo * const _control_property_info_pointers[] = |
| 263 | { |
| 264 | &_control_property_info_poll_interval, |
| 265 | &_control_property_info_heatbeat, |
| 266 | NULL |
| 267 | }; |
| 268 | |
| 269 | static const _ExtendedGDBusInterfaceInfo _control_interface_info = |
| 270 | { |
| 271 | { |
| 272 | -1, |
| 273 | (gchar *) "org.openbmc.Control", |
| 274 | (GDBusMethodInfo **) &_control_method_info_pointers, |
| 275 | (GDBusSignalInfo **) &_control_signal_info_pointers, |
| 276 | (GDBusPropertyInfo **) &_control_property_info_pointers, |
| 277 | NULL |
| 278 | }, |
| 279 | "control", |
| 280 | }; |
| 281 | |
| 282 | |
| 283 | /** |
| 284 | * control_interface_info: |
| 285 | * |
| 286 | * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link> D-Bus interface. |
| 287 | * |
| 288 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. |
| 289 | */ |
| 290 | GDBusInterfaceInfo * |
| 291 | control_interface_info (void) |
| 292 | { |
| 293 | return (GDBusInterfaceInfo *) &_control_interface_info.parent_struct; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * control_override_properties: |
| 298 | * @klass: The class structure for a #GObject<!-- -->-derived class. |
| 299 | * @property_id_begin: The property id to assign to the first overridden property. |
| 300 | * |
| 301 | * Overrides all #GObject properties in the #Control interface for a concrete class. |
| 302 | * The properties are overridden in the order they are defined. |
| 303 | * |
| 304 | * Returns: The last property id. |
| 305 | */ |
| 306 | guint |
| 307 | control_override_properties (GObjectClass *klass, guint property_id_begin) |
| 308 | { |
| 309 | g_object_class_override_property (klass, property_id_begin++, "poll-interval"); |
| 310 | g_object_class_override_property (klass, property_id_begin++, "heatbeat"); |
| 311 | return property_id_begin - 1; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | |
| 316 | /** |
| 317 | * Control: |
| 318 | * |
| 319 | * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>. |
| 320 | */ |
| 321 | |
| 322 | /** |
| 323 | * ControlIface: |
| 324 | * @parent_iface: The parent interface. |
| 325 | * @handle_set_poll_interval: Handler for the #Control::handle-set-poll-interval signal. |
| 326 | * @get_heatbeat: Getter for the #Control:heatbeat property. |
| 327 | * @get_poll_interval: Getter for the #Control:poll-interval property. |
| 328 | * @heartbeat: Handler for the #Control::heartbeat signal. |
| 329 | * |
| 330 | * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>. |
| 331 | */ |
| 332 | |
| 333 | typedef ControlIface ControlInterface; |
| 334 | G_DEFINE_INTERFACE (Control, control, G_TYPE_OBJECT); |
| 335 | |
| 336 | static void |
| 337 | control_default_init (ControlIface *iface) |
| 338 | { |
| 339 | /* GObject signals for incoming D-Bus method calls: */ |
| 340 | /** |
| 341 | * Control::handle-set-poll-interval: |
| 342 | * @object: A #Control. |
| 343 | * @invocation: A #GDBusMethodInvocation. |
| 344 | * @arg_poll_interval: Argument passed by remote caller. |
| 345 | * |
| 346 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-Control.setPollInterval">setPollInterval()</link> D-Bus method. |
| 347 | * |
| 348 | * 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_complete_set_poll_interval() 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. |
| 349 | * |
| 350 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 351 | */ |
| 352 | g_signal_new ("handle-set-poll-interval", |
| 353 | G_TYPE_FROM_INTERFACE (iface), |
| 354 | G_SIGNAL_RUN_LAST, |
| 355 | G_STRUCT_OFFSET (ControlIface, handle_set_poll_interval), |
| 356 | g_signal_accumulator_true_handled, |
| 357 | NULL, |
| 358 | g_cclosure_marshal_generic, |
| 359 | G_TYPE_BOOLEAN, |
| 360 | 2, |
| 361 | G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT); |
| 362 | |
| 363 | /* GObject signals for received D-Bus signals: */ |
| 364 | /** |
| 365 | * Control::heartbeat: |
| 366 | * @object: A #Control. |
| 367 | * @arg_bus_name: Argument. |
| 368 | * |
| 369 | * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-Control.Heartbeat">"Heartbeat"</link> is received. |
| 370 | * |
| 371 | * 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. |
| 372 | */ |
| 373 | g_signal_new ("heartbeat", |
| 374 | G_TYPE_FROM_INTERFACE (iface), |
| 375 | G_SIGNAL_RUN_LAST, |
| 376 | G_STRUCT_OFFSET (ControlIface, heartbeat), |
| 377 | NULL, |
| 378 | NULL, |
| 379 | g_cclosure_marshal_generic, |
| 380 | G_TYPE_NONE, |
| 381 | 1, G_TYPE_STRING); |
| 382 | |
| 383 | /* GObject properties for D-Bus properties: */ |
| 384 | /** |
| 385 | * Control:poll-interval: |
| 386 | * |
| 387 | * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-Control.poll_interval">"poll_interval"</link>. |
| 388 | * |
| 389 | * 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. |
| 390 | */ |
| 391 | g_object_interface_install_property (iface, |
| 392 | g_param_spec_int ("poll-interval", "poll_interval", "poll_interval", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 393 | /** |
| 394 | * Control:heatbeat: |
| 395 | * |
| 396 | * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-Control.heatbeat">"heatbeat"</link>. |
| 397 | * |
| 398 | * 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. |
| 399 | */ |
| 400 | g_object_interface_install_property (iface, |
| 401 | g_param_spec_int ("heatbeat", "heatbeat", "heatbeat", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * control_get_poll_interval: (skip) |
| 406 | * @object: A #Control. |
| 407 | * |
| 408 | * Gets the value of the <link linkend="gdbus-property-org-openbmc-Control.poll_interval">"poll_interval"</link> D-Bus property. |
| 409 | * |
| 410 | * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. |
| 411 | * |
| 412 | * Returns: The property value. |
| 413 | */ |
| 414 | gint |
| 415 | control_get_poll_interval (Control *object) |
| 416 | { |
| 417 | return CONTROL_GET_IFACE (object)->get_poll_interval (object); |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * control_set_poll_interval: (skip) |
| 422 | * @object: A #Control. |
| 423 | * @value: The value to set. |
| 424 | * |
| 425 | * Sets the <link linkend="gdbus-property-org-openbmc-Control.poll_interval">"poll_interval"</link> D-Bus property to @value. |
| 426 | * |
| 427 | * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. |
| 428 | */ |
| 429 | void |
| 430 | control_set_poll_interval (Control *object, gint value) |
| 431 | { |
| 432 | g_object_set (G_OBJECT (object), "poll-interval", value, NULL); |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * control_get_heatbeat: (skip) |
| 437 | * @object: A #Control. |
| 438 | * |
| 439 | * Gets the value of the <link linkend="gdbus-property-org-openbmc-Control.heatbeat">"heatbeat"</link> D-Bus property. |
| 440 | * |
| 441 | * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. |
| 442 | * |
| 443 | * Returns: The property value. |
| 444 | */ |
| 445 | gint |
| 446 | control_get_heatbeat (Control *object) |
| 447 | { |
| 448 | return CONTROL_GET_IFACE (object)->get_heatbeat (object); |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * control_set_heatbeat: (skip) |
| 453 | * @object: A #Control. |
| 454 | * @value: The value to set. |
| 455 | * |
| 456 | * Sets the <link linkend="gdbus-property-org-openbmc-Control.heatbeat">"heatbeat"</link> D-Bus property to @value. |
| 457 | * |
| 458 | * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. |
| 459 | */ |
| 460 | void |
| 461 | control_set_heatbeat (Control *object, gint value) |
| 462 | { |
| 463 | g_object_set (G_OBJECT (object), "heatbeat", value, NULL); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * control_emit_heartbeat: |
| 468 | * @object: A #Control. |
| 469 | * @arg_bus_name: Argument to pass with the signal. |
| 470 | * |
| 471 | * Emits the <link linkend="gdbus-signal-org-openbmc-Control.Heartbeat">"Heartbeat"</link> D-Bus signal. |
| 472 | */ |
| 473 | void |
| 474 | control_emit_heartbeat ( |
| 475 | Control *object, |
| 476 | const gchar *arg_bus_name) |
| 477 | { |
| 478 | g_signal_emit_by_name (object, "heartbeat", arg_bus_name); |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * control_call_set_poll_interval: |
| 483 | * @proxy: A #ControlProxy. |
| 484 | * @arg_poll_interval: Argument to pass with the method invocation. |
| 485 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 486 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 487 | * @user_data: User data to pass to @callback. |
| 488 | * |
| 489 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-Control.setPollInterval">setPollInterval()</link> D-Bus method on @proxy. |
| 490 | * 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. |
| 491 | * You can then call control_call_set_poll_interval_finish() to get the result of the operation. |
| 492 | * |
| 493 | * See control_call_set_poll_interval_sync() for the synchronous, blocking version of this method. |
| 494 | */ |
| 495 | void |
| 496 | control_call_set_poll_interval ( |
| 497 | Control *proxy, |
| 498 | gint arg_poll_interval, |
| 499 | GCancellable *cancellable, |
| 500 | GAsyncReadyCallback callback, |
| 501 | gpointer user_data) |
| 502 | { |
| 503 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 504 | "setPollInterval", |
| 505 | g_variant_new ("(i)", |
| 506 | arg_poll_interval), |
| 507 | G_DBUS_CALL_FLAGS_NONE, |
| 508 | -1, |
| 509 | cancellable, |
| 510 | callback, |
| 511 | user_data); |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * control_call_set_poll_interval_finish: |
| 516 | * @proxy: A #ControlProxy. |
| 517 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_call_set_poll_interval(). |
| 518 | * @error: Return location for error or %NULL. |
| 519 | * |
| 520 | * Finishes an operation started with control_call_set_poll_interval(). |
| 521 | * |
| 522 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 523 | */ |
| 524 | gboolean |
| 525 | control_call_set_poll_interval_finish ( |
| 526 | Control *proxy, |
| 527 | GAsyncResult *res, |
| 528 | GError **error) |
| 529 | { |
| 530 | GVariant *_ret; |
| 531 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 532 | if (_ret == NULL) |
| 533 | goto _out; |
| 534 | g_variant_get (_ret, |
| 535 | "()"); |
| 536 | g_variant_unref (_ret); |
| 537 | _out: |
| 538 | return _ret != NULL; |
| 539 | } |
| 540 | |
| 541 | /** |
| 542 | * control_call_set_poll_interval_sync: |
| 543 | * @proxy: A #ControlProxy. |
| 544 | * @arg_poll_interval: Argument to pass with the method invocation. |
| 545 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 546 | * @error: Return location for error or %NULL. |
| 547 | * |
| 548 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-Control.setPollInterval">setPollInterval()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. |
| 549 | * |
| 550 | * See control_call_set_poll_interval() for the asynchronous version of this method. |
| 551 | * |
| 552 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 553 | */ |
| 554 | gboolean |
| 555 | control_call_set_poll_interval_sync ( |
| 556 | Control *proxy, |
| 557 | gint arg_poll_interval, |
| 558 | GCancellable *cancellable, |
| 559 | GError **error) |
| 560 | { |
| 561 | GVariant *_ret; |
| 562 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 563 | "setPollInterval", |
| 564 | g_variant_new ("(i)", |
| 565 | arg_poll_interval), |
| 566 | G_DBUS_CALL_FLAGS_NONE, |
| 567 | -1, |
| 568 | cancellable, |
| 569 | error); |
| 570 | if (_ret == NULL) |
| 571 | goto _out; |
| 572 | g_variant_get (_ret, |
| 573 | "()"); |
| 574 | g_variant_unref (_ret); |
| 575 | _out: |
| 576 | return _ret != NULL; |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * control_complete_set_poll_interval: |
| 581 | * @object: A #Control. |
| 582 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 583 | * |
| 584 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-Control.setPollInterval">setPollInterval()</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. |
| 585 | * |
| 586 | * This method will free @invocation, you cannot use it afterwards. |
| 587 | */ |
| 588 | void |
| 589 | control_complete_set_poll_interval ( |
| 590 | Control *object, |
| 591 | GDBusMethodInvocation *invocation) |
| 592 | { |
| 593 | g_dbus_method_invocation_return_value (invocation, |
| 594 | g_variant_new ("()")); |
| 595 | } |
| 596 | |
| 597 | /* ------------------------------------------------------------------------ */ |
| 598 | |
| 599 | /** |
| 600 | * ControlProxy: |
| 601 | * |
| 602 | * The #ControlProxy structure contains only private data and should only be accessed using the provided API. |
| 603 | */ |
| 604 | |
| 605 | /** |
| 606 | * ControlProxyClass: |
| 607 | * @parent_class: The parent class. |
| 608 | * |
| 609 | * Class structure for #ControlProxy. |
| 610 | */ |
| 611 | |
| 612 | struct _ControlProxyPrivate |
| 613 | { |
| 614 | GData *qdata; |
| 615 | }; |
| 616 | |
| 617 | static void control_proxy_iface_init (ControlIface *iface); |
| 618 | |
| 619 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 620 | G_DEFINE_TYPE_WITH_CODE (ControlProxy, control_proxy, G_TYPE_DBUS_PROXY, |
| 621 | G_ADD_PRIVATE (ControlProxy) |
| 622 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL, control_proxy_iface_init)); |
| 623 | |
| 624 | #else |
| 625 | G_DEFINE_TYPE_WITH_CODE (ControlProxy, control_proxy, G_TYPE_DBUS_PROXY, |
| 626 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL, control_proxy_iface_init)); |
| 627 | |
| 628 | #endif |
| 629 | static void |
| 630 | control_proxy_finalize (GObject *object) |
| 631 | { |
| 632 | ControlProxy *proxy = CONTROL_PROXY (object); |
| 633 | g_datalist_clear (&proxy->priv->qdata); |
| 634 | G_OBJECT_CLASS (control_proxy_parent_class)->finalize (object); |
| 635 | } |
| 636 | |
| 637 | static void |
| 638 | control_proxy_get_property (GObject *object, |
| 639 | guint prop_id, |
| 640 | GValue *value, |
| 641 | GParamSpec *pspec G_GNUC_UNUSED) |
| 642 | { |
| 643 | const _ExtendedGDBusPropertyInfo *info; |
| 644 | GVariant *variant; |
| 645 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 646 | info = _control_property_info_pointers[prop_id - 1]; |
| 647 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name); |
| 648 | if (info->use_gvariant) |
| 649 | { |
| 650 | g_value_set_variant (value, variant); |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | if (variant != NULL) |
| 655 | g_dbus_gvariant_to_gvalue (variant, value); |
| 656 | } |
| 657 | if (variant != NULL) |
| 658 | g_variant_unref (variant); |
| 659 | } |
| 660 | |
| 661 | static void |
| 662 | control_proxy_set_property_cb (GDBusProxy *proxy, |
| 663 | GAsyncResult *res, |
| 664 | gpointer user_data) |
| 665 | { |
| 666 | const _ExtendedGDBusPropertyInfo *info = user_data; |
| 667 | GError *error; |
| 668 | GVariant *_ret; |
| 669 | error = NULL; |
| 670 | _ret = g_dbus_proxy_call_finish (proxy, res, &error); |
| 671 | if (!_ret) |
| 672 | { |
| 673 | g_warning ("Error setting property '%s' on interface org.openbmc.Control: %s (%s, %d)", |
| 674 | info->parent_struct.name, |
| 675 | error->message, g_quark_to_string (error->domain), error->code); |
| 676 | g_error_free (error); |
| 677 | } |
| 678 | else |
| 679 | { |
| 680 | g_variant_unref (_ret); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | static void |
| 685 | control_proxy_set_property (GObject *object, |
| 686 | guint prop_id, |
| 687 | const GValue *value, |
| 688 | GParamSpec *pspec G_GNUC_UNUSED) |
| 689 | { |
| 690 | const _ExtendedGDBusPropertyInfo *info; |
| 691 | GVariant *variant; |
| 692 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 693 | info = _control_property_info_pointers[prop_id - 1]; |
| 694 | variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 695 | g_dbus_proxy_call (G_DBUS_PROXY (object), |
| 696 | "org.freedesktop.DBus.Properties.Set", |
| 697 | g_variant_new ("(ssv)", "org.openbmc.Control", info->parent_struct.name, variant), |
| 698 | G_DBUS_CALL_FLAGS_NONE, |
| 699 | -1, |
| 700 | NULL, (GAsyncReadyCallback) control_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct); |
| 701 | g_variant_unref (variant); |
| 702 | } |
| 703 | |
| 704 | static void |
| 705 | control_proxy_g_signal (GDBusProxy *proxy, |
| 706 | const gchar *sender_name G_GNUC_UNUSED, |
| 707 | const gchar *signal_name, |
| 708 | GVariant *parameters) |
| 709 | { |
| 710 | _ExtendedGDBusSignalInfo *info; |
| 711 | GVariantIter iter; |
| 712 | GVariant *child; |
| 713 | GValue *paramv; |
| 714 | guint num_params; |
| 715 | guint n; |
| 716 | guint signal_id; |
| 717 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_control_interface_info.parent_struct, signal_name); |
| 718 | if (info == NULL) |
| 719 | return; |
| 720 | num_params = g_variant_n_children (parameters); |
| 721 | paramv = g_new0 (GValue, num_params + 1); |
| 722 | g_value_init (¶mv[0], TYPE_CONTROL); |
| 723 | g_value_set_object (¶mv[0], proxy); |
| 724 | g_variant_iter_init (&iter, parameters); |
| 725 | n = 1; |
| 726 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 727 | { |
| 728 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; |
| 729 | if (arg_info->use_gvariant) |
| 730 | { |
| 731 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 732 | g_value_set_variant (¶mv[n], child); |
| 733 | n++; |
| 734 | } |
| 735 | else |
| 736 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 737 | g_variant_unref (child); |
| 738 | } |
| 739 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL); |
| 740 | g_signal_emitv (paramv, signal_id, 0, NULL); |
| 741 | for (n = 0; n < num_params + 1; n++) |
| 742 | g_value_unset (¶mv[n]); |
| 743 | g_free (paramv); |
| 744 | } |
| 745 | |
| 746 | static void |
| 747 | control_proxy_g_properties_changed (GDBusProxy *_proxy, |
| 748 | GVariant *changed_properties, |
| 749 | const gchar *const *invalidated_properties) |
| 750 | { |
| 751 | ControlProxy *proxy = CONTROL_PROXY (_proxy); |
| 752 | guint n; |
| 753 | const gchar *key; |
| 754 | GVariantIter *iter; |
| 755 | _ExtendedGDBusPropertyInfo *info; |
| 756 | g_variant_get (changed_properties, "a{sv}", &iter); |
| 757 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) |
| 758 | { |
| 759 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_interface_info.parent_struct, key); |
| 760 | g_datalist_remove_data (&proxy->priv->qdata, key); |
| 761 | if (info != NULL) |
| 762 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 763 | } |
| 764 | g_variant_iter_free (iter); |
| 765 | for (n = 0; invalidated_properties[n] != NULL; n++) |
| 766 | { |
| 767 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_interface_info.parent_struct, invalidated_properties[n]); |
| 768 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); |
| 769 | if (info != NULL) |
| 770 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | static gint |
| 775 | control_proxy_get_poll_interval (Control *object) |
| 776 | { |
| 777 | ControlProxy *proxy = CONTROL_PROXY (object); |
| 778 | GVariant *variant; |
| 779 | gint value = 0; |
| 780 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "poll_interval"); |
| 781 | if (variant != NULL) |
| 782 | { |
| 783 | value = g_variant_get_int32 (variant); |
| 784 | g_variant_unref (variant); |
| 785 | } |
| 786 | return value; |
| 787 | } |
| 788 | |
| 789 | static gint |
| 790 | control_proxy_get_heatbeat (Control *object) |
| 791 | { |
| 792 | ControlProxy *proxy = CONTROL_PROXY (object); |
| 793 | GVariant *variant; |
| 794 | gint value = 0; |
| 795 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "heatbeat"); |
| 796 | if (variant != NULL) |
| 797 | { |
| 798 | value = g_variant_get_int32 (variant); |
| 799 | g_variant_unref (variant); |
| 800 | } |
| 801 | return value; |
| 802 | } |
| 803 | |
| 804 | static void |
| 805 | control_proxy_init (ControlProxy *proxy) |
| 806 | { |
| 807 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 808 | proxy->priv = control_proxy_get_instance_private (proxy); |
| 809 | #else |
| 810 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_CONTROL_PROXY, ControlProxyPrivate); |
| 811 | #endif |
| 812 | |
| 813 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), control_interface_info ()); |
| 814 | } |
| 815 | |
| 816 | static void |
| 817 | control_proxy_class_init (ControlProxyClass *klass) |
| 818 | { |
| 819 | GObjectClass *gobject_class; |
| 820 | GDBusProxyClass *proxy_class; |
| 821 | |
| 822 | gobject_class = G_OBJECT_CLASS (klass); |
| 823 | gobject_class->finalize = control_proxy_finalize; |
| 824 | gobject_class->get_property = control_proxy_get_property; |
| 825 | gobject_class->set_property = control_proxy_set_property; |
| 826 | |
| 827 | proxy_class = G_DBUS_PROXY_CLASS (klass); |
| 828 | proxy_class->g_signal = control_proxy_g_signal; |
| 829 | proxy_class->g_properties_changed = control_proxy_g_properties_changed; |
| 830 | |
| 831 | control_override_properties (gobject_class, 1); |
| 832 | |
| 833 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 834 | g_type_class_add_private (klass, sizeof (ControlProxyPrivate)); |
| 835 | #endif |
| 836 | } |
| 837 | |
| 838 | static void |
| 839 | control_proxy_iface_init (ControlIface *iface) |
| 840 | { |
| 841 | iface->get_poll_interval = control_proxy_get_poll_interval; |
| 842 | iface->get_heatbeat = control_proxy_get_heatbeat; |
| 843 | } |
| 844 | |
| 845 | /** |
| 846 | * control_proxy_new: |
| 847 | * @connection: A #GDBusConnection. |
| 848 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 849 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 850 | * @object_path: An object path. |
| 851 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 852 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 853 | * @user_data: User data to pass to @callback. |
| 854 | * |
| 855 | * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>. See g_dbus_proxy_new() for more details. |
| 856 | * |
| 857 | * 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. |
| 858 | * You can then call control_proxy_new_finish() to get the result of the operation. |
| 859 | * |
| 860 | * See control_proxy_new_sync() for the synchronous, blocking version of this constructor. |
| 861 | */ |
| 862 | void |
| 863 | control_proxy_new ( |
| 864 | GDBusConnection *connection, |
| 865 | GDBusProxyFlags flags, |
| 866 | const gchar *name, |
| 867 | const gchar *object_path, |
| 868 | GCancellable *cancellable, |
| 869 | GAsyncReadyCallback callback, |
| 870 | gpointer user_data) |
| 871 | { |
| 872 | g_async_initable_new_async (TYPE_CONTROL_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", NULL); |
| 873 | } |
| 874 | |
| 875 | /** |
| 876 | * control_proxy_new_finish: |
| 877 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_proxy_new(). |
| 878 | * @error: Return location for error or %NULL |
| 879 | * |
| 880 | * Finishes an operation started with control_proxy_new(). |
| 881 | * |
| 882 | * Returns: (transfer full) (type ControlProxy): The constructed proxy object or %NULL if @error is set. |
| 883 | */ |
| 884 | Control * |
| 885 | control_proxy_new_finish ( |
| 886 | GAsyncResult *res, |
| 887 | GError **error) |
| 888 | { |
| 889 | GObject *ret; |
| 890 | GObject *source_object; |
| 891 | source_object = g_async_result_get_source_object (res); |
| 892 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 893 | g_object_unref (source_object); |
| 894 | if (ret != NULL) |
| 895 | return CONTROL (ret); |
| 896 | else |
| 897 | return NULL; |
| 898 | } |
| 899 | |
| 900 | /** |
| 901 | * control_proxy_new_sync: |
| 902 | * @connection: A #GDBusConnection. |
| 903 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 904 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 905 | * @object_path: An object path. |
| 906 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 907 | * @error: Return location for error or %NULL |
| 908 | * |
| 909 | * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>. See g_dbus_proxy_new_sync() for more details. |
| 910 | * |
| 911 | * The calling thread is blocked until a reply is received. |
| 912 | * |
| 913 | * See control_proxy_new() for the asynchronous version of this constructor. |
| 914 | * |
| 915 | * Returns: (transfer full) (type ControlProxy): The constructed proxy object or %NULL if @error is set. |
| 916 | */ |
| 917 | Control * |
| 918 | control_proxy_new_sync ( |
| 919 | GDBusConnection *connection, |
| 920 | GDBusProxyFlags flags, |
| 921 | const gchar *name, |
| 922 | const gchar *object_path, |
| 923 | GCancellable *cancellable, |
| 924 | GError **error) |
| 925 | { |
| 926 | GInitable *ret; |
| 927 | ret = g_initable_new (TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.Control", NULL); |
| 928 | if (ret != NULL) |
| 929 | return CONTROL (ret); |
| 930 | else |
| 931 | return NULL; |
| 932 | } |
| 933 | |
| 934 | |
| 935 | /** |
| 936 | * control_proxy_new_for_bus: |
| 937 | * @bus_type: A #GBusType. |
| 938 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 939 | * @name: A bus name (well-known or unique). |
| 940 | * @object_path: An object path. |
| 941 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 942 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 943 | * @user_data: User data to pass to @callback. |
| 944 | * |
| 945 | * Like control_proxy_new() but takes a #GBusType instead of a #GDBusConnection. |
| 946 | * |
| 947 | * 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. |
| 948 | * You can then call control_proxy_new_for_bus_finish() to get the result of the operation. |
| 949 | * |
| 950 | * See control_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. |
| 951 | */ |
| 952 | void |
| 953 | control_proxy_new_for_bus ( |
| 954 | GBusType bus_type, |
| 955 | GDBusProxyFlags flags, |
| 956 | const gchar *name, |
| 957 | const gchar *object_path, |
| 958 | GCancellable *cancellable, |
| 959 | GAsyncReadyCallback callback, |
| 960 | gpointer user_data) |
| 961 | { |
| 962 | g_async_initable_new_async (TYPE_CONTROL_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", NULL); |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * control_proxy_new_for_bus_finish: |
| 967 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_proxy_new_for_bus(). |
| 968 | * @error: Return location for error or %NULL |
| 969 | * |
| 970 | * Finishes an operation started with control_proxy_new_for_bus(). |
| 971 | * |
| 972 | * Returns: (transfer full) (type ControlProxy): The constructed proxy object or %NULL if @error is set. |
| 973 | */ |
| 974 | Control * |
| 975 | control_proxy_new_for_bus_finish ( |
| 976 | GAsyncResult *res, |
| 977 | GError **error) |
| 978 | { |
| 979 | GObject *ret; |
| 980 | GObject *source_object; |
| 981 | source_object = g_async_result_get_source_object (res); |
| 982 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 983 | g_object_unref (source_object); |
| 984 | if (ret != NULL) |
| 985 | return CONTROL (ret); |
| 986 | else |
| 987 | return NULL; |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * control_proxy_new_for_bus_sync: |
| 992 | * @bus_type: A #GBusType. |
| 993 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 994 | * @name: A bus name (well-known or unique). |
| 995 | * @object_path: An object path. |
| 996 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 997 | * @error: Return location for error or %NULL |
| 998 | * |
| 999 | * Like control_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. |
| 1000 | * |
| 1001 | * The calling thread is blocked until a reply is received. |
| 1002 | * |
| 1003 | * See control_proxy_new_for_bus() for the asynchronous version of this constructor. |
| 1004 | * |
| 1005 | * Returns: (transfer full) (type ControlProxy): The constructed proxy object or %NULL if @error is set. |
| 1006 | */ |
| 1007 | Control * |
| 1008 | control_proxy_new_for_bus_sync ( |
| 1009 | GBusType bus_type, |
| 1010 | GDBusProxyFlags flags, |
| 1011 | const gchar *name, |
| 1012 | const gchar *object_path, |
| 1013 | GCancellable *cancellable, |
| 1014 | GError **error) |
| 1015 | { |
| 1016 | GInitable *ret; |
| 1017 | ret = g_initable_new (TYPE_CONTROL_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", NULL); |
| 1018 | if (ret != NULL) |
| 1019 | return CONTROL (ret); |
| 1020 | else |
| 1021 | return NULL; |
| 1022 | } |
| 1023 | |
| 1024 | |
| 1025 | /* ------------------------------------------------------------------------ */ |
| 1026 | |
| 1027 | /** |
| 1028 | * ControlSkeleton: |
| 1029 | * |
| 1030 | * The #ControlSkeleton structure contains only private data and should only be accessed using the provided API. |
| 1031 | */ |
| 1032 | |
| 1033 | /** |
| 1034 | * ControlSkeletonClass: |
| 1035 | * @parent_class: The parent class. |
| 1036 | * |
| 1037 | * Class structure for #ControlSkeleton. |
| 1038 | */ |
| 1039 | |
| 1040 | struct _ControlSkeletonPrivate |
| 1041 | { |
| 1042 | GValue *properties; |
| 1043 | GList *changed_properties; |
| 1044 | GSource *changed_properties_idle_source; |
| 1045 | GMainContext *context; |
| 1046 | GMutex lock; |
| 1047 | }; |
| 1048 | |
| 1049 | static void |
| 1050 | _control_skeleton_handle_method_call ( |
| 1051 | GDBusConnection *connection G_GNUC_UNUSED, |
| 1052 | const gchar *sender G_GNUC_UNUSED, |
| 1053 | const gchar *object_path G_GNUC_UNUSED, |
| 1054 | const gchar *interface_name, |
| 1055 | const gchar *method_name, |
| 1056 | GVariant *parameters, |
| 1057 | GDBusMethodInvocation *invocation, |
| 1058 | gpointer user_data) |
| 1059 | { |
| 1060 | ControlSkeleton *skeleton = CONTROL_SKELETON (user_data); |
| 1061 | _ExtendedGDBusMethodInfo *info; |
| 1062 | GVariantIter iter; |
| 1063 | GVariant *child; |
| 1064 | GValue *paramv; |
| 1065 | guint num_params; |
| 1066 | guint num_extra; |
| 1067 | guint n; |
| 1068 | guint signal_id; |
| 1069 | GValue return_value = G_VALUE_INIT; |
| 1070 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); |
| 1071 | g_assert (info != NULL); |
| 1072 | num_params = g_variant_n_children (parameters); |
| 1073 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); |
| 1074 | n = 0; |
| 1075 | g_value_init (¶mv[n], TYPE_CONTROL); |
| 1076 | g_value_set_object (¶mv[n++], skeleton); |
| 1077 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); |
| 1078 | g_value_set_object (¶mv[n++], invocation); |
| 1079 | if (info->pass_fdlist) |
| 1080 | { |
| 1081 | #ifdef G_OS_UNIX |
| 1082 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); |
| 1083 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); |
| 1084 | #else |
| 1085 | g_assert_not_reached (); |
| 1086 | #endif |
| 1087 | } |
| 1088 | g_variant_iter_init (&iter, parameters); |
| 1089 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 1090 | { |
| 1091 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; |
| 1092 | if (arg_info->use_gvariant) |
| 1093 | { |
| 1094 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 1095 | g_value_set_variant (¶mv[n], child); |
| 1096 | n++; |
| 1097 | } |
| 1098 | else |
| 1099 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 1100 | g_variant_unref (child); |
| 1101 | } |
| 1102 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL); |
| 1103 | g_value_init (&return_value, G_TYPE_BOOLEAN); |
| 1104 | g_signal_emitv (paramv, signal_id, 0, &return_value); |
| 1105 | if (!g_value_get_boolean (&return_value)) |
| 1106 | 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); |
| 1107 | g_value_unset (&return_value); |
| 1108 | for (n = 0; n < num_params + num_extra; n++) |
| 1109 | g_value_unset (¶mv[n]); |
| 1110 | g_free (paramv); |
| 1111 | } |
| 1112 | |
| 1113 | static GVariant * |
| 1114 | _control_skeleton_handle_get_property ( |
| 1115 | GDBusConnection *connection G_GNUC_UNUSED, |
| 1116 | const gchar *sender G_GNUC_UNUSED, |
| 1117 | const gchar *object_path G_GNUC_UNUSED, |
| 1118 | const gchar *interface_name G_GNUC_UNUSED, |
| 1119 | const gchar *property_name, |
| 1120 | GError **error, |
| 1121 | gpointer user_data) |
| 1122 | { |
| 1123 | ControlSkeleton *skeleton = CONTROL_SKELETON (user_data); |
| 1124 | GValue value = G_VALUE_INIT; |
| 1125 | GParamSpec *pspec; |
| 1126 | _ExtendedGDBusPropertyInfo *info; |
| 1127 | GVariant *ret; |
| 1128 | ret = NULL; |
| 1129 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_interface_info.parent_struct, property_name); |
| 1130 | g_assert (info != NULL); |
| 1131 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 1132 | if (pspec == NULL) |
| 1133 | { |
| 1134 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 1135 | } |
| 1136 | else |
| 1137 | { |
| 1138 | g_value_init (&value, pspec->value_type); |
| 1139 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 1140 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 1141 | g_value_unset (&value); |
| 1142 | } |
| 1143 | return ret; |
| 1144 | } |
| 1145 | |
| 1146 | static gboolean |
| 1147 | _control_skeleton_handle_set_property ( |
| 1148 | GDBusConnection *connection G_GNUC_UNUSED, |
| 1149 | const gchar *sender G_GNUC_UNUSED, |
| 1150 | const gchar *object_path G_GNUC_UNUSED, |
| 1151 | const gchar *interface_name G_GNUC_UNUSED, |
| 1152 | const gchar *property_name, |
| 1153 | GVariant *variant, |
| 1154 | GError **error, |
| 1155 | gpointer user_data) |
| 1156 | { |
| 1157 | ControlSkeleton *skeleton = CONTROL_SKELETON (user_data); |
| 1158 | GValue value = G_VALUE_INIT; |
| 1159 | GParamSpec *pspec; |
| 1160 | _ExtendedGDBusPropertyInfo *info; |
| 1161 | gboolean ret; |
| 1162 | ret = FALSE; |
| 1163 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_interface_info.parent_struct, property_name); |
| 1164 | g_assert (info != NULL); |
| 1165 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 1166 | if (pspec == NULL) |
| 1167 | { |
| 1168 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 1169 | } |
| 1170 | else |
| 1171 | { |
| 1172 | if (info->use_gvariant) |
| 1173 | g_value_set_variant (&value, variant); |
| 1174 | else |
| 1175 | g_dbus_gvariant_to_gvalue (variant, &value); |
| 1176 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 1177 | g_value_unset (&value); |
| 1178 | ret = TRUE; |
| 1179 | } |
| 1180 | return ret; |
| 1181 | } |
| 1182 | |
| 1183 | static const GDBusInterfaceVTable _control_skeleton_vtable = |
| 1184 | { |
| 1185 | _control_skeleton_handle_method_call, |
| 1186 | _control_skeleton_handle_get_property, |
| 1187 | _control_skeleton_handle_set_property, |
| 1188 | {NULL} |
| 1189 | }; |
| 1190 | |
| 1191 | static GDBusInterfaceInfo * |
| 1192 | control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 1193 | { |
| 1194 | return control_interface_info (); |
| 1195 | } |
| 1196 | |
| 1197 | static GDBusInterfaceVTable * |
| 1198 | control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 1199 | { |
| 1200 | return (GDBusInterfaceVTable *) &_control_skeleton_vtable; |
| 1201 | } |
| 1202 | |
| 1203 | static GVariant * |
| 1204 | control_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) |
| 1205 | { |
| 1206 | ControlSkeleton *skeleton = CONTROL_SKELETON (_skeleton); |
| 1207 | |
| 1208 | GVariantBuilder builder; |
| 1209 | guint n; |
| 1210 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 1211 | if (_control_interface_info.parent_struct.properties == NULL) |
| 1212 | goto out; |
| 1213 | for (n = 0; _control_interface_info.parent_struct.properties[n] != NULL; n++) |
| 1214 | { |
| 1215 | GDBusPropertyInfo *info = _control_interface_info.parent_struct.properties[n]; |
| 1216 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) |
| 1217 | { |
| 1218 | GVariant *value; |
| 1219 | value = _control_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", info->name, NULL, skeleton); |
| 1220 | if (value != NULL) |
| 1221 | { |
| 1222 | g_variant_take_ref (value); |
| 1223 | g_variant_builder_add (&builder, "{sv}", info->name, value); |
| 1224 | g_variant_unref (value); |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | out: |
| 1229 | return g_variant_builder_end (&builder); |
| 1230 | } |
| 1231 | |
| 1232 | static gboolean _control_emit_changed (gpointer user_data); |
| 1233 | |
| 1234 | static void |
| 1235 | control_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) |
| 1236 | { |
| 1237 | ControlSkeleton *skeleton = CONTROL_SKELETON (_skeleton); |
| 1238 | gboolean emit_changed = FALSE; |
| 1239 | |
| 1240 | g_mutex_lock (&skeleton->priv->lock); |
| 1241 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 1242 | { |
| 1243 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 1244 | skeleton->priv->changed_properties_idle_source = NULL; |
| 1245 | emit_changed = TRUE; |
| 1246 | } |
| 1247 | g_mutex_unlock (&skeleton->priv->lock); |
| 1248 | |
| 1249 | if (emit_changed) |
| 1250 | _control_emit_changed (skeleton); |
| 1251 | } |
| 1252 | |
| 1253 | static void |
| 1254 | _control_on_signal_heartbeat ( |
| 1255 | Control *object, |
| 1256 | const gchar *arg_bus_name) |
| 1257 | { |
| 1258 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1259 | |
| 1260 | GList *connections, *l; |
| 1261 | GVariant *signal_variant; |
| 1262 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 1263 | |
| 1264 | signal_variant = g_variant_ref_sink (g_variant_new ("(s)", |
| 1265 | arg_bus_name)); |
| 1266 | for (l = connections; l != NULL; l = l->next) |
| 1267 | { |
| 1268 | GDBusConnection *connection = l->data; |
| 1269 | g_dbus_connection_emit_signal (connection, |
| 1270 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.Control", "Heartbeat", |
| 1271 | signal_variant, NULL); |
| 1272 | } |
| 1273 | g_variant_unref (signal_variant); |
| 1274 | g_list_free_full (connections, g_object_unref); |
| 1275 | } |
| 1276 | |
| 1277 | static void control_skeleton_iface_init (ControlIface *iface); |
| 1278 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 1279 | G_DEFINE_TYPE_WITH_CODE (ControlSkeleton, control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 1280 | G_ADD_PRIVATE (ControlSkeleton) |
| 1281 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL, control_skeleton_iface_init)); |
| 1282 | |
| 1283 | #else |
| 1284 | G_DEFINE_TYPE_WITH_CODE (ControlSkeleton, control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 1285 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL, control_skeleton_iface_init)); |
| 1286 | |
| 1287 | #endif |
| 1288 | static void |
| 1289 | control_skeleton_finalize (GObject *object) |
| 1290 | { |
| 1291 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1292 | guint n; |
| 1293 | for (n = 0; n < 2; n++) |
| 1294 | g_value_unset (&skeleton->priv->properties[n]); |
| 1295 | g_free (skeleton->priv->properties); |
| 1296 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 1297 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 1298 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 1299 | g_main_context_unref (skeleton->priv->context); |
| 1300 | g_mutex_clear (&skeleton->priv->lock); |
| 1301 | G_OBJECT_CLASS (control_skeleton_parent_class)->finalize (object); |
| 1302 | } |
| 1303 | |
| 1304 | static void |
| 1305 | control_skeleton_get_property (GObject *object, |
| 1306 | guint prop_id, |
| 1307 | GValue *value, |
| 1308 | GParamSpec *pspec G_GNUC_UNUSED) |
| 1309 | { |
| 1310 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1311 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 1312 | g_mutex_lock (&skeleton->priv->lock); |
| 1313 | g_value_copy (&skeleton->priv->properties[prop_id - 1], value); |
| 1314 | g_mutex_unlock (&skeleton->priv->lock); |
| 1315 | } |
| 1316 | |
| 1317 | static gboolean |
| 1318 | _control_emit_changed (gpointer user_data) |
| 1319 | { |
| 1320 | ControlSkeleton *skeleton = CONTROL_SKELETON (user_data); |
| 1321 | GList *l; |
| 1322 | GVariantBuilder builder; |
| 1323 | GVariantBuilder invalidated_builder; |
| 1324 | guint num_changes; |
| 1325 | |
| 1326 | g_mutex_lock (&skeleton->priv->lock); |
| 1327 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 1328 | g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")); |
| 1329 | for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next) |
| 1330 | { |
| 1331 | ChangedProperty *cp = l->data; |
| 1332 | GVariant *variant; |
| 1333 | const GValue *cur_value; |
| 1334 | |
| 1335 | cur_value = &skeleton->priv->properties[cp->prop_id - 1]; |
| 1336 | if (!_g_value_equal (cur_value, &cp->orig_value)) |
| 1337 | { |
| 1338 | variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature)); |
| 1339 | g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant); |
| 1340 | g_variant_unref (variant); |
| 1341 | num_changes++; |
| 1342 | } |
| 1343 | } |
| 1344 | if (num_changes > 0) |
| 1345 | { |
| 1346 | GList *connections, *ll; |
| 1347 | GVariant *signal_variant; |
| 1348 | signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.Control", |
| 1349 | &builder, &invalidated_builder)); |
| 1350 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 1351 | for (ll = connections; ll != NULL; ll = ll->next) |
| 1352 | { |
| 1353 | GDBusConnection *connection = ll->data; |
| 1354 | |
| 1355 | g_dbus_connection_emit_signal (connection, |
| 1356 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), |
| 1357 | "org.freedesktop.DBus.Properties", |
| 1358 | "PropertiesChanged", |
| 1359 | signal_variant, |
| 1360 | NULL); |
| 1361 | } |
| 1362 | g_variant_unref (signal_variant); |
| 1363 | g_list_free_full (connections, g_object_unref); |
| 1364 | } |
| 1365 | else |
| 1366 | { |
| 1367 | g_variant_builder_clear (&builder); |
| 1368 | g_variant_builder_clear (&invalidated_builder); |
| 1369 | } |
| 1370 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 1371 | skeleton->priv->changed_properties = NULL; |
| 1372 | skeleton->priv->changed_properties_idle_source = NULL; |
| 1373 | g_mutex_unlock (&skeleton->priv->lock); |
| 1374 | return FALSE; |
| 1375 | } |
| 1376 | |
| 1377 | static void |
| 1378 | _control_schedule_emit_changed (ControlSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value) |
| 1379 | { |
| 1380 | ChangedProperty *cp; |
| 1381 | GList *l; |
| 1382 | cp = NULL; |
| 1383 | for (l = skeleton->priv->changed_properties; l != NULL; l = l->next) |
| 1384 | { |
| 1385 | ChangedProperty *i_cp = l->data; |
| 1386 | if (i_cp->info == info) |
| 1387 | { |
| 1388 | cp = i_cp; |
| 1389 | break; |
| 1390 | } |
| 1391 | } |
| 1392 | if (cp == NULL) |
| 1393 | { |
| 1394 | cp = g_new0 (ChangedProperty, 1); |
| 1395 | cp->prop_id = prop_id; |
| 1396 | cp->info = info; |
| 1397 | skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp); |
| 1398 | g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value)); |
| 1399 | g_value_copy (orig_value, &cp->orig_value); |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | static void |
| 1404 | control_skeleton_notify (GObject *object, |
| 1405 | GParamSpec *pspec G_GNUC_UNUSED) |
| 1406 | { |
| 1407 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1408 | g_mutex_lock (&skeleton->priv->lock); |
| 1409 | if (skeleton->priv->changed_properties != NULL && |
| 1410 | skeleton->priv->changed_properties_idle_source == NULL) |
| 1411 | { |
| 1412 | skeleton->priv->changed_properties_idle_source = g_idle_source_new (); |
| 1413 | g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT); |
| 1414 | g_source_set_callback (skeleton->priv->changed_properties_idle_source, _control_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref); |
| 1415 | g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context); |
| 1416 | g_source_unref (skeleton->priv->changed_properties_idle_source); |
| 1417 | } |
| 1418 | g_mutex_unlock (&skeleton->priv->lock); |
| 1419 | } |
| 1420 | |
| 1421 | static void |
| 1422 | control_skeleton_set_property (GObject *object, |
| 1423 | guint prop_id, |
| 1424 | const GValue *value, |
| 1425 | GParamSpec *pspec) |
| 1426 | { |
| 1427 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1428 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 1429 | g_mutex_lock (&skeleton->priv->lock); |
| 1430 | g_object_freeze_notify (object); |
| 1431 | if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1])) |
| 1432 | { |
| 1433 | if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL) |
| 1434 | _control_schedule_emit_changed (skeleton, _control_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]); |
| 1435 | g_value_copy (value, &skeleton->priv->properties[prop_id - 1]); |
| 1436 | g_object_notify_by_pspec (object, pspec); |
| 1437 | } |
| 1438 | g_mutex_unlock (&skeleton->priv->lock); |
| 1439 | g_object_thaw_notify (object); |
| 1440 | } |
| 1441 | |
| 1442 | static void |
| 1443 | control_skeleton_init (ControlSkeleton *skeleton) |
| 1444 | { |
| 1445 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 1446 | skeleton->priv = control_skeleton_get_instance_private (skeleton); |
| 1447 | #else |
| 1448 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_CONTROL_SKELETON, ControlSkeletonPrivate); |
| 1449 | #endif |
| 1450 | |
| 1451 | g_mutex_init (&skeleton->priv->lock); |
| 1452 | skeleton->priv->context = g_main_context_ref_thread_default (); |
| 1453 | skeleton->priv->properties = g_new0 (GValue, 2); |
| 1454 | g_value_init (&skeleton->priv->properties[0], G_TYPE_INT); |
| 1455 | g_value_init (&skeleton->priv->properties[1], G_TYPE_INT); |
| 1456 | } |
| 1457 | |
| 1458 | static gint |
| 1459 | control_skeleton_get_poll_interval (Control *object) |
| 1460 | { |
| 1461 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1462 | gint value; |
| 1463 | g_mutex_lock (&skeleton->priv->lock); |
| 1464 | value = g_value_get_int (&(skeleton->priv->properties[0])); |
| 1465 | g_mutex_unlock (&skeleton->priv->lock); |
| 1466 | return value; |
| 1467 | } |
| 1468 | |
| 1469 | static gint |
| 1470 | control_skeleton_get_heatbeat (Control *object) |
| 1471 | { |
| 1472 | ControlSkeleton *skeleton = CONTROL_SKELETON (object); |
| 1473 | gint value; |
| 1474 | g_mutex_lock (&skeleton->priv->lock); |
| 1475 | value = g_value_get_int (&(skeleton->priv->properties[1])); |
| 1476 | g_mutex_unlock (&skeleton->priv->lock); |
| 1477 | return value; |
| 1478 | } |
| 1479 | |
| 1480 | static void |
| 1481 | control_skeleton_class_init (ControlSkeletonClass *klass) |
| 1482 | { |
| 1483 | GObjectClass *gobject_class; |
| 1484 | GDBusInterfaceSkeletonClass *skeleton_class; |
| 1485 | |
| 1486 | gobject_class = G_OBJECT_CLASS (klass); |
| 1487 | gobject_class->finalize = control_skeleton_finalize; |
| 1488 | gobject_class->get_property = control_skeleton_get_property; |
| 1489 | gobject_class->set_property = control_skeleton_set_property; |
| 1490 | gobject_class->notify = control_skeleton_notify; |
| 1491 | |
| 1492 | |
| 1493 | control_override_properties (gobject_class, 1); |
| 1494 | |
| 1495 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); |
| 1496 | skeleton_class->get_info = control_skeleton_dbus_interface_get_info; |
| 1497 | skeleton_class->get_properties = control_skeleton_dbus_interface_get_properties; |
| 1498 | skeleton_class->flush = control_skeleton_dbus_interface_flush; |
| 1499 | skeleton_class->get_vtable = control_skeleton_dbus_interface_get_vtable; |
| 1500 | |
| 1501 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 1502 | g_type_class_add_private (klass, sizeof (ControlSkeletonPrivate)); |
| 1503 | #endif |
| 1504 | } |
| 1505 | |
| 1506 | static void |
| 1507 | control_skeleton_iface_init (ControlIface *iface) |
| 1508 | { |
| 1509 | iface->heartbeat = _control_on_signal_heartbeat; |
| 1510 | iface->get_poll_interval = control_skeleton_get_poll_interval; |
| 1511 | iface->get_heatbeat = control_skeleton_get_heatbeat; |
| 1512 | } |
| 1513 | |
| 1514 | /** |
| 1515 | * control_skeleton_new: |
| 1516 | * |
| 1517 | * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>. |
| 1518 | * |
| 1519 | * Returns: (transfer full) (type ControlSkeleton): The skeleton object. |
| 1520 | */ |
| 1521 | Control * |
| 1522 | control_skeleton_new (void) |
| 1523 | { |
| 1524 | return CONTROL (g_object_new (TYPE_CONTROL_SKELETON, NULL)); |
| 1525 | } |
| 1526 | |
| 1527 | /* ------------------------------------------------------------------------ |
| 1528 | * Code for interface org.openbmc.control.Host |
| 1529 | * ------------------------------------------------------------------------ |
| 1530 | */ |
| 1531 | |
| 1532 | /** |
| 1533 | * SECTION:ControlHost |
| 1534 | * @title: ControlHost |
| 1535 | * @short_description: Generated C code for the org.openbmc.control.Host D-Bus interface |
| 1536 | * |
| 1537 | * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link> D-Bus interface in C. |
| 1538 | */ |
| 1539 | |
| 1540 | /* ---- Introspection data for org.openbmc.control.Host ---- */ |
| 1541 | |
| 1542 | static const _ExtendedGDBusMethodInfo _control_host_method_info_boot = |
| 1543 | { |
| 1544 | { |
| 1545 | -1, |
| 1546 | (gchar *) "boot", |
| 1547 | NULL, |
| 1548 | NULL, |
| 1549 | NULL |
| 1550 | }, |
| 1551 | "handle-boot", |
| 1552 | FALSE |
| 1553 | }; |
| 1554 | |
| 1555 | static const _ExtendedGDBusMethodInfo _control_host_method_info_shutdown = |
| 1556 | { |
| 1557 | { |
| 1558 | -1, |
| 1559 | (gchar *) "shutdown", |
| 1560 | NULL, |
| 1561 | NULL, |
| 1562 | NULL |
| 1563 | }, |
| 1564 | "handle-shutdown", |
| 1565 | FALSE |
| 1566 | }; |
| 1567 | |
| 1568 | static const _ExtendedGDBusMethodInfo _control_host_method_info_reboot = |
| 1569 | { |
| 1570 | { |
| 1571 | -1, |
| 1572 | (gchar *) "reboot", |
| 1573 | NULL, |
| 1574 | NULL, |
| 1575 | NULL |
| 1576 | }, |
| 1577 | "handle-reboot", |
| 1578 | FALSE |
| 1579 | }; |
| 1580 | |
| 1581 | static const _ExtendedGDBusMethodInfo * const _control_host_method_info_pointers[] = |
| 1582 | { |
| 1583 | &_control_host_method_info_boot, |
| 1584 | &_control_host_method_info_shutdown, |
| 1585 | &_control_host_method_info_reboot, |
| 1586 | NULL |
| 1587 | }; |
| 1588 | |
| 1589 | static const _ExtendedGDBusSignalInfo _control_host_signal_info_booted = |
| 1590 | { |
| 1591 | { |
| 1592 | -1, |
| 1593 | (gchar *) "Booted", |
| 1594 | NULL, |
| 1595 | NULL |
| 1596 | }, |
| 1597 | "booted" |
| 1598 | }; |
| 1599 | |
| 1600 | static const _ExtendedGDBusSignalInfo * const _control_host_signal_info_pointers[] = |
| 1601 | { |
| 1602 | &_control_host_signal_info_booted, |
| 1603 | NULL |
| 1604 | }; |
| 1605 | |
| 1606 | static const _ExtendedGDBusInterfaceInfo _control_host_interface_info = |
| 1607 | { |
| 1608 | { |
| 1609 | -1, |
| 1610 | (gchar *) "org.openbmc.control.Host", |
| 1611 | (GDBusMethodInfo **) &_control_host_method_info_pointers, |
| 1612 | (GDBusSignalInfo **) &_control_host_signal_info_pointers, |
| 1613 | NULL, |
| 1614 | NULL |
| 1615 | }, |
| 1616 | "control-host", |
| 1617 | }; |
| 1618 | |
| 1619 | |
| 1620 | /** |
| 1621 | * control_host_interface_info: |
| 1622 | * |
| 1623 | * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link> D-Bus interface. |
| 1624 | * |
| 1625 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. |
| 1626 | */ |
| 1627 | GDBusInterfaceInfo * |
| 1628 | control_host_interface_info (void) |
| 1629 | { |
| 1630 | return (GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct; |
| 1631 | } |
| 1632 | |
| 1633 | /** |
| 1634 | * control_host_override_properties: |
| 1635 | * @klass: The class structure for a #GObject<!-- -->-derived class. |
| 1636 | * @property_id_begin: The property id to assign to the first overridden property. |
| 1637 | * |
| 1638 | * Overrides all #GObject properties in the #ControlHost interface for a concrete class. |
| 1639 | * The properties are overridden in the order they are defined. |
| 1640 | * |
| 1641 | * Returns: The last property id. |
| 1642 | */ |
| 1643 | guint |
| 1644 | control_host_override_properties (GObjectClass *klass, guint property_id_begin) |
| 1645 | { |
| 1646 | return property_id_begin - 1; |
| 1647 | } |
| 1648 | |
| 1649 | |
| 1650 | |
| 1651 | /** |
| 1652 | * ControlHost: |
| 1653 | * |
| 1654 | * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>. |
| 1655 | */ |
| 1656 | |
| 1657 | /** |
| 1658 | * ControlHostIface: |
| 1659 | * @parent_iface: The parent interface. |
| 1660 | * @handle_boot: Handler for the #ControlHost::handle-boot signal. |
| 1661 | * @handle_reboot: Handler for the #ControlHost::handle-reboot signal. |
| 1662 | * @handle_shutdown: Handler for the #ControlHost::handle-shutdown signal. |
| 1663 | * @booted: Handler for the #ControlHost::booted signal. |
| 1664 | * |
| 1665 | * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>. |
| 1666 | */ |
| 1667 | |
| 1668 | typedef ControlHostIface ControlHostInterface; |
| 1669 | G_DEFINE_INTERFACE (ControlHost, control_host, G_TYPE_OBJECT); |
| 1670 | |
| 1671 | static void |
| 1672 | control_host_default_init (ControlHostIface *iface) |
| 1673 | { |
| 1674 | /* GObject signals for incoming D-Bus method calls: */ |
| 1675 | /** |
| 1676 | * ControlHost::handle-boot: |
| 1677 | * @object: A #ControlHost. |
| 1678 | * @invocation: A #GDBusMethodInvocation. |
| 1679 | * |
| 1680 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-control-Host.boot">boot()</link> D-Bus method. |
| 1681 | * |
| 1682 | * 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_host_complete_boot() 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. |
| 1683 | * |
| 1684 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 1685 | */ |
| 1686 | g_signal_new ("handle-boot", |
| 1687 | G_TYPE_FROM_INTERFACE (iface), |
| 1688 | G_SIGNAL_RUN_LAST, |
| 1689 | G_STRUCT_OFFSET (ControlHostIface, handle_boot), |
| 1690 | g_signal_accumulator_true_handled, |
| 1691 | NULL, |
| 1692 | g_cclosure_marshal_generic, |
| 1693 | G_TYPE_BOOLEAN, |
| 1694 | 1, |
| 1695 | G_TYPE_DBUS_METHOD_INVOCATION); |
| 1696 | |
| 1697 | /** |
| 1698 | * ControlHost::handle-shutdown: |
| 1699 | * @object: A #ControlHost. |
| 1700 | * @invocation: A #GDBusMethodInvocation. |
| 1701 | * |
| 1702 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-control-Host.shutdown">shutdown()</link> D-Bus method. |
| 1703 | * |
| 1704 | * 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_host_complete_shutdown() 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. |
| 1705 | * |
| 1706 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 1707 | */ |
| 1708 | g_signal_new ("handle-shutdown", |
| 1709 | G_TYPE_FROM_INTERFACE (iface), |
| 1710 | G_SIGNAL_RUN_LAST, |
| 1711 | G_STRUCT_OFFSET (ControlHostIface, handle_shutdown), |
| 1712 | g_signal_accumulator_true_handled, |
| 1713 | NULL, |
| 1714 | g_cclosure_marshal_generic, |
| 1715 | G_TYPE_BOOLEAN, |
| 1716 | 1, |
| 1717 | G_TYPE_DBUS_METHOD_INVOCATION); |
| 1718 | |
| 1719 | /** |
| 1720 | * ControlHost::handle-reboot: |
| 1721 | * @object: A #ControlHost. |
| 1722 | * @invocation: A #GDBusMethodInvocation. |
| 1723 | * |
| 1724 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-control-Host.reboot">reboot()</link> D-Bus method. |
| 1725 | * |
| 1726 | * 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_host_complete_reboot() 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. |
| 1727 | * |
| 1728 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 1729 | */ |
| 1730 | g_signal_new ("handle-reboot", |
| 1731 | G_TYPE_FROM_INTERFACE (iface), |
| 1732 | G_SIGNAL_RUN_LAST, |
| 1733 | G_STRUCT_OFFSET (ControlHostIface, handle_reboot), |
| 1734 | g_signal_accumulator_true_handled, |
| 1735 | NULL, |
| 1736 | g_cclosure_marshal_generic, |
| 1737 | G_TYPE_BOOLEAN, |
| 1738 | 1, |
| 1739 | G_TYPE_DBUS_METHOD_INVOCATION); |
| 1740 | |
| 1741 | /* GObject signals for received D-Bus signals: */ |
| 1742 | /** |
| 1743 | * ControlHost::booted: |
| 1744 | * @object: A #ControlHost. |
| 1745 | * |
| 1746 | * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-control-Host.Booted">"Booted"</link> is received. |
| 1747 | * |
| 1748 | * 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. |
| 1749 | */ |
| 1750 | g_signal_new ("booted", |
| 1751 | G_TYPE_FROM_INTERFACE (iface), |
| 1752 | G_SIGNAL_RUN_LAST, |
| 1753 | G_STRUCT_OFFSET (ControlHostIface, booted), |
| 1754 | NULL, |
| 1755 | NULL, |
| 1756 | g_cclosure_marshal_generic, |
| 1757 | G_TYPE_NONE, |
| 1758 | 0); |
| 1759 | |
| 1760 | } |
| 1761 | |
| 1762 | /** |
| 1763 | * control_host_emit_booted: |
| 1764 | * @object: A #ControlHost. |
| 1765 | * |
| 1766 | * Emits the <link linkend="gdbus-signal-org-openbmc-control-Host.Booted">"Booted"</link> D-Bus signal. |
| 1767 | */ |
| 1768 | void |
| 1769 | control_host_emit_booted ( |
| 1770 | ControlHost *object) |
| 1771 | { |
| 1772 | g_signal_emit_by_name (object, "booted"); |
| 1773 | } |
| 1774 | |
| 1775 | /** |
| 1776 | * control_host_call_boot: |
| 1777 | * @proxy: A #ControlHostProxy. |
| 1778 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 1779 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 1780 | * @user_data: User data to pass to @callback. |
| 1781 | * |
| 1782 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.boot">boot()</link> D-Bus method on @proxy. |
| 1783 | * 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. |
| 1784 | * You can then call control_host_call_boot_finish() to get the result of the operation. |
| 1785 | * |
| 1786 | * See control_host_call_boot_sync() for the synchronous, blocking version of this method. |
| 1787 | */ |
| 1788 | void |
| 1789 | control_host_call_boot ( |
| 1790 | ControlHost *proxy, |
| 1791 | GCancellable *cancellable, |
| 1792 | GAsyncReadyCallback callback, |
| 1793 | gpointer user_data) |
| 1794 | { |
| 1795 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 1796 | "boot", |
| 1797 | g_variant_new ("()"), |
| 1798 | G_DBUS_CALL_FLAGS_NONE, |
| 1799 | -1, |
| 1800 | cancellable, |
| 1801 | callback, |
| 1802 | user_data); |
| 1803 | } |
| 1804 | |
| 1805 | /** |
| 1806 | * control_host_call_boot_finish: |
| 1807 | * @proxy: A #ControlHostProxy. |
| 1808 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_host_call_boot(). |
| 1809 | * @error: Return location for error or %NULL. |
| 1810 | * |
| 1811 | * Finishes an operation started with control_host_call_boot(). |
| 1812 | * |
| 1813 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 1814 | */ |
| 1815 | gboolean |
| 1816 | control_host_call_boot_finish ( |
| 1817 | ControlHost *proxy, |
| 1818 | GAsyncResult *res, |
| 1819 | GError **error) |
| 1820 | { |
| 1821 | GVariant *_ret; |
| 1822 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 1823 | if (_ret == NULL) |
| 1824 | goto _out; |
| 1825 | g_variant_get (_ret, |
| 1826 | "()"); |
| 1827 | g_variant_unref (_ret); |
| 1828 | _out: |
| 1829 | return _ret != NULL; |
| 1830 | } |
| 1831 | |
| 1832 | /** |
| 1833 | * control_host_call_boot_sync: |
| 1834 | * @proxy: A #ControlHostProxy. |
| 1835 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 1836 | * @error: Return location for error or %NULL. |
| 1837 | * |
| 1838 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.boot">boot()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. |
| 1839 | * |
| 1840 | * See control_host_call_boot() for the asynchronous version of this method. |
| 1841 | * |
| 1842 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 1843 | */ |
| 1844 | gboolean |
| 1845 | control_host_call_boot_sync ( |
| 1846 | ControlHost *proxy, |
| 1847 | GCancellable *cancellable, |
| 1848 | GError **error) |
| 1849 | { |
| 1850 | GVariant *_ret; |
| 1851 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 1852 | "boot", |
| 1853 | g_variant_new ("()"), |
| 1854 | G_DBUS_CALL_FLAGS_NONE, |
| 1855 | -1, |
| 1856 | cancellable, |
| 1857 | error); |
| 1858 | if (_ret == NULL) |
| 1859 | goto _out; |
| 1860 | g_variant_get (_ret, |
| 1861 | "()"); |
| 1862 | g_variant_unref (_ret); |
| 1863 | _out: |
| 1864 | return _ret != NULL; |
| 1865 | } |
| 1866 | |
| 1867 | /** |
| 1868 | * control_host_call_shutdown: |
| 1869 | * @proxy: A #ControlHostProxy. |
| 1870 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 1871 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 1872 | * @user_data: User data to pass to @callback. |
| 1873 | * |
| 1874 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.shutdown">shutdown()</link> D-Bus method on @proxy. |
| 1875 | * 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. |
| 1876 | * You can then call control_host_call_shutdown_finish() to get the result of the operation. |
| 1877 | * |
| 1878 | * See control_host_call_shutdown_sync() for the synchronous, blocking version of this method. |
| 1879 | */ |
| 1880 | void |
| 1881 | control_host_call_shutdown ( |
| 1882 | ControlHost *proxy, |
| 1883 | GCancellable *cancellable, |
| 1884 | GAsyncReadyCallback callback, |
| 1885 | gpointer user_data) |
| 1886 | { |
| 1887 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 1888 | "shutdown", |
| 1889 | g_variant_new ("()"), |
| 1890 | G_DBUS_CALL_FLAGS_NONE, |
| 1891 | -1, |
| 1892 | cancellable, |
| 1893 | callback, |
| 1894 | user_data); |
| 1895 | } |
| 1896 | |
| 1897 | /** |
| 1898 | * control_host_call_shutdown_finish: |
| 1899 | * @proxy: A #ControlHostProxy. |
| 1900 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_host_call_shutdown(). |
| 1901 | * @error: Return location for error or %NULL. |
| 1902 | * |
| 1903 | * Finishes an operation started with control_host_call_shutdown(). |
| 1904 | * |
| 1905 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 1906 | */ |
| 1907 | gboolean |
| 1908 | control_host_call_shutdown_finish ( |
| 1909 | ControlHost *proxy, |
| 1910 | GAsyncResult *res, |
| 1911 | GError **error) |
| 1912 | { |
| 1913 | GVariant *_ret; |
| 1914 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 1915 | if (_ret == NULL) |
| 1916 | goto _out; |
| 1917 | g_variant_get (_ret, |
| 1918 | "()"); |
| 1919 | g_variant_unref (_ret); |
| 1920 | _out: |
| 1921 | return _ret != NULL; |
| 1922 | } |
| 1923 | |
| 1924 | /** |
| 1925 | * control_host_call_shutdown_sync: |
| 1926 | * @proxy: A #ControlHostProxy. |
| 1927 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 1928 | * @error: Return location for error or %NULL. |
| 1929 | * |
| 1930 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.shutdown">shutdown()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. |
| 1931 | * |
| 1932 | * See control_host_call_shutdown() for the asynchronous version of this method. |
| 1933 | * |
| 1934 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 1935 | */ |
| 1936 | gboolean |
| 1937 | control_host_call_shutdown_sync ( |
| 1938 | ControlHost *proxy, |
| 1939 | GCancellable *cancellable, |
| 1940 | GError **error) |
| 1941 | { |
| 1942 | GVariant *_ret; |
| 1943 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 1944 | "shutdown", |
| 1945 | g_variant_new ("()"), |
| 1946 | G_DBUS_CALL_FLAGS_NONE, |
| 1947 | -1, |
| 1948 | cancellable, |
| 1949 | error); |
| 1950 | if (_ret == NULL) |
| 1951 | goto _out; |
| 1952 | g_variant_get (_ret, |
| 1953 | "()"); |
| 1954 | g_variant_unref (_ret); |
| 1955 | _out: |
| 1956 | return _ret != NULL; |
| 1957 | } |
| 1958 | |
| 1959 | /** |
| 1960 | * control_host_call_reboot: |
| 1961 | * @proxy: A #ControlHostProxy. |
| 1962 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 1963 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 1964 | * @user_data: User data to pass to @callback. |
| 1965 | * |
| 1966 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.reboot">reboot()</link> D-Bus method on @proxy. |
| 1967 | * 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. |
| 1968 | * You can then call control_host_call_reboot_finish() to get the result of the operation. |
| 1969 | * |
| 1970 | * See control_host_call_reboot_sync() for the synchronous, blocking version of this method. |
| 1971 | */ |
| 1972 | void |
| 1973 | control_host_call_reboot ( |
| 1974 | ControlHost *proxy, |
| 1975 | GCancellable *cancellable, |
| 1976 | GAsyncReadyCallback callback, |
| 1977 | gpointer user_data) |
| 1978 | { |
| 1979 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 1980 | "reboot", |
| 1981 | g_variant_new ("()"), |
| 1982 | G_DBUS_CALL_FLAGS_NONE, |
| 1983 | -1, |
| 1984 | cancellable, |
| 1985 | callback, |
| 1986 | user_data); |
| 1987 | } |
| 1988 | |
| 1989 | /** |
| 1990 | * control_host_call_reboot_finish: |
| 1991 | * @proxy: A #ControlHostProxy. |
| 1992 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_host_call_reboot(). |
| 1993 | * @error: Return location for error or %NULL. |
| 1994 | * |
| 1995 | * Finishes an operation started with control_host_call_reboot(). |
| 1996 | * |
| 1997 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 1998 | */ |
| 1999 | gboolean |
| 2000 | control_host_call_reboot_finish ( |
| 2001 | ControlHost *proxy, |
| 2002 | GAsyncResult *res, |
| 2003 | GError **error) |
| 2004 | { |
| 2005 | GVariant *_ret; |
| 2006 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 2007 | if (_ret == NULL) |
| 2008 | goto _out; |
| 2009 | g_variant_get (_ret, |
| 2010 | "()"); |
| 2011 | g_variant_unref (_ret); |
| 2012 | _out: |
| 2013 | return _ret != NULL; |
| 2014 | } |
| 2015 | |
| 2016 | /** |
| 2017 | * control_host_call_reboot_sync: |
| 2018 | * @proxy: A #ControlHostProxy. |
| 2019 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 2020 | * @error: Return location for error or %NULL. |
| 2021 | * |
| 2022 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Host.reboot">reboot()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. |
| 2023 | * |
| 2024 | * See control_host_call_reboot() for the asynchronous version of this method. |
| 2025 | * |
| 2026 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 2027 | */ |
| 2028 | gboolean |
| 2029 | control_host_call_reboot_sync ( |
| 2030 | ControlHost *proxy, |
| 2031 | GCancellable *cancellable, |
| 2032 | GError **error) |
| 2033 | { |
| 2034 | GVariant *_ret; |
| 2035 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 2036 | "reboot", |
| 2037 | g_variant_new ("()"), |
| 2038 | G_DBUS_CALL_FLAGS_NONE, |
| 2039 | -1, |
| 2040 | cancellable, |
| 2041 | error); |
| 2042 | if (_ret == NULL) |
| 2043 | goto _out; |
| 2044 | g_variant_get (_ret, |
| 2045 | "()"); |
| 2046 | g_variant_unref (_ret); |
| 2047 | _out: |
| 2048 | return _ret != NULL; |
| 2049 | } |
| 2050 | |
| 2051 | /** |
| 2052 | * control_host_complete_boot: |
| 2053 | * @object: A #ControlHost. |
| 2054 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 2055 | * |
| 2056 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-control-Host.boot">boot()</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. |
| 2057 | * |
| 2058 | * This method will free @invocation, you cannot use it afterwards. |
| 2059 | */ |
| 2060 | void |
| 2061 | control_host_complete_boot ( |
| 2062 | ControlHost *object, |
| 2063 | GDBusMethodInvocation *invocation) |
| 2064 | { |
| 2065 | g_dbus_method_invocation_return_value (invocation, |
| 2066 | g_variant_new ("()")); |
| 2067 | } |
| 2068 | |
| 2069 | /** |
| 2070 | * control_host_complete_shutdown: |
| 2071 | * @object: A #ControlHost. |
| 2072 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 2073 | * |
| 2074 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-control-Host.shutdown">shutdown()</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. |
| 2075 | * |
| 2076 | * This method will free @invocation, you cannot use it afterwards. |
| 2077 | */ |
| 2078 | void |
| 2079 | control_host_complete_shutdown ( |
| 2080 | ControlHost *object, |
| 2081 | GDBusMethodInvocation *invocation) |
| 2082 | { |
| 2083 | g_dbus_method_invocation_return_value (invocation, |
| 2084 | g_variant_new ("()")); |
| 2085 | } |
| 2086 | |
| 2087 | /** |
| 2088 | * control_host_complete_reboot: |
| 2089 | * @object: A #ControlHost. |
| 2090 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 2091 | * |
| 2092 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-control-Host.reboot">reboot()</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. |
| 2093 | * |
| 2094 | * This method will free @invocation, you cannot use it afterwards. |
| 2095 | */ |
| 2096 | void |
| 2097 | control_host_complete_reboot ( |
| 2098 | ControlHost *object, |
| 2099 | GDBusMethodInvocation *invocation) |
| 2100 | { |
| 2101 | g_dbus_method_invocation_return_value (invocation, |
| 2102 | g_variant_new ("()")); |
| 2103 | } |
| 2104 | |
| 2105 | /* ------------------------------------------------------------------------ */ |
| 2106 | |
| 2107 | /** |
| 2108 | * ControlHostProxy: |
| 2109 | * |
| 2110 | * The #ControlHostProxy structure contains only private data and should only be accessed using the provided API. |
| 2111 | */ |
| 2112 | |
| 2113 | /** |
| 2114 | * ControlHostProxyClass: |
| 2115 | * @parent_class: The parent class. |
| 2116 | * |
| 2117 | * Class structure for #ControlHostProxy. |
| 2118 | */ |
| 2119 | |
| 2120 | struct _ControlHostProxyPrivate |
| 2121 | { |
| 2122 | GData *qdata; |
| 2123 | }; |
| 2124 | |
| 2125 | static void control_host_proxy_iface_init (ControlHostIface *iface); |
| 2126 | |
| 2127 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 2128 | G_DEFINE_TYPE_WITH_CODE (ControlHostProxy, control_host_proxy, G_TYPE_DBUS_PROXY, |
| 2129 | G_ADD_PRIVATE (ControlHostProxy) |
| 2130 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_HOST, control_host_proxy_iface_init)); |
| 2131 | |
| 2132 | #else |
| 2133 | G_DEFINE_TYPE_WITH_CODE (ControlHostProxy, control_host_proxy, G_TYPE_DBUS_PROXY, |
| 2134 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_HOST, control_host_proxy_iface_init)); |
| 2135 | |
| 2136 | #endif |
| 2137 | static void |
| 2138 | control_host_proxy_finalize (GObject *object) |
| 2139 | { |
| 2140 | ControlHostProxy *proxy = CONTROL_HOST_PROXY (object); |
| 2141 | g_datalist_clear (&proxy->priv->qdata); |
| 2142 | G_OBJECT_CLASS (control_host_proxy_parent_class)->finalize (object); |
| 2143 | } |
| 2144 | |
| 2145 | static void |
| 2146 | control_host_proxy_get_property (GObject *object, |
| 2147 | guint prop_id, |
| 2148 | GValue *value, |
| 2149 | GParamSpec *pspec G_GNUC_UNUSED) |
| 2150 | { |
| 2151 | } |
| 2152 | |
| 2153 | static void |
| 2154 | control_host_proxy_set_property (GObject *object, |
| 2155 | guint prop_id, |
| 2156 | const GValue *value, |
| 2157 | GParamSpec *pspec G_GNUC_UNUSED) |
| 2158 | { |
| 2159 | } |
| 2160 | |
| 2161 | static void |
| 2162 | control_host_proxy_g_signal (GDBusProxy *proxy, |
| 2163 | const gchar *sender_name G_GNUC_UNUSED, |
| 2164 | const gchar *signal_name, |
| 2165 | GVariant *parameters) |
| 2166 | { |
| 2167 | _ExtendedGDBusSignalInfo *info; |
| 2168 | GVariantIter iter; |
| 2169 | GVariant *child; |
| 2170 | GValue *paramv; |
| 2171 | guint num_params; |
| 2172 | guint n; |
| 2173 | guint signal_id; |
| 2174 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct, signal_name); |
| 2175 | if (info == NULL) |
| 2176 | return; |
| 2177 | num_params = g_variant_n_children (parameters); |
| 2178 | paramv = g_new0 (GValue, num_params + 1); |
| 2179 | g_value_init (¶mv[0], TYPE_CONTROL_HOST); |
| 2180 | g_value_set_object (¶mv[0], proxy); |
| 2181 | g_variant_iter_init (&iter, parameters); |
| 2182 | n = 1; |
| 2183 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 2184 | { |
| 2185 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; |
| 2186 | if (arg_info->use_gvariant) |
| 2187 | { |
| 2188 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 2189 | g_value_set_variant (¶mv[n], child); |
| 2190 | n++; |
| 2191 | } |
| 2192 | else |
| 2193 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 2194 | g_variant_unref (child); |
| 2195 | } |
| 2196 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL_HOST); |
| 2197 | g_signal_emitv (paramv, signal_id, 0, NULL); |
| 2198 | for (n = 0; n < num_params + 1; n++) |
| 2199 | g_value_unset (¶mv[n]); |
| 2200 | g_free (paramv); |
| 2201 | } |
| 2202 | |
| 2203 | static void |
| 2204 | control_host_proxy_g_properties_changed (GDBusProxy *_proxy, |
| 2205 | GVariant *changed_properties, |
| 2206 | const gchar *const *invalidated_properties) |
| 2207 | { |
| 2208 | ControlHostProxy *proxy = CONTROL_HOST_PROXY (_proxy); |
| 2209 | guint n; |
| 2210 | const gchar *key; |
| 2211 | GVariantIter *iter; |
| 2212 | _ExtendedGDBusPropertyInfo *info; |
| 2213 | g_variant_get (changed_properties, "a{sv}", &iter); |
| 2214 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) |
| 2215 | { |
| 2216 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct, key); |
| 2217 | g_datalist_remove_data (&proxy->priv->qdata, key); |
| 2218 | if (info != NULL) |
| 2219 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 2220 | } |
| 2221 | g_variant_iter_free (iter); |
| 2222 | for (n = 0; invalidated_properties[n] != NULL; n++) |
| 2223 | { |
| 2224 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct, invalidated_properties[n]); |
| 2225 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); |
| 2226 | if (info != NULL) |
| 2227 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | static void |
| 2232 | control_host_proxy_init (ControlHostProxy *proxy) |
| 2233 | { |
| 2234 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 2235 | proxy->priv = control_host_proxy_get_instance_private (proxy); |
| 2236 | #else |
| 2237 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_CONTROL_HOST_PROXY, ControlHostProxyPrivate); |
| 2238 | #endif |
| 2239 | |
| 2240 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), control_host_interface_info ()); |
| 2241 | } |
| 2242 | |
| 2243 | static void |
| 2244 | control_host_proxy_class_init (ControlHostProxyClass *klass) |
| 2245 | { |
| 2246 | GObjectClass *gobject_class; |
| 2247 | GDBusProxyClass *proxy_class; |
| 2248 | |
| 2249 | gobject_class = G_OBJECT_CLASS (klass); |
| 2250 | gobject_class->finalize = control_host_proxy_finalize; |
| 2251 | gobject_class->get_property = control_host_proxy_get_property; |
| 2252 | gobject_class->set_property = control_host_proxy_set_property; |
| 2253 | |
| 2254 | proxy_class = G_DBUS_PROXY_CLASS (klass); |
| 2255 | proxy_class->g_signal = control_host_proxy_g_signal; |
| 2256 | proxy_class->g_properties_changed = control_host_proxy_g_properties_changed; |
| 2257 | |
| 2258 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 2259 | g_type_class_add_private (klass, sizeof (ControlHostProxyPrivate)); |
| 2260 | #endif |
| 2261 | } |
| 2262 | |
| 2263 | static void |
| 2264 | control_host_proxy_iface_init (ControlHostIface *iface) |
| 2265 | { |
| 2266 | } |
| 2267 | |
| 2268 | /** |
| 2269 | * control_host_proxy_new: |
| 2270 | * @connection: A #GDBusConnection. |
| 2271 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 2272 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 2273 | * @object_path: An object path. |
| 2274 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 2275 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 2276 | * @user_data: User data to pass to @callback. |
| 2277 | * |
| 2278 | * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>. See g_dbus_proxy_new() for more details. |
| 2279 | * |
| 2280 | * 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. |
| 2281 | * You can then call control_host_proxy_new_finish() to get the result of the operation. |
| 2282 | * |
| 2283 | * See control_host_proxy_new_sync() for the synchronous, blocking version of this constructor. |
| 2284 | */ |
| 2285 | void |
| 2286 | control_host_proxy_new ( |
| 2287 | GDBusConnection *connection, |
| 2288 | GDBusProxyFlags flags, |
| 2289 | const gchar *name, |
| 2290 | const gchar *object_path, |
| 2291 | GCancellable *cancellable, |
| 2292 | GAsyncReadyCallback callback, |
| 2293 | gpointer user_data) |
| 2294 | { |
| 2295 | g_async_initable_new_async (TYPE_CONTROL_HOST_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.Host", NULL); |
| 2296 | } |
| 2297 | |
| 2298 | /** |
| 2299 | * control_host_proxy_new_finish: |
| 2300 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_host_proxy_new(). |
| 2301 | * @error: Return location for error or %NULL |
| 2302 | * |
| 2303 | * Finishes an operation started with control_host_proxy_new(). |
| 2304 | * |
| 2305 | * Returns: (transfer full) (type ControlHostProxy): The constructed proxy object or %NULL if @error is set. |
| 2306 | */ |
| 2307 | ControlHost * |
| 2308 | control_host_proxy_new_finish ( |
| 2309 | GAsyncResult *res, |
| 2310 | GError **error) |
| 2311 | { |
| 2312 | GObject *ret; |
| 2313 | GObject *source_object; |
| 2314 | source_object = g_async_result_get_source_object (res); |
| 2315 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 2316 | g_object_unref (source_object); |
| 2317 | if (ret != NULL) |
| 2318 | return CONTROL_HOST (ret); |
| 2319 | else |
| 2320 | return NULL; |
| 2321 | } |
| 2322 | |
| 2323 | /** |
| 2324 | * control_host_proxy_new_sync: |
| 2325 | * @connection: A #GDBusConnection. |
| 2326 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 2327 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 2328 | * @object_path: An object path. |
| 2329 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 2330 | * @error: Return location for error or %NULL |
| 2331 | * |
| 2332 | * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>. See g_dbus_proxy_new_sync() for more details. |
| 2333 | * |
| 2334 | * The calling thread is blocked until a reply is received. |
| 2335 | * |
| 2336 | * See control_host_proxy_new() for the asynchronous version of this constructor. |
| 2337 | * |
| 2338 | * Returns: (transfer full) (type ControlHostProxy): The constructed proxy object or %NULL if @error is set. |
| 2339 | */ |
| 2340 | ControlHost * |
| 2341 | control_host_proxy_new_sync ( |
| 2342 | GDBusConnection *connection, |
| 2343 | GDBusProxyFlags flags, |
| 2344 | const gchar *name, |
| 2345 | const gchar *object_path, |
| 2346 | GCancellable *cancellable, |
| 2347 | GError **error) |
| 2348 | { |
| 2349 | GInitable *ret; |
| 2350 | ret = g_initable_new (TYPE_CONTROL_HOST_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.control.Host", NULL); |
| 2351 | if (ret != NULL) |
| 2352 | return CONTROL_HOST (ret); |
| 2353 | else |
| 2354 | return NULL; |
| 2355 | } |
| 2356 | |
| 2357 | |
| 2358 | /** |
| 2359 | * control_host_proxy_new_for_bus: |
| 2360 | * @bus_type: A #GBusType. |
| 2361 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 2362 | * @name: A bus name (well-known or unique). |
| 2363 | * @object_path: An object path. |
| 2364 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 2365 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 2366 | * @user_data: User data to pass to @callback. |
| 2367 | * |
| 2368 | * Like control_host_proxy_new() but takes a #GBusType instead of a #GDBusConnection. |
| 2369 | * |
| 2370 | * 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. |
| 2371 | * You can then call control_host_proxy_new_for_bus_finish() to get the result of the operation. |
| 2372 | * |
| 2373 | * See control_host_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. |
| 2374 | */ |
| 2375 | void |
| 2376 | control_host_proxy_new_for_bus ( |
| 2377 | GBusType bus_type, |
| 2378 | GDBusProxyFlags flags, |
| 2379 | const gchar *name, |
| 2380 | const gchar *object_path, |
| 2381 | GCancellable *cancellable, |
| 2382 | GAsyncReadyCallback callback, |
| 2383 | gpointer user_data) |
| 2384 | { |
| 2385 | g_async_initable_new_async (TYPE_CONTROL_HOST_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.Host", NULL); |
| 2386 | } |
| 2387 | |
| 2388 | /** |
| 2389 | * control_host_proxy_new_for_bus_finish: |
| 2390 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_host_proxy_new_for_bus(). |
| 2391 | * @error: Return location for error or %NULL |
| 2392 | * |
| 2393 | * Finishes an operation started with control_host_proxy_new_for_bus(). |
| 2394 | * |
| 2395 | * Returns: (transfer full) (type ControlHostProxy): The constructed proxy object or %NULL if @error is set. |
| 2396 | */ |
| 2397 | ControlHost * |
| 2398 | control_host_proxy_new_for_bus_finish ( |
| 2399 | GAsyncResult *res, |
| 2400 | GError **error) |
| 2401 | { |
| 2402 | GObject *ret; |
| 2403 | GObject *source_object; |
| 2404 | source_object = g_async_result_get_source_object (res); |
| 2405 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 2406 | g_object_unref (source_object); |
| 2407 | if (ret != NULL) |
| 2408 | return CONTROL_HOST (ret); |
| 2409 | else |
| 2410 | return NULL; |
| 2411 | } |
| 2412 | |
| 2413 | /** |
| 2414 | * control_host_proxy_new_for_bus_sync: |
| 2415 | * @bus_type: A #GBusType. |
| 2416 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 2417 | * @name: A bus name (well-known or unique). |
| 2418 | * @object_path: An object path. |
| 2419 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 2420 | * @error: Return location for error or %NULL |
| 2421 | * |
| 2422 | * Like control_host_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. |
| 2423 | * |
| 2424 | * The calling thread is blocked until a reply is received. |
| 2425 | * |
| 2426 | * See control_host_proxy_new_for_bus() for the asynchronous version of this constructor. |
| 2427 | * |
| 2428 | * Returns: (transfer full) (type ControlHostProxy): The constructed proxy object or %NULL if @error is set. |
| 2429 | */ |
| 2430 | ControlHost * |
| 2431 | control_host_proxy_new_for_bus_sync ( |
| 2432 | GBusType bus_type, |
| 2433 | GDBusProxyFlags flags, |
| 2434 | const gchar *name, |
| 2435 | const gchar *object_path, |
| 2436 | GCancellable *cancellable, |
| 2437 | GError **error) |
| 2438 | { |
| 2439 | GInitable *ret; |
| 2440 | ret = g_initable_new (TYPE_CONTROL_HOST_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.Host", NULL); |
| 2441 | if (ret != NULL) |
| 2442 | return CONTROL_HOST (ret); |
| 2443 | else |
| 2444 | return NULL; |
| 2445 | } |
| 2446 | |
| 2447 | |
| 2448 | /* ------------------------------------------------------------------------ */ |
| 2449 | |
| 2450 | /** |
| 2451 | * ControlHostSkeleton: |
| 2452 | * |
| 2453 | * The #ControlHostSkeleton structure contains only private data and should only be accessed using the provided API. |
| 2454 | */ |
| 2455 | |
| 2456 | /** |
| 2457 | * ControlHostSkeletonClass: |
| 2458 | * @parent_class: The parent class. |
| 2459 | * |
| 2460 | * Class structure for #ControlHostSkeleton. |
| 2461 | */ |
| 2462 | |
| 2463 | struct _ControlHostSkeletonPrivate |
| 2464 | { |
| 2465 | GValue *properties; |
| 2466 | GList *changed_properties; |
| 2467 | GSource *changed_properties_idle_source; |
| 2468 | GMainContext *context; |
| 2469 | GMutex lock; |
| 2470 | }; |
| 2471 | |
| 2472 | static void |
| 2473 | _control_host_skeleton_handle_method_call ( |
| 2474 | GDBusConnection *connection G_GNUC_UNUSED, |
| 2475 | const gchar *sender G_GNUC_UNUSED, |
| 2476 | const gchar *object_path G_GNUC_UNUSED, |
| 2477 | const gchar *interface_name, |
| 2478 | const gchar *method_name, |
| 2479 | GVariant *parameters, |
| 2480 | GDBusMethodInvocation *invocation, |
| 2481 | gpointer user_data) |
| 2482 | { |
| 2483 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (user_data); |
| 2484 | _ExtendedGDBusMethodInfo *info; |
| 2485 | GVariantIter iter; |
| 2486 | GVariant *child; |
| 2487 | GValue *paramv; |
| 2488 | guint num_params; |
| 2489 | guint num_extra; |
| 2490 | guint n; |
| 2491 | guint signal_id; |
| 2492 | GValue return_value = G_VALUE_INIT; |
| 2493 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); |
| 2494 | g_assert (info != NULL); |
| 2495 | num_params = g_variant_n_children (parameters); |
| 2496 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); |
| 2497 | n = 0; |
| 2498 | g_value_init (¶mv[n], TYPE_CONTROL_HOST); |
| 2499 | g_value_set_object (¶mv[n++], skeleton); |
| 2500 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); |
| 2501 | g_value_set_object (¶mv[n++], invocation); |
| 2502 | if (info->pass_fdlist) |
| 2503 | { |
| 2504 | #ifdef G_OS_UNIX |
| 2505 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); |
| 2506 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); |
| 2507 | #else |
| 2508 | g_assert_not_reached (); |
| 2509 | #endif |
| 2510 | } |
| 2511 | g_variant_iter_init (&iter, parameters); |
| 2512 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 2513 | { |
| 2514 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; |
| 2515 | if (arg_info->use_gvariant) |
| 2516 | { |
| 2517 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 2518 | g_value_set_variant (¶mv[n], child); |
| 2519 | n++; |
| 2520 | } |
| 2521 | else |
| 2522 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 2523 | g_variant_unref (child); |
| 2524 | } |
| 2525 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL_HOST); |
| 2526 | g_value_init (&return_value, G_TYPE_BOOLEAN); |
| 2527 | g_signal_emitv (paramv, signal_id, 0, &return_value); |
| 2528 | if (!g_value_get_boolean (&return_value)) |
| 2529 | 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); |
| 2530 | g_value_unset (&return_value); |
| 2531 | for (n = 0; n < num_params + num_extra; n++) |
| 2532 | g_value_unset (¶mv[n]); |
| 2533 | g_free (paramv); |
| 2534 | } |
| 2535 | |
| 2536 | static GVariant * |
| 2537 | _control_host_skeleton_handle_get_property ( |
| 2538 | GDBusConnection *connection G_GNUC_UNUSED, |
| 2539 | const gchar *sender G_GNUC_UNUSED, |
| 2540 | const gchar *object_path G_GNUC_UNUSED, |
| 2541 | const gchar *interface_name G_GNUC_UNUSED, |
| 2542 | const gchar *property_name, |
| 2543 | GError **error, |
| 2544 | gpointer user_data) |
| 2545 | { |
| 2546 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (user_data); |
| 2547 | GValue value = G_VALUE_INIT; |
| 2548 | GParamSpec *pspec; |
| 2549 | _ExtendedGDBusPropertyInfo *info; |
| 2550 | GVariant *ret; |
| 2551 | ret = NULL; |
| 2552 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct, property_name); |
| 2553 | g_assert (info != NULL); |
| 2554 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 2555 | if (pspec == NULL) |
| 2556 | { |
| 2557 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 2558 | } |
| 2559 | else |
| 2560 | { |
| 2561 | g_value_init (&value, pspec->value_type); |
| 2562 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 2563 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 2564 | g_value_unset (&value); |
| 2565 | } |
| 2566 | return ret; |
| 2567 | } |
| 2568 | |
| 2569 | static gboolean |
| 2570 | _control_host_skeleton_handle_set_property ( |
| 2571 | GDBusConnection *connection G_GNUC_UNUSED, |
| 2572 | const gchar *sender G_GNUC_UNUSED, |
| 2573 | const gchar *object_path G_GNUC_UNUSED, |
| 2574 | const gchar *interface_name G_GNUC_UNUSED, |
| 2575 | const gchar *property_name, |
| 2576 | GVariant *variant, |
| 2577 | GError **error, |
| 2578 | gpointer user_data) |
| 2579 | { |
| 2580 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (user_data); |
| 2581 | GValue value = G_VALUE_INIT; |
| 2582 | GParamSpec *pspec; |
| 2583 | _ExtendedGDBusPropertyInfo *info; |
| 2584 | gboolean ret; |
| 2585 | ret = FALSE; |
| 2586 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_host_interface_info.parent_struct, property_name); |
| 2587 | g_assert (info != NULL); |
| 2588 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 2589 | if (pspec == NULL) |
| 2590 | { |
| 2591 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 2592 | } |
| 2593 | else |
| 2594 | { |
| 2595 | if (info->use_gvariant) |
| 2596 | g_value_set_variant (&value, variant); |
| 2597 | else |
| 2598 | g_dbus_gvariant_to_gvalue (variant, &value); |
| 2599 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 2600 | g_value_unset (&value); |
| 2601 | ret = TRUE; |
| 2602 | } |
| 2603 | return ret; |
| 2604 | } |
| 2605 | |
| 2606 | static const GDBusInterfaceVTable _control_host_skeleton_vtable = |
| 2607 | { |
| 2608 | _control_host_skeleton_handle_method_call, |
| 2609 | _control_host_skeleton_handle_get_property, |
| 2610 | _control_host_skeleton_handle_set_property, |
| 2611 | {NULL} |
| 2612 | }; |
| 2613 | |
| 2614 | static GDBusInterfaceInfo * |
| 2615 | control_host_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 2616 | { |
| 2617 | return control_host_interface_info (); |
| 2618 | } |
| 2619 | |
| 2620 | static GDBusInterfaceVTable * |
| 2621 | control_host_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 2622 | { |
| 2623 | return (GDBusInterfaceVTable *) &_control_host_skeleton_vtable; |
| 2624 | } |
| 2625 | |
| 2626 | static GVariant * |
| 2627 | control_host_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) |
| 2628 | { |
| 2629 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (_skeleton); |
| 2630 | |
| 2631 | GVariantBuilder builder; |
| 2632 | guint n; |
| 2633 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 2634 | if (_control_host_interface_info.parent_struct.properties == NULL) |
| 2635 | goto out; |
| 2636 | for (n = 0; _control_host_interface_info.parent_struct.properties[n] != NULL; n++) |
| 2637 | { |
| 2638 | GDBusPropertyInfo *info = _control_host_interface_info.parent_struct.properties[n]; |
| 2639 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) |
| 2640 | { |
| 2641 | GVariant *value; |
| 2642 | value = _control_host_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.Host", info->name, NULL, skeleton); |
| 2643 | if (value != NULL) |
| 2644 | { |
| 2645 | g_variant_take_ref (value); |
| 2646 | g_variant_builder_add (&builder, "{sv}", info->name, value); |
| 2647 | g_variant_unref (value); |
| 2648 | } |
| 2649 | } |
| 2650 | } |
| 2651 | out: |
| 2652 | return g_variant_builder_end (&builder); |
| 2653 | } |
| 2654 | |
| 2655 | static void |
| 2656 | control_host_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) |
| 2657 | { |
| 2658 | } |
| 2659 | |
| 2660 | static void |
| 2661 | _control_host_on_signal_booted ( |
| 2662 | ControlHost *object) |
| 2663 | { |
| 2664 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (object); |
| 2665 | |
| 2666 | GList *connections, *l; |
| 2667 | GVariant *signal_variant; |
| 2668 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 2669 | |
| 2670 | signal_variant = g_variant_ref_sink (g_variant_new ("()")); |
| 2671 | for (l = connections; l != NULL; l = l->next) |
| 2672 | { |
| 2673 | GDBusConnection *connection = l->data; |
| 2674 | g_dbus_connection_emit_signal (connection, |
| 2675 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.control.Host", "Booted", |
| 2676 | signal_variant, NULL); |
| 2677 | } |
| 2678 | g_variant_unref (signal_variant); |
| 2679 | g_list_free_full (connections, g_object_unref); |
| 2680 | } |
| 2681 | |
| 2682 | static void control_host_skeleton_iface_init (ControlHostIface *iface); |
| 2683 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 2684 | G_DEFINE_TYPE_WITH_CODE (ControlHostSkeleton, control_host_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 2685 | G_ADD_PRIVATE (ControlHostSkeleton) |
| 2686 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_HOST, control_host_skeleton_iface_init)); |
| 2687 | |
| 2688 | #else |
| 2689 | G_DEFINE_TYPE_WITH_CODE (ControlHostSkeleton, control_host_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 2690 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_HOST, control_host_skeleton_iface_init)); |
| 2691 | |
| 2692 | #endif |
| 2693 | static void |
| 2694 | control_host_skeleton_finalize (GObject *object) |
| 2695 | { |
| 2696 | ControlHostSkeleton *skeleton = CONTROL_HOST_SKELETON (object); |
| 2697 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 2698 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 2699 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 2700 | g_main_context_unref (skeleton->priv->context); |
| 2701 | g_mutex_clear (&skeleton->priv->lock); |
| 2702 | G_OBJECT_CLASS (control_host_skeleton_parent_class)->finalize (object); |
| 2703 | } |
| 2704 | |
| 2705 | static void |
| 2706 | control_host_skeleton_init (ControlHostSkeleton *skeleton) |
| 2707 | { |
| 2708 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 2709 | skeleton->priv = control_host_skeleton_get_instance_private (skeleton); |
| 2710 | #else |
| 2711 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_CONTROL_HOST_SKELETON, ControlHostSkeletonPrivate); |
| 2712 | #endif |
| 2713 | |
| 2714 | g_mutex_init (&skeleton->priv->lock); |
| 2715 | skeleton->priv->context = g_main_context_ref_thread_default (); |
| 2716 | } |
| 2717 | |
| 2718 | static void |
| 2719 | control_host_skeleton_class_init (ControlHostSkeletonClass *klass) |
| 2720 | { |
| 2721 | GObjectClass *gobject_class; |
| 2722 | GDBusInterfaceSkeletonClass *skeleton_class; |
| 2723 | |
| 2724 | gobject_class = G_OBJECT_CLASS (klass); |
| 2725 | gobject_class->finalize = control_host_skeleton_finalize; |
| 2726 | |
| 2727 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); |
| 2728 | skeleton_class->get_info = control_host_skeleton_dbus_interface_get_info; |
| 2729 | skeleton_class->get_properties = control_host_skeleton_dbus_interface_get_properties; |
| 2730 | skeleton_class->flush = control_host_skeleton_dbus_interface_flush; |
| 2731 | skeleton_class->get_vtable = control_host_skeleton_dbus_interface_get_vtable; |
| 2732 | |
| 2733 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 2734 | g_type_class_add_private (klass, sizeof (ControlHostSkeletonPrivate)); |
| 2735 | #endif |
| 2736 | } |
| 2737 | |
| 2738 | static void |
| 2739 | control_host_skeleton_iface_init (ControlHostIface *iface) |
| 2740 | { |
| 2741 | iface->booted = _control_host_on_signal_booted; |
| 2742 | } |
| 2743 | |
| 2744 | /** |
| 2745 | * control_host_skeleton_new: |
| 2746 | * |
| 2747 | * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>. |
| 2748 | * |
| 2749 | * Returns: (transfer full) (type ControlHostSkeleton): The skeleton object. |
| 2750 | */ |
| 2751 | ControlHost * |
| 2752 | control_host_skeleton_new (void) |
| 2753 | { |
| 2754 | return CONTROL_HOST (g_object_new (TYPE_CONTROL_HOST_SKELETON, NULL)); |
| 2755 | } |
| 2756 | |
| 2757 | /* ------------------------------------------------------------------------ |
| 2758 | * Code for interface org.openbmc.control.Power |
| 2759 | * ------------------------------------------------------------------------ |
| 2760 | */ |
| 2761 | |
| 2762 | /** |
| 2763 | * SECTION:ControlPower |
| 2764 | * @title: ControlPower |
| 2765 | * @short_description: Generated C code for the org.openbmc.control.Power D-Bus interface |
| 2766 | * |
| 2767 | * 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. |
| 2768 | */ |
| 2769 | |
| 2770 | /* ---- Introspection data for org.openbmc.control.Power ---- */ |
| 2771 | |
| 2772 | static const _ExtendedGDBusArgInfo _control_power_method_info_set_power_state_IN_ARG_state = |
| 2773 | { |
| 2774 | { |
| 2775 | -1, |
| 2776 | (gchar *) "state", |
| 2777 | (gchar *) "i", |
| 2778 | NULL |
| 2779 | }, |
| 2780 | FALSE |
| 2781 | }; |
| 2782 | |
| 2783 | static const _ExtendedGDBusArgInfo * const _control_power_method_info_set_power_state_IN_ARG_pointers[] = |
| 2784 | { |
| 2785 | &_control_power_method_info_set_power_state_IN_ARG_state, |
| 2786 | NULL |
| 2787 | }; |
| 2788 | |
| 2789 | static const _ExtendedGDBusMethodInfo _control_power_method_info_set_power_state = |
| 2790 | { |
| 2791 | { |
| 2792 | -1, |
| 2793 | (gchar *) "setPowerState", |
| 2794 | (GDBusArgInfo **) &_control_power_method_info_set_power_state_IN_ARG_pointers, |
| 2795 | NULL, |
| 2796 | NULL |
| 2797 | }, |
| 2798 | "handle-set-power-state", |
| 2799 | FALSE |
| 2800 | }; |
| 2801 | |
| 2802 | static const _ExtendedGDBusArgInfo _control_power_method_info_get_power_state_OUT_ARG_state = |
| 2803 | { |
| 2804 | { |
| 2805 | -1, |
| 2806 | (gchar *) "state", |
| 2807 | (gchar *) "i", |
| 2808 | NULL |
| 2809 | }, |
| 2810 | FALSE |
| 2811 | }; |
| 2812 | |
| 2813 | static const _ExtendedGDBusArgInfo * const _control_power_method_info_get_power_state_OUT_ARG_pointers[] = |
| 2814 | { |
| 2815 | &_control_power_method_info_get_power_state_OUT_ARG_state, |
| 2816 | NULL |
| 2817 | }; |
| 2818 | |
| 2819 | static const _ExtendedGDBusMethodInfo _control_power_method_info_get_power_state = |
| 2820 | { |
| 2821 | { |
| 2822 | -1, |
| 2823 | (gchar *) "getPowerState", |
| 2824 | NULL, |
| 2825 | (GDBusArgInfo **) &_control_power_method_info_get_power_state_OUT_ARG_pointers, |
| 2826 | NULL |
| 2827 | }, |
| 2828 | "handle-get-power-state", |
| 2829 | FALSE |
| 2830 | }; |
| 2831 | |
| 2832 | static const _ExtendedGDBusMethodInfo * const _control_power_method_info_pointers[] = |
| 2833 | { |
| 2834 | &_control_power_method_info_set_power_state, |
| 2835 | &_control_power_method_info_get_power_state, |
| 2836 | NULL |
| 2837 | }; |
| 2838 | |
| 2839 | static const _ExtendedGDBusSignalInfo _control_power_signal_info_power_good = |
| 2840 | { |
| 2841 | { |
| 2842 | -1, |
| 2843 | (gchar *) "PowerGood", |
| 2844 | NULL, |
| 2845 | NULL |
| 2846 | }, |
| 2847 | "power-good" |
| 2848 | }; |
| 2849 | |
| 2850 | static const _ExtendedGDBusSignalInfo _control_power_signal_info_power_lost = |
| 2851 | { |
| 2852 | { |
| 2853 | -1, |
| 2854 | (gchar *) "PowerLost", |
| 2855 | NULL, |
| 2856 | NULL |
| 2857 | }, |
| 2858 | "power-lost" |
| 2859 | }; |
| 2860 | |
| 2861 | static const _ExtendedGDBusSignalInfo * const _control_power_signal_info_pointers[] = |
| 2862 | { |
| 2863 | &_control_power_signal_info_power_good, |
| 2864 | &_control_power_signal_info_power_lost, |
| 2865 | NULL |
| 2866 | }; |
| 2867 | |
| 2868 | static const _ExtendedGDBusPropertyInfo _control_power_property_info_pgood = |
| 2869 | { |
| 2870 | { |
| 2871 | -1, |
| 2872 | (gchar *) "pgood", |
| 2873 | (gchar *) "i", |
| 2874 | G_DBUS_PROPERTY_INFO_FLAGS_READABLE, |
| 2875 | NULL |
| 2876 | }, |
| 2877 | "pgood", |
| 2878 | FALSE |
| 2879 | }; |
| 2880 | |
| 2881 | static const _ExtendedGDBusPropertyInfo _control_power_property_info_state = |
| 2882 | { |
| 2883 | { |
| 2884 | -1, |
| 2885 | (gchar *) "state", |
| 2886 | (gchar *) "i", |
| 2887 | G_DBUS_PROPERTY_INFO_FLAGS_READABLE, |
| 2888 | NULL |
| 2889 | }, |
| 2890 | "state", |
| 2891 | FALSE |
| 2892 | }; |
| 2893 | |
| 2894 | static const _ExtendedGDBusPropertyInfo * const _control_power_property_info_pointers[] = |
| 2895 | { |
| 2896 | &_control_power_property_info_pgood, |
| 2897 | &_control_power_property_info_state, |
| 2898 | NULL |
| 2899 | }; |
| 2900 | |
| 2901 | static const _ExtendedGDBusInterfaceInfo _control_power_interface_info = |
| 2902 | { |
| 2903 | { |
| 2904 | -1, |
| 2905 | (gchar *) "org.openbmc.control.Power", |
| 2906 | (GDBusMethodInfo **) &_control_power_method_info_pointers, |
| 2907 | (GDBusSignalInfo **) &_control_power_signal_info_pointers, |
| 2908 | (GDBusPropertyInfo **) &_control_power_property_info_pointers, |
| 2909 | NULL |
| 2910 | }, |
| 2911 | "control-power", |
| 2912 | }; |
| 2913 | |
| 2914 | |
| 2915 | /** |
| 2916 | * control_power_interface_info: |
| 2917 | * |
| 2918 | * 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. |
| 2919 | * |
| 2920 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. |
| 2921 | */ |
| 2922 | GDBusInterfaceInfo * |
| 2923 | control_power_interface_info (void) |
| 2924 | { |
| 2925 | return (GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct; |
| 2926 | } |
| 2927 | |
| 2928 | /** |
| 2929 | * control_power_override_properties: |
| 2930 | * @klass: The class structure for a #GObject<!-- -->-derived class. |
| 2931 | * @property_id_begin: The property id to assign to the first overridden property. |
| 2932 | * |
| 2933 | * Overrides all #GObject properties in the #ControlPower interface for a concrete class. |
| 2934 | * The properties are overridden in the order they are defined. |
| 2935 | * |
| 2936 | * Returns: The last property id. |
| 2937 | */ |
| 2938 | guint |
| 2939 | control_power_override_properties (GObjectClass *klass, guint property_id_begin) |
| 2940 | { |
| 2941 | g_object_class_override_property (klass, property_id_begin++, "pgood"); |
| 2942 | g_object_class_override_property (klass, property_id_begin++, "state"); |
| 2943 | return property_id_begin - 1; |
| 2944 | } |
| 2945 | |
| 2946 | |
| 2947 | |
| 2948 | /** |
| 2949 | * ControlPower: |
| 2950 | * |
| 2951 | * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Power.top_of_page">org.openbmc.control.Power</link>. |
| 2952 | */ |
| 2953 | |
| 2954 | /** |
| 2955 | * ControlPowerIface: |
| 2956 | * @parent_iface: The parent interface. |
| 2957 | * @handle_get_power_state: Handler for the #ControlPower::handle-get-power-state signal. |
| 2958 | * @handle_set_power_state: Handler for the #ControlPower::handle-set-power-state signal. |
| 2959 | * @get_pgood: Getter for the #ControlPower:pgood property. |
| 2960 | * @get_state: Getter for the #ControlPower:state property. |
| 2961 | * @power_good: Handler for the #ControlPower::power-good signal. |
| 2962 | * @power_lost: Handler for the #ControlPower::power-lost signal. |
| 2963 | * |
| 2964 | * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Power.top_of_page">org.openbmc.control.Power</link>. |
| 2965 | */ |
| 2966 | |
| 2967 | typedef ControlPowerIface ControlPowerInterface; |
| 2968 | G_DEFINE_INTERFACE (ControlPower, control_power, G_TYPE_OBJECT); |
| 2969 | |
| 2970 | static void |
| 2971 | control_power_default_init (ControlPowerIface *iface) |
| 2972 | { |
| 2973 | /* GObject signals for incoming D-Bus method calls: */ |
| 2974 | /** |
| 2975 | * ControlPower::handle-set-power-state: |
| 2976 | * @object: A #ControlPower. |
| 2977 | * @invocation: A #GDBusMethodInvocation. |
| 2978 | * @arg_state: Argument passed by remote caller. |
| 2979 | * |
| 2980 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-control-Power.setPowerState">setPowerState()</link> D-Bus method. |
| 2981 | * |
| 2982 | * 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. |
| 2983 | * |
| 2984 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 2985 | */ |
| 2986 | g_signal_new ("handle-set-power-state", |
| 2987 | G_TYPE_FROM_INTERFACE (iface), |
| 2988 | G_SIGNAL_RUN_LAST, |
| 2989 | G_STRUCT_OFFSET (ControlPowerIface, handle_set_power_state), |
| 2990 | g_signal_accumulator_true_handled, |
| 2991 | NULL, |
| 2992 | g_cclosure_marshal_generic, |
| 2993 | G_TYPE_BOOLEAN, |
| 2994 | 2, |
| 2995 | G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT); |
| 2996 | |
| 2997 | /** |
| 2998 | * ControlPower::handle-get-power-state: |
| 2999 | * @object: A #ControlPower. |
| 3000 | * @invocation: A #GDBusMethodInvocation. |
| 3001 | * |
| 3002 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-control-Power.getPowerState">getPowerState()</link> D-Bus method. |
| 3003 | * |
| 3004 | * 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. |
| 3005 | * |
| 3006 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. |
| 3007 | */ |
| 3008 | g_signal_new ("handle-get-power-state", |
| 3009 | G_TYPE_FROM_INTERFACE (iface), |
| 3010 | G_SIGNAL_RUN_LAST, |
| 3011 | G_STRUCT_OFFSET (ControlPowerIface, handle_get_power_state), |
| 3012 | g_signal_accumulator_true_handled, |
| 3013 | NULL, |
| 3014 | g_cclosure_marshal_generic, |
| 3015 | G_TYPE_BOOLEAN, |
| 3016 | 1, |
| 3017 | G_TYPE_DBUS_METHOD_INVOCATION); |
| 3018 | |
| 3019 | /* GObject signals for received D-Bus signals: */ |
| 3020 | /** |
| 3021 | * ControlPower::power-good: |
| 3022 | * @object: A #ControlPower. |
| 3023 | * |
| 3024 | * 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. |
| 3025 | * |
| 3026 | * 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. |
| 3027 | */ |
| 3028 | g_signal_new ("power-good", |
| 3029 | G_TYPE_FROM_INTERFACE (iface), |
| 3030 | G_SIGNAL_RUN_LAST, |
| 3031 | G_STRUCT_OFFSET (ControlPowerIface, power_good), |
| 3032 | NULL, |
| 3033 | NULL, |
| 3034 | g_cclosure_marshal_generic, |
| 3035 | G_TYPE_NONE, |
| 3036 | 0); |
| 3037 | |
| 3038 | /** |
| 3039 | * ControlPower::power-lost: |
| 3040 | * @object: A #ControlPower. |
| 3041 | * |
| 3042 | * 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. |
| 3043 | * |
| 3044 | * 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. |
| 3045 | */ |
| 3046 | g_signal_new ("power-lost", |
| 3047 | G_TYPE_FROM_INTERFACE (iface), |
| 3048 | G_SIGNAL_RUN_LAST, |
| 3049 | G_STRUCT_OFFSET (ControlPowerIface, power_lost), |
| 3050 | NULL, |
| 3051 | NULL, |
| 3052 | g_cclosure_marshal_generic, |
| 3053 | G_TYPE_NONE, |
| 3054 | 0); |
| 3055 | |
| 3056 | /* GObject properties for D-Bus properties: */ |
| 3057 | /** |
| 3058 | * ControlPower:pgood: |
| 3059 | * |
| 3060 | * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-control-Power.pgood">"pgood"</link>. |
| 3061 | * |
| 3062 | * 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. |
| 3063 | */ |
| 3064 | g_object_interface_install_property (iface, |
| 3065 | g_param_spec_int ("pgood", "pgood", "pgood", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 3066 | /** |
| 3067 | * ControlPower:state: |
| 3068 | * |
| 3069 | * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-control-Power.state">"state"</link>. |
| 3070 | * |
| 3071 | * 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. |
| 3072 | */ |
| 3073 | g_object_interface_install_property (iface, |
| 3074 | g_param_spec_int ("state", "state", "state", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 3075 | } |
| 3076 | |
| 3077 | /** |
| 3078 | * control_power_get_pgood: (skip) |
| 3079 | * @object: A #ControlPower. |
| 3080 | * |
| 3081 | * Gets the value of the <link linkend="gdbus-property-org-openbmc-control-Power.pgood">"pgood"</link> D-Bus property. |
| 3082 | * |
| 3083 | * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. |
| 3084 | * |
| 3085 | * Returns: The property value. |
| 3086 | */ |
| 3087 | gint |
| 3088 | control_power_get_pgood (ControlPower *object) |
| 3089 | { |
| 3090 | return CONTROL_POWER_GET_IFACE (object)->get_pgood (object); |
| 3091 | } |
| 3092 | |
| 3093 | /** |
| 3094 | * control_power_set_pgood: (skip) |
| 3095 | * @object: A #ControlPower. |
| 3096 | * @value: The value to set. |
| 3097 | * |
| 3098 | * Sets the <link linkend="gdbus-property-org-openbmc-control-Power.pgood">"pgood"</link> D-Bus property to @value. |
| 3099 | * |
| 3100 | * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. |
| 3101 | */ |
| 3102 | void |
| 3103 | control_power_set_pgood (ControlPower *object, gint value) |
| 3104 | { |
| 3105 | g_object_set (G_OBJECT (object), "pgood", value, NULL); |
| 3106 | } |
| 3107 | |
| 3108 | /** |
| 3109 | * control_power_get_state: (skip) |
| 3110 | * @object: A #ControlPower. |
| 3111 | * |
| 3112 | * Gets the value of the <link linkend="gdbus-property-org-openbmc-control-Power.state">"state"</link> D-Bus property. |
| 3113 | * |
| 3114 | * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side. |
| 3115 | * |
| 3116 | * Returns: The property value. |
| 3117 | */ |
| 3118 | gint |
| 3119 | control_power_get_state (ControlPower *object) |
| 3120 | { |
| 3121 | return CONTROL_POWER_GET_IFACE (object)->get_state (object); |
| 3122 | } |
| 3123 | |
| 3124 | /** |
| 3125 | * control_power_set_state: (skip) |
| 3126 | * @object: A #ControlPower. |
| 3127 | * @value: The value to set. |
| 3128 | * |
| 3129 | * Sets the <link linkend="gdbus-property-org-openbmc-control-Power.state">"state"</link> D-Bus property to @value. |
| 3130 | * |
| 3131 | * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side. |
| 3132 | */ |
| 3133 | void |
| 3134 | control_power_set_state (ControlPower *object, gint value) |
| 3135 | { |
| 3136 | g_object_set (G_OBJECT (object), "state", value, NULL); |
| 3137 | } |
| 3138 | |
| 3139 | /** |
| 3140 | * control_power_emit_power_good: |
| 3141 | * @object: A #ControlPower. |
| 3142 | * |
| 3143 | * Emits the <link linkend="gdbus-signal-org-openbmc-control-Power.PowerGood">"PowerGood"</link> D-Bus signal. |
| 3144 | */ |
| 3145 | void |
| 3146 | control_power_emit_power_good ( |
| 3147 | ControlPower *object) |
| 3148 | { |
| 3149 | g_signal_emit_by_name (object, "power-good"); |
| 3150 | } |
| 3151 | |
| 3152 | /** |
| 3153 | * control_power_emit_power_lost: |
| 3154 | * @object: A #ControlPower. |
| 3155 | * |
| 3156 | * Emits the <link linkend="gdbus-signal-org-openbmc-control-Power.PowerLost">"PowerLost"</link> D-Bus signal. |
| 3157 | */ |
| 3158 | void |
| 3159 | control_power_emit_power_lost ( |
| 3160 | ControlPower *object) |
| 3161 | { |
| 3162 | g_signal_emit_by_name (object, "power-lost"); |
| 3163 | } |
| 3164 | |
| 3165 | /** |
| 3166 | * control_power_call_set_power_state: |
| 3167 | * @proxy: A #ControlPowerProxy. |
| 3168 | * @arg_state: Argument to pass with the method invocation. |
| 3169 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3170 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 3171 | * @user_data: User data to pass to @callback. |
| 3172 | * |
| 3173 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Power.setPowerState">setPowerState()</link> D-Bus method on @proxy. |
| 3174 | * 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. |
| 3175 | * You can then call control_power_call_set_power_state_finish() to get the result of the operation. |
| 3176 | * |
| 3177 | * See control_power_call_set_power_state_sync() for the synchronous, blocking version of this method. |
| 3178 | */ |
| 3179 | void |
| 3180 | control_power_call_set_power_state ( |
| 3181 | ControlPower *proxy, |
| 3182 | gint arg_state, |
| 3183 | GCancellable *cancellable, |
| 3184 | GAsyncReadyCallback callback, |
| 3185 | gpointer user_data) |
| 3186 | { |
| 3187 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 3188 | "setPowerState", |
| 3189 | g_variant_new ("(i)", |
| 3190 | arg_state), |
| 3191 | G_DBUS_CALL_FLAGS_NONE, |
| 3192 | -1, |
| 3193 | cancellable, |
| 3194 | callback, |
| 3195 | user_data); |
| 3196 | } |
| 3197 | |
| 3198 | /** |
| 3199 | * control_power_call_set_power_state_finish: |
| 3200 | * @proxy: A #ControlPowerProxy. |
| 3201 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_power_call_set_power_state(). |
| 3202 | * @error: Return location for error or %NULL. |
| 3203 | * |
| 3204 | * Finishes an operation started with control_power_call_set_power_state(). |
| 3205 | * |
| 3206 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 3207 | */ |
| 3208 | gboolean |
| 3209 | control_power_call_set_power_state_finish ( |
| 3210 | ControlPower *proxy, |
| 3211 | GAsyncResult *res, |
| 3212 | GError **error) |
| 3213 | { |
| 3214 | GVariant *_ret; |
| 3215 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 3216 | if (_ret == NULL) |
| 3217 | goto _out; |
| 3218 | g_variant_get (_ret, |
| 3219 | "()"); |
| 3220 | g_variant_unref (_ret); |
| 3221 | _out: |
| 3222 | return _ret != NULL; |
| 3223 | } |
| 3224 | |
| 3225 | /** |
| 3226 | * control_power_call_set_power_state_sync: |
| 3227 | * @proxy: A #ControlPowerProxy. |
| 3228 | * @arg_state: Argument to pass with the method invocation. |
| 3229 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3230 | * @error: Return location for error or %NULL. |
| 3231 | * |
| 3232 | * 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. |
| 3233 | * |
| 3234 | * See control_power_call_set_power_state() for the asynchronous version of this method. |
| 3235 | * |
| 3236 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 3237 | */ |
| 3238 | gboolean |
| 3239 | control_power_call_set_power_state_sync ( |
| 3240 | ControlPower *proxy, |
| 3241 | gint arg_state, |
| 3242 | GCancellable *cancellable, |
| 3243 | GError **error) |
| 3244 | { |
| 3245 | GVariant *_ret; |
| 3246 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 3247 | "setPowerState", |
| 3248 | g_variant_new ("(i)", |
| 3249 | arg_state), |
| 3250 | G_DBUS_CALL_FLAGS_NONE, |
| 3251 | -1, |
| 3252 | cancellable, |
| 3253 | error); |
| 3254 | if (_ret == NULL) |
| 3255 | goto _out; |
| 3256 | g_variant_get (_ret, |
| 3257 | "()"); |
| 3258 | g_variant_unref (_ret); |
| 3259 | _out: |
| 3260 | return _ret != NULL; |
| 3261 | } |
| 3262 | |
| 3263 | /** |
| 3264 | * control_power_call_get_power_state: |
| 3265 | * @proxy: A #ControlPowerProxy. |
| 3266 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3267 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. |
| 3268 | * @user_data: User data to pass to @callback. |
| 3269 | * |
| 3270 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-control-Power.getPowerState">getPowerState()</link> D-Bus method on @proxy. |
| 3271 | * 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. |
| 3272 | * You can then call control_power_call_get_power_state_finish() to get the result of the operation. |
| 3273 | * |
| 3274 | * See control_power_call_get_power_state_sync() for the synchronous, blocking version of this method. |
| 3275 | */ |
| 3276 | void |
| 3277 | control_power_call_get_power_state ( |
| 3278 | ControlPower *proxy, |
| 3279 | GCancellable *cancellable, |
| 3280 | GAsyncReadyCallback callback, |
| 3281 | gpointer user_data) |
| 3282 | { |
| 3283 | g_dbus_proxy_call (G_DBUS_PROXY (proxy), |
| 3284 | "getPowerState", |
| 3285 | g_variant_new ("()"), |
| 3286 | G_DBUS_CALL_FLAGS_NONE, |
| 3287 | -1, |
| 3288 | cancellable, |
| 3289 | callback, |
| 3290 | user_data); |
| 3291 | } |
| 3292 | |
| 3293 | /** |
| 3294 | * control_power_call_get_power_state_finish: |
| 3295 | * @proxy: A #ControlPowerProxy. |
| 3296 | * @out_state: (out): Return location for return parameter or %NULL to ignore. |
| 3297 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_power_call_get_power_state(). |
| 3298 | * @error: Return location for error or %NULL. |
| 3299 | * |
| 3300 | * Finishes an operation started with control_power_call_get_power_state(). |
| 3301 | * |
| 3302 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 3303 | */ |
| 3304 | gboolean |
| 3305 | control_power_call_get_power_state_finish ( |
| 3306 | ControlPower *proxy, |
| 3307 | gint *out_state, |
| 3308 | GAsyncResult *res, |
| 3309 | GError **error) |
| 3310 | { |
| 3311 | GVariant *_ret; |
| 3312 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); |
| 3313 | if (_ret == NULL) |
| 3314 | goto _out; |
| 3315 | g_variant_get (_ret, |
| 3316 | "(i)", |
| 3317 | out_state); |
| 3318 | g_variant_unref (_ret); |
| 3319 | _out: |
| 3320 | return _ret != NULL; |
| 3321 | } |
| 3322 | |
| 3323 | /** |
| 3324 | * control_power_call_get_power_state_sync: |
| 3325 | * @proxy: A #ControlPowerProxy. |
| 3326 | * @out_state: (out): Return location for return parameter or %NULL to ignore. |
| 3327 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3328 | * @error: Return location for error or %NULL. |
| 3329 | * |
| 3330 | * 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. |
| 3331 | * |
| 3332 | * See control_power_call_get_power_state() for the asynchronous version of this method. |
| 3333 | * |
| 3334 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. |
| 3335 | */ |
| 3336 | gboolean |
| 3337 | control_power_call_get_power_state_sync ( |
| 3338 | ControlPower *proxy, |
| 3339 | gint *out_state, |
| 3340 | GCancellable *cancellable, |
| 3341 | GError **error) |
| 3342 | { |
| 3343 | GVariant *_ret; |
| 3344 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), |
| 3345 | "getPowerState", |
| 3346 | g_variant_new ("()"), |
| 3347 | G_DBUS_CALL_FLAGS_NONE, |
| 3348 | -1, |
| 3349 | cancellable, |
| 3350 | error); |
| 3351 | if (_ret == NULL) |
| 3352 | goto _out; |
| 3353 | g_variant_get (_ret, |
| 3354 | "(i)", |
| 3355 | out_state); |
| 3356 | g_variant_unref (_ret); |
| 3357 | _out: |
| 3358 | return _ret != NULL; |
| 3359 | } |
| 3360 | |
| 3361 | /** |
| 3362 | * control_power_complete_set_power_state: |
| 3363 | * @object: A #ControlPower. |
| 3364 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 3365 | * |
| 3366 | * 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. |
| 3367 | * |
| 3368 | * This method will free @invocation, you cannot use it afterwards. |
| 3369 | */ |
| 3370 | void |
| 3371 | control_power_complete_set_power_state ( |
| 3372 | ControlPower *object, |
| 3373 | GDBusMethodInvocation *invocation) |
| 3374 | { |
| 3375 | g_dbus_method_invocation_return_value (invocation, |
| 3376 | g_variant_new ("()")); |
| 3377 | } |
| 3378 | |
| 3379 | /** |
| 3380 | * control_power_complete_get_power_state: |
| 3381 | * @object: A #ControlPower. |
| 3382 | * @invocation: (transfer full): A #GDBusMethodInvocation. |
| 3383 | * @state: Parameter to return. |
| 3384 | * |
| 3385 | * 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. |
| 3386 | * |
| 3387 | * This method will free @invocation, you cannot use it afterwards. |
| 3388 | */ |
| 3389 | void |
| 3390 | control_power_complete_get_power_state ( |
| 3391 | ControlPower *object, |
| 3392 | GDBusMethodInvocation *invocation, |
| 3393 | gint state) |
| 3394 | { |
| 3395 | g_dbus_method_invocation_return_value (invocation, |
| 3396 | g_variant_new ("(i)", |
| 3397 | state)); |
| 3398 | } |
| 3399 | |
| 3400 | /* ------------------------------------------------------------------------ */ |
| 3401 | |
| 3402 | /** |
| 3403 | * ControlPowerProxy: |
| 3404 | * |
| 3405 | * The #ControlPowerProxy structure contains only private data and should only be accessed using the provided API. |
| 3406 | */ |
| 3407 | |
| 3408 | /** |
| 3409 | * ControlPowerProxyClass: |
| 3410 | * @parent_class: The parent class. |
| 3411 | * |
| 3412 | * Class structure for #ControlPowerProxy. |
| 3413 | */ |
| 3414 | |
| 3415 | struct _ControlPowerProxyPrivate |
| 3416 | { |
| 3417 | GData *qdata; |
| 3418 | }; |
| 3419 | |
| 3420 | static void control_power_proxy_iface_init (ControlPowerIface *iface); |
| 3421 | |
| 3422 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 3423 | G_DEFINE_TYPE_WITH_CODE (ControlPowerProxy, control_power_proxy, G_TYPE_DBUS_PROXY, |
| 3424 | G_ADD_PRIVATE (ControlPowerProxy) |
| 3425 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_POWER, control_power_proxy_iface_init)); |
| 3426 | |
| 3427 | #else |
| 3428 | G_DEFINE_TYPE_WITH_CODE (ControlPowerProxy, control_power_proxy, G_TYPE_DBUS_PROXY, |
| 3429 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_POWER, control_power_proxy_iface_init)); |
| 3430 | |
| 3431 | #endif |
| 3432 | static void |
| 3433 | control_power_proxy_finalize (GObject *object) |
| 3434 | { |
| 3435 | ControlPowerProxy *proxy = CONTROL_POWER_PROXY (object); |
| 3436 | g_datalist_clear (&proxy->priv->qdata); |
| 3437 | G_OBJECT_CLASS (control_power_proxy_parent_class)->finalize (object); |
| 3438 | } |
| 3439 | |
| 3440 | static void |
| 3441 | control_power_proxy_get_property (GObject *object, |
| 3442 | guint prop_id, |
| 3443 | GValue *value, |
| 3444 | GParamSpec *pspec G_GNUC_UNUSED) |
| 3445 | { |
| 3446 | const _ExtendedGDBusPropertyInfo *info; |
| 3447 | GVariant *variant; |
| 3448 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 3449 | info = _control_power_property_info_pointers[prop_id - 1]; |
| 3450 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name); |
| 3451 | if (info->use_gvariant) |
| 3452 | { |
| 3453 | g_value_set_variant (value, variant); |
| 3454 | } |
| 3455 | else |
| 3456 | { |
| 3457 | if (variant != NULL) |
| 3458 | g_dbus_gvariant_to_gvalue (variant, value); |
| 3459 | } |
| 3460 | if (variant != NULL) |
| 3461 | g_variant_unref (variant); |
| 3462 | } |
| 3463 | |
| 3464 | static void |
| 3465 | control_power_proxy_set_property_cb (GDBusProxy *proxy, |
| 3466 | GAsyncResult *res, |
| 3467 | gpointer user_data) |
| 3468 | { |
| 3469 | const _ExtendedGDBusPropertyInfo *info = user_data; |
| 3470 | GError *error; |
| 3471 | GVariant *_ret; |
| 3472 | error = NULL; |
| 3473 | _ret = g_dbus_proxy_call_finish (proxy, res, &error); |
| 3474 | if (!_ret) |
| 3475 | { |
| 3476 | g_warning ("Error setting property '%s' on interface org.openbmc.control.Power: %s (%s, %d)", |
| 3477 | info->parent_struct.name, |
| 3478 | error->message, g_quark_to_string (error->domain), error->code); |
| 3479 | g_error_free (error); |
| 3480 | } |
| 3481 | else |
| 3482 | { |
| 3483 | g_variant_unref (_ret); |
| 3484 | } |
| 3485 | } |
| 3486 | |
| 3487 | static void |
| 3488 | control_power_proxy_set_property (GObject *object, |
| 3489 | guint prop_id, |
| 3490 | const GValue *value, |
| 3491 | GParamSpec *pspec G_GNUC_UNUSED) |
| 3492 | { |
| 3493 | const _ExtendedGDBusPropertyInfo *info; |
| 3494 | GVariant *variant; |
| 3495 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 3496 | info = _control_power_property_info_pointers[prop_id - 1]; |
| 3497 | variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 3498 | g_dbus_proxy_call (G_DBUS_PROXY (object), |
| 3499 | "org.freedesktop.DBus.Properties.Set", |
| 3500 | g_variant_new ("(ssv)", "org.openbmc.control.Power", info->parent_struct.name, variant), |
| 3501 | G_DBUS_CALL_FLAGS_NONE, |
| 3502 | -1, |
| 3503 | NULL, (GAsyncReadyCallback) control_power_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct); |
| 3504 | g_variant_unref (variant); |
| 3505 | } |
| 3506 | |
| 3507 | static void |
| 3508 | control_power_proxy_g_signal (GDBusProxy *proxy, |
| 3509 | const gchar *sender_name G_GNUC_UNUSED, |
| 3510 | const gchar *signal_name, |
| 3511 | GVariant *parameters) |
| 3512 | { |
| 3513 | _ExtendedGDBusSignalInfo *info; |
| 3514 | GVariantIter iter; |
| 3515 | GVariant *child; |
| 3516 | GValue *paramv; |
| 3517 | guint num_params; |
| 3518 | guint n; |
| 3519 | guint signal_id; |
| 3520 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct, signal_name); |
| 3521 | if (info == NULL) |
| 3522 | return; |
| 3523 | num_params = g_variant_n_children (parameters); |
| 3524 | paramv = g_new0 (GValue, num_params + 1); |
| 3525 | g_value_init (¶mv[0], TYPE_CONTROL_POWER); |
| 3526 | g_value_set_object (¶mv[0], proxy); |
| 3527 | g_variant_iter_init (&iter, parameters); |
| 3528 | n = 1; |
| 3529 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 3530 | { |
| 3531 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; |
| 3532 | if (arg_info->use_gvariant) |
| 3533 | { |
| 3534 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 3535 | g_value_set_variant (¶mv[n], child); |
| 3536 | n++; |
| 3537 | } |
| 3538 | else |
| 3539 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 3540 | g_variant_unref (child); |
| 3541 | } |
| 3542 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL_POWER); |
| 3543 | g_signal_emitv (paramv, signal_id, 0, NULL); |
| 3544 | for (n = 0; n < num_params + 1; n++) |
| 3545 | g_value_unset (¶mv[n]); |
| 3546 | g_free (paramv); |
| 3547 | } |
| 3548 | |
| 3549 | static void |
| 3550 | control_power_proxy_g_properties_changed (GDBusProxy *_proxy, |
| 3551 | GVariant *changed_properties, |
| 3552 | const gchar *const *invalidated_properties) |
| 3553 | { |
| 3554 | ControlPowerProxy *proxy = CONTROL_POWER_PROXY (_proxy); |
| 3555 | guint n; |
| 3556 | const gchar *key; |
| 3557 | GVariantIter *iter; |
| 3558 | _ExtendedGDBusPropertyInfo *info; |
| 3559 | g_variant_get (changed_properties, "a{sv}", &iter); |
| 3560 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) |
| 3561 | { |
| 3562 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct, key); |
| 3563 | g_datalist_remove_data (&proxy->priv->qdata, key); |
| 3564 | if (info != NULL) |
| 3565 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 3566 | } |
| 3567 | g_variant_iter_free (iter); |
| 3568 | for (n = 0; invalidated_properties[n] != NULL; n++) |
| 3569 | { |
| 3570 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct, invalidated_properties[n]); |
| 3571 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); |
| 3572 | if (info != NULL) |
| 3573 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | static gint |
| 3578 | control_power_proxy_get_pgood (ControlPower *object) |
| 3579 | { |
| 3580 | ControlPowerProxy *proxy = CONTROL_POWER_PROXY (object); |
| 3581 | GVariant *variant; |
| 3582 | gint value = 0; |
| 3583 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "pgood"); |
| 3584 | if (variant != NULL) |
| 3585 | { |
| 3586 | value = g_variant_get_int32 (variant); |
| 3587 | g_variant_unref (variant); |
| 3588 | } |
| 3589 | return value; |
| 3590 | } |
| 3591 | |
| 3592 | static gint |
| 3593 | control_power_proxy_get_state (ControlPower *object) |
| 3594 | { |
| 3595 | ControlPowerProxy *proxy = CONTROL_POWER_PROXY (object); |
| 3596 | GVariant *variant; |
| 3597 | gint value = 0; |
| 3598 | variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "state"); |
| 3599 | if (variant != NULL) |
| 3600 | { |
| 3601 | value = g_variant_get_int32 (variant); |
| 3602 | g_variant_unref (variant); |
| 3603 | } |
| 3604 | return value; |
| 3605 | } |
| 3606 | |
| 3607 | static void |
| 3608 | control_power_proxy_init (ControlPowerProxy *proxy) |
| 3609 | { |
| 3610 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 3611 | proxy->priv = control_power_proxy_get_instance_private (proxy); |
| 3612 | #else |
| 3613 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_CONTROL_POWER_PROXY, ControlPowerProxyPrivate); |
| 3614 | #endif |
| 3615 | |
| 3616 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), control_power_interface_info ()); |
| 3617 | } |
| 3618 | |
| 3619 | static void |
| 3620 | control_power_proxy_class_init (ControlPowerProxyClass *klass) |
| 3621 | { |
| 3622 | GObjectClass *gobject_class; |
| 3623 | GDBusProxyClass *proxy_class; |
| 3624 | |
| 3625 | gobject_class = G_OBJECT_CLASS (klass); |
| 3626 | gobject_class->finalize = control_power_proxy_finalize; |
| 3627 | gobject_class->get_property = control_power_proxy_get_property; |
| 3628 | gobject_class->set_property = control_power_proxy_set_property; |
| 3629 | |
| 3630 | proxy_class = G_DBUS_PROXY_CLASS (klass); |
| 3631 | proxy_class->g_signal = control_power_proxy_g_signal; |
| 3632 | proxy_class->g_properties_changed = control_power_proxy_g_properties_changed; |
| 3633 | |
| 3634 | control_power_override_properties (gobject_class, 1); |
| 3635 | |
| 3636 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 3637 | g_type_class_add_private (klass, sizeof (ControlPowerProxyPrivate)); |
| 3638 | #endif |
| 3639 | } |
| 3640 | |
| 3641 | static void |
| 3642 | control_power_proxy_iface_init (ControlPowerIface *iface) |
| 3643 | { |
| 3644 | iface->get_pgood = control_power_proxy_get_pgood; |
| 3645 | iface->get_state = control_power_proxy_get_state; |
| 3646 | } |
| 3647 | |
| 3648 | /** |
| 3649 | * control_power_proxy_new: |
| 3650 | * @connection: A #GDBusConnection. |
| 3651 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 3652 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 3653 | * @object_path: An object path. |
| 3654 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3655 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 3656 | * @user_data: User data to pass to @callback. |
| 3657 | * |
| 3658 | * 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. |
| 3659 | * |
| 3660 | * 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. |
| 3661 | * You can then call control_power_proxy_new_finish() to get the result of the operation. |
| 3662 | * |
| 3663 | * See control_power_proxy_new_sync() for the synchronous, blocking version of this constructor. |
| 3664 | */ |
| 3665 | void |
| 3666 | control_power_proxy_new ( |
| 3667 | GDBusConnection *connection, |
| 3668 | GDBusProxyFlags flags, |
| 3669 | const gchar *name, |
| 3670 | const gchar *object_path, |
| 3671 | GCancellable *cancellable, |
| 3672 | GAsyncReadyCallback callback, |
| 3673 | gpointer user_data) |
| 3674 | { |
| 3675 | 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); |
| 3676 | } |
| 3677 | |
| 3678 | /** |
| 3679 | * control_power_proxy_new_finish: |
| 3680 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_power_proxy_new(). |
| 3681 | * @error: Return location for error or %NULL |
| 3682 | * |
| 3683 | * Finishes an operation started with control_power_proxy_new(). |
| 3684 | * |
| 3685 | * Returns: (transfer full) (type ControlPowerProxy): The constructed proxy object or %NULL if @error is set. |
| 3686 | */ |
| 3687 | ControlPower * |
| 3688 | control_power_proxy_new_finish ( |
| 3689 | GAsyncResult *res, |
| 3690 | GError **error) |
| 3691 | { |
| 3692 | GObject *ret; |
| 3693 | GObject *source_object; |
| 3694 | source_object = g_async_result_get_source_object (res); |
| 3695 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 3696 | g_object_unref (source_object); |
| 3697 | if (ret != NULL) |
| 3698 | return CONTROL_POWER (ret); |
| 3699 | else |
| 3700 | return NULL; |
| 3701 | } |
| 3702 | |
| 3703 | /** |
| 3704 | * control_power_proxy_new_sync: |
| 3705 | * @connection: A #GDBusConnection. |
| 3706 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 3707 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 3708 | * @object_path: An object path. |
| 3709 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3710 | * @error: Return location for error or %NULL |
| 3711 | * |
| 3712 | * 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. |
| 3713 | * |
| 3714 | * The calling thread is blocked until a reply is received. |
| 3715 | * |
| 3716 | * See control_power_proxy_new() for the asynchronous version of this constructor. |
| 3717 | * |
| 3718 | * Returns: (transfer full) (type ControlPowerProxy): The constructed proxy object or %NULL if @error is set. |
| 3719 | */ |
| 3720 | ControlPower * |
| 3721 | control_power_proxy_new_sync ( |
| 3722 | GDBusConnection *connection, |
| 3723 | GDBusProxyFlags flags, |
| 3724 | const gchar *name, |
| 3725 | const gchar *object_path, |
| 3726 | GCancellable *cancellable, |
| 3727 | GError **error) |
| 3728 | { |
| 3729 | GInitable *ret; |
| 3730 | 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); |
| 3731 | if (ret != NULL) |
| 3732 | return CONTROL_POWER (ret); |
| 3733 | else |
| 3734 | return NULL; |
| 3735 | } |
| 3736 | |
| 3737 | |
| 3738 | /** |
| 3739 | * control_power_proxy_new_for_bus: |
| 3740 | * @bus_type: A #GBusType. |
| 3741 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 3742 | * @name: A bus name (well-known or unique). |
| 3743 | * @object_path: An object path. |
| 3744 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3745 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 3746 | * @user_data: User data to pass to @callback. |
| 3747 | * |
| 3748 | * Like control_power_proxy_new() but takes a #GBusType instead of a #GDBusConnection. |
| 3749 | * |
| 3750 | * 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. |
| 3751 | * You can then call control_power_proxy_new_for_bus_finish() to get the result of the operation. |
| 3752 | * |
| 3753 | * See control_power_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. |
| 3754 | */ |
| 3755 | void |
| 3756 | control_power_proxy_new_for_bus ( |
| 3757 | GBusType bus_type, |
| 3758 | GDBusProxyFlags flags, |
| 3759 | const gchar *name, |
| 3760 | const gchar *object_path, |
| 3761 | GCancellable *cancellable, |
| 3762 | GAsyncReadyCallback callback, |
| 3763 | gpointer user_data) |
| 3764 | { |
| 3765 | 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); |
| 3766 | } |
| 3767 | |
| 3768 | /** |
| 3769 | * control_power_proxy_new_for_bus_finish: |
| 3770 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to control_power_proxy_new_for_bus(). |
| 3771 | * @error: Return location for error or %NULL |
| 3772 | * |
| 3773 | * Finishes an operation started with control_power_proxy_new_for_bus(). |
| 3774 | * |
| 3775 | * Returns: (transfer full) (type ControlPowerProxy): The constructed proxy object or %NULL if @error is set. |
| 3776 | */ |
| 3777 | ControlPower * |
| 3778 | control_power_proxy_new_for_bus_finish ( |
| 3779 | GAsyncResult *res, |
| 3780 | GError **error) |
| 3781 | { |
| 3782 | GObject *ret; |
| 3783 | GObject *source_object; |
| 3784 | source_object = g_async_result_get_source_object (res); |
| 3785 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 3786 | g_object_unref (source_object); |
| 3787 | if (ret != NULL) |
| 3788 | return CONTROL_POWER (ret); |
| 3789 | else |
| 3790 | return NULL; |
| 3791 | } |
| 3792 | |
| 3793 | /** |
| 3794 | * control_power_proxy_new_for_bus_sync: |
| 3795 | * @bus_type: A #GBusType. |
| 3796 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 3797 | * @name: A bus name (well-known or unique). |
| 3798 | * @object_path: An object path. |
| 3799 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 3800 | * @error: Return location for error or %NULL |
| 3801 | * |
| 3802 | * Like control_power_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. |
| 3803 | * |
| 3804 | * The calling thread is blocked until a reply is received. |
| 3805 | * |
| 3806 | * See control_power_proxy_new_for_bus() for the asynchronous version of this constructor. |
| 3807 | * |
| 3808 | * Returns: (transfer full) (type ControlPowerProxy): The constructed proxy object or %NULL if @error is set. |
| 3809 | */ |
| 3810 | ControlPower * |
| 3811 | control_power_proxy_new_for_bus_sync ( |
| 3812 | GBusType bus_type, |
| 3813 | GDBusProxyFlags flags, |
| 3814 | const gchar *name, |
| 3815 | const gchar *object_path, |
| 3816 | GCancellable *cancellable, |
| 3817 | GError **error) |
| 3818 | { |
| 3819 | GInitable *ret; |
| 3820 | 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); |
| 3821 | if (ret != NULL) |
| 3822 | return CONTROL_POWER (ret); |
| 3823 | else |
| 3824 | return NULL; |
| 3825 | } |
| 3826 | |
| 3827 | |
| 3828 | /* ------------------------------------------------------------------------ */ |
| 3829 | |
| 3830 | /** |
| 3831 | * ControlPowerSkeleton: |
| 3832 | * |
| 3833 | * The #ControlPowerSkeleton structure contains only private data and should only be accessed using the provided API. |
| 3834 | */ |
| 3835 | |
| 3836 | /** |
| 3837 | * ControlPowerSkeletonClass: |
| 3838 | * @parent_class: The parent class. |
| 3839 | * |
| 3840 | * Class structure for #ControlPowerSkeleton. |
| 3841 | */ |
| 3842 | |
| 3843 | struct _ControlPowerSkeletonPrivate |
| 3844 | { |
| 3845 | GValue *properties; |
| 3846 | GList *changed_properties; |
| 3847 | GSource *changed_properties_idle_source; |
| 3848 | GMainContext *context; |
| 3849 | GMutex lock; |
| 3850 | }; |
| 3851 | |
| 3852 | static void |
| 3853 | _control_power_skeleton_handle_method_call ( |
| 3854 | GDBusConnection *connection G_GNUC_UNUSED, |
| 3855 | const gchar *sender G_GNUC_UNUSED, |
| 3856 | const gchar *object_path G_GNUC_UNUSED, |
| 3857 | const gchar *interface_name, |
| 3858 | const gchar *method_name, |
| 3859 | GVariant *parameters, |
| 3860 | GDBusMethodInvocation *invocation, |
| 3861 | gpointer user_data) |
| 3862 | { |
| 3863 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (user_data); |
| 3864 | _ExtendedGDBusMethodInfo *info; |
| 3865 | GVariantIter iter; |
| 3866 | GVariant *child; |
| 3867 | GValue *paramv; |
| 3868 | guint num_params; |
| 3869 | guint num_extra; |
| 3870 | guint n; |
| 3871 | guint signal_id; |
| 3872 | GValue return_value = G_VALUE_INIT; |
| 3873 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); |
| 3874 | g_assert (info != NULL); |
| 3875 | num_params = g_variant_n_children (parameters); |
| 3876 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); |
| 3877 | n = 0; |
| 3878 | g_value_init (¶mv[n], TYPE_CONTROL_POWER); |
| 3879 | g_value_set_object (¶mv[n++], skeleton); |
| 3880 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); |
| 3881 | g_value_set_object (¶mv[n++], invocation); |
| 3882 | if (info->pass_fdlist) |
| 3883 | { |
| 3884 | #ifdef G_OS_UNIX |
| 3885 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); |
| 3886 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); |
| 3887 | #else |
| 3888 | g_assert_not_reached (); |
| 3889 | #endif |
| 3890 | } |
| 3891 | g_variant_iter_init (&iter, parameters); |
| 3892 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 3893 | { |
| 3894 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; |
| 3895 | if (arg_info->use_gvariant) |
| 3896 | { |
| 3897 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 3898 | g_value_set_variant (¶mv[n], child); |
| 3899 | n++; |
| 3900 | } |
| 3901 | else |
| 3902 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 3903 | g_variant_unref (child); |
| 3904 | } |
| 3905 | signal_id = g_signal_lookup (info->signal_name, TYPE_CONTROL_POWER); |
| 3906 | g_value_init (&return_value, G_TYPE_BOOLEAN); |
| 3907 | g_signal_emitv (paramv, signal_id, 0, &return_value); |
| 3908 | if (!g_value_get_boolean (&return_value)) |
| 3909 | 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); |
| 3910 | g_value_unset (&return_value); |
| 3911 | for (n = 0; n < num_params + num_extra; n++) |
| 3912 | g_value_unset (¶mv[n]); |
| 3913 | g_free (paramv); |
| 3914 | } |
| 3915 | |
| 3916 | static GVariant * |
| 3917 | _control_power_skeleton_handle_get_property ( |
| 3918 | GDBusConnection *connection G_GNUC_UNUSED, |
| 3919 | const gchar *sender G_GNUC_UNUSED, |
| 3920 | const gchar *object_path G_GNUC_UNUSED, |
| 3921 | const gchar *interface_name G_GNUC_UNUSED, |
| 3922 | const gchar *property_name, |
| 3923 | GError **error, |
| 3924 | gpointer user_data) |
| 3925 | { |
| 3926 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (user_data); |
| 3927 | GValue value = G_VALUE_INIT; |
| 3928 | GParamSpec *pspec; |
| 3929 | _ExtendedGDBusPropertyInfo *info; |
| 3930 | GVariant *ret; |
| 3931 | ret = NULL; |
| 3932 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct, property_name); |
| 3933 | g_assert (info != NULL); |
| 3934 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 3935 | if (pspec == NULL) |
| 3936 | { |
| 3937 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 3938 | } |
| 3939 | else |
| 3940 | { |
| 3941 | g_value_init (&value, pspec->value_type); |
| 3942 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 3943 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 3944 | g_value_unset (&value); |
| 3945 | } |
| 3946 | return ret; |
| 3947 | } |
| 3948 | |
| 3949 | static gboolean |
| 3950 | _control_power_skeleton_handle_set_property ( |
| 3951 | GDBusConnection *connection G_GNUC_UNUSED, |
| 3952 | const gchar *sender G_GNUC_UNUSED, |
| 3953 | const gchar *object_path G_GNUC_UNUSED, |
| 3954 | const gchar *interface_name G_GNUC_UNUSED, |
| 3955 | const gchar *property_name, |
| 3956 | GVariant *variant, |
| 3957 | GError **error, |
| 3958 | gpointer user_data) |
| 3959 | { |
| 3960 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (user_data); |
| 3961 | GValue value = G_VALUE_INIT; |
| 3962 | GParamSpec *pspec; |
| 3963 | _ExtendedGDBusPropertyInfo *info; |
| 3964 | gboolean ret; |
| 3965 | ret = FALSE; |
| 3966 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_control_power_interface_info.parent_struct, property_name); |
| 3967 | g_assert (info != NULL); |
| 3968 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 3969 | if (pspec == NULL) |
| 3970 | { |
| 3971 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 3972 | } |
| 3973 | else |
| 3974 | { |
| 3975 | if (info->use_gvariant) |
| 3976 | g_value_set_variant (&value, variant); |
| 3977 | else |
| 3978 | g_dbus_gvariant_to_gvalue (variant, &value); |
| 3979 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 3980 | g_value_unset (&value); |
| 3981 | ret = TRUE; |
| 3982 | } |
| 3983 | return ret; |
| 3984 | } |
| 3985 | |
| 3986 | static const GDBusInterfaceVTable _control_power_skeleton_vtable = |
| 3987 | { |
| 3988 | _control_power_skeleton_handle_method_call, |
| 3989 | _control_power_skeleton_handle_get_property, |
| 3990 | _control_power_skeleton_handle_set_property, |
| 3991 | {NULL} |
| 3992 | }; |
| 3993 | |
| 3994 | static GDBusInterfaceInfo * |
| 3995 | control_power_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 3996 | { |
| 3997 | return control_power_interface_info (); |
| 3998 | } |
| 3999 | |
| 4000 | static GDBusInterfaceVTable * |
| 4001 | control_power_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 4002 | { |
| 4003 | return (GDBusInterfaceVTable *) &_control_power_skeleton_vtable; |
| 4004 | } |
| 4005 | |
| 4006 | static GVariant * |
| 4007 | control_power_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) |
| 4008 | { |
| 4009 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (_skeleton); |
| 4010 | |
| 4011 | GVariantBuilder builder; |
| 4012 | guint n; |
| 4013 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 4014 | if (_control_power_interface_info.parent_struct.properties == NULL) |
| 4015 | goto out; |
| 4016 | for (n = 0; _control_power_interface_info.parent_struct.properties[n] != NULL; n++) |
| 4017 | { |
| 4018 | GDBusPropertyInfo *info = _control_power_interface_info.parent_struct.properties[n]; |
| 4019 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) |
| 4020 | { |
| 4021 | GVariant *value; |
| 4022 | 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); |
| 4023 | if (value != NULL) |
| 4024 | { |
| 4025 | g_variant_take_ref (value); |
| 4026 | g_variant_builder_add (&builder, "{sv}", info->name, value); |
| 4027 | g_variant_unref (value); |
| 4028 | } |
| 4029 | } |
| 4030 | } |
| 4031 | out: |
| 4032 | return g_variant_builder_end (&builder); |
| 4033 | } |
| 4034 | |
| 4035 | static gboolean _control_power_emit_changed (gpointer user_data); |
| 4036 | |
| 4037 | static void |
| 4038 | control_power_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) |
| 4039 | { |
| 4040 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (_skeleton); |
| 4041 | gboolean emit_changed = FALSE; |
| 4042 | |
| 4043 | g_mutex_lock (&skeleton->priv->lock); |
| 4044 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 4045 | { |
| 4046 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 4047 | skeleton->priv->changed_properties_idle_source = NULL; |
| 4048 | emit_changed = TRUE; |
| 4049 | } |
| 4050 | g_mutex_unlock (&skeleton->priv->lock); |
| 4051 | |
| 4052 | if (emit_changed) |
| 4053 | _control_power_emit_changed (skeleton); |
| 4054 | } |
| 4055 | |
| 4056 | static void |
| 4057 | _control_power_on_signal_power_good ( |
| 4058 | ControlPower *object) |
| 4059 | { |
| 4060 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4061 | |
| 4062 | GList *connections, *l; |
| 4063 | GVariant *signal_variant; |
| 4064 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 4065 | |
| 4066 | signal_variant = g_variant_ref_sink (g_variant_new ("()")); |
| 4067 | for (l = connections; l != NULL; l = l->next) |
| 4068 | { |
| 4069 | GDBusConnection *connection = l->data; |
| 4070 | g_dbus_connection_emit_signal (connection, |
| 4071 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.control.Power", "PowerGood", |
| 4072 | signal_variant, NULL); |
| 4073 | } |
| 4074 | g_variant_unref (signal_variant); |
| 4075 | g_list_free_full (connections, g_object_unref); |
| 4076 | } |
| 4077 | |
| 4078 | static void |
| 4079 | _control_power_on_signal_power_lost ( |
| 4080 | ControlPower *object) |
| 4081 | { |
| 4082 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4083 | |
| 4084 | GList *connections, *l; |
| 4085 | GVariant *signal_variant; |
| 4086 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 4087 | |
| 4088 | signal_variant = g_variant_ref_sink (g_variant_new ("()")); |
| 4089 | for (l = connections; l != NULL; l = l->next) |
| 4090 | { |
| 4091 | GDBusConnection *connection = l->data; |
| 4092 | g_dbus_connection_emit_signal (connection, |
| 4093 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.control.Power", "PowerLost", |
| 4094 | signal_variant, NULL); |
| 4095 | } |
| 4096 | g_variant_unref (signal_variant); |
| 4097 | g_list_free_full (connections, g_object_unref); |
| 4098 | } |
| 4099 | |
| 4100 | static void control_power_skeleton_iface_init (ControlPowerIface *iface); |
| 4101 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 4102 | G_DEFINE_TYPE_WITH_CODE (ControlPowerSkeleton, control_power_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 4103 | G_ADD_PRIVATE (ControlPowerSkeleton) |
| 4104 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_POWER, control_power_skeleton_iface_init)); |
| 4105 | |
| 4106 | #else |
| 4107 | G_DEFINE_TYPE_WITH_CODE (ControlPowerSkeleton, control_power_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 4108 | G_IMPLEMENT_INTERFACE (TYPE_CONTROL_POWER, control_power_skeleton_iface_init)); |
| 4109 | |
| 4110 | #endif |
| 4111 | static void |
| 4112 | control_power_skeleton_finalize (GObject *object) |
| 4113 | { |
| 4114 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4115 | guint n; |
| 4116 | for (n = 0; n < 2; n++) |
| 4117 | g_value_unset (&skeleton->priv->properties[n]); |
| 4118 | g_free (skeleton->priv->properties); |
| 4119 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 4120 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 4121 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 4122 | g_main_context_unref (skeleton->priv->context); |
| 4123 | g_mutex_clear (&skeleton->priv->lock); |
| 4124 | G_OBJECT_CLASS (control_power_skeleton_parent_class)->finalize (object); |
| 4125 | } |
| 4126 | |
| 4127 | static void |
| 4128 | control_power_skeleton_get_property (GObject *object, |
| 4129 | guint prop_id, |
| 4130 | GValue *value, |
| 4131 | GParamSpec *pspec G_GNUC_UNUSED) |
| 4132 | { |
| 4133 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4134 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 4135 | g_mutex_lock (&skeleton->priv->lock); |
| 4136 | g_value_copy (&skeleton->priv->properties[prop_id - 1], value); |
| 4137 | g_mutex_unlock (&skeleton->priv->lock); |
| 4138 | } |
| 4139 | |
| 4140 | static gboolean |
| 4141 | _control_power_emit_changed (gpointer user_data) |
| 4142 | { |
| 4143 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (user_data); |
| 4144 | GList *l; |
| 4145 | GVariantBuilder builder; |
| 4146 | GVariantBuilder invalidated_builder; |
| 4147 | guint num_changes; |
| 4148 | |
| 4149 | g_mutex_lock (&skeleton->priv->lock); |
| 4150 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 4151 | g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")); |
| 4152 | for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next) |
| 4153 | { |
| 4154 | ChangedProperty *cp = l->data; |
| 4155 | GVariant *variant; |
| 4156 | const GValue *cur_value; |
| 4157 | |
| 4158 | cur_value = &skeleton->priv->properties[cp->prop_id - 1]; |
| 4159 | if (!_g_value_equal (cur_value, &cp->orig_value)) |
| 4160 | { |
| 4161 | variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature)); |
| 4162 | g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant); |
| 4163 | g_variant_unref (variant); |
| 4164 | num_changes++; |
| 4165 | } |
| 4166 | } |
| 4167 | if (num_changes > 0) |
| 4168 | { |
| 4169 | GList *connections, *ll; |
| 4170 | GVariant *signal_variant; |
| 4171 | signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.control.Power", |
| 4172 | &builder, &invalidated_builder)); |
| 4173 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 4174 | for (ll = connections; ll != NULL; ll = ll->next) |
| 4175 | { |
| 4176 | GDBusConnection *connection = ll->data; |
| 4177 | |
| 4178 | g_dbus_connection_emit_signal (connection, |
| 4179 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), |
| 4180 | "org.freedesktop.DBus.Properties", |
| 4181 | "PropertiesChanged", |
| 4182 | signal_variant, |
| 4183 | NULL); |
| 4184 | } |
| 4185 | g_variant_unref (signal_variant); |
| 4186 | g_list_free_full (connections, g_object_unref); |
| 4187 | } |
| 4188 | else |
| 4189 | { |
| 4190 | g_variant_builder_clear (&builder); |
| 4191 | g_variant_builder_clear (&invalidated_builder); |
| 4192 | } |
| 4193 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 4194 | skeleton->priv->changed_properties = NULL; |
| 4195 | skeleton->priv->changed_properties_idle_source = NULL; |
| 4196 | g_mutex_unlock (&skeleton->priv->lock); |
| 4197 | return FALSE; |
| 4198 | } |
| 4199 | |
| 4200 | static void |
| 4201 | _control_power_schedule_emit_changed (ControlPowerSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value) |
| 4202 | { |
| 4203 | ChangedProperty *cp; |
| 4204 | GList *l; |
| 4205 | cp = NULL; |
| 4206 | for (l = skeleton->priv->changed_properties; l != NULL; l = l->next) |
| 4207 | { |
| 4208 | ChangedProperty *i_cp = l->data; |
| 4209 | if (i_cp->info == info) |
| 4210 | { |
| 4211 | cp = i_cp; |
| 4212 | break; |
| 4213 | } |
| 4214 | } |
| 4215 | if (cp == NULL) |
| 4216 | { |
| 4217 | cp = g_new0 (ChangedProperty, 1); |
| 4218 | cp->prop_id = prop_id; |
| 4219 | cp->info = info; |
| 4220 | skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp); |
| 4221 | g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value)); |
| 4222 | g_value_copy (orig_value, &cp->orig_value); |
| 4223 | } |
| 4224 | } |
| 4225 | |
| 4226 | static void |
| 4227 | control_power_skeleton_notify (GObject *object, |
| 4228 | GParamSpec *pspec G_GNUC_UNUSED) |
| 4229 | { |
| 4230 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4231 | g_mutex_lock (&skeleton->priv->lock); |
| 4232 | if (skeleton->priv->changed_properties != NULL && |
| 4233 | skeleton->priv->changed_properties_idle_source == NULL) |
| 4234 | { |
| 4235 | skeleton->priv->changed_properties_idle_source = g_idle_source_new (); |
| 4236 | g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT); |
| 4237 | g_source_set_callback (skeleton->priv->changed_properties_idle_source, _control_power_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref); |
| 4238 | g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context); |
| 4239 | g_source_unref (skeleton->priv->changed_properties_idle_source); |
| 4240 | } |
| 4241 | g_mutex_unlock (&skeleton->priv->lock); |
| 4242 | } |
| 4243 | |
| 4244 | static void |
| 4245 | control_power_skeleton_set_property (GObject *object, |
| 4246 | guint prop_id, |
| 4247 | const GValue *value, |
| 4248 | GParamSpec *pspec) |
| 4249 | { |
| 4250 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4251 | g_assert (prop_id != 0 && prop_id - 1 < 2); |
| 4252 | g_mutex_lock (&skeleton->priv->lock); |
| 4253 | g_object_freeze_notify (object); |
| 4254 | if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1])) |
| 4255 | { |
| 4256 | if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL) |
| 4257 | _control_power_schedule_emit_changed (skeleton, _control_power_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]); |
| 4258 | g_value_copy (value, &skeleton->priv->properties[prop_id - 1]); |
| 4259 | g_object_notify_by_pspec (object, pspec); |
| 4260 | } |
| 4261 | g_mutex_unlock (&skeleton->priv->lock); |
| 4262 | g_object_thaw_notify (object); |
| 4263 | } |
| 4264 | |
| 4265 | static void |
| 4266 | control_power_skeleton_init (ControlPowerSkeleton *skeleton) |
| 4267 | { |
| 4268 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 4269 | skeleton->priv = control_power_skeleton_get_instance_private (skeleton); |
| 4270 | #else |
| 4271 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_CONTROL_POWER_SKELETON, ControlPowerSkeletonPrivate); |
| 4272 | #endif |
| 4273 | |
| 4274 | g_mutex_init (&skeleton->priv->lock); |
| 4275 | skeleton->priv->context = g_main_context_ref_thread_default (); |
| 4276 | skeleton->priv->properties = g_new0 (GValue, 2); |
| 4277 | g_value_init (&skeleton->priv->properties[0], G_TYPE_INT); |
| 4278 | g_value_init (&skeleton->priv->properties[1], G_TYPE_INT); |
| 4279 | } |
| 4280 | |
| 4281 | static gint |
| 4282 | control_power_skeleton_get_pgood (ControlPower *object) |
| 4283 | { |
| 4284 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4285 | gint value; |
| 4286 | g_mutex_lock (&skeleton->priv->lock); |
| 4287 | value = g_value_get_int (&(skeleton->priv->properties[0])); |
| 4288 | g_mutex_unlock (&skeleton->priv->lock); |
| 4289 | return value; |
| 4290 | } |
| 4291 | |
| 4292 | static gint |
| 4293 | control_power_skeleton_get_state (ControlPower *object) |
| 4294 | { |
| 4295 | ControlPowerSkeleton *skeleton = CONTROL_POWER_SKELETON (object); |
| 4296 | gint value; |
| 4297 | g_mutex_lock (&skeleton->priv->lock); |
| 4298 | value = g_value_get_int (&(skeleton->priv->properties[1])); |
| 4299 | g_mutex_unlock (&skeleton->priv->lock); |
| 4300 | return value; |
| 4301 | } |
| 4302 | |
| 4303 | static void |
| 4304 | control_power_skeleton_class_init (ControlPowerSkeletonClass *klass) |
| 4305 | { |
| 4306 | GObjectClass *gobject_class; |
| 4307 | GDBusInterfaceSkeletonClass *skeleton_class; |
| 4308 | |
| 4309 | gobject_class = G_OBJECT_CLASS (klass); |
| 4310 | gobject_class->finalize = control_power_skeleton_finalize; |
| 4311 | gobject_class->get_property = control_power_skeleton_get_property; |
| 4312 | gobject_class->set_property = control_power_skeleton_set_property; |
| 4313 | gobject_class->notify = control_power_skeleton_notify; |
| 4314 | |
| 4315 | |
| 4316 | control_power_override_properties (gobject_class, 1); |
| 4317 | |
| 4318 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); |
| 4319 | skeleton_class->get_info = control_power_skeleton_dbus_interface_get_info; |
| 4320 | skeleton_class->get_properties = control_power_skeleton_dbus_interface_get_properties; |
| 4321 | skeleton_class->flush = control_power_skeleton_dbus_interface_flush; |
| 4322 | skeleton_class->get_vtable = control_power_skeleton_dbus_interface_get_vtable; |
| 4323 | |
| 4324 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 4325 | g_type_class_add_private (klass, sizeof (ControlPowerSkeletonPrivate)); |
| 4326 | #endif |
| 4327 | } |
| 4328 | |
| 4329 | static void |
| 4330 | control_power_skeleton_iface_init (ControlPowerIface *iface) |
| 4331 | { |
| 4332 | iface->power_good = _control_power_on_signal_power_good; |
| 4333 | iface->power_lost = _control_power_on_signal_power_lost; |
| 4334 | iface->get_pgood = control_power_skeleton_get_pgood; |
| 4335 | iface->get_state = control_power_skeleton_get_state; |
| 4336 | } |
| 4337 | |
| 4338 | /** |
| 4339 | * control_power_skeleton_new: |
| 4340 | * |
| 4341 | * 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>. |
| 4342 | * |
| 4343 | * Returns: (transfer full) (type ControlPowerSkeleton): The skeleton object. |
| 4344 | */ |
| 4345 | ControlPower * |
| 4346 | control_power_skeleton_new (void) |
| 4347 | { |
| 4348 | return CONTROL_POWER (g_object_new (TYPE_CONTROL_POWER_SKELETON, NULL)); |
| 4349 | } |
| 4350 | |
| 4351 | /* ------------------------------------------------------------------------ |
| 4352 | * Code for interface org.openbmc.EventLog |
| 4353 | * ------------------------------------------------------------------------ |
| 4354 | */ |
| 4355 | |
| 4356 | /** |
| 4357 | * SECTION:EventLog |
| 4358 | * @title: EventLog |
| 4359 | * @short_description: Generated C code for the org.openbmc.EventLog D-Bus interface |
| 4360 | * |
| 4361 | * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> D-Bus interface in C. |
| 4362 | */ |
| 4363 | |
| 4364 | /* ---- Introspection data for org.openbmc.EventLog ---- */ |
| 4365 | |
| 4366 | static const _ExtendedGDBusArgInfo _event_log_signal_info_event_log_ARG_message = |
| 4367 | { |
| 4368 | { |
| 4369 | -1, |
| 4370 | (gchar *) "message", |
| 4371 | (gchar *) "a{ss}", |
| 4372 | NULL |
| 4373 | }, |
| 4374 | FALSE |
| 4375 | }; |
| 4376 | |
| 4377 | static const _ExtendedGDBusArgInfo * const _event_log_signal_info_event_log_ARG_pointers[] = |
| 4378 | { |
| 4379 | &_event_log_signal_info_event_log_ARG_message, |
| 4380 | NULL |
| 4381 | }; |
| 4382 | |
| 4383 | static const _ExtendedGDBusSignalInfo _event_log_signal_info_event_log = |
| 4384 | { |
| 4385 | { |
| 4386 | -1, |
| 4387 | (gchar *) "EventLog", |
| 4388 | (GDBusArgInfo **) &_event_log_signal_info_event_log_ARG_pointers, |
| 4389 | NULL |
| 4390 | }, |
| 4391 | "event-log" |
| 4392 | }; |
| 4393 | |
| 4394 | static const _ExtendedGDBusSignalInfo * const _event_log_signal_info_pointers[] = |
| 4395 | { |
| 4396 | &_event_log_signal_info_event_log, |
| 4397 | NULL |
| 4398 | }; |
| 4399 | |
| 4400 | static const _ExtendedGDBusInterfaceInfo _event_log_interface_info = |
| 4401 | { |
| 4402 | { |
| 4403 | -1, |
| 4404 | (gchar *) "org.openbmc.EventLog", |
| 4405 | NULL, |
| 4406 | (GDBusSignalInfo **) &_event_log_signal_info_pointers, |
| 4407 | NULL, |
| 4408 | NULL |
| 4409 | }, |
| 4410 | "event-log", |
| 4411 | }; |
| 4412 | |
| 4413 | |
| 4414 | /** |
| 4415 | * event_log_interface_info: |
| 4416 | * |
| 4417 | * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> D-Bus interface. |
| 4418 | * |
| 4419 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. |
| 4420 | */ |
| 4421 | GDBusInterfaceInfo * |
| 4422 | event_log_interface_info (void) |
| 4423 | { |
| 4424 | return (GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct; |
| 4425 | } |
| 4426 | |
| 4427 | /** |
| 4428 | * event_log_override_properties: |
| 4429 | * @klass: The class structure for a #GObject<!-- -->-derived class. |
| 4430 | * @property_id_begin: The property id to assign to the first overridden property. |
| 4431 | * |
| 4432 | * Overrides all #GObject properties in the #EventLog interface for a concrete class. |
| 4433 | * The properties are overridden in the order they are defined. |
| 4434 | * |
| 4435 | * Returns: The last property id. |
| 4436 | */ |
| 4437 | guint |
| 4438 | event_log_override_properties (GObjectClass *klass, guint property_id_begin) |
| 4439 | { |
| 4440 | return property_id_begin - 1; |
| 4441 | } |
| 4442 | |
| 4443 | |
| 4444 | |
| 4445 | /** |
| 4446 | * EventLog: |
| 4447 | * |
| 4448 | * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. |
| 4449 | */ |
| 4450 | |
| 4451 | /** |
| 4452 | * EventLogIface: |
| 4453 | * @parent_iface: The parent interface. |
| 4454 | * @event_log: Handler for the #EventLog::event-log signal. |
| 4455 | * |
| 4456 | * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. |
| 4457 | */ |
| 4458 | |
| 4459 | typedef EventLogIface EventLogInterface; |
| 4460 | G_DEFINE_INTERFACE (EventLog, event_log, G_TYPE_OBJECT); |
| 4461 | |
| 4462 | static void |
| 4463 | event_log_default_init (EventLogIface *iface) |
| 4464 | { |
| 4465 | /* GObject signals for received D-Bus signals: */ |
| 4466 | /** |
| 4467 | * EventLog::event-log: |
| 4468 | * @object: A #EventLog. |
| 4469 | * @arg_message: Argument. |
| 4470 | * |
| 4471 | * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-EventLog.EventLog">"EventLog"</link> is received. |
| 4472 | * |
| 4473 | * 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. |
| 4474 | */ |
| 4475 | g_signal_new ("event-log", |
| 4476 | G_TYPE_FROM_INTERFACE (iface), |
| 4477 | G_SIGNAL_RUN_LAST, |
| 4478 | G_STRUCT_OFFSET (EventLogIface, event_log), |
| 4479 | NULL, |
| 4480 | NULL, |
| 4481 | g_cclosure_marshal_generic, |
| 4482 | G_TYPE_NONE, |
| 4483 | 1, G_TYPE_VARIANT); |
| 4484 | |
| 4485 | } |
| 4486 | |
| 4487 | /** |
| 4488 | * event_log_emit_event_log: |
| 4489 | * @object: A #EventLog. |
| 4490 | * @arg_message: Argument to pass with the signal. |
| 4491 | * |
| 4492 | * Emits the <link linkend="gdbus-signal-org-openbmc-EventLog.EventLog">"EventLog"</link> D-Bus signal. |
| 4493 | */ |
| 4494 | void |
| 4495 | event_log_emit_event_log ( |
| 4496 | EventLog *object, |
| 4497 | GVariant *arg_message) |
| 4498 | { |
| 4499 | g_signal_emit_by_name (object, "event-log", arg_message); |
| 4500 | } |
| 4501 | |
| 4502 | /* ------------------------------------------------------------------------ */ |
| 4503 | |
| 4504 | /** |
| 4505 | * EventLogProxy: |
| 4506 | * |
| 4507 | * The #EventLogProxy structure contains only private data and should only be accessed using the provided API. |
| 4508 | */ |
| 4509 | |
| 4510 | /** |
| 4511 | * EventLogProxyClass: |
| 4512 | * @parent_class: The parent class. |
| 4513 | * |
| 4514 | * Class structure for #EventLogProxy. |
| 4515 | */ |
| 4516 | |
| 4517 | struct _EventLogProxyPrivate |
| 4518 | { |
| 4519 | GData *qdata; |
| 4520 | }; |
| 4521 | |
| 4522 | static void event_log_proxy_iface_init (EventLogIface *iface); |
| 4523 | |
| 4524 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 4525 | G_DEFINE_TYPE_WITH_CODE (EventLogProxy, event_log_proxy, G_TYPE_DBUS_PROXY, |
| 4526 | G_ADD_PRIVATE (EventLogProxy) |
| 4527 | G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_proxy_iface_init)); |
| 4528 | |
| 4529 | #else |
| 4530 | G_DEFINE_TYPE_WITH_CODE (EventLogProxy, event_log_proxy, G_TYPE_DBUS_PROXY, |
| 4531 | G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_proxy_iface_init)); |
| 4532 | |
| 4533 | #endif |
| 4534 | static void |
| 4535 | event_log_proxy_finalize (GObject *object) |
| 4536 | { |
| 4537 | EventLogProxy *proxy = EVENT_LOG_PROXY (object); |
| 4538 | g_datalist_clear (&proxy->priv->qdata); |
| 4539 | G_OBJECT_CLASS (event_log_proxy_parent_class)->finalize (object); |
| 4540 | } |
| 4541 | |
| 4542 | static void |
| 4543 | event_log_proxy_get_property (GObject *object, |
| 4544 | guint prop_id, |
| 4545 | GValue *value, |
| 4546 | GParamSpec *pspec G_GNUC_UNUSED) |
| 4547 | { |
| 4548 | } |
| 4549 | |
| 4550 | static void |
| 4551 | event_log_proxy_set_property (GObject *object, |
| 4552 | guint prop_id, |
| 4553 | const GValue *value, |
| 4554 | GParamSpec *pspec G_GNUC_UNUSED) |
| 4555 | { |
| 4556 | } |
| 4557 | |
| 4558 | static void |
| 4559 | event_log_proxy_g_signal (GDBusProxy *proxy, |
| 4560 | const gchar *sender_name G_GNUC_UNUSED, |
| 4561 | const gchar *signal_name, |
| 4562 | GVariant *parameters) |
| 4563 | { |
| 4564 | _ExtendedGDBusSignalInfo *info; |
| 4565 | GVariantIter iter; |
| 4566 | GVariant *child; |
| 4567 | GValue *paramv; |
| 4568 | guint num_params; |
| 4569 | guint n; |
| 4570 | guint signal_id; |
| 4571 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, signal_name); |
| 4572 | if (info == NULL) |
| 4573 | return; |
| 4574 | num_params = g_variant_n_children (parameters); |
| 4575 | paramv = g_new0 (GValue, num_params + 1); |
| 4576 | g_value_init (¶mv[0], TYPE_EVENT_LOG); |
| 4577 | g_value_set_object (¶mv[0], proxy); |
| 4578 | g_variant_iter_init (&iter, parameters); |
| 4579 | n = 1; |
| 4580 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 4581 | { |
| 4582 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; |
| 4583 | if (arg_info->use_gvariant) |
| 4584 | { |
| 4585 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 4586 | g_value_set_variant (¶mv[n], child); |
| 4587 | n++; |
| 4588 | } |
| 4589 | else |
| 4590 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 4591 | g_variant_unref (child); |
| 4592 | } |
| 4593 | signal_id = g_signal_lookup (info->signal_name, TYPE_EVENT_LOG); |
| 4594 | g_signal_emitv (paramv, signal_id, 0, NULL); |
| 4595 | for (n = 0; n < num_params + 1; n++) |
| 4596 | g_value_unset (¶mv[n]); |
| 4597 | g_free (paramv); |
| 4598 | } |
| 4599 | |
| 4600 | static void |
| 4601 | event_log_proxy_g_properties_changed (GDBusProxy *_proxy, |
| 4602 | GVariant *changed_properties, |
| 4603 | const gchar *const *invalidated_properties) |
| 4604 | { |
| 4605 | EventLogProxy *proxy = EVENT_LOG_PROXY (_proxy); |
| 4606 | guint n; |
| 4607 | const gchar *key; |
| 4608 | GVariantIter *iter; |
| 4609 | _ExtendedGDBusPropertyInfo *info; |
| 4610 | g_variant_get (changed_properties, "a{sv}", &iter); |
| 4611 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) |
| 4612 | { |
| 4613 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, key); |
| 4614 | g_datalist_remove_data (&proxy->priv->qdata, key); |
| 4615 | if (info != NULL) |
| 4616 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 4617 | } |
| 4618 | g_variant_iter_free (iter); |
| 4619 | for (n = 0; invalidated_properties[n] != NULL; n++) |
| 4620 | { |
| 4621 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, invalidated_properties[n]); |
| 4622 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); |
| 4623 | if (info != NULL) |
| 4624 | g_object_notify (G_OBJECT (proxy), info->hyphen_name); |
| 4625 | } |
| 4626 | } |
| 4627 | |
| 4628 | static void |
| 4629 | event_log_proxy_init (EventLogProxy *proxy) |
| 4630 | { |
| 4631 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 4632 | proxy->priv = event_log_proxy_get_instance_private (proxy); |
| 4633 | #else |
| 4634 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_EVENT_LOG_PROXY, EventLogProxyPrivate); |
| 4635 | #endif |
| 4636 | |
| 4637 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), event_log_interface_info ()); |
| 4638 | } |
| 4639 | |
| 4640 | static void |
| 4641 | event_log_proxy_class_init (EventLogProxyClass *klass) |
| 4642 | { |
| 4643 | GObjectClass *gobject_class; |
| 4644 | GDBusProxyClass *proxy_class; |
| 4645 | |
| 4646 | gobject_class = G_OBJECT_CLASS (klass); |
| 4647 | gobject_class->finalize = event_log_proxy_finalize; |
| 4648 | gobject_class->get_property = event_log_proxy_get_property; |
| 4649 | gobject_class->set_property = event_log_proxy_set_property; |
| 4650 | |
| 4651 | proxy_class = G_DBUS_PROXY_CLASS (klass); |
| 4652 | proxy_class->g_signal = event_log_proxy_g_signal; |
| 4653 | proxy_class->g_properties_changed = event_log_proxy_g_properties_changed; |
| 4654 | |
| 4655 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 4656 | g_type_class_add_private (klass, sizeof (EventLogProxyPrivate)); |
| 4657 | #endif |
| 4658 | } |
| 4659 | |
| 4660 | static void |
| 4661 | event_log_proxy_iface_init (EventLogIface *iface) |
| 4662 | { |
| 4663 | } |
| 4664 | |
| 4665 | /** |
| 4666 | * event_log_proxy_new: |
| 4667 | * @connection: A #GDBusConnection. |
| 4668 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 4669 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 4670 | * @object_path: An object path. |
| 4671 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 4672 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 4673 | * @user_data: User data to pass to @callback. |
| 4674 | * |
| 4675 | * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. See g_dbus_proxy_new() for more details. |
| 4676 | * |
| 4677 | * 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. |
| 4678 | * You can then call event_log_proxy_new_finish() to get the result of the operation. |
| 4679 | * |
| 4680 | * See event_log_proxy_new_sync() for the synchronous, blocking version of this constructor. |
| 4681 | */ |
| 4682 | void |
| 4683 | event_log_proxy_new ( |
| 4684 | GDBusConnection *connection, |
| 4685 | GDBusProxyFlags flags, |
| 4686 | const gchar *name, |
| 4687 | const gchar *object_path, |
| 4688 | GCancellable *cancellable, |
| 4689 | GAsyncReadyCallback callback, |
| 4690 | gpointer user_data) |
| 4691 | { |
| 4692 | g_async_initable_new_async (TYPE_EVENT_LOG_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.EventLog", NULL); |
| 4693 | } |
| 4694 | |
| 4695 | /** |
| 4696 | * event_log_proxy_new_finish: |
| 4697 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to event_log_proxy_new(). |
| 4698 | * @error: Return location for error or %NULL |
| 4699 | * |
| 4700 | * Finishes an operation started with event_log_proxy_new(). |
| 4701 | * |
| 4702 | * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set. |
| 4703 | */ |
| 4704 | EventLog * |
| 4705 | event_log_proxy_new_finish ( |
| 4706 | GAsyncResult *res, |
| 4707 | GError **error) |
| 4708 | { |
| 4709 | GObject *ret; |
| 4710 | GObject *source_object; |
| 4711 | source_object = g_async_result_get_source_object (res); |
| 4712 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 4713 | g_object_unref (source_object); |
| 4714 | if (ret != NULL) |
| 4715 | return EVENT_LOG (ret); |
| 4716 | else |
| 4717 | return NULL; |
| 4718 | } |
| 4719 | |
| 4720 | /** |
| 4721 | * event_log_proxy_new_sync: |
| 4722 | * @connection: A #GDBusConnection. |
| 4723 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 4724 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 4725 | * @object_path: An object path. |
| 4726 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 4727 | * @error: Return location for error or %NULL |
| 4728 | * |
| 4729 | * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. See g_dbus_proxy_new_sync() for more details. |
| 4730 | * |
| 4731 | * The calling thread is blocked until a reply is received. |
| 4732 | * |
| 4733 | * See event_log_proxy_new() for the asynchronous version of this constructor. |
| 4734 | * |
| 4735 | * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set. |
| 4736 | */ |
| 4737 | EventLog * |
| 4738 | event_log_proxy_new_sync ( |
| 4739 | GDBusConnection *connection, |
| 4740 | GDBusProxyFlags flags, |
| 4741 | const gchar *name, |
| 4742 | const gchar *object_path, |
| 4743 | GCancellable *cancellable, |
| 4744 | GError **error) |
| 4745 | { |
| 4746 | GInitable *ret; |
| 4747 | ret = g_initable_new (TYPE_EVENT_LOG_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL); |
| 4748 | if (ret != NULL) |
| 4749 | return EVENT_LOG (ret); |
| 4750 | else |
| 4751 | return NULL; |
| 4752 | } |
| 4753 | |
| 4754 | |
| 4755 | /** |
| 4756 | * event_log_proxy_new_for_bus: |
| 4757 | * @bus_type: A #GBusType. |
| 4758 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 4759 | * @name: A bus name (well-known or unique). |
| 4760 | * @object_path: An object path. |
| 4761 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 4762 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 4763 | * @user_data: User data to pass to @callback. |
| 4764 | * |
| 4765 | * Like event_log_proxy_new() but takes a #GBusType instead of a #GDBusConnection. |
| 4766 | * |
| 4767 | * 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. |
| 4768 | * You can then call event_log_proxy_new_for_bus_finish() to get the result of the operation. |
| 4769 | * |
| 4770 | * See event_log_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. |
| 4771 | */ |
| 4772 | void |
| 4773 | event_log_proxy_new_for_bus ( |
| 4774 | GBusType bus_type, |
| 4775 | GDBusProxyFlags flags, |
| 4776 | const gchar *name, |
| 4777 | const gchar *object_path, |
| 4778 | GCancellable *cancellable, |
| 4779 | GAsyncReadyCallback callback, |
| 4780 | gpointer user_data) |
| 4781 | { |
| 4782 | g_async_initable_new_async (TYPE_EVENT_LOG_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.EventLog", NULL); |
| 4783 | } |
| 4784 | |
| 4785 | /** |
| 4786 | * event_log_proxy_new_for_bus_finish: |
| 4787 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to event_log_proxy_new_for_bus(). |
| 4788 | * @error: Return location for error or %NULL |
| 4789 | * |
| 4790 | * Finishes an operation started with event_log_proxy_new_for_bus(). |
| 4791 | * |
| 4792 | * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set. |
| 4793 | */ |
| 4794 | EventLog * |
| 4795 | event_log_proxy_new_for_bus_finish ( |
| 4796 | GAsyncResult *res, |
| 4797 | GError **error) |
| 4798 | { |
| 4799 | GObject *ret; |
| 4800 | GObject *source_object; |
| 4801 | source_object = g_async_result_get_source_object (res); |
| 4802 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 4803 | g_object_unref (source_object); |
| 4804 | if (ret != NULL) |
| 4805 | return EVENT_LOG (ret); |
| 4806 | else |
| 4807 | return NULL; |
| 4808 | } |
| 4809 | |
| 4810 | /** |
| 4811 | * event_log_proxy_new_for_bus_sync: |
| 4812 | * @bus_type: A #GBusType. |
| 4813 | * @flags: Flags from the #GDBusProxyFlags enumeration. |
| 4814 | * @name: A bus name (well-known or unique). |
| 4815 | * @object_path: An object path. |
| 4816 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 4817 | * @error: Return location for error or %NULL |
| 4818 | * |
| 4819 | * Like event_log_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. |
| 4820 | * |
| 4821 | * The calling thread is blocked until a reply is received. |
| 4822 | * |
| 4823 | * See event_log_proxy_new_for_bus() for the asynchronous version of this constructor. |
| 4824 | * |
| 4825 | * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set. |
| 4826 | */ |
| 4827 | EventLog * |
| 4828 | event_log_proxy_new_for_bus_sync ( |
| 4829 | GBusType bus_type, |
| 4830 | GDBusProxyFlags flags, |
| 4831 | const gchar *name, |
| 4832 | const gchar *object_path, |
| 4833 | GCancellable *cancellable, |
| 4834 | GError **error) |
| 4835 | { |
| 4836 | GInitable *ret; |
| 4837 | ret = g_initable_new (TYPE_EVENT_LOG_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL); |
| 4838 | if (ret != NULL) |
| 4839 | return EVENT_LOG (ret); |
| 4840 | else |
| 4841 | return NULL; |
| 4842 | } |
| 4843 | |
| 4844 | |
| 4845 | /* ------------------------------------------------------------------------ */ |
| 4846 | |
| 4847 | /** |
| 4848 | * EventLogSkeleton: |
| 4849 | * |
| 4850 | * The #EventLogSkeleton structure contains only private data and should only be accessed using the provided API. |
| 4851 | */ |
| 4852 | |
| 4853 | /** |
| 4854 | * EventLogSkeletonClass: |
| 4855 | * @parent_class: The parent class. |
| 4856 | * |
| 4857 | * Class structure for #EventLogSkeleton. |
| 4858 | */ |
| 4859 | |
| 4860 | struct _EventLogSkeletonPrivate |
| 4861 | { |
| 4862 | GValue *properties; |
| 4863 | GList *changed_properties; |
| 4864 | GSource *changed_properties_idle_source; |
| 4865 | GMainContext *context; |
| 4866 | GMutex lock; |
| 4867 | }; |
| 4868 | |
| 4869 | static void |
| 4870 | _event_log_skeleton_handle_method_call ( |
| 4871 | GDBusConnection *connection G_GNUC_UNUSED, |
| 4872 | const gchar *sender G_GNUC_UNUSED, |
| 4873 | const gchar *object_path G_GNUC_UNUSED, |
| 4874 | const gchar *interface_name, |
| 4875 | const gchar *method_name, |
| 4876 | GVariant *parameters, |
| 4877 | GDBusMethodInvocation *invocation, |
| 4878 | gpointer user_data) |
| 4879 | { |
| 4880 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data); |
| 4881 | _ExtendedGDBusMethodInfo *info; |
| 4882 | GVariantIter iter; |
| 4883 | GVariant *child; |
| 4884 | GValue *paramv; |
| 4885 | guint num_params; |
| 4886 | guint num_extra; |
| 4887 | guint n; |
| 4888 | guint signal_id; |
| 4889 | GValue return_value = G_VALUE_INIT; |
| 4890 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); |
| 4891 | g_assert (info != NULL); |
| 4892 | num_params = g_variant_n_children (parameters); |
| 4893 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); |
| 4894 | n = 0; |
| 4895 | g_value_init (¶mv[n], TYPE_EVENT_LOG); |
| 4896 | g_value_set_object (¶mv[n++], skeleton); |
| 4897 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); |
| 4898 | g_value_set_object (¶mv[n++], invocation); |
| 4899 | if (info->pass_fdlist) |
| 4900 | { |
| 4901 | #ifdef G_OS_UNIX |
| 4902 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); |
| 4903 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); |
| 4904 | #else |
| 4905 | g_assert_not_reached (); |
| 4906 | #endif |
| 4907 | } |
| 4908 | g_variant_iter_init (&iter, parameters); |
| 4909 | while ((child = g_variant_iter_next_value (&iter)) != NULL) |
| 4910 | { |
| 4911 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; |
| 4912 | if (arg_info->use_gvariant) |
| 4913 | { |
| 4914 | g_value_init (¶mv[n], G_TYPE_VARIANT); |
| 4915 | g_value_set_variant (¶mv[n], child); |
| 4916 | n++; |
| 4917 | } |
| 4918 | else |
| 4919 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); |
| 4920 | g_variant_unref (child); |
| 4921 | } |
| 4922 | signal_id = g_signal_lookup (info->signal_name, TYPE_EVENT_LOG); |
| 4923 | g_value_init (&return_value, G_TYPE_BOOLEAN); |
| 4924 | g_signal_emitv (paramv, signal_id, 0, &return_value); |
| 4925 | if (!g_value_get_boolean (&return_value)) |
| 4926 | 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); |
| 4927 | g_value_unset (&return_value); |
| 4928 | for (n = 0; n < num_params + num_extra; n++) |
| 4929 | g_value_unset (¶mv[n]); |
| 4930 | g_free (paramv); |
| 4931 | } |
| 4932 | |
| 4933 | static GVariant * |
| 4934 | _event_log_skeleton_handle_get_property ( |
| 4935 | GDBusConnection *connection G_GNUC_UNUSED, |
| 4936 | const gchar *sender G_GNUC_UNUSED, |
| 4937 | const gchar *object_path G_GNUC_UNUSED, |
| 4938 | const gchar *interface_name G_GNUC_UNUSED, |
| 4939 | const gchar *property_name, |
| 4940 | GError **error, |
| 4941 | gpointer user_data) |
| 4942 | { |
| 4943 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data); |
| 4944 | GValue value = G_VALUE_INIT; |
| 4945 | GParamSpec *pspec; |
| 4946 | _ExtendedGDBusPropertyInfo *info; |
| 4947 | GVariant *ret; |
| 4948 | ret = NULL; |
| 4949 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, property_name); |
| 4950 | g_assert (info != NULL); |
| 4951 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 4952 | if (pspec == NULL) |
| 4953 | { |
| 4954 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 4955 | } |
| 4956 | else |
| 4957 | { |
| 4958 | g_value_init (&value, pspec->value_type); |
| 4959 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 4960 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); |
| 4961 | g_value_unset (&value); |
| 4962 | } |
| 4963 | return ret; |
| 4964 | } |
| 4965 | |
| 4966 | static gboolean |
| 4967 | _event_log_skeleton_handle_set_property ( |
| 4968 | GDBusConnection *connection G_GNUC_UNUSED, |
| 4969 | const gchar *sender G_GNUC_UNUSED, |
| 4970 | const gchar *object_path G_GNUC_UNUSED, |
| 4971 | const gchar *interface_name G_GNUC_UNUSED, |
| 4972 | const gchar *property_name, |
| 4973 | GVariant *variant, |
| 4974 | GError **error, |
| 4975 | gpointer user_data) |
| 4976 | { |
| 4977 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data); |
| 4978 | GValue value = G_VALUE_INIT; |
| 4979 | GParamSpec *pspec; |
| 4980 | _ExtendedGDBusPropertyInfo *info; |
| 4981 | gboolean ret; |
| 4982 | ret = FALSE; |
| 4983 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, property_name); |
| 4984 | g_assert (info != NULL); |
| 4985 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); |
| 4986 | if (pspec == NULL) |
| 4987 | { |
| 4988 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); |
| 4989 | } |
| 4990 | else |
| 4991 | { |
| 4992 | if (info->use_gvariant) |
| 4993 | g_value_set_variant (&value, variant); |
| 4994 | else |
| 4995 | g_dbus_gvariant_to_gvalue (variant, &value); |
| 4996 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); |
| 4997 | g_value_unset (&value); |
| 4998 | ret = TRUE; |
| 4999 | } |
| 5000 | return ret; |
| 5001 | } |
| 5002 | |
| 5003 | static const GDBusInterfaceVTable _event_log_skeleton_vtable = |
| 5004 | { |
| 5005 | _event_log_skeleton_handle_method_call, |
| 5006 | _event_log_skeleton_handle_get_property, |
| 5007 | _event_log_skeleton_handle_set_property, |
| 5008 | {NULL} |
| 5009 | }; |
| 5010 | |
| 5011 | static GDBusInterfaceInfo * |
| 5012 | event_log_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 5013 | { |
| 5014 | return event_log_interface_info (); |
| 5015 | } |
| 5016 | |
| 5017 | static GDBusInterfaceVTable * |
| 5018 | event_log_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) |
| 5019 | { |
| 5020 | return (GDBusInterfaceVTable *) &_event_log_skeleton_vtable; |
| 5021 | } |
| 5022 | |
| 5023 | static GVariant * |
| 5024 | event_log_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) |
| 5025 | { |
| 5026 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (_skeleton); |
| 5027 | |
| 5028 | GVariantBuilder builder; |
| 5029 | guint n; |
| 5030 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); |
| 5031 | if (_event_log_interface_info.parent_struct.properties == NULL) |
| 5032 | goto out; |
| 5033 | for (n = 0; _event_log_interface_info.parent_struct.properties[n] != NULL; n++) |
| 5034 | { |
| 5035 | GDBusPropertyInfo *info = _event_log_interface_info.parent_struct.properties[n]; |
| 5036 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) |
| 5037 | { |
| 5038 | GVariant *value; |
| 5039 | value = _event_log_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.EventLog", info->name, NULL, skeleton); |
| 5040 | if (value != NULL) |
| 5041 | { |
| 5042 | g_variant_take_ref (value); |
| 5043 | g_variant_builder_add (&builder, "{sv}", info->name, value); |
| 5044 | g_variant_unref (value); |
| 5045 | } |
| 5046 | } |
| 5047 | } |
| 5048 | out: |
| 5049 | return g_variant_builder_end (&builder); |
| 5050 | } |
| 5051 | |
| 5052 | static void |
| 5053 | event_log_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) |
| 5054 | { |
| 5055 | } |
| 5056 | |
| 5057 | static void |
| 5058 | _event_log_on_signal_event_log ( |
| 5059 | EventLog *object, |
| 5060 | GVariant *arg_message) |
| 5061 | { |
| 5062 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object); |
| 5063 | |
| 5064 | GList *connections, *l; |
| 5065 | GVariant *signal_variant; |
| 5066 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton)); |
| 5067 | |
| 5068 | signal_variant = g_variant_ref_sink (g_variant_new ("(@a{ss})", |
| 5069 | arg_message)); |
| 5070 | for (l = connections; l != NULL; l = l->next) |
| 5071 | { |
| 5072 | GDBusConnection *connection = l->data; |
| 5073 | g_dbus_connection_emit_signal (connection, |
| 5074 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.EventLog", "EventLog", |
| 5075 | signal_variant, NULL); |
| 5076 | } |
| 5077 | g_variant_unref (signal_variant); |
| 5078 | g_list_free_full (connections, g_object_unref); |
| 5079 | } |
| 5080 | |
| 5081 | static void event_log_skeleton_iface_init (EventLogIface *iface); |
| 5082 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 5083 | G_DEFINE_TYPE_WITH_CODE (EventLogSkeleton, event_log_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 5084 | G_ADD_PRIVATE (EventLogSkeleton) |
| 5085 | G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_skeleton_iface_init)); |
| 5086 | |
| 5087 | #else |
| 5088 | G_DEFINE_TYPE_WITH_CODE (EventLogSkeleton, event_log_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, |
| 5089 | G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_skeleton_iface_init)); |
| 5090 | |
| 5091 | #endif |
| 5092 | static void |
| 5093 | event_log_skeleton_finalize (GObject *object) |
| 5094 | { |
| 5095 | EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object); |
| 5096 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); |
| 5097 | if (skeleton->priv->changed_properties_idle_source != NULL) |
| 5098 | g_source_destroy (skeleton->priv->changed_properties_idle_source); |
| 5099 | g_main_context_unref (skeleton->priv->context); |
| 5100 | g_mutex_clear (&skeleton->priv->lock); |
| 5101 | G_OBJECT_CLASS (event_log_skeleton_parent_class)->finalize (object); |
| 5102 | } |
| 5103 | |
| 5104 | static void |
| 5105 | event_log_skeleton_init (EventLogSkeleton *skeleton) |
| 5106 | { |
| 5107 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 |
| 5108 | skeleton->priv = event_log_skeleton_get_instance_private (skeleton); |
| 5109 | #else |
| 5110 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_EVENT_LOG_SKELETON, EventLogSkeletonPrivate); |
| 5111 | #endif |
| 5112 | |
| 5113 | g_mutex_init (&skeleton->priv->lock); |
| 5114 | skeleton->priv->context = g_main_context_ref_thread_default (); |
| 5115 | } |
| 5116 | |
| 5117 | static void |
| 5118 | event_log_skeleton_class_init (EventLogSkeletonClass *klass) |
| 5119 | { |
| 5120 | GObjectClass *gobject_class; |
| 5121 | GDBusInterfaceSkeletonClass *skeleton_class; |
| 5122 | |
| 5123 | gobject_class = G_OBJECT_CLASS (klass); |
| 5124 | gobject_class->finalize = event_log_skeleton_finalize; |
| 5125 | |
| 5126 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); |
| 5127 | skeleton_class->get_info = event_log_skeleton_dbus_interface_get_info; |
| 5128 | skeleton_class->get_properties = event_log_skeleton_dbus_interface_get_properties; |
| 5129 | skeleton_class->flush = event_log_skeleton_dbus_interface_flush; |
| 5130 | skeleton_class->get_vtable = event_log_skeleton_dbus_interface_get_vtable; |
| 5131 | |
| 5132 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 |
| 5133 | g_type_class_add_private (klass, sizeof (EventLogSkeletonPrivate)); |
| 5134 | #endif |
| 5135 | } |
| 5136 | |
| 5137 | static void |
| 5138 | event_log_skeleton_iface_init (EventLogIface *iface) |
| 5139 | { |
| 5140 | iface->event_log = _event_log_on_signal_event_log; |
| 5141 | } |
| 5142 | |
| 5143 | /** |
| 5144 | * event_log_skeleton_new: |
| 5145 | * |
| 5146 | * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. |
| 5147 | * |
| 5148 | * Returns: (transfer full) (type EventLogSkeleton): The skeleton object. |
| 5149 | */ |
| 5150 | EventLog * |
| 5151 | event_log_skeleton_new (void) |
| 5152 | { |
| 5153 | return EVENT_LOG (g_object_new (TYPE_EVENT_LOG_SKELETON, NULL)); |
| 5154 | } |
| 5155 | |
| 5156 | /* ------------------------------------------------------------------------ |
| 5157 | * Code for Object, ObjectProxy and ObjectSkeleton |
| 5158 | * ------------------------------------------------------------------------ |
| 5159 | */ |
| 5160 | |
| 5161 | /** |
| 5162 | * SECTION:Object |
| 5163 | * @title: Object |
| 5164 | * @short_description: Specialized GDBusObject types |
| 5165 | * |
| 5166 | * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces. |
| 5167 | */ |
| 5168 | |
| 5169 | /** |
| 5170 | * Object: |
| 5171 | * |
| 5172 | * The #Object type is a specialized container of interfaces. |
| 5173 | */ |
| 5174 | |
| 5175 | /** |
| 5176 | * ObjectIface: |
| 5177 | * @parent_iface: The parent interface. |
| 5178 | * |
| 5179 | * Virtual table for the #Object interface. |
| 5180 | */ |
| 5181 | |
| 5182 | typedef ObjectIface ObjectInterface; |
| 5183 | G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT)); |
| 5184 | |
| 5185 | static void |
| 5186 | object_default_init (ObjectIface *iface) |
| 5187 | { |
| 5188 | /** |
| 5189 | * Object:control: |
| 5190 | * |
| 5191 | * The #Control instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link>, if any. |
| 5192 | * |
| 5193 | * Connect to the #GObject::notify signal to get informed of property changes. |
| 5194 | */ |
| 5195 | g_object_interface_install_property (iface, g_param_spec_object ("control", "control", "control", TYPE_CONTROL, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS)); |
| 5196 | |
| 5197 | /** |
| 5198 | * Object:control-host: |
| 5199 | * |
| 5200 | * The #ControlHost instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link>, if any. |
| 5201 | * |
| 5202 | * Connect to the #GObject::notify signal to get informed of property changes. |
| 5203 | */ |
| 5204 | g_object_interface_install_property (iface, g_param_spec_object ("control-host", "control-host", "control-host", TYPE_CONTROL_HOST, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS)); |
| 5205 | |
| 5206 | /** |
| 5207 | * Object:control-power: |
| 5208 | * |
| 5209 | * 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. |
| 5210 | * |
| 5211 | * Connect to the #GObject::notify signal to get informed of property changes. |
| 5212 | */ |
| 5213 | 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)); |
| 5214 | |
| 5215 | /** |
| 5216 | * Object:event-log: |
| 5217 | * |
| 5218 | * The #EventLog instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>, if any. |
| 5219 | * |
| 5220 | * Connect to the #GObject::notify signal to get informed of property changes. |
| 5221 | */ |
| 5222 | g_object_interface_install_property (iface, g_param_spec_object ("event-log", "event-log", "event-log", TYPE_EVENT_LOG, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS)); |
| 5223 | |
| 5224 | } |
| 5225 | |
| 5226 | /** |
| 5227 | * object_get_control: |
| 5228 | * @object: A #Object. |
| 5229 | * |
| 5230 | * Gets the #Control instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link> on @object, if any. |
| 5231 | * |
| 5232 | * Returns: (transfer full): A #Control that must be freed with g_object_unref() or %NULL if @object does not implement the interface. |
| 5233 | */ |
| 5234 | Control *object_get_control (Object *object) |
| 5235 | { |
| 5236 | GDBusInterface *ret; |
| 5237 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.Control"); |
| 5238 | if (ret == NULL) |
| 5239 | return NULL; |
| 5240 | return CONTROL (ret); |
| 5241 | } |
| 5242 | |
| 5243 | /** |
| 5244 | * object_get_control_host: |
| 5245 | * @object: A #Object. |
| 5246 | * |
| 5247 | * Gets the #ControlHost instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link> on @object, if any. |
| 5248 | * |
| 5249 | * Returns: (transfer full): A #ControlHost that must be freed with g_object_unref() or %NULL if @object does not implement the interface. |
| 5250 | */ |
| 5251 | ControlHost *object_get_control_host (Object *object) |
| 5252 | { |
| 5253 | GDBusInterface *ret; |
| 5254 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Host"); |
| 5255 | if (ret == NULL) |
| 5256 | return NULL; |
| 5257 | return CONTROL_HOST (ret); |
| 5258 | } |
| 5259 | |
| 5260 | /** |
| 5261 | * object_get_control_power: |
| 5262 | * @object: A #Object. |
| 5263 | * |
| 5264 | * 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. |
| 5265 | * |
| 5266 | * Returns: (transfer full): A #ControlPower that must be freed with g_object_unref() or %NULL if @object does not implement the interface. |
| 5267 | */ |
| 5268 | ControlPower *object_get_control_power (Object *object) |
| 5269 | { |
| 5270 | GDBusInterface *ret; |
| 5271 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Power"); |
| 5272 | if (ret == NULL) |
| 5273 | return NULL; |
| 5274 | return CONTROL_POWER (ret); |
| 5275 | } |
| 5276 | |
| 5277 | /** |
| 5278 | * object_get_event_log: |
| 5279 | * @object: A #Object. |
| 5280 | * |
| 5281 | * Gets the #EventLog instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> on @object, if any. |
| 5282 | * |
| 5283 | * Returns: (transfer full): A #EventLog that must be freed with g_object_unref() or %NULL if @object does not implement the interface. |
| 5284 | */ |
| 5285 | EventLog *object_get_event_log (Object *object) |
| 5286 | { |
| 5287 | GDBusInterface *ret; |
| 5288 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.EventLog"); |
| 5289 | if (ret == NULL) |
| 5290 | return NULL; |
| 5291 | return EVENT_LOG (ret); |
| 5292 | } |
| 5293 | |
| 5294 | |
| 5295 | /** |
| 5296 | * object_peek_control: (skip) |
| 5297 | * @object: A #Object. |
| 5298 | * |
| 5299 | * Like object_get_control() but doesn't increase the reference count on the returned object. |
| 5300 | * |
| 5301 | * <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> |
| 5302 | * |
| 5303 | * Returns: (transfer none): A #Control or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object. |
| 5304 | */ |
| 5305 | Control *object_peek_control (Object *object) |
| 5306 | { |
| 5307 | GDBusInterface *ret; |
| 5308 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.Control"); |
| 5309 | if (ret == NULL) |
| 5310 | return NULL; |
| 5311 | g_object_unref (ret); |
| 5312 | return CONTROL (ret); |
| 5313 | } |
| 5314 | |
| 5315 | /** |
| 5316 | * object_peek_control_host: (skip) |
| 5317 | * @object: A #Object. |
| 5318 | * |
| 5319 | * Like object_get_control_host() but doesn't increase the reference count on the returned object. |
| 5320 | * |
| 5321 | * <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> |
| 5322 | * |
| 5323 | * Returns: (transfer none): A #ControlHost or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object. |
| 5324 | */ |
| 5325 | ControlHost *object_peek_control_host (Object *object) |
| 5326 | { |
| 5327 | GDBusInterface *ret; |
| 5328 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Host"); |
| 5329 | if (ret == NULL) |
| 5330 | return NULL; |
| 5331 | g_object_unref (ret); |
| 5332 | return CONTROL_HOST (ret); |
| 5333 | } |
| 5334 | |
| 5335 | /** |
| 5336 | * object_peek_control_power: (skip) |
| 5337 | * @object: A #Object. |
| 5338 | * |
| 5339 | * Like object_get_control_power() but doesn't increase the reference count on the returned object. |
| 5340 | * |
| 5341 | * <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> |
| 5342 | * |
| 5343 | * 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. |
| 5344 | */ |
| 5345 | ControlPower *object_peek_control_power (Object *object) |
| 5346 | { |
| 5347 | GDBusInterface *ret; |
| 5348 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Power"); |
| 5349 | if (ret == NULL) |
| 5350 | return NULL; |
| 5351 | g_object_unref (ret); |
| 5352 | return CONTROL_POWER (ret); |
| 5353 | } |
| 5354 | |
| 5355 | /** |
| 5356 | * object_peek_event_log: (skip) |
| 5357 | * @object: A #Object. |
| 5358 | * |
| 5359 | * Like object_get_event_log() but doesn't increase the reference count on the returned object. |
| 5360 | * |
| 5361 | * <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> |
| 5362 | * |
| 5363 | * Returns: (transfer none): A #EventLog or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object. |
| 5364 | */ |
| 5365 | EventLog *object_peek_event_log (Object *object) |
| 5366 | { |
| 5367 | GDBusInterface *ret; |
| 5368 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.EventLog"); |
| 5369 | if (ret == NULL) |
| 5370 | return NULL; |
| 5371 | g_object_unref (ret); |
| 5372 | return EVENT_LOG (ret); |
| 5373 | } |
| 5374 | |
| 5375 | |
| 5376 | static void |
| 5377 | object_notify (GDBusObject *object, GDBusInterface *interface) |
| 5378 | { |
| 5379 | _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface); |
| 5380 | /* info can be NULL if the other end is using a D-Bus interface we don't know |
| 5381 | * anything about, for example old generated code in this process talking to |
| 5382 | * newer generated code in the other process. */ |
| 5383 | if (info != NULL) |
| 5384 | g_object_notify (G_OBJECT (object), info->hyphen_name); |
| 5385 | } |
| 5386 | |
| 5387 | /** |
| 5388 | * ObjectProxy: |
| 5389 | * |
| 5390 | * The #ObjectProxy structure contains only private data and should only be accessed using the provided API. |
| 5391 | */ |
| 5392 | |
| 5393 | /** |
| 5394 | * ObjectProxyClass: |
| 5395 | * @parent_class: The parent class. |
| 5396 | * |
| 5397 | * Class structure for #ObjectProxy. |
| 5398 | */ |
| 5399 | |
| 5400 | static void |
| 5401 | object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED) |
| 5402 | { |
| 5403 | } |
| 5404 | |
| 5405 | static void |
| 5406 | object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface) |
| 5407 | { |
| 5408 | iface->interface_added = object_notify; |
| 5409 | iface->interface_removed = object_notify; |
| 5410 | } |
| 5411 | |
| 5412 | |
| 5413 | G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY, |
| 5414 | G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init) |
| 5415 | G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init)); |
| 5416 | |
| 5417 | static void |
| 5418 | object_proxy_init (ObjectProxy *object G_GNUC_UNUSED) |
| 5419 | { |
| 5420 | } |
| 5421 | |
| 5422 | static void |
| 5423 | object_proxy_set_property (GObject *gobject, |
| 5424 | guint prop_id, |
| 5425 | const GValue *value G_GNUC_UNUSED, |
| 5426 | GParamSpec *pspec) |
| 5427 | { |
| 5428 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 5429 | } |
| 5430 | |
| 5431 | static void |
| 5432 | object_proxy_get_property (GObject *gobject, |
| 5433 | guint prop_id, |
| 5434 | GValue *value, |
| 5435 | GParamSpec *pspec) |
| 5436 | { |
| 5437 | ObjectProxy *object = OBJECT_PROXY (gobject); |
| 5438 | GDBusInterface *interface; |
| 5439 | |
| 5440 | switch (prop_id) |
| 5441 | { |
| 5442 | case 1: |
| 5443 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.Control"); |
| 5444 | g_value_take_object (value, interface); |
| 5445 | break; |
| 5446 | |
| 5447 | case 2: |
| 5448 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Host"); |
| 5449 | g_value_take_object (value, interface); |
| 5450 | break; |
| 5451 | |
| 5452 | case 3: |
| 5453 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Power"); |
| 5454 | g_value_take_object (value, interface); |
| 5455 | break; |
| 5456 | |
| 5457 | case 4: |
| 5458 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.EventLog"); |
| 5459 | g_value_take_object (value, interface); |
| 5460 | break; |
| 5461 | |
| 5462 | default: |
| 5463 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 5464 | break; |
| 5465 | } |
| 5466 | } |
| 5467 | |
| 5468 | static void |
| 5469 | object_proxy_class_init (ObjectProxyClass *klass) |
| 5470 | { |
| 5471 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 5472 | |
| 5473 | gobject_class->set_property = object_proxy_set_property; |
| 5474 | gobject_class->get_property = object_proxy_get_property; |
| 5475 | |
| 5476 | g_object_class_override_property (gobject_class, 1, "control"); |
| 5477 | g_object_class_override_property (gobject_class, 2, "control-host"); |
| 5478 | g_object_class_override_property (gobject_class, 3, "control-power"); |
| 5479 | g_object_class_override_property (gobject_class, 4, "event-log"); |
| 5480 | } |
| 5481 | |
| 5482 | /** |
| 5483 | * object_proxy_new: |
| 5484 | * @connection: A #GDBusConnection. |
| 5485 | * @object_path: An object path. |
| 5486 | * |
| 5487 | * Creates a new proxy object. |
| 5488 | * |
| 5489 | * Returns: (transfer full): The proxy object. |
| 5490 | */ |
| 5491 | ObjectProxy * |
| 5492 | object_proxy_new (GDBusConnection *connection, |
| 5493 | const gchar *object_path) |
| 5494 | { |
| 5495 | g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); |
| 5496 | g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); |
| 5497 | return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL)); |
| 5498 | } |
| 5499 | |
| 5500 | /** |
| 5501 | * ObjectSkeleton: |
| 5502 | * |
| 5503 | * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API. |
| 5504 | */ |
| 5505 | |
| 5506 | /** |
| 5507 | * ObjectSkeletonClass: |
| 5508 | * @parent_class: The parent class. |
| 5509 | * |
| 5510 | * Class structure for #ObjectSkeleton. |
| 5511 | */ |
| 5512 | |
| 5513 | static void |
| 5514 | object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED) |
| 5515 | { |
| 5516 | } |
| 5517 | |
| 5518 | |
| 5519 | static void |
| 5520 | object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface) |
| 5521 | { |
| 5522 | iface->interface_added = object_notify; |
| 5523 | iface->interface_removed = object_notify; |
| 5524 | } |
| 5525 | |
| 5526 | G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON, |
| 5527 | G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init) |
| 5528 | G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init)); |
| 5529 | |
| 5530 | static void |
| 5531 | object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED) |
| 5532 | { |
| 5533 | } |
| 5534 | |
| 5535 | static void |
| 5536 | object_skeleton_set_property (GObject *gobject, |
| 5537 | guint prop_id, |
| 5538 | const GValue *value, |
| 5539 | GParamSpec *pspec) |
| 5540 | { |
| 5541 | ObjectSkeleton *object = OBJECT_SKELETON (gobject); |
| 5542 | GDBusInterfaceSkeleton *interface; |
| 5543 | |
| 5544 | switch (prop_id) |
| 5545 | { |
| 5546 | case 1: |
| 5547 | interface = g_value_get_object (value); |
| 5548 | if (interface != NULL) |
| 5549 | { |
| 5550 | g_warn_if_fail (IS_CONTROL (interface)); |
| 5551 | g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); |
| 5552 | } |
| 5553 | else |
| 5554 | { |
| 5555 | g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.Control"); |
| 5556 | } |
| 5557 | break; |
| 5558 | |
| 5559 | case 2: |
| 5560 | interface = g_value_get_object (value); |
| 5561 | if (interface != NULL) |
| 5562 | { |
| 5563 | g_warn_if_fail (IS_CONTROL_HOST (interface)); |
| 5564 | g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); |
| 5565 | } |
| 5566 | else |
| 5567 | { |
| 5568 | g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.control.Host"); |
| 5569 | } |
| 5570 | break; |
| 5571 | |
| 5572 | case 3: |
| 5573 | interface = g_value_get_object (value); |
| 5574 | if (interface != NULL) |
| 5575 | { |
| 5576 | g_warn_if_fail (IS_CONTROL_POWER (interface)); |
| 5577 | g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); |
| 5578 | } |
| 5579 | else |
| 5580 | { |
| 5581 | g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.control.Power"); |
| 5582 | } |
| 5583 | break; |
| 5584 | |
| 5585 | case 4: |
| 5586 | interface = g_value_get_object (value); |
| 5587 | if (interface != NULL) |
| 5588 | { |
| 5589 | g_warn_if_fail (IS_EVENT_LOG (interface)); |
| 5590 | g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface); |
| 5591 | } |
| 5592 | else |
| 5593 | { |
| 5594 | g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.EventLog"); |
| 5595 | } |
| 5596 | break; |
| 5597 | |
| 5598 | default: |
| 5599 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 5600 | break; |
| 5601 | } |
| 5602 | } |
| 5603 | |
| 5604 | static void |
| 5605 | object_skeleton_get_property (GObject *gobject, |
| 5606 | guint prop_id, |
| 5607 | GValue *value, |
| 5608 | GParamSpec *pspec) |
| 5609 | { |
| 5610 | ObjectSkeleton *object = OBJECT_SKELETON (gobject); |
| 5611 | GDBusInterface *interface; |
| 5612 | |
| 5613 | switch (prop_id) |
| 5614 | { |
| 5615 | case 1: |
| 5616 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.Control"); |
| 5617 | g_value_take_object (value, interface); |
| 5618 | break; |
| 5619 | |
| 5620 | case 2: |
| 5621 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Host"); |
| 5622 | g_value_take_object (value, interface); |
| 5623 | break; |
| 5624 | |
| 5625 | case 3: |
| 5626 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.control.Power"); |
| 5627 | g_value_take_object (value, interface); |
| 5628 | break; |
| 5629 | |
| 5630 | case 4: |
| 5631 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.EventLog"); |
| 5632 | g_value_take_object (value, interface); |
| 5633 | break; |
| 5634 | |
| 5635 | default: |
| 5636 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 5637 | break; |
| 5638 | } |
| 5639 | } |
| 5640 | |
| 5641 | static void |
| 5642 | object_skeleton_class_init (ObjectSkeletonClass *klass) |
| 5643 | { |
| 5644 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 5645 | |
| 5646 | gobject_class->set_property = object_skeleton_set_property; |
| 5647 | gobject_class->get_property = object_skeleton_get_property; |
| 5648 | |
| 5649 | g_object_class_override_property (gobject_class, 1, "control"); |
| 5650 | g_object_class_override_property (gobject_class, 2, "control-host"); |
| 5651 | g_object_class_override_property (gobject_class, 3, "control-power"); |
| 5652 | g_object_class_override_property (gobject_class, 4, "event-log"); |
| 5653 | } |
| 5654 | |
| 5655 | /** |
| 5656 | * object_skeleton_new: |
| 5657 | * @object_path: An object path. |
| 5658 | * |
| 5659 | * Creates a new skeleton object. |
| 5660 | * |
| 5661 | * Returns: (transfer full): The skeleton object. |
| 5662 | */ |
| 5663 | ObjectSkeleton * |
| 5664 | object_skeleton_new (const gchar *object_path) |
| 5665 | { |
| 5666 | g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); |
| 5667 | return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL)); |
| 5668 | } |
| 5669 | |
| 5670 | /** |
| 5671 | * object_skeleton_set_control: |
| 5672 | * @object: A #ObjectSkeleton. |
| 5673 | * @interface_: (allow-none): A #Control or %NULL to clear the interface. |
| 5674 | * |
| 5675 | * Sets the #Control instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-Control.top_of_page">org.openbmc.Control</link> on @object. |
| 5676 | */ |
| 5677 | void object_skeleton_set_control (ObjectSkeleton *object, Control *interface_) |
| 5678 | { |
| 5679 | g_object_set (G_OBJECT (object), "control", interface_, NULL); |
| 5680 | } |
| 5681 | |
| 5682 | /** |
| 5683 | * object_skeleton_set_control_host: |
| 5684 | * @object: A #ObjectSkeleton. |
| 5685 | * @interface_: (allow-none): A #ControlHost or %NULL to clear the interface. |
| 5686 | * |
| 5687 | * Sets the #ControlHost instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-control-Host.top_of_page">org.openbmc.control.Host</link> on @object. |
| 5688 | */ |
| 5689 | void object_skeleton_set_control_host (ObjectSkeleton *object, ControlHost *interface_) |
| 5690 | { |
| 5691 | g_object_set (G_OBJECT (object), "control-host", interface_, NULL); |
| 5692 | } |
| 5693 | |
| 5694 | /** |
| 5695 | * object_skeleton_set_control_power: |
| 5696 | * @object: A #ObjectSkeleton. |
| 5697 | * @interface_: (allow-none): A #ControlPower or %NULL to clear the interface. |
| 5698 | * |
| 5699 | * 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. |
| 5700 | */ |
| 5701 | void object_skeleton_set_control_power (ObjectSkeleton *object, ControlPower *interface_) |
| 5702 | { |
| 5703 | g_object_set (G_OBJECT (object), "control-power", interface_, NULL); |
| 5704 | } |
| 5705 | |
| 5706 | /** |
| 5707 | * object_skeleton_set_event_log: |
| 5708 | * @object: A #ObjectSkeleton. |
| 5709 | * @interface_: (allow-none): A #EventLog or %NULL to clear the interface. |
| 5710 | * |
| 5711 | * Sets the #EventLog instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> on @object. |
| 5712 | */ |
| 5713 | void object_skeleton_set_event_log (ObjectSkeleton *object, EventLog *interface_) |
| 5714 | { |
| 5715 | g_object_set (G_OBJECT (object), "event-log", interface_, NULL); |
| 5716 | } |
| 5717 | |
| 5718 | |
| 5719 | /* ------------------------------------------------------------------------ |
| 5720 | * Code for ObjectManager client |
| 5721 | * ------------------------------------------------------------------------ |
| 5722 | */ |
| 5723 | |
| 5724 | /** |
| 5725 | * SECTION:ObjectManagerClient |
| 5726 | * @title: ObjectManagerClient |
| 5727 | * @short_description: Generated GDBusObjectManagerClient type |
| 5728 | * |
| 5729 | * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. |
| 5730 | */ |
| 5731 | |
| 5732 | /** |
| 5733 | * ObjectManagerClient: |
| 5734 | * |
| 5735 | * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API. |
| 5736 | */ |
| 5737 | |
| 5738 | /** |
| 5739 | * ObjectManagerClientClass: |
| 5740 | * @parent_class: The parent class. |
| 5741 | * |
| 5742 | * Class structure for #ObjectManagerClient. |
| 5743 | */ |
| 5744 | |
| 5745 | G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT); |
| 5746 | |
| 5747 | static void |
| 5748 | object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED) |
| 5749 | { |
| 5750 | } |
| 5751 | |
| 5752 | static void |
| 5753 | object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED) |
| 5754 | { |
| 5755 | } |
| 5756 | |
| 5757 | /** |
| 5758 | * object_manager_client_get_proxy_type: |
| 5759 | * @manager: A #GDBusObjectManagerClient. |
| 5760 | * @object_path: The object path of the remote object (unused). |
| 5761 | * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType. |
| 5762 | * @user_data: User data (unused). |
| 5763 | * |
| 5764 | * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types. |
| 5765 | * |
| 5766 | * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy. |
| 5767 | */ |
| 5768 | GType |
| 5769 | 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) |
| 5770 | { |
| 5771 | static gsize once_init_value = 0; |
| 5772 | static GHashTable *lookup_hash; |
| 5773 | GType ret; |
| 5774 | |
| 5775 | if (interface_name == NULL) |
| 5776 | return TYPE_OBJECT_PROXY; |
| 5777 | if (g_once_init_enter (&once_init_value)) |
| 5778 | { |
| 5779 | lookup_hash = g_hash_table_new (g_str_hash, g_str_equal); |
| 5780 | g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.Control", GSIZE_TO_POINTER (TYPE_CONTROL_PROXY)); |
| 5781 | g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.control.Host", GSIZE_TO_POINTER (TYPE_CONTROL_HOST_PROXY)); |
| 5782 | g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.control.Power", GSIZE_TO_POINTER (TYPE_CONTROL_POWER_PROXY)); |
| 5783 | g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.EventLog", GSIZE_TO_POINTER (TYPE_EVENT_LOG_PROXY)); |
| 5784 | g_once_init_leave (&once_init_value, 1); |
| 5785 | } |
| 5786 | ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name)); |
| 5787 | if (ret == (GType) 0) |
| 5788 | ret = G_TYPE_DBUS_PROXY; |
| 5789 | return ret; |
| 5790 | } |
| 5791 | |
| 5792 | /** |
| 5793 | * object_manager_client_new: |
| 5794 | * @connection: A #GDBusConnection. |
| 5795 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. |
| 5796 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 5797 | * @object_path: An object path. |
| 5798 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 5799 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 5800 | * @user_data: User data to pass to @callback. |
| 5801 | * |
| 5802 | * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details. |
| 5803 | * |
| 5804 | * 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. |
| 5805 | * You can then call object_manager_client_new_finish() to get the result of the operation. |
| 5806 | * |
| 5807 | * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor. |
| 5808 | */ |
| 5809 | void |
| 5810 | object_manager_client_new ( |
| 5811 | GDBusConnection *connection, |
| 5812 | GDBusObjectManagerClientFlags flags, |
| 5813 | const gchar *name, |
| 5814 | const gchar *object_path, |
| 5815 | GCancellable *cancellable, |
| 5816 | GAsyncReadyCallback callback, |
| 5817 | gpointer user_data) |
| 5818 | { |
| 5819 | 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); |
| 5820 | } |
| 5821 | |
| 5822 | /** |
| 5823 | * object_manager_client_new_finish: |
| 5824 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new(). |
| 5825 | * @error: Return location for error or %NULL |
| 5826 | * |
| 5827 | * Finishes an operation started with object_manager_client_new(). |
| 5828 | * |
| 5829 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set. |
| 5830 | */ |
| 5831 | GDBusObjectManager * |
| 5832 | object_manager_client_new_finish ( |
| 5833 | GAsyncResult *res, |
| 5834 | GError **error) |
| 5835 | { |
| 5836 | GObject *ret; |
| 5837 | GObject *source_object; |
| 5838 | source_object = g_async_result_get_source_object (res); |
| 5839 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 5840 | g_object_unref (source_object); |
| 5841 | if (ret != NULL) |
| 5842 | return G_DBUS_OBJECT_MANAGER (ret); |
| 5843 | else |
| 5844 | return NULL; |
| 5845 | } |
| 5846 | |
| 5847 | /** |
| 5848 | * object_manager_client_new_sync: |
| 5849 | * @connection: A #GDBusConnection. |
| 5850 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. |
| 5851 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. |
| 5852 | * @object_path: An object path. |
| 5853 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 5854 | * @error: Return location for error or %NULL |
| 5855 | * |
| 5856 | * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details. |
| 5857 | * |
| 5858 | * The calling thread is blocked until a reply is received. |
| 5859 | * |
| 5860 | * See object_manager_client_new() for the asynchronous version of this constructor. |
| 5861 | * |
| 5862 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set. |
| 5863 | */ |
| 5864 | GDBusObjectManager * |
| 5865 | object_manager_client_new_sync ( |
| 5866 | GDBusConnection *connection, |
| 5867 | GDBusObjectManagerClientFlags flags, |
| 5868 | const gchar *name, |
| 5869 | const gchar *object_path, |
| 5870 | GCancellable *cancellable, |
| 5871 | GError **error) |
| 5872 | { |
| 5873 | GInitable *ret; |
| 5874 | 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); |
| 5875 | if (ret != NULL) |
| 5876 | return G_DBUS_OBJECT_MANAGER (ret); |
| 5877 | else |
| 5878 | return NULL; |
| 5879 | } |
| 5880 | |
| 5881 | |
| 5882 | /** |
| 5883 | * object_manager_client_new_for_bus: |
| 5884 | * @bus_type: A #GBusType. |
| 5885 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. |
| 5886 | * @name: A bus name (well-known or unique). |
| 5887 | * @object_path: An object path. |
| 5888 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 5889 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied. |
| 5890 | * @user_data: User data to pass to @callback. |
| 5891 | * |
| 5892 | * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection. |
| 5893 | * |
| 5894 | * 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. |
| 5895 | * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation. |
| 5896 | * |
| 5897 | * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor. |
| 5898 | */ |
| 5899 | void |
| 5900 | object_manager_client_new_for_bus ( |
| 5901 | GBusType bus_type, |
| 5902 | GDBusObjectManagerClientFlags flags, |
| 5903 | const gchar *name, |
| 5904 | const gchar *object_path, |
| 5905 | GCancellable *cancellable, |
| 5906 | GAsyncReadyCallback callback, |
| 5907 | gpointer user_data) |
| 5908 | { |
| 5909 | 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); |
| 5910 | } |
| 5911 | |
| 5912 | /** |
| 5913 | * object_manager_client_new_for_bus_finish: |
| 5914 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus(). |
| 5915 | * @error: Return location for error or %NULL |
| 5916 | * |
| 5917 | * Finishes an operation started with object_manager_client_new_for_bus(). |
| 5918 | * |
| 5919 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set. |
| 5920 | */ |
| 5921 | GDBusObjectManager * |
| 5922 | object_manager_client_new_for_bus_finish ( |
| 5923 | GAsyncResult *res, |
| 5924 | GError **error) |
| 5925 | { |
| 5926 | GObject *ret; |
| 5927 | GObject *source_object; |
| 5928 | source_object = g_async_result_get_source_object (res); |
| 5929 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); |
| 5930 | g_object_unref (source_object); |
| 5931 | if (ret != NULL) |
| 5932 | return G_DBUS_OBJECT_MANAGER (ret); |
| 5933 | else |
| 5934 | return NULL; |
| 5935 | } |
| 5936 | |
| 5937 | /** |
| 5938 | * object_manager_client_new_for_bus_sync: |
| 5939 | * @bus_type: A #GBusType. |
| 5940 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration. |
| 5941 | * @name: A bus name (well-known or unique). |
| 5942 | * @object_path: An object path. |
| 5943 | * @cancellable: (allow-none): A #GCancellable or %NULL. |
| 5944 | * @error: Return location for error or %NULL |
| 5945 | * |
| 5946 | * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection. |
| 5947 | * |
| 5948 | * The calling thread is blocked until a reply is received. |
| 5949 | * |
| 5950 | * See object_manager_client_new_for_bus() for the asynchronous version of this constructor. |
| 5951 | * |
| 5952 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set. |
| 5953 | */ |
| 5954 | GDBusObjectManager * |
| 5955 | object_manager_client_new_for_bus_sync ( |
| 5956 | GBusType bus_type, |
| 5957 | GDBusObjectManagerClientFlags flags, |
| 5958 | const gchar *name, |
| 5959 | const gchar *object_path, |
| 5960 | GCancellable *cancellable, |
| 5961 | GError **error) |
| 5962 | { |
| 5963 | GInitable *ret; |
| 5964 | 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); |
| 5965 | if (ret != NULL) |
| 5966 | return G_DBUS_OBJECT_MANAGER (ret); |
| 5967 | else |
| 5968 | return NULL; |
| 5969 | } |
| 5970 | |
| 5971 | |