Norman James | e276510 | 2015-08-19 22:00: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/host_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.HostControl
|
| 153 | * ------------------------------------------------------------------------
|
| 154 | */
|
| 155 |
|
| 156 | /**
|
| 157 | * SECTION:HostControl
|
| 158 | * @title: HostControl
|
| 159 | * @short_description: Generated C code for the org.openbmc.HostControl D-Bus interface
|
| 160 | *
|
| 161 | * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link> D-Bus interface in C.
|
| 162 | */
|
| 163 |
|
| 164 | /* ---- Introspection data for org.openbmc.HostControl ---- */
|
| 165 |
|
| 166 | static const _ExtendedGDBusMethodInfo _host_control_method_info_boot =
|
| 167 | {
|
| 168 | {
|
| 169 | -1,
|
| 170 | (gchar *) "boot",
|
| 171 | NULL,
|
| 172 | NULL,
|
| 173 | NULL
|
| 174 | },
|
| 175 | "handle-boot",
|
| 176 | FALSE
|
| 177 | };
|
| 178 |
|
| 179 | static const _ExtendedGDBusMethodInfo _host_control_method_info_shutdown =
|
| 180 | {
|
| 181 | {
|
| 182 | -1,
|
| 183 | (gchar *) "shutdown",
|
| 184 | NULL,
|
| 185 | NULL,
|
| 186 | NULL
|
| 187 | },
|
| 188 | "handle-shutdown",
|
| 189 | FALSE
|
| 190 | };
|
| 191 |
|
| 192 | static const _ExtendedGDBusMethodInfo * const _host_control_method_info_pointers[] =
|
| 193 | {
|
| 194 | &_host_control_method_info_boot,
|
| 195 | &_host_control_method_info_shutdown,
|
| 196 | NULL
|
| 197 | };
|
| 198 |
|
| 199 | static const _ExtendedGDBusSignalInfo _host_control_signal_info_booted =
|
| 200 | {
|
| 201 | {
|
| 202 | -1,
|
| 203 | (gchar *) "booted",
|
| 204 | NULL,
|
| 205 | NULL
|
| 206 | },
|
| 207 | "booted"
|
| 208 | };
|
| 209 |
|
| 210 | static const _ExtendedGDBusSignalInfo * const _host_control_signal_info_pointers[] =
|
| 211 | {
|
| 212 | &_host_control_signal_info_booted,
|
| 213 | NULL
|
| 214 | };
|
| 215 |
|
| 216 | static const _ExtendedGDBusInterfaceInfo _host_control_interface_info =
|
| 217 | {
|
| 218 | {
|
| 219 | -1,
|
| 220 | (gchar *) "org.openbmc.HostControl",
|
| 221 | (GDBusMethodInfo **) &_host_control_method_info_pointers,
|
| 222 | (GDBusSignalInfo **) &_host_control_signal_info_pointers,
|
| 223 | NULL,
|
| 224 | NULL
|
| 225 | },
|
| 226 | "host-control",
|
| 227 | };
|
| 228 |
|
| 229 |
|
| 230 | /**
|
| 231 | * host_control_interface_info:
|
| 232 | *
|
| 233 | * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link> D-Bus interface.
|
| 234 | *
|
| 235 | * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
|
| 236 | */
|
| 237 | GDBusInterfaceInfo *
|
| 238 | host_control_interface_info (void)
|
| 239 | {
|
| 240 | return (GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct;
|
| 241 | }
|
| 242 |
|
| 243 | /**
|
| 244 | * host_control_override_properties:
|
| 245 | * @klass: The class structure for a #GObject<!-- -->-derived class.
|
| 246 | * @property_id_begin: The property id to assign to the first overridden property.
|
| 247 | *
|
| 248 | * Overrides all #GObject properties in the #HostControl interface for a concrete class.
|
| 249 | * The properties are overridden in the order they are defined.
|
| 250 | *
|
| 251 | * Returns: The last property id.
|
| 252 | */
|
| 253 | guint
|
| 254 | host_control_override_properties (GObjectClass *klass, guint property_id_begin)
|
| 255 | {
|
| 256 | return property_id_begin - 1;
|
| 257 | }
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 | /**
|
| 262 | * HostControl:
|
| 263 | *
|
| 264 | * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>.
|
| 265 | */
|
| 266 |
|
| 267 | /**
|
| 268 | * HostControlIface:
|
| 269 | * @parent_iface: The parent interface.
|
| 270 | * @handle_boot: Handler for the #HostControl::handle-boot signal.
|
| 271 | * @handle_shutdown: Handler for the #HostControl::handle-shutdown signal.
|
| 272 | * @booted: Handler for the #HostControl::booted signal.
|
| 273 | *
|
| 274 | * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>.
|
| 275 | */
|
| 276 |
|
| 277 | typedef HostControlIface HostControlInterface;
|
| 278 | G_DEFINE_INTERFACE (HostControl, host_control, G_TYPE_OBJECT);
|
| 279 |
|
| 280 | static void
|
| 281 | host_control_default_init (HostControlIface *iface)
|
| 282 | {
|
| 283 | /* GObject signals for incoming D-Bus method calls: */
|
| 284 | /**
|
| 285 | * HostControl::handle-boot:
|
| 286 | * @object: A #HostControl.
|
| 287 | * @invocation: A #GDBusMethodInvocation.
|
| 288 | *
|
| 289 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-HostControl.boot">boot()</link> D-Bus method.
|
| 290 | *
|
| 291 | * 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 host_control_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.
|
| 292 | *
|
| 293 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
|
| 294 | */
|
| 295 | g_signal_new ("handle-boot",
|
| 296 | G_TYPE_FROM_INTERFACE (iface),
|
| 297 | G_SIGNAL_RUN_LAST,
|
| 298 | G_STRUCT_OFFSET (HostControlIface, handle_boot),
|
| 299 | g_signal_accumulator_true_handled,
|
| 300 | NULL,
|
| 301 | g_cclosure_marshal_generic,
|
| 302 | G_TYPE_BOOLEAN,
|
| 303 | 1,
|
| 304 | G_TYPE_DBUS_METHOD_INVOCATION);
|
| 305 |
|
| 306 | /**
|
| 307 | * HostControl::handle-shutdown:
|
| 308 | * @object: A #HostControl.
|
| 309 | * @invocation: A #GDBusMethodInvocation.
|
| 310 | *
|
| 311 | * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-HostControl.shutdown">shutdown()</link> D-Bus method.
|
| 312 | *
|
| 313 | * 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 host_control_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.
|
| 314 | *
|
| 315 | * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
|
| 316 | */
|
| 317 | g_signal_new ("handle-shutdown",
|
| 318 | G_TYPE_FROM_INTERFACE (iface),
|
| 319 | G_SIGNAL_RUN_LAST,
|
| 320 | G_STRUCT_OFFSET (HostControlIface, handle_shutdown),
|
| 321 | g_signal_accumulator_true_handled,
|
| 322 | NULL,
|
| 323 | g_cclosure_marshal_generic,
|
| 324 | G_TYPE_BOOLEAN,
|
| 325 | 1,
|
| 326 | G_TYPE_DBUS_METHOD_INVOCATION);
|
| 327 |
|
| 328 | /* GObject signals for received D-Bus signals: */
|
| 329 | /**
|
| 330 | * HostControl::booted:
|
| 331 | * @object: A #HostControl.
|
| 332 | *
|
| 333 | * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-HostControl.booted">"booted"</link> is received.
|
| 334 | *
|
| 335 | * 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.
|
| 336 | */
|
| 337 | g_signal_new ("booted",
|
| 338 | G_TYPE_FROM_INTERFACE (iface),
|
| 339 | G_SIGNAL_RUN_LAST,
|
| 340 | G_STRUCT_OFFSET (HostControlIface, booted),
|
| 341 | NULL,
|
| 342 | NULL,
|
| 343 | g_cclosure_marshal_generic,
|
| 344 | G_TYPE_NONE,
|
| 345 | 0);
|
| 346 |
|
| 347 | }
|
| 348 |
|
| 349 | /**
|
| 350 | * host_control_emit_booted:
|
| 351 | * @object: A #HostControl.
|
| 352 | *
|
| 353 | * Emits the <link linkend="gdbus-signal-org-openbmc-HostControl.booted">"booted"</link> D-Bus signal.
|
| 354 | */
|
| 355 | void
|
| 356 | host_control_emit_booted (
|
| 357 | HostControl *object)
|
| 358 | {
|
| 359 | g_signal_emit_by_name (object, "booted");
|
| 360 | }
|
| 361 |
|
| 362 | /**
|
| 363 | * host_control_call_boot:
|
| 364 | * @proxy: A #HostControlProxy.
|
| 365 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 366 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
| 367 | * @user_data: User data to pass to @callback.
|
| 368 | *
|
| 369 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-HostControl.boot">boot()</link> D-Bus method on @proxy.
|
| 370 | * 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.
|
| 371 | * You can then call host_control_call_boot_finish() to get the result of the operation.
|
| 372 | *
|
| 373 | * See host_control_call_boot_sync() for the synchronous, blocking version of this method.
|
| 374 | */
|
| 375 | void
|
| 376 | host_control_call_boot (
|
| 377 | HostControl *proxy,
|
| 378 | GCancellable *cancellable,
|
| 379 | GAsyncReadyCallback callback,
|
| 380 | gpointer user_data)
|
| 381 | {
|
| 382 | g_dbus_proxy_call (G_DBUS_PROXY (proxy),
|
| 383 | "boot",
|
| 384 | g_variant_new ("()"),
|
| 385 | G_DBUS_CALL_FLAGS_NONE,
|
| 386 | -1,
|
| 387 | cancellable,
|
| 388 | callback,
|
| 389 | user_data);
|
| 390 | }
|
| 391 |
|
| 392 | /**
|
| 393 | * host_control_call_boot_finish:
|
| 394 | * @proxy: A #HostControlProxy.
|
| 395 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to host_control_call_boot().
|
| 396 | * @error: Return location for error or %NULL.
|
| 397 | *
|
| 398 | * Finishes an operation started with host_control_call_boot().
|
| 399 | *
|
| 400 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
|
| 401 | */
|
| 402 | gboolean
|
| 403 | host_control_call_boot_finish (
|
| 404 | HostControl *proxy,
|
| 405 | GAsyncResult *res,
|
| 406 | GError **error)
|
| 407 | {
|
| 408 | GVariant *_ret;
|
| 409 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
|
| 410 | if (_ret == NULL)
|
| 411 | goto _out;
|
| 412 | g_variant_get (_ret,
|
| 413 | "()");
|
| 414 | g_variant_unref (_ret);
|
| 415 | _out:
|
| 416 | return _ret != NULL;
|
| 417 | }
|
| 418 |
|
| 419 | /**
|
| 420 | * host_control_call_boot_sync:
|
| 421 | * @proxy: A #HostControlProxy.
|
| 422 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 423 | * @error: Return location for error or %NULL.
|
| 424 | *
|
| 425 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-HostControl.boot">boot()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
|
| 426 | *
|
| 427 | * See host_control_call_boot() for the asynchronous version of this method.
|
| 428 | *
|
| 429 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
|
| 430 | */
|
| 431 | gboolean
|
| 432 | host_control_call_boot_sync (
|
| 433 | HostControl *proxy,
|
| 434 | GCancellable *cancellable,
|
| 435 | GError **error)
|
| 436 | {
|
| 437 | GVariant *_ret;
|
| 438 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
|
| 439 | "boot",
|
| 440 | g_variant_new ("()"),
|
| 441 | G_DBUS_CALL_FLAGS_NONE,
|
| 442 | -1,
|
| 443 | cancellable,
|
| 444 | error);
|
| 445 | if (_ret == NULL)
|
| 446 | goto _out;
|
| 447 | g_variant_get (_ret,
|
| 448 | "()");
|
| 449 | g_variant_unref (_ret);
|
| 450 | _out:
|
| 451 | return _ret != NULL;
|
| 452 | }
|
| 453 |
|
| 454 | /**
|
| 455 | * host_control_call_shutdown:
|
| 456 | * @proxy: A #HostControlProxy.
|
| 457 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 458 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
| 459 | * @user_data: User data to pass to @callback.
|
| 460 | *
|
| 461 | * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-HostControl.shutdown">shutdown()</link> D-Bus method on @proxy.
|
| 462 | * 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.
|
| 463 | * You can then call host_control_call_shutdown_finish() to get the result of the operation.
|
| 464 | *
|
| 465 | * See host_control_call_shutdown_sync() for the synchronous, blocking version of this method.
|
| 466 | */
|
| 467 | void
|
| 468 | host_control_call_shutdown (
|
| 469 | HostControl *proxy,
|
| 470 | GCancellable *cancellable,
|
| 471 | GAsyncReadyCallback callback,
|
| 472 | gpointer user_data)
|
| 473 | {
|
| 474 | g_dbus_proxy_call (G_DBUS_PROXY (proxy),
|
| 475 | "shutdown",
|
| 476 | g_variant_new ("()"),
|
| 477 | G_DBUS_CALL_FLAGS_NONE,
|
| 478 | -1,
|
| 479 | cancellable,
|
| 480 | callback,
|
| 481 | user_data);
|
| 482 | }
|
| 483 |
|
| 484 | /**
|
| 485 | * host_control_call_shutdown_finish:
|
| 486 | * @proxy: A #HostControlProxy.
|
| 487 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to host_control_call_shutdown().
|
| 488 | * @error: Return location for error or %NULL.
|
| 489 | *
|
| 490 | * Finishes an operation started with host_control_call_shutdown().
|
| 491 | *
|
| 492 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
|
| 493 | */
|
| 494 | gboolean
|
| 495 | host_control_call_shutdown_finish (
|
| 496 | HostControl *proxy,
|
| 497 | GAsyncResult *res,
|
| 498 | GError **error)
|
| 499 | {
|
| 500 | GVariant *_ret;
|
| 501 | _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
|
| 502 | if (_ret == NULL)
|
| 503 | goto _out;
|
| 504 | g_variant_get (_ret,
|
| 505 | "()");
|
| 506 | g_variant_unref (_ret);
|
| 507 | _out:
|
| 508 | return _ret != NULL;
|
| 509 | }
|
| 510 |
|
| 511 | /**
|
| 512 | * host_control_call_shutdown_sync:
|
| 513 | * @proxy: A #HostControlProxy.
|
| 514 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 515 | * @error: Return location for error or %NULL.
|
| 516 | *
|
| 517 | * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-HostControl.shutdown">shutdown()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
|
| 518 | *
|
| 519 | * See host_control_call_shutdown() for the asynchronous version of this method.
|
| 520 | *
|
| 521 | * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
|
| 522 | */
|
| 523 | gboolean
|
| 524 | host_control_call_shutdown_sync (
|
| 525 | HostControl *proxy,
|
| 526 | GCancellable *cancellable,
|
| 527 | GError **error)
|
| 528 | {
|
| 529 | GVariant *_ret;
|
| 530 | _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
|
| 531 | "shutdown",
|
| 532 | g_variant_new ("()"),
|
| 533 | G_DBUS_CALL_FLAGS_NONE,
|
| 534 | -1,
|
| 535 | cancellable,
|
| 536 | error);
|
| 537 | if (_ret == NULL)
|
| 538 | goto _out;
|
| 539 | g_variant_get (_ret,
|
| 540 | "()");
|
| 541 | g_variant_unref (_ret);
|
| 542 | _out:
|
| 543 | return _ret != NULL;
|
| 544 | }
|
| 545 |
|
| 546 | /**
|
| 547 | * host_control_complete_boot:
|
| 548 | * @object: A #HostControl.
|
| 549 | * @invocation: (transfer full): A #GDBusMethodInvocation.
|
| 550 | *
|
| 551 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-HostControl.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.
|
| 552 | *
|
| 553 | * This method will free @invocation, you cannot use it afterwards.
|
| 554 | */
|
| 555 | void
|
| 556 | host_control_complete_boot (
|
| 557 | HostControl *object,
|
| 558 | GDBusMethodInvocation *invocation)
|
| 559 | {
|
| 560 | g_dbus_method_invocation_return_value (invocation,
|
| 561 | g_variant_new ("()"));
|
| 562 | }
|
| 563 |
|
| 564 | /**
|
| 565 | * host_control_complete_shutdown:
|
| 566 | * @object: A #HostControl.
|
| 567 | * @invocation: (transfer full): A #GDBusMethodInvocation.
|
| 568 | *
|
| 569 | * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-HostControl.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.
|
| 570 | *
|
| 571 | * This method will free @invocation, you cannot use it afterwards.
|
| 572 | */
|
| 573 | void
|
| 574 | host_control_complete_shutdown (
|
| 575 | HostControl *object,
|
| 576 | GDBusMethodInvocation *invocation)
|
| 577 | {
|
| 578 | g_dbus_method_invocation_return_value (invocation,
|
| 579 | g_variant_new ("()"));
|
| 580 | }
|
| 581 |
|
| 582 | /* ------------------------------------------------------------------------ */
|
| 583 |
|
| 584 | /**
|
| 585 | * HostControlProxy:
|
| 586 | *
|
| 587 | * The #HostControlProxy structure contains only private data and should only be accessed using the provided API.
|
| 588 | */
|
| 589 |
|
| 590 | /**
|
| 591 | * HostControlProxyClass:
|
| 592 | * @parent_class: The parent class.
|
| 593 | *
|
| 594 | * Class structure for #HostControlProxy.
|
| 595 | */
|
| 596 |
|
| 597 | struct _HostControlProxyPrivate
|
| 598 | {
|
| 599 | GData *qdata;
|
| 600 | };
|
| 601 |
|
| 602 | static void host_control_proxy_iface_init (HostControlIface *iface);
|
| 603 |
|
| 604 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
|
| 605 | G_DEFINE_TYPE_WITH_CODE (HostControlProxy, host_control_proxy, G_TYPE_DBUS_PROXY,
|
| 606 | G_ADD_PRIVATE (HostControlProxy)
|
| 607 | G_IMPLEMENT_INTERFACE (TYPE_HOST_CONTROL, host_control_proxy_iface_init));
|
| 608 |
|
| 609 | #else
|
| 610 | G_DEFINE_TYPE_WITH_CODE (HostControlProxy, host_control_proxy, G_TYPE_DBUS_PROXY,
|
| 611 | G_IMPLEMENT_INTERFACE (TYPE_HOST_CONTROL, host_control_proxy_iface_init));
|
| 612 |
|
| 613 | #endif
|
| 614 | static void
|
| 615 | host_control_proxy_finalize (GObject *object)
|
| 616 | {
|
| 617 | HostControlProxy *proxy = HOST_CONTROL_PROXY (object);
|
| 618 | g_datalist_clear (&proxy->priv->qdata);
|
| 619 | G_OBJECT_CLASS (host_control_proxy_parent_class)->finalize (object);
|
| 620 | }
|
| 621 |
|
| 622 | static void
|
| 623 | host_control_proxy_get_property (GObject *object,
|
| 624 | guint prop_id,
|
| 625 | GValue *value,
|
| 626 | GParamSpec *pspec G_GNUC_UNUSED)
|
| 627 | {
|
| 628 | }
|
| 629 |
|
| 630 | static void
|
| 631 | host_control_proxy_set_property (GObject *object,
|
| 632 | guint prop_id,
|
| 633 | const GValue *value,
|
| 634 | GParamSpec *pspec G_GNUC_UNUSED)
|
| 635 | {
|
| 636 | }
|
| 637 |
|
| 638 | static void
|
| 639 | host_control_proxy_g_signal (GDBusProxy *proxy,
|
| 640 | const gchar *sender_name G_GNUC_UNUSED,
|
| 641 | const gchar *signal_name,
|
| 642 | GVariant *parameters)
|
| 643 | {
|
| 644 | _ExtendedGDBusSignalInfo *info;
|
| 645 | GVariantIter iter;
|
| 646 | GVariant *child;
|
| 647 | GValue *paramv;
|
| 648 | guint num_params;
|
| 649 | guint n;
|
| 650 | guint signal_id;
|
| 651 | info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct, signal_name);
|
| 652 | if (info == NULL)
|
| 653 | return;
|
| 654 | num_params = g_variant_n_children (parameters);
|
| 655 | paramv = g_new0 (GValue, num_params + 1);
|
| 656 | g_value_init (¶mv[0], TYPE_HOST_CONTROL);
|
| 657 | g_value_set_object (¶mv[0], proxy);
|
| 658 | g_variant_iter_init (&iter, parameters);
|
| 659 | n = 1;
|
| 660 | while ((child = g_variant_iter_next_value (&iter)) != NULL)
|
| 661 | {
|
| 662 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
|
| 663 | if (arg_info->use_gvariant)
|
| 664 | {
|
| 665 | g_value_init (¶mv[n], G_TYPE_VARIANT);
|
| 666 | g_value_set_variant (¶mv[n], child);
|
| 667 | n++;
|
| 668 | }
|
| 669 | else
|
| 670 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
|
| 671 | g_variant_unref (child);
|
| 672 | }
|
| 673 | signal_id = g_signal_lookup (info->signal_name, TYPE_HOST_CONTROL);
|
| 674 | g_signal_emitv (paramv, signal_id, 0, NULL);
|
| 675 | for (n = 0; n < num_params + 1; n++)
|
| 676 | g_value_unset (¶mv[n]);
|
| 677 | g_free (paramv);
|
| 678 | }
|
| 679 |
|
| 680 | static void
|
| 681 | host_control_proxy_g_properties_changed (GDBusProxy *_proxy,
|
| 682 | GVariant *changed_properties,
|
| 683 | const gchar *const *invalidated_properties)
|
| 684 | {
|
| 685 | HostControlProxy *proxy = HOST_CONTROL_PROXY (_proxy);
|
| 686 | guint n;
|
| 687 | const gchar *key;
|
| 688 | GVariantIter *iter;
|
| 689 | _ExtendedGDBusPropertyInfo *info;
|
| 690 | g_variant_get (changed_properties, "a{sv}", &iter);
|
| 691 | while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
|
| 692 | {
|
| 693 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct, key);
|
| 694 | g_datalist_remove_data (&proxy->priv->qdata, key);
|
| 695 | if (info != NULL)
|
| 696 | g_object_notify (G_OBJECT (proxy), info->hyphen_name);
|
| 697 | }
|
| 698 | g_variant_iter_free (iter);
|
| 699 | for (n = 0; invalidated_properties[n] != NULL; n++)
|
| 700 | {
|
| 701 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct, invalidated_properties[n]);
|
| 702 | g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
|
| 703 | if (info != NULL)
|
| 704 | g_object_notify (G_OBJECT (proxy), info->hyphen_name);
|
| 705 | }
|
| 706 | }
|
| 707 |
|
| 708 | static void
|
| 709 | host_control_proxy_init (HostControlProxy *proxy)
|
| 710 | {
|
| 711 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
|
| 712 | proxy->priv = host_control_proxy_get_instance_private (proxy);
|
| 713 | #else
|
| 714 | proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_HOST_CONTROL_PROXY, HostControlProxyPrivate);
|
| 715 | #endif
|
| 716 |
|
| 717 | g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), host_control_interface_info ());
|
| 718 | }
|
| 719 |
|
| 720 | static void
|
| 721 | host_control_proxy_class_init (HostControlProxyClass *klass)
|
| 722 | {
|
| 723 | GObjectClass *gobject_class;
|
| 724 | GDBusProxyClass *proxy_class;
|
| 725 |
|
| 726 | gobject_class = G_OBJECT_CLASS (klass);
|
| 727 | gobject_class->finalize = host_control_proxy_finalize;
|
| 728 | gobject_class->get_property = host_control_proxy_get_property;
|
| 729 | gobject_class->set_property = host_control_proxy_set_property;
|
| 730 |
|
| 731 | proxy_class = G_DBUS_PROXY_CLASS (klass);
|
| 732 | proxy_class->g_signal = host_control_proxy_g_signal;
|
| 733 | proxy_class->g_properties_changed = host_control_proxy_g_properties_changed;
|
| 734 |
|
| 735 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
|
| 736 | g_type_class_add_private (klass, sizeof (HostControlProxyPrivate));
|
| 737 | #endif
|
| 738 | }
|
| 739 |
|
| 740 | static void
|
| 741 | host_control_proxy_iface_init (HostControlIface *iface)
|
| 742 | {
|
| 743 | }
|
| 744 |
|
| 745 | /**
|
| 746 | * host_control_proxy_new:
|
| 747 | * @connection: A #GDBusConnection.
|
| 748 | * @flags: Flags from the #GDBusProxyFlags enumeration.
|
| 749 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
|
| 750 | * @object_path: An object path.
|
| 751 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 752 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
|
| 753 | * @user_data: User data to pass to @callback.
|
| 754 | *
|
| 755 | * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>. See g_dbus_proxy_new() for more details.
|
| 756 | *
|
| 757 | * 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.
|
| 758 | * You can then call host_control_proxy_new_finish() to get the result of the operation.
|
| 759 | *
|
| 760 | * See host_control_proxy_new_sync() for the synchronous, blocking version of this constructor.
|
| 761 | */
|
| 762 | void
|
| 763 | host_control_proxy_new (
|
| 764 | GDBusConnection *connection,
|
| 765 | GDBusProxyFlags flags,
|
| 766 | const gchar *name,
|
| 767 | const gchar *object_path,
|
| 768 | GCancellable *cancellable,
|
| 769 | GAsyncReadyCallback callback,
|
| 770 | gpointer user_data)
|
| 771 | {
|
| 772 | g_async_initable_new_async (TYPE_HOST_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.HostControl", NULL);
|
| 773 | }
|
| 774 |
|
| 775 | /**
|
| 776 | * host_control_proxy_new_finish:
|
| 777 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to host_control_proxy_new().
|
| 778 | * @error: Return location for error or %NULL
|
| 779 | *
|
| 780 | * Finishes an operation started with host_control_proxy_new().
|
| 781 | *
|
| 782 | * Returns: (transfer full) (type HostControlProxy): The constructed proxy object or %NULL if @error is set.
|
| 783 | */
|
| 784 | HostControl *
|
| 785 | host_control_proxy_new_finish (
|
| 786 | GAsyncResult *res,
|
| 787 | GError **error)
|
| 788 | {
|
| 789 | GObject *ret;
|
| 790 | GObject *source_object;
|
| 791 | source_object = g_async_result_get_source_object (res);
|
| 792 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
|
| 793 | g_object_unref (source_object);
|
| 794 | if (ret != NULL)
|
| 795 | return HOST_CONTROL (ret);
|
| 796 | else
|
| 797 | return NULL;
|
| 798 | }
|
| 799 |
|
| 800 | /**
|
| 801 | * host_control_proxy_new_sync:
|
| 802 | * @connection: A #GDBusConnection.
|
| 803 | * @flags: Flags from the #GDBusProxyFlags enumeration.
|
| 804 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
|
| 805 | * @object_path: An object path.
|
| 806 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 807 | * @error: Return location for error or %NULL
|
| 808 | *
|
| 809 | * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>. See g_dbus_proxy_new_sync() for more details.
|
| 810 | *
|
| 811 | * The calling thread is blocked until a reply is received.
|
| 812 | *
|
| 813 | * See host_control_proxy_new() for the asynchronous version of this constructor.
|
| 814 | *
|
| 815 | * Returns: (transfer full) (type HostControlProxy): The constructed proxy object or %NULL if @error is set.
|
| 816 | */
|
| 817 | HostControl *
|
| 818 | host_control_proxy_new_sync (
|
| 819 | GDBusConnection *connection,
|
| 820 | GDBusProxyFlags flags,
|
| 821 | const gchar *name,
|
| 822 | const gchar *object_path,
|
| 823 | GCancellable *cancellable,
|
| 824 | GError **error)
|
| 825 | {
|
| 826 | GInitable *ret;
|
| 827 | ret = g_initable_new (TYPE_HOST_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.HostControl", NULL);
|
| 828 | if (ret != NULL)
|
| 829 | return HOST_CONTROL (ret);
|
| 830 | else
|
| 831 | return NULL;
|
| 832 | }
|
| 833 |
|
| 834 |
|
| 835 | /**
|
| 836 | * host_control_proxy_new_for_bus:
|
| 837 | * @bus_type: A #GBusType.
|
| 838 | * @flags: Flags from the #GDBusProxyFlags enumeration.
|
| 839 | * @name: A bus name (well-known or unique).
|
| 840 | * @object_path: An object path.
|
| 841 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 842 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
|
| 843 | * @user_data: User data to pass to @callback.
|
| 844 | *
|
| 845 | * Like host_control_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
|
| 846 | *
|
| 847 | * 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.
|
| 848 | * You can then call host_control_proxy_new_for_bus_finish() to get the result of the operation.
|
| 849 | *
|
| 850 | * See host_control_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
|
| 851 | */
|
| 852 | void
|
| 853 | host_control_proxy_new_for_bus (
|
| 854 | GBusType bus_type,
|
| 855 | GDBusProxyFlags flags,
|
| 856 | const gchar *name,
|
| 857 | const gchar *object_path,
|
| 858 | GCancellable *cancellable,
|
| 859 | GAsyncReadyCallback callback,
|
| 860 | gpointer user_data)
|
| 861 | {
|
| 862 | g_async_initable_new_async (TYPE_HOST_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.HostControl", NULL);
|
| 863 | }
|
| 864 |
|
| 865 | /**
|
| 866 | * host_control_proxy_new_for_bus_finish:
|
| 867 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to host_control_proxy_new_for_bus().
|
| 868 | * @error: Return location for error or %NULL
|
| 869 | *
|
| 870 | * Finishes an operation started with host_control_proxy_new_for_bus().
|
| 871 | *
|
| 872 | * Returns: (transfer full) (type HostControlProxy): The constructed proxy object or %NULL if @error is set.
|
| 873 | */
|
| 874 | HostControl *
|
| 875 | host_control_proxy_new_for_bus_finish (
|
| 876 | GAsyncResult *res,
|
| 877 | GError **error)
|
| 878 | {
|
| 879 | GObject *ret;
|
| 880 | GObject *source_object;
|
| 881 | source_object = g_async_result_get_source_object (res);
|
| 882 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
|
| 883 | g_object_unref (source_object);
|
| 884 | if (ret != NULL)
|
| 885 | return HOST_CONTROL (ret);
|
| 886 | else
|
| 887 | return NULL;
|
| 888 | }
|
| 889 |
|
| 890 | /**
|
| 891 | * host_control_proxy_new_for_bus_sync:
|
| 892 | * @bus_type: A #GBusType.
|
| 893 | * @flags: Flags from the #GDBusProxyFlags enumeration.
|
| 894 | * @name: A bus name (well-known or unique).
|
| 895 | * @object_path: An object path.
|
| 896 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 897 | * @error: Return location for error or %NULL
|
| 898 | *
|
| 899 | * Like host_control_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
|
| 900 | *
|
| 901 | * The calling thread is blocked until a reply is received.
|
| 902 | *
|
| 903 | * See host_control_proxy_new_for_bus() for the asynchronous version of this constructor.
|
| 904 | *
|
| 905 | * Returns: (transfer full) (type HostControlProxy): The constructed proxy object or %NULL if @error is set.
|
| 906 | */
|
| 907 | HostControl *
|
| 908 | host_control_proxy_new_for_bus_sync (
|
| 909 | GBusType bus_type,
|
| 910 | GDBusProxyFlags flags,
|
| 911 | const gchar *name,
|
| 912 | const gchar *object_path,
|
| 913 | GCancellable *cancellable,
|
| 914 | GError **error)
|
| 915 | {
|
| 916 | GInitable *ret;
|
| 917 | ret = g_initable_new (TYPE_HOST_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.HostControl", NULL);
|
| 918 | if (ret != NULL)
|
| 919 | return HOST_CONTROL (ret);
|
| 920 | else
|
| 921 | return NULL;
|
| 922 | }
|
| 923 |
|
| 924 |
|
| 925 | /* ------------------------------------------------------------------------ */
|
| 926 |
|
| 927 | /**
|
| 928 | * HostControlSkeleton:
|
| 929 | *
|
| 930 | * The #HostControlSkeleton structure contains only private data and should only be accessed using the provided API.
|
| 931 | */
|
| 932 |
|
| 933 | /**
|
| 934 | * HostControlSkeletonClass:
|
| 935 | * @parent_class: The parent class.
|
| 936 | *
|
| 937 | * Class structure for #HostControlSkeleton.
|
| 938 | */
|
| 939 |
|
| 940 | struct _HostControlSkeletonPrivate
|
| 941 | {
|
| 942 | GValue *properties;
|
| 943 | GList *changed_properties;
|
| 944 | GSource *changed_properties_idle_source;
|
| 945 | GMainContext *context;
|
| 946 | GMutex lock;
|
| 947 | };
|
| 948 |
|
| 949 | static void
|
| 950 | _host_control_skeleton_handle_method_call (
|
| 951 | GDBusConnection *connection G_GNUC_UNUSED,
|
| 952 | const gchar *sender G_GNUC_UNUSED,
|
| 953 | const gchar *object_path G_GNUC_UNUSED,
|
| 954 | const gchar *interface_name,
|
| 955 | const gchar *method_name,
|
| 956 | GVariant *parameters,
|
| 957 | GDBusMethodInvocation *invocation,
|
| 958 | gpointer user_data)
|
| 959 | {
|
| 960 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (user_data);
|
| 961 | _ExtendedGDBusMethodInfo *info;
|
| 962 | GVariantIter iter;
|
| 963 | GVariant *child;
|
| 964 | GValue *paramv;
|
| 965 | guint num_params;
|
| 966 | guint num_extra;
|
| 967 | guint n;
|
| 968 | guint signal_id;
|
| 969 | GValue return_value = G_VALUE_INIT;
|
| 970 | info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
|
| 971 | g_assert (info != NULL);
|
| 972 | num_params = g_variant_n_children (parameters);
|
| 973 | num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
|
| 974 | n = 0;
|
| 975 | g_value_init (¶mv[n], TYPE_HOST_CONTROL);
|
| 976 | g_value_set_object (¶mv[n++], skeleton);
|
| 977 | g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION);
|
| 978 | g_value_set_object (¶mv[n++], invocation);
|
| 979 | if (info->pass_fdlist)
|
| 980 | {
|
| 981 | #ifdef G_OS_UNIX
|
| 982 | g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST);
|
| 983 | g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
|
| 984 | #else
|
| 985 | g_assert_not_reached ();
|
| 986 | #endif
|
| 987 | }
|
| 988 | g_variant_iter_init (&iter, parameters);
|
| 989 | while ((child = g_variant_iter_next_value (&iter)) != NULL)
|
| 990 | {
|
| 991 | _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
|
| 992 | if (arg_info->use_gvariant)
|
| 993 | {
|
| 994 | g_value_init (¶mv[n], G_TYPE_VARIANT);
|
| 995 | g_value_set_variant (¶mv[n], child);
|
| 996 | n++;
|
| 997 | }
|
| 998 | else
|
| 999 | g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
|
| 1000 | g_variant_unref (child);
|
| 1001 | }
|
| 1002 | signal_id = g_signal_lookup (info->signal_name, TYPE_HOST_CONTROL);
|
| 1003 | g_value_init (&return_value, G_TYPE_BOOLEAN);
|
| 1004 | g_signal_emitv (paramv, signal_id, 0, &return_value);
|
| 1005 | if (!g_value_get_boolean (&return_value))
|
| 1006 | 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);
|
| 1007 | g_value_unset (&return_value);
|
| 1008 | for (n = 0; n < num_params + num_extra; n++)
|
| 1009 | g_value_unset (¶mv[n]);
|
| 1010 | g_free (paramv);
|
| 1011 | }
|
| 1012 |
|
| 1013 | static GVariant *
|
| 1014 | _host_control_skeleton_handle_get_property (
|
| 1015 | GDBusConnection *connection G_GNUC_UNUSED,
|
| 1016 | const gchar *sender G_GNUC_UNUSED,
|
| 1017 | const gchar *object_path G_GNUC_UNUSED,
|
| 1018 | const gchar *interface_name G_GNUC_UNUSED,
|
| 1019 | const gchar *property_name,
|
| 1020 | GError **error,
|
| 1021 | gpointer user_data)
|
| 1022 | {
|
| 1023 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (user_data);
|
| 1024 | GValue value = G_VALUE_INIT;
|
| 1025 | GParamSpec *pspec;
|
| 1026 | _ExtendedGDBusPropertyInfo *info;
|
| 1027 | GVariant *ret;
|
| 1028 | ret = NULL;
|
| 1029 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct, property_name);
|
| 1030 | g_assert (info != NULL);
|
| 1031 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
|
| 1032 | if (pspec == NULL)
|
| 1033 | {
|
| 1034 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
|
| 1035 | }
|
| 1036 | else
|
| 1037 | {
|
| 1038 | g_value_init (&value, pspec->value_type);
|
| 1039 | g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
|
| 1040 | ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
|
| 1041 | g_value_unset (&value);
|
| 1042 | }
|
| 1043 | return ret;
|
| 1044 | }
|
| 1045 |
|
| 1046 | static gboolean
|
| 1047 | _host_control_skeleton_handle_set_property (
|
| 1048 | GDBusConnection *connection G_GNUC_UNUSED,
|
| 1049 | const gchar *sender G_GNUC_UNUSED,
|
| 1050 | const gchar *object_path G_GNUC_UNUSED,
|
| 1051 | const gchar *interface_name G_GNUC_UNUSED,
|
| 1052 | const gchar *property_name,
|
| 1053 | GVariant *variant,
|
| 1054 | GError **error,
|
| 1055 | gpointer user_data)
|
| 1056 | {
|
| 1057 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (user_data);
|
| 1058 | GValue value = G_VALUE_INIT;
|
| 1059 | GParamSpec *pspec;
|
| 1060 | _ExtendedGDBusPropertyInfo *info;
|
| 1061 | gboolean ret;
|
| 1062 | ret = FALSE;
|
| 1063 | info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_host_control_interface_info.parent_struct, property_name);
|
| 1064 | g_assert (info != NULL);
|
| 1065 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
|
| 1066 | if (pspec == NULL)
|
| 1067 | {
|
| 1068 | g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
|
| 1069 | }
|
| 1070 | else
|
| 1071 | {
|
| 1072 | if (info->use_gvariant)
|
| 1073 | g_value_set_variant (&value, variant);
|
| 1074 | else
|
| 1075 | g_dbus_gvariant_to_gvalue (variant, &value);
|
| 1076 | g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
|
| 1077 | g_value_unset (&value);
|
| 1078 | ret = TRUE;
|
| 1079 | }
|
| 1080 | return ret;
|
| 1081 | }
|
| 1082 |
|
| 1083 | static const GDBusInterfaceVTable _host_control_skeleton_vtable =
|
| 1084 | {
|
| 1085 | _host_control_skeleton_handle_method_call,
|
| 1086 | _host_control_skeleton_handle_get_property,
|
| 1087 | _host_control_skeleton_handle_set_property,
|
| 1088 | {NULL}
|
| 1089 | };
|
| 1090 |
|
| 1091 | static GDBusInterfaceInfo *
|
| 1092 | host_control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
|
| 1093 | {
|
| 1094 | return host_control_interface_info ();
|
| 1095 | }
|
| 1096 |
|
| 1097 | static GDBusInterfaceVTable *
|
| 1098 | host_control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
|
| 1099 | {
|
| 1100 | return (GDBusInterfaceVTable *) &_host_control_skeleton_vtable;
|
| 1101 | }
|
| 1102 |
|
| 1103 | static GVariant *
|
| 1104 | host_control_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
|
| 1105 | {
|
| 1106 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (_skeleton);
|
| 1107 |
|
| 1108 | GVariantBuilder builder;
|
| 1109 | guint n;
|
| 1110 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
| 1111 | if (_host_control_interface_info.parent_struct.properties == NULL)
|
| 1112 | goto out;
|
| 1113 | for (n = 0; _host_control_interface_info.parent_struct.properties[n] != NULL; n++)
|
| 1114 | {
|
| 1115 | GDBusPropertyInfo *info = _host_control_interface_info.parent_struct.properties[n];
|
| 1116 | if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
|
| 1117 | {
|
| 1118 | GVariant *value;
|
| 1119 | value = _host_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.HostControl", info->name, NULL, skeleton);
|
| 1120 | if (value != NULL)
|
| 1121 | {
|
| 1122 | g_variant_take_ref (value);
|
| 1123 | g_variant_builder_add (&builder, "{sv}", info->name, value);
|
| 1124 | g_variant_unref (value);
|
| 1125 | }
|
| 1126 | }
|
| 1127 | }
|
| 1128 | out:
|
| 1129 | return g_variant_builder_end (&builder);
|
| 1130 | }
|
| 1131 |
|
| 1132 | static void
|
| 1133 | host_control_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
|
| 1134 | {
|
| 1135 | }
|
| 1136 |
|
| 1137 | static void
|
| 1138 | _host_control_on_signal_booted (
|
| 1139 | HostControl *object)
|
| 1140 | {
|
| 1141 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (object);
|
| 1142 |
|
| 1143 | GList *connections, *l;
|
| 1144 | GVariant *signal_variant;
|
| 1145 | connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
|
| 1146 |
|
| 1147 | signal_variant = g_variant_ref_sink (g_variant_new ("()"));
|
| 1148 | for (l = connections; l != NULL; l = l->next)
|
| 1149 | {
|
| 1150 | GDBusConnection *connection = l->data;
|
| 1151 | g_dbus_connection_emit_signal (connection,
|
| 1152 | NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.HostControl", "booted",
|
| 1153 | signal_variant, NULL);
|
| 1154 | }
|
| 1155 | g_variant_unref (signal_variant);
|
| 1156 | g_list_free_full (connections, g_object_unref);
|
| 1157 | }
|
| 1158 |
|
| 1159 | static void host_control_skeleton_iface_init (HostControlIface *iface);
|
| 1160 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
|
| 1161 | G_DEFINE_TYPE_WITH_CODE (HostControlSkeleton, host_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
|
| 1162 | G_ADD_PRIVATE (HostControlSkeleton)
|
| 1163 | G_IMPLEMENT_INTERFACE (TYPE_HOST_CONTROL, host_control_skeleton_iface_init));
|
| 1164 |
|
| 1165 | #else
|
| 1166 | G_DEFINE_TYPE_WITH_CODE (HostControlSkeleton, host_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
|
| 1167 | G_IMPLEMENT_INTERFACE (TYPE_HOST_CONTROL, host_control_skeleton_iface_init));
|
| 1168 |
|
| 1169 | #endif
|
| 1170 | static void
|
| 1171 | host_control_skeleton_finalize (GObject *object)
|
| 1172 | {
|
| 1173 | HostControlSkeleton *skeleton = HOST_CONTROL_SKELETON (object);
|
| 1174 | g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
|
| 1175 | if (skeleton->priv->changed_properties_idle_source != NULL)
|
| 1176 | g_source_destroy (skeleton->priv->changed_properties_idle_source);
|
| 1177 | g_main_context_unref (skeleton->priv->context);
|
| 1178 | g_mutex_clear (&skeleton->priv->lock);
|
| 1179 | G_OBJECT_CLASS (host_control_skeleton_parent_class)->finalize (object);
|
| 1180 | }
|
| 1181 |
|
| 1182 | static void
|
| 1183 | host_control_skeleton_init (HostControlSkeleton *skeleton)
|
| 1184 | {
|
| 1185 | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
|
| 1186 | skeleton->priv = host_control_skeleton_get_instance_private (skeleton);
|
| 1187 | #else
|
| 1188 | skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_HOST_CONTROL_SKELETON, HostControlSkeletonPrivate);
|
| 1189 | #endif
|
| 1190 |
|
| 1191 | g_mutex_init (&skeleton->priv->lock);
|
| 1192 | skeleton->priv->context = g_main_context_ref_thread_default ();
|
| 1193 | }
|
| 1194 |
|
| 1195 | static void
|
| 1196 | host_control_skeleton_class_init (HostControlSkeletonClass *klass)
|
| 1197 | {
|
| 1198 | GObjectClass *gobject_class;
|
| 1199 | GDBusInterfaceSkeletonClass *skeleton_class;
|
| 1200 |
|
| 1201 | gobject_class = G_OBJECT_CLASS (klass);
|
| 1202 | gobject_class->finalize = host_control_skeleton_finalize;
|
| 1203 |
|
| 1204 | skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
|
| 1205 | skeleton_class->get_info = host_control_skeleton_dbus_interface_get_info;
|
| 1206 | skeleton_class->get_properties = host_control_skeleton_dbus_interface_get_properties;
|
| 1207 | skeleton_class->flush = host_control_skeleton_dbus_interface_flush;
|
| 1208 | skeleton_class->get_vtable = host_control_skeleton_dbus_interface_get_vtable;
|
| 1209 |
|
| 1210 | #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
|
| 1211 | g_type_class_add_private (klass, sizeof (HostControlSkeletonPrivate));
|
| 1212 | #endif
|
| 1213 | }
|
| 1214 |
|
| 1215 | static void
|
| 1216 | host_control_skeleton_iface_init (HostControlIface *iface)
|
| 1217 | {
|
| 1218 | iface->booted = _host_control_on_signal_booted;
|
| 1219 | }
|
| 1220 |
|
| 1221 | /**
|
| 1222 | * host_control_skeleton_new:
|
| 1223 | *
|
| 1224 | * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>.
|
| 1225 | *
|
| 1226 | * Returns: (transfer full) (type HostControlSkeleton): The skeleton object.
|
| 1227 | */
|
| 1228 | HostControl *
|
| 1229 | host_control_skeleton_new (void)
|
| 1230 | {
|
| 1231 | return HOST_CONTROL (g_object_new (TYPE_HOST_CONTROL_SKELETON, NULL));
|
| 1232 | }
|
| 1233 |
|
| 1234 | /* ------------------------------------------------------------------------
|
| 1235 | * Code for Object, ObjectProxy and ObjectSkeleton
|
| 1236 | * ------------------------------------------------------------------------
|
| 1237 | */
|
| 1238 |
|
| 1239 | /**
|
| 1240 | * SECTION:Object
|
| 1241 | * @title: Object
|
| 1242 | * @short_description: Specialized GDBusObject types
|
| 1243 | *
|
| 1244 | * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
|
| 1245 | */
|
| 1246 |
|
| 1247 | /**
|
| 1248 | * Object:
|
| 1249 | *
|
| 1250 | * The #Object type is a specialized container of interfaces.
|
| 1251 | */
|
| 1252 |
|
| 1253 | /**
|
| 1254 | * ObjectIface:
|
| 1255 | * @parent_iface: The parent interface.
|
| 1256 | *
|
| 1257 | * Virtual table for the #Object interface.
|
| 1258 | */
|
| 1259 |
|
| 1260 | typedef ObjectIface ObjectInterface;
|
| 1261 | G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
|
| 1262 |
|
| 1263 | static void
|
| 1264 | object_default_init (ObjectIface *iface)
|
| 1265 | {
|
| 1266 | /**
|
| 1267 | * Object:host-control:
|
| 1268 | *
|
| 1269 | * The #HostControl instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link>, if any.
|
| 1270 | *
|
| 1271 | * Connect to the #GObject::notify signal to get informed of property changes.
|
| 1272 | */
|
| 1273 | g_object_interface_install_property (iface, g_param_spec_object ("host-control", "host-control", "host-control", TYPE_HOST_CONTROL, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
|
| 1274 |
|
| 1275 | }
|
| 1276 |
|
| 1277 | /**
|
| 1278 | * object_get_host_control:
|
| 1279 | * @object: A #Object.
|
| 1280 | *
|
| 1281 | * Gets the #HostControl instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link> on @object, if any.
|
| 1282 | *
|
| 1283 | * Returns: (transfer full): A #HostControl that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
|
| 1284 | */
|
| 1285 | HostControl *object_get_host_control (Object *object)
|
| 1286 | {
|
| 1287 | GDBusInterface *ret;
|
| 1288 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.HostControl");
|
| 1289 | if (ret == NULL)
|
| 1290 | return NULL;
|
| 1291 | return HOST_CONTROL (ret);
|
| 1292 | }
|
| 1293 |
|
| 1294 |
|
| 1295 | /**
|
| 1296 | * object_peek_host_control: (skip)
|
| 1297 | * @object: A #Object.
|
| 1298 | *
|
| 1299 | * Like object_get_host_control() but doesn't increase the reference count on the returned object.
|
| 1300 | *
|
| 1301 | * <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>
|
| 1302 | *
|
| 1303 | * Returns: (transfer none): A #HostControl or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
|
| 1304 | */
|
| 1305 | HostControl *object_peek_host_control (Object *object)
|
| 1306 | {
|
| 1307 | GDBusInterface *ret;
|
| 1308 | ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.HostControl");
|
| 1309 | if (ret == NULL)
|
| 1310 | return NULL;
|
| 1311 | g_object_unref (ret);
|
| 1312 | return HOST_CONTROL (ret);
|
| 1313 | }
|
| 1314 |
|
| 1315 |
|
| 1316 | static void
|
| 1317 | object_notify (GDBusObject *object, GDBusInterface *interface)
|
| 1318 | {
|
| 1319 | _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
|
| 1320 | /* info can be NULL if the other end is using a D-Bus interface we don't know
|
| 1321 | * anything about, for example old generated code in this process talking to
|
| 1322 | * newer generated code in the other process. */
|
| 1323 | if (info != NULL)
|
| 1324 | g_object_notify (G_OBJECT (object), info->hyphen_name);
|
| 1325 | }
|
| 1326 |
|
| 1327 | /**
|
| 1328 | * ObjectProxy:
|
| 1329 | *
|
| 1330 | * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
|
| 1331 | */
|
| 1332 |
|
| 1333 | /**
|
| 1334 | * ObjectProxyClass:
|
| 1335 | * @parent_class: The parent class.
|
| 1336 | *
|
| 1337 | * Class structure for #ObjectProxy.
|
| 1338 | */
|
| 1339 |
|
| 1340 | static void
|
| 1341 | object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
|
| 1342 | {
|
| 1343 | }
|
| 1344 |
|
| 1345 | static void
|
| 1346 | object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
|
| 1347 | {
|
| 1348 | iface->interface_added = object_notify;
|
| 1349 | iface->interface_removed = object_notify;
|
| 1350 | }
|
| 1351 |
|
| 1352 |
|
| 1353 | G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
|
| 1354 | G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
|
| 1355 | G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
|
| 1356 |
|
| 1357 | static void
|
| 1358 | object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
|
| 1359 | {
|
| 1360 | }
|
| 1361 |
|
| 1362 | static void
|
| 1363 | object_proxy_set_property (GObject *gobject,
|
| 1364 | guint prop_id,
|
| 1365 | const GValue *value G_GNUC_UNUSED,
|
| 1366 | GParamSpec *pspec)
|
| 1367 | {
|
| 1368 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
| 1369 | }
|
| 1370 |
|
| 1371 | static void
|
| 1372 | object_proxy_get_property (GObject *gobject,
|
| 1373 | guint prop_id,
|
| 1374 | GValue *value,
|
| 1375 | GParamSpec *pspec)
|
| 1376 | {
|
| 1377 | ObjectProxy *object = OBJECT_PROXY (gobject);
|
| 1378 | GDBusInterface *interface;
|
| 1379 |
|
| 1380 | switch (prop_id)
|
| 1381 | {
|
| 1382 | case 1:
|
| 1383 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.HostControl");
|
| 1384 | g_value_take_object (value, interface);
|
| 1385 | break;
|
| 1386 |
|
| 1387 | default:
|
| 1388 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
| 1389 | break;
|
| 1390 | }
|
| 1391 | }
|
| 1392 |
|
| 1393 | static void
|
| 1394 | object_proxy_class_init (ObjectProxyClass *klass)
|
| 1395 | {
|
| 1396 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
| 1397 |
|
| 1398 | gobject_class->set_property = object_proxy_set_property;
|
| 1399 | gobject_class->get_property = object_proxy_get_property;
|
| 1400 |
|
| 1401 | g_object_class_override_property (gobject_class, 1, "host-control");
|
| 1402 | }
|
| 1403 |
|
| 1404 | /**
|
| 1405 | * object_proxy_new:
|
| 1406 | * @connection: A #GDBusConnection.
|
| 1407 | * @object_path: An object path.
|
| 1408 | *
|
| 1409 | * Creates a new proxy object.
|
| 1410 | *
|
| 1411 | * Returns: (transfer full): The proxy object.
|
| 1412 | */
|
| 1413 | ObjectProxy *
|
| 1414 | object_proxy_new (GDBusConnection *connection,
|
| 1415 | const gchar *object_path)
|
| 1416 | {
|
| 1417 | g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
|
| 1418 | g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
|
| 1419 | return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
|
| 1420 | }
|
| 1421 |
|
| 1422 | /**
|
| 1423 | * ObjectSkeleton:
|
| 1424 | *
|
| 1425 | * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
|
| 1426 | */
|
| 1427 |
|
| 1428 | /**
|
| 1429 | * ObjectSkeletonClass:
|
| 1430 | * @parent_class: The parent class.
|
| 1431 | *
|
| 1432 | * Class structure for #ObjectSkeleton.
|
| 1433 | */
|
| 1434 |
|
| 1435 | static void
|
| 1436 | object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
|
| 1437 | {
|
| 1438 | }
|
| 1439 |
|
| 1440 |
|
| 1441 | static void
|
| 1442 | object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
|
| 1443 | {
|
| 1444 | iface->interface_added = object_notify;
|
| 1445 | iface->interface_removed = object_notify;
|
| 1446 | }
|
| 1447 |
|
| 1448 | G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
|
| 1449 | G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
|
| 1450 | G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
|
| 1451 |
|
| 1452 | static void
|
| 1453 | object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
|
| 1454 | {
|
| 1455 | }
|
| 1456 |
|
| 1457 | static void
|
| 1458 | object_skeleton_set_property (GObject *gobject,
|
| 1459 | guint prop_id,
|
| 1460 | const GValue *value,
|
| 1461 | GParamSpec *pspec)
|
| 1462 | {
|
| 1463 | ObjectSkeleton *object = OBJECT_SKELETON (gobject);
|
| 1464 | GDBusInterfaceSkeleton *interface;
|
| 1465 |
|
| 1466 | switch (prop_id)
|
| 1467 | {
|
| 1468 | case 1:
|
| 1469 | interface = g_value_get_object (value);
|
| 1470 | if (interface != NULL)
|
| 1471 | {
|
| 1472 | g_warn_if_fail (IS_HOST_CONTROL (interface));
|
| 1473 | g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
|
| 1474 | }
|
| 1475 | else
|
| 1476 | {
|
| 1477 | g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.HostControl");
|
| 1478 | }
|
| 1479 | break;
|
| 1480 |
|
| 1481 | default:
|
| 1482 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
| 1483 | break;
|
| 1484 | }
|
| 1485 | }
|
| 1486 |
|
| 1487 | static void
|
| 1488 | object_skeleton_get_property (GObject *gobject,
|
| 1489 | guint prop_id,
|
| 1490 | GValue *value,
|
| 1491 | GParamSpec *pspec)
|
| 1492 | {
|
| 1493 | ObjectSkeleton *object = OBJECT_SKELETON (gobject);
|
| 1494 | GDBusInterface *interface;
|
| 1495 |
|
| 1496 | switch (prop_id)
|
| 1497 | {
|
| 1498 | case 1:
|
| 1499 | interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.HostControl");
|
| 1500 | g_value_take_object (value, interface);
|
| 1501 | break;
|
| 1502 |
|
| 1503 | default:
|
| 1504 | G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
| 1505 | break;
|
| 1506 | }
|
| 1507 | }
|
| 1508 |
|
| 1509 | static void
|
| 1510 | object_skeleton_class_init (ObjectSkeletonClass *klass)
|
| 1511 | {
|
| 1512 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
| 1513 |
|
| 1514 | gobject_class->set_property = object_skeleton_set_property;
|
| 1515 | gobject_class->get_property = object_skeleton_get_property;
|
| 1516 |
|
| 1517 | g_object_class_override_property (gobject_class, 1, "host-control");
|
| 1518 | }
|
| 1519 |
|
| 1520 | /**
|
| 1521 | * object_skeleton_new:
|
| 1522 | * @object_path: An object path.
|
| 1523 | *
|
| 1524 | * Creates a new skeleton object.
|
| 1525 | *
|
| 1526 | * Returns: (transfer full): The skeleton object.
|
| 1527 | */
|
| 1528 | ObjectSkeleton *
|
| 1529 | object_skeleton_new (const gchar *object_path)
|
| 1530 | {
|
| 1531 | g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
|
| 1532 | return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
|
| 1533 | }
|
| 1534 |
|
| 1535 | /**
|
| 1536 | * object_skeleton_set_host_control:
|
| 1537 | * @object: A #ObjectSkeleton.
|
| 1538 | * @interface_: (allow-none): A #HostControl or %NULL to clear the interface.
|
| 1539 | *
|
| 1540 | * Sets the #HostControl instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-HostControl.top_of_page">org.openbmc.HostControl</link> on @object.
|
| 1541 | */
|
| 1542 | void object_skeleton_set_host_control (ObjectSkeleton *object, HostControl *interface_)
|
| 1543 | {
|
| 1544 | g_object_set (G_OBJECT (object), "host-control", interface_, NULL);
|
| 1545 | }
|
| 1546 |
|
| 1547 |
|
| 1548 | /* ------------------------------------------------------------------------
|
| 1549 | * Code for ObjectManager client
|
| 1550 | * ------------------------------------------------------------------------
|
| 1551 | */
|
| 1552 |
|
| 1553 | /**
|
| 1554 | * SECTION:ObjectManagerClient
|
| 1555 | * @title: ObjectManagerClient
|
| 1556 | * @short_description: Generated GDBusObjectManagerClient type
|
| 1557 | *
|
| 1558 | * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
|
| 1559 | */
|
| 1560 |
|
| 1561 | /**
|
| 1562 | * ObjectManagerClient:
|
| 1563 | *
|
| 1564 | * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
|
| 1565 | */
|
| 1566 |
|
| 1567 | /**
|
| 1568 | * ObjectManagerClientClass:
|
| 1569 | * @parent_class: The parent class.
|
| 1570 | *
|
| 1571 | * Class structure for #ObjectManagerClient.
|
| 1572 | */
|
| 1573 |
|
| 1574 | G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
|
| 1575 |
|
| 1576 | static void
|
| 1577 | object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
|
| 1578 | {
|
| 1579 | }
|
| 1580 |
|
| 1581 | static void
|
| 1582 | object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
|
| 1583 | {
|
| 1584 | }
|
| 1585 |
|
| 1586 | /**
|
| 1587 | * object_manager_client_get_proxy_type:
|
| 1588 | * @manager: A #GDBusObjectManagerClient.
|
| 1589 | * @object_path: The object path of the remote object (unused).
|
| 1590 | * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
|
| 1591 | * @user_data: User data (unused).
|
| 1592 | *
|
| 1593 | * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
|
| 1594 | *
|
| 1595 | * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
|
| 1596 | */
|
| 1597 | GType
|
| 1598 | 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)
|
| 1599 | {
|
| 1600 | static gsize once_init_value = 0;
|
| 1601 | static GHashTable *lookup_hash;
|
| 1602 | GType ret;
|
| 1603 |
|
| 1604 | if (interface_name == NULL)
|
| 1605 | return TYPE_OBJECT_PROXY;
|
| 1606 | if (g_once_init_enter (&once_init_value))
|
| 1607 | {
|
| 1608 | lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
| 1609 | g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.HostControl", GSIZE_TO_POINTER (TYPE_HOST_CONTROL_PROXY));
|
| 1610 | g_once_init_leave (&once_init_value, 1);
|
| 1611 | }
|
| 1612 | ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
|
| 1613 | if (ret == (GType) 0)
|
| 1614 | ret = G_TYPE_DBUS_PROXY;
|
| 1615 | return ret;
|
| 1616 | }
|
| 1617 |
|
| 1618 | /**
|
| 1619 | * object_manager_client_new:
|
| 1620 | * @connection: A #GDBusConnection.
|
| 1621 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
|
| 1622 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
|
| 1623 | * @object_path: An object path.
|
| 1624 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 1625 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
|
| 1626 | * @user_data: User data to pass to @callback.
|
| 1627 | *
|
| 1628 | * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
|
| 1629 | *
|
| 1630 | * 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.
|
| 1631 | * You can then call object_manager_client_new_finish() to get the result of the operation.
|
| 1632 | *
|
| 1633 | * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
|
| 1634 | */
|
| 1635 | void
|
| 1636 | object_manager_client_new (
|
| 1637 | GDBusConnection *connection,
|
| 1638 | GDBusObjectManagerClientFlags flags,
|
| 1639 | const gchar *name,
|
| 1640 | const gchar *object_path,
|
| 1641 | GCancellable *cancellable,
|
| 1642 | GAsyncReadyCallback callback,
|
| 1643 | gpointer user_data)
|
| 1644 | {
|
| 1645 | 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);
|
| 1646 | }
|
| 1647 |
|
| 1648 | /**
|
| 1649 | * object_manager_client_new_finish:
|
| 1650 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
|
| 1651 | * @error: Return location for error or %NULL
|
| 1652 | *
|
| 1653 | * Finishes an operation started with object_manager_client_new().
|
| 1654 | *
|
| 1655 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
|
| 1656 | */
|
| 1657 | GDBusObjectManager *
|
| 1658 | object_manager_client_new_finish (
|
| 1659 | GAsyncResult *res,
|
| 1660 | GError **error)
|
| 1661 | {
|
| 1662 | GObject *ret;
|
| 1663 | GObject *source_object;
|
| 1664 | source_object = g_async_result_get_source_object (res);
|
| 1665 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
|
| 1666 | g_object_unref (source_object);
|
| 1667 | if (ret != NULL)
|
| 1668 | return G_DBUS_OBJECT_MANAGER (ret);
|
| 1669 | else
|
| 1670 | return NULL;
|
| 1671 | }
|
| 1672 |
|
| 1673 | /**
|
| 1674 | * object_manager_client_new_sync:
|
| 1675 | * @connection: A #GDBusConnection.
|
| 1676 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
|
| 1677 | * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
|
| 1678 | * @object_path: An object path.
|
| 1679 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 1680 | * @error: Return location for error or %NULL
|
| 1681 | *
|
| 1682 | * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
|
| 1683 | *
|
| 1684 | * The calling thread is blocked until a reply is received.
|
| 1685 | *
|
| 1686 | * See object_manager_client_new() for the asynchronous version of this constructor.
|
| 1687 | *
|
| 1688 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
|
| 1689 | */
|
| 1690 | GDBusObjectManager *
|
| 1691 | object_manager_client_new_sync (
|
| 1692 | GDBusConnection *connection,
|
| 1693 | GDBusObjectManagerClientFlags flags,
|
| 1694 | const gchar *name,
|
| 1695 | const gchar *object_path,
|
| 1696 | GCancellable *cancellable,
|
| 1697 | GError **error)
|
| 1698 | {
|
| 1699 | GInitable *ret;
|
| 1700 | 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);
|
| 1701 | if (ret != NULL)
|
| 1702 | return G_DBUS_OBJECT_MANAGER (ret);
|
| 1703 | else
|
| 1704 | return NULL;
|
| 1705 | }
|
| 1706 |
|
| 1707 |
|
| 1708 | /**
|
| 1709 | * object_manager_client_new_for_bus:
|
| 1710 | * @bus_type: A #GBusType.
|
| 1711 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
|
| 1712 | * @name: A bus name (well-known or unique).
|
| 1713 | * @object_path: An object path.
|
| 1714 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 1715 | * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
|
| 1716 | * @user_data: User data to pass to @callback.
|
| 1717 | *
|
| 1718 | * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
|
| 1719 | *
|
| 1720 | * 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.
|
| 1721 | * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
|
| 1722 | *
|
| 1723 | * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
|
| 1724 | */
|
| 1725 | void
|
| 1726 | object_manager_client_new_for_bus (
|
| 1727 | GBusType bus_type,
|
| 1728 | GDBusObjectManagerClientFlags flags,
|
| 1729 | const gchar *name,
|
| 1730 | const gchar *object_path,
|
| 1731 | GCancellable *cancellable,
|
| 1732 | GAsyncReadyCallback callback,
|
| 1733 | gpointer user_data)
|
| 1734 | {
|
| 1735 | 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);
|
| 1736 | }
|
| 1737 |
|
| 1738 | /**
|
| 1739 | * object_manager_client_new_for_bus_finish:
|
| 1740 | * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
|
| 1741 | * @error: Return location for error or %NULL
|
| 1742 | *
|
| 1743 | * Finishes an operation started with object_manager_client_new_for_bus().
|
| 1744 | *
|
| 1745 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
|
| 1746 | */
|
| 1747 | GDBusObjectManager *
|
| 1748 | object_manager_client_new_for_bus_finish (
|
| 1749 | GAsyncResult *res,
|
| 1750 | GError **error)
|
| 1751 | {
|
| 1752 | GObject *ret;
|
| 1753 | GObject *source_object;
|
| 1754 | source_object = g_async_result_get_source_object (res);
|
| 1755 | ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
|
| 1756 | g_object_unref (source_object);
|
| 1757 | if (ret != NULL)
|
| 1758 | return G_DBUS_OBJECT_MANAGER (ret);
|
| 1759 | else
|
| 1760 | return NULL;
|
| 1761 | }
|
| 1762 |
|
| 1763 | /**
|
| 1764 | * object_manager_client_new_for_bus_sync:
|
| 1765 | * @bus_type: A #GBusType.
|
| 1766 | * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
|
| 1767 | * @name: A bus name (well-known or unique).
|
| 1768 | * @object_path: An object path.
|
| 1769 | * @cancellable: (allow-none): A #GCancellable or %NULL.
|
| 1770 | * @error: Return location for error or %NULL
|
| 1771 | *
|
| 1772 | * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
|
| 1773 | *
|
| 1774 | * The calling thread is blocked until a reply is received.
|
| 1775 | *
|
| 1776 | * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
|
| 1777 | *
|
| 1778 | * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
|
| 1779 | */
|
| 1780 | GDBusObjectManager *
|
| 1781 | object_manager_client_new_for_bus_sync (
|
| 1782 | GBusType bus_type,
|
| 1783 | GDBusObjectManagerClientFlags flags,
|
| 1784 | const gchar *name,
|
| 1785 | const gchar *object_path,
|
| 1786 | GCancellable *cancellable,
|
| 1787 | GError **error)
|
| 1788 | {
|
| 1789 | GInitable *ret;
|
| 1790 | 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);
|
| 1791 | if (ret != NULL)
|
| 1792 | return G_DBUS_OBJECT_MANAGER (ret);
|
| 1793 | else
|
| 1794 | return NULL;
|
| 1795 | }
|
| 1796 |
|
| 1797 |
|