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