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