blob: 94ab510f7dfcb361eb04c02e2d3bc9c99c502851 [file] [log] [blame]
Norman Jamese2765102015-08-19 22:00:55 -05001/*
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
18typedef struct
19{
20 GDBusArgInfo parent_struct;
21 gboolean use_gvariant;
22} _ExtendedGDBusArgInfo;
23
24typedef struct
25{
26 GDBusMethodInfo parent_struct;
27 const gchar *signal_name;
28 gboolean pass_fdlist;
29} _ExtendedGDBusMethodInfo;
30
31typedef struct
32{
33 GDBusSignalInfo parent_struct;
34 const gchar *signal_name;
35} _ExtendedGDBusSignalInfo;
36
37typedef struct
38{
39 GDBusPropertyInfo parent_struct;
40 const gchar *hyphen_name;
41 gboolean use_gvariant;
42} _ExtendedGDBusPropertyInfo;
43
44typedef struct
45{
46 GDBusInterfaceInfo parent_struct;
47 const gchar *hyphen_name;
48} _ExtendedGDBusInterfaceInfo;
49
50typedef struct
51{
52 const _ExtendedGDBusPropertyInfo *info;
53 guint prop_id;
54 GValue orig_value; /* the value before the change */
55} ChangedProperty;
56
57static void
58_changed_property_free (ChangedProperty *data)
59{
60 g_value_unset (&data->orig_value);
61 g_free (data);
62}
63
64static 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;
82out:
83 return ret;
84}
85
86static 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);
98out:
99 return ret;
100}
101
102G_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/* ------------------------------------------------------------------------
Norman James5d78b4d2015-09-05 13:34:34 -0500152 * Code for interface org.openbmc.SensorValue
Norman Jamese2765102015-08-19 22:00:55 -0500153 * ------------------------------------------------------------------------
154 */
155
156/**
Norman James5d78b4d2015-09-05 13:34:34 -0500157 * SECTION:SensorValue
158 * @title: SensorValue
159 * @short_description: Generated C code for the org.openbmc.SensorValue D-Bus interface
Norman Jamese2765102015-08-19 22:00:55 -0500160 *
Norman James5d78b4d2015-09-05 13:34:34 -0500161 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link> D-Bus interface in C.
Norman Jamese2765102015-08-19 22:00:55 -0500162 */
163
Norman James5d78b4d2015-09-05 13:34:34 -0500164/* ---- Introspection data for org.openbmc.SensorValue ---- */
Norman Jamese2765102015-08-19 22:00:55 -0500165
Norman James5d78b4d2015-09-05 13:34:34 -0500166static const _ExtendedGDBusMethodInfo _sensor_value_method_info_init =
Norman James90baede2015-09-02 20:32:49 -0500167{
168 {
169 -1,
170 (gchar *) "init",
171 NULL,
172 NULL,
173 NULL
174 },
175 "handle-init",
176 FALSE
177};
178
Norman James5d78b4d2015-09-05 13:34:34 -0500179static const _ExtendedGDBusArgInfo _sensor_value_method_info_get_value_OUT_ARG_value =
Norman Jamese2765102015-08-19 22:00:55 -0500180{
181 {
182 -1,
183 (gchar *) "value",
Norman James5d78b4d2015-09-05 13:34:34 -0500184 (gchar *) "v",
Norman Jamese2765102015-08-19 22:00:55 -0500185 NULL
186 },
187 FALSE
188};
189
Norman James5d78b4d2015-09-05 13:34:34 -0500190static const _ExtendedGDBusArgInfo * const _sensor_value_method_info_get_value_OUT_ARG_pointers[] =
Norman Jamese2765102015-08-19 22:00:55 -0500191{
Norman James5d78b4d2015-09-05 13:34:34 -0500192 &_sensor_value_method_info_get_value_OUT_ARG_value,
Norman Jamese2765102015-08-19 22:00:55 -0500193 NULL
194};
195
Norman James5d78b4d2015-09-05 13:34:34 -0500196static const _ExtendedGDBusMethodInfo _sensor_value_method_info_get_value =
Norman Jamese2765102015-08-19 22:00:55 -0500197{
198 {
199 -1,
200 (gchar *) "getValue",
201 NULL,
Norman James5d78b4d2015-09-05 13:34:34 -0500202 (GDBusArgInfo **) &_sensor_value_method_info_get_value_OUT_ARG_pointers,
Norman Jamese2765102015-08-19 22:00:55 -0500203 NULL
204 },
205 "handle-get-value",
206 FALSE
207};
208
Norman James5d78b4d2015-09-05 13:34:34 -0500209static const _ExtendedGDBusArgInfo _sensor_value_method_info_set_value_IN_ARG_value =
Norman James90baede2015-09-02 20:32:49 -0500210{
211 {
212 -1,
213 (gchar *) "value",
Norman James5d78b4d2015-09-05 13:34:34 -0500214 (gchar *) "v",
Norman James90baede2015-09-02 20:32:49 -0500215 NULL
216 },
217 FALSE
218};
219
Norman James5d78b4d2015-09-05 13:34:34 -0500220static const _ExtendedGDBusArgInfo * const _sensor_value_method_info_set_value_IN_ARG_pointers[] =
Norman James90baede2015-09-02 20:32:49 -0500221{
Norman James5d78b4d2015-09-05 13:34:34 -0500222 &_sensor_value_method_info_set_value_IN_ARG_value,
Norman James90baede2015-09-02 20:32:49 -0500223 NULL
224};
225
Norman James5d78b4d2015-09-05 13:34:34 -0500226static const _ExtendedGDBusMethodInfo _sensor_value_method_info_set_value =
Norman James90baede2015-09-02 20:32:49 -0500227{
228 {
229 -1,
230 (gchar *) "setValue",
Norman James5d78b4d2015-09-05 13:34:34 -0500231 (GDBusArgInfo **) &_sensor_value_method_info_set_value_IN_ARG_pointers,
Norman James90baede2015-09-02 20:32:49 -0500232 NULL,
233 NULL
234 },
235 "handle-set-value",
236 FALSE
237};
238
Norman James5d78b4d2015-09-05 13:34:34 -0500239static const _ExtendedGDBusMethodInfo * const _sensor_value_method_info_pointers[] =
Norman Jamese2765102015-08-19 22:00:55 -0500240{
Norman James5d78b4d2015-09-05 13:34:34 -0500241 &_sensor_value_method_info_init,
242 &_sensor_value_method_info_get_value,
243 &_sensor_value_method_info_set_value,
Norman Jamese2765102015-08-19 22:00:55 -0500244 NULL
245};
246
Norman James5d78b4d2015-09-05 13:34:34 -0500247static const _ExtendedGDBusArgInfo _sensor_value_signal_info_changed_ARG_value =
Norman Jamese2765102015-08-19 22:00:55 -0500248{
249 {
250 -1,
251 (gchar *) "value",
Norman James5d78b4d2015-09-05 13:34:34 -0500252 (gchar *) "v",
Norman Jamese2765102015-08-19 22:00:55 -0500253 NULL
254 },
255 FALSE
256};
257
Norman James5d78b4d2015-09-05 13:34:34 -0500258static const _ExtendedGDBusArgInfo _sensor_value_signal_info_changed_ARG_units =
Norman James90baede2015-09-02 20:32:49 -0500259{
260 {
261 -1,
262 (gchar *) "units",
263 (gchar *) "s",
264 NULL
265 },
266 FALSE
267};
268
Norman James5d78b4d2015-09-05 13:34:34 -0500269static const _ExtendedGDBusArgInfo * const _sensor_value_signal_info_changed_ARG_pointers[] =
Norman Jamese2765102015-08-19 22:00:55 -0500270{
Norman James5d78b4d2015-09-05 13:34:34 -0500271 &_sensor_value_signal_info_changed_ARG_value,
272 &_sensor_value_signal_info_changed_ARG_units,
Norman Jamese2765102015-08-19 22:00:55 -0500273 NULL
274};
275
Norman James5d78b4d2015-09-05 13:34:34 -0500276static const _ExtendedGDBusSignalInfo _sensor_value_signal_info_changed =
Norman Jamese2765102015-08-19 22:00:55 -0500277{
278 {
279 -1,
280 (gchar *) "Changed",
Norman James5d78b4d2015-09-05 13:34:34 -0500281 (GDBusArgInfo **) &_sensor_value_signal_info_changed_ARG_pointers,
Norman Jamese2765102015-08-19 22:00:55 -0500282 NULL
283 },
284 "changed"
285};
286
Norman James5d78b4d2015-09-05 13:34:34 -0500287static const _ExtendedGDBusArgInfo _sensor_value_signal_info_heartbeat_ARG_bus_name =
Norman James3f97c5d2015-08-26 17:44:14 -0500288{
289 {
290 -1,
Norman James90baede2015-09-02 20:32:49 -0500291 (gchar *) "bus_name",
292 (gchar *) "s",
Norman James3f97c5d2015-08-26 17:44:14 -0500293 NULL
294 },
Norman James90baede2015-09-02 20:32:49 -0500295 FALSE
Norman James3f97c5d2015-08-26 17:44:14 -0500296};
297
Norman James5d78b4d2015-09-05 13:34:34 -0500298static const _ExtendedGDBusArgInfo * const _sensor_value_signal_info_heartbeat_ARG_pointers[] =
Norman James90baede2015-09-02 20:32:49 -0500299{
Norman James5d78b4d2015-09-05 13:34:34 -0500300 &_sensor_value_signal_info_heartbeat_ARG_bus_name,
Norman James90baede2015-09-02 20:32:49 -0500301 NULL
302};
303
Norman James5d78b4d2015-09-05 13:34:34 -0500304static const _ExtendedGDBusSignalInfo _sensor_value_signal_info_heartbeat =
Norman James3f97c5d2015-08-26 17:44:14 -0500305{
306 {
307 -1,
Norman James90baede2015-09-02 20:32:49 -0500308 (gchar *) "Heartbeat",
Norman James5d78b4d2015-09-05 13:34:34 -0500309 (GDBusArgInfo **) &_sensor_value_signal_info_heartbeat_ARG_pointers,
Norman James3f97c5d2015-08-26 17:44:14 -0500310 NULL
311 },
Norman James90baede2015-09-02 20:32:49 -0500312 "heartbeat"
Norman James3f97c5d2015-08-26 17:44:14 -0500313};
314
Norman James5d78b4d2015-09-05 13:34:34 -0500315static const _ExtendedGDBusSignalInfo * const _sensor_value_signal_info_pointers[] =
Norman Jamese2765102015-08-19 22:00:55 -0500316{
Norman James5d78b4d2015-09-05 13:34:34 -0500317 &_sensor_value_signal_info_changed,
318 &_sensor_value_signal_info_heartbeat,
Norman Jamese2765102015-08-19 22:00:55 -0500319 NULL
320};
321
Norman James5d78b4d2015-09-05 13:34:34 -0500322static const _ExtendedGDBusPropertyInfo _sensor_value_property_info_value =
Norman Jamese2765102015-08-19 22:00:55 -0500323{
324 {
325 -1,
326 (gchar *) "value",
Norman James5d78b4d2015-09-05 13:34:34 -0500327 (gchar *) "v",
Norman James9e6acf92015-09-08 07:00:04 -0500328 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
Norman Jamese2765102015-08-19 22:00:55 -0500329 NULL
330 },
331 "value",
332 FALSE
333};
334
Norman James5d78b4d2015-09-05 13:34:34 -0500335static const _ExtendedGDBusPropertyInfo _sensor_value_property_info_units =
Norman Jamese2765102015-08-19 22:00:55 -0500336{
337 {
338 -1,
339 (gchar *) "units",
340 (gchar *) "s",
341 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
342 NULL
343 },
344 "units",
345 FALSE
346};
347
Norman James5d78b4d2015-09-05 13:34:34 -0500348static const _ExtendedGDBusPropertyInfo _sensor_value_property_info_poll_interval =
Norman Jamescc7ae122015-08-24 14:26:09 -0500349{
350 {
351 -1,
352 (gchar *) "poll_interval",
353 (gchar *) "i",
Norman James9e6acf92015-09-08 07:00:04 -0500354 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
Norman Jamescc7ae122015-08-24 14:26:09 -0500355 NULL
356 },
357 "poll-interval",
358 FALSE
359};
360
Norman James5d78b4d2015-09-05 13:34:34 -0500361static const _ExtendedGDBusPropertyInfo _sensor_value_property_info_heatbeat =
Norman Jamescc7ae122015-08-24 14:26:09 -0500362{
363 {
364 -1,
Norman James90baede2015-09-02 20:32:49 -0500365 (gchar *) "heatbeat",
Norman Jamescc7ae122015-08-24 14:26:09 -0500366 (gchar *) "i",
367 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
368 NULL
369 },
Norman James90baede2015-09-02 20:32:49 -0500370 "heatbeat",
Norman Jamescc7ae122015-08-24 14:26:09 -0500371 FALSE
372};
373
Norman James9e6acf92015-09-08 07:00:04 -0500374static const _ExtendedGDBusPropertyInfo _sensor_value_property_info_settable =
375{
376 {
377 -1,
378 (gchar *) "settable",
379 (gchar *) "b",
380 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
381 NULL
382 },
383 "settable",
384 FALSE
385};
386
Norman James5d78b4d2015-09-05 13:34:34 -0500387static const _ExtendedGDBusPropertyInfo * const _sensor_value_property_info_pointers[] =
Norman Jamese2765102015-08-19 22:00:55 -0500388{
Norman James5d78b4d2015-09-05 13:34:34 -0500389 &_sensor_value_property_info_value,
390 &_sensor_value_property_info_units,
391 &_sensor_value_property_info_poll_interval,
392 &_sensor_value_property_info_heatbeat,
Norman James9e6acf92015-09-08 07:00:04 -0500393 &_sensor_value_property_info_settable,
Norman Jamese2765102015-08-19 22:00:55 -0500394 NULL
395};
396
Norman James5d78b4d2015-09-05 13:34:34 -0500397static const _ExtendedGDBusInterfaceInfo _sensor_value_interface_info =
Norman Jamese2765102015-08-19 22:00:55 -0500398{
399 {
400 -1,
Norman James5d78b4d2015-09-05 13:34:34 -0500401 (gchar *) "org.openbmc.SensorValue",
402 (GDBusMethodInfo **) &_sensor_value_method_info_pointers,
403 (GDBusSignalInfo **) &_sensor_value_signal_info_pointers,
404 (GDBusPropertyInfo **) &_sensor_value_property_info_pointers,
Norman Jamese2765102015-08-19 22:00:55 -0500405 NULL
406 },
Norman James5d78b4d2015-09-05 13:34:34 -0500407 "sensor-value",
Norman Jamese2765102015-08-19 22:00:55 -0500408};
409
410
411/**
Norman James5d78b4d2015-09-05 13:34:34 -0500412 * sensor_value_interface_info:
Norman Jamese2765102015-08-19 22:00:55 -0500413 *
Norman James5d78b4d2015-09-05 13:34:34 -0500414 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link> D-Bus interface.
Norman Jamese2765102015-08-19 22:00:55 -0500415 *
416 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
417 */
418GDBusInterfaceInfo *
Norman James5d78b4d2015-09-05 13:34:34 -0500419sensor_value_interface_info (void)
Norman Jamese2765102015-08-19 22:00:55 -0500420{
Norman James5d78b4d2015-09-05 13:34:34 -0500421 return (GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct;
Norman Jamese2765102015-08-19 22:00:55 -0500422}
423
424/**
Norman James5d78b4d2015-09-05 13:34:34 -0500425 * sensor_value_override_properties:
Norman Jamese2765102015-08-19 22:00:55 -0500426 * @klass: The class structure for a #GObject<!-- -->-derived class.
427 * @property_id_begin: The property id to assign to the first overridden property.
428 *
Norman James5d78b4d2015-09-05 13:34:34 -0500429 * Overrides all #GObject properties in the #SensorValue interface for a concrete class.
Norman Jamese2765102015-08-19 22:00:55 -0500430 * The properties are overridden in the order they are defined.
431 *
432 * Returns: The last property id.
433 */
434guint
Norman James5d78b4d2015-09-05 13:34:34 -0500435sensor_value_override_properties (GObjectClass *klass, guint property_id_begin)
Norman Jamese2765102015-08-19 22:00:55 -0500436{
437 g_object_class_override_property (klass, property_id_begin++, "value");
438 g_object_class_override_property (klass, property_id_begin++, "units");
Norman Jamescc7ae122015-08-24 14:26:09 -0500439 g_object_class_override_property (klass, property_id_begin++, "poll-interval");
Norman James90baede2015-09-02 20:32:49 -0500440 g_object_class_override_property (klass, property_id_begin++, "heatbeat");
Norman James9e6acf92015-09-08 07:00:04 -0500441 g_object_class_override_property (klass, property_id_begin++, "settable");
Norman Jamese2765102015-08-19 22:00:55 -0500442 return property_id_begin - 1;
443}
444
445
446
447/**
Norman James5d78b4d2015-09-05 13:34:34 -0500448 * SensorValue:
Norman Jamese2765102015-08-19 22:00:55 -0500449 *
Norman James5d78b4d2015-09-05 13:34:34 -0500450 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>.
Norman Jamese2765102015-08-19 22:00:55 -0500451 */
452
453/**
Norman James5d78b4d2015-09-05 13:34:34 -0500454 * SensorValueIface:
Norman Jamese2765102015-08-19 22:00:55 -0500455 * @parent_iface: The parent interface.
Norman James5d78b4d2015-09-05 13:34:34 -0500456 * @handle_get_value: Handler for the #SensorValue::handle-get-value signal.
457 * @handle_init: Handler for the #SensorValue::handle-init signal.
458 * @handle_set_value: Handler for the #SensorValue::handle-set-value signal.
459 * @get_heatbeat: Getter for the #SensorValue:heatbeat property.
460 * @get_poll_interval: Getter for the #SensorValue:poll-interval property.
Norman James9e6acf92015-09-08 07:00:04 -0500461 * @get_settable: Getter for the #SensorValue:settable property.
Norman James5d78b4d2015-09-05 13:34:34 -0500462 * @get_units: Getter for the #SensorValue:units property.
463 * @get_value: Getter for the #SensorValue:value property.
464 * @changed: Handler for the #SensorValue::changed signal.
465 * @heartbeat: Handler for the #SensorValue::heartbeat signal.
Norman Jamese2765102015-08-19 22:00:55 -0500466 *
Norman James5d78b4d2015-09-05 13:34:34 -0500467 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>.
Norman Jamese2765102015-08-19 22:00:55 -0500468 */
469
Norman James5d78b4d2015-09-05 13:34:34 -0500470typedef SensorValueIface SensorValueInterface;
471G_DEFINE_INTERFACE (SensorValue, sensor_value, G_TYPE_OBJECT);
Norman Jamese2765102015-08-19 22:00:55 -0500472
473static void
Norman James5d78b4d2015-09-05 13:34:34 -0500474sensor_value_default_init (SensorValueIface *iface)
Norman Jamese2765102015-08-19 22:00:55 -0500475{
476 /* GObject signals for incoming D-Bus method calls: */
477 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500478 * SensorValue::handle-init:
479 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -0500480 * @invocation: A #GDBusMethodInvocation.
481 *
Norman James5d78b4d2015-09-05 13:34:34 -0500482 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorValue.init">init()</link> D-Bus method.
Norman James90baede2015-09-02 20:32:49 -0500483 *
Norman James5d78b4d2015-09-05 13:34:34 -0500484 * 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_value_complete_init() 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.
Norman James90baede2015-09-02 20:32:49 -0500485 *
486 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
487 */
488 g_signal_new ("handle-init",
489 G_TYPE_FROM_INTERFACE (iface),
490 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -0500491 G_STRUCT_OFFSET (SensorValueIface, handle_init),
Norman James90baede2015-09-02 20:32:49 -0500492 g_signal_accumulator_true_handled,
493 NULL,
494 g_cclosure_marshal_generic,
495 G_TYPE_BOOLEAN,
496 1,
497 G_TYPE_DBUS_METHOD_INVOCATION);
498
499 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500500 * SensorValue::handle-get-value:
501 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500502 * @invocation: A #GDBusMethodInvocation.
503 *
Norman James5d78b4d2015-09-05 13:34:34 -0500504 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorValue.getValue">getValue()</link> D-Bus method.
Norman Jamese2765102015-08-19 22:00:55 -0500505 *
Norman James5d78b4d2015-09-05 13:34:34 -0500506 * 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_value_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.
Norman Jamese2765102015-08-19 22:00:55 -0500507 *
508 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
509 */
510 g_signal_new ("handle-get-value",
511 G_TYPE_FROM_INTERFACE (iface),
512 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -0500513 G_STRUCT_OFFSET (SensorValueIface, handle_get_value),
Norman Jamese2765102015-08-19 22:00:55 -0500514 g_signal_accumulator_true_handled,
515 NULL,
516 g_cclosure_marshal_generic,
517 G_TYPE_BOOLEAN,
518 1,
519 G_TYPE_DBUS_METHOD_INVOCATION);
520
521 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500522 * SensorValue::handle-set-value:
523 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -0500524 * @invocation: A #GDBusMethodInvocation.
525 * @arg_value: Argument passed by remote caller.
526 *
Norman James5d78b4d2015-09-05 13:34:34 -0500527 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorValue.setValue">setValue()</link> D-Bus method.
Norman James90baede2015-09-02 20:32:49 -0500528 *
Norman James5d78b4d2015-09-05 13:34:34 -0500529 * 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_value_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.
Norman James90baede2015-09-02 20:32:49 -0500530 *
531 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
532 */
533 g_signal_new ("handle-set-value",
534 G_TYPE_FROM_INTERFACE (iface),
535 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -0500536 G_STRUCT_OFFSET (SensorValueIface, handle_set_value),
Norman James90baede2015-09-02 20:32:49 -0500537 g_signal_accumulator_true_handled,
538 NULL,
539 g_cclosure_marshal_generic,
540 G_TYPE_BOOLEAN,
541 2,
Norman James5d78b4d2015-09-05 13:34:34 -0500542 G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT);
Norman Jamescc7ae122015-08-24 14:26:09 -0500543
Norman Jamese2765102015-08-19 22:00:55 -0500544 /* GObject signals for received D-Bus signals: */
545 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500546 * SensorValue::changed:
547 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500548 * @arg_value: Argument.
Norman James90baede2015-09-02 20:32:49 -0500549 * @arg_units: Argument.
Norman Jamese2765102015-08-19 22:00:55 -0500550 *
Norman James5d78b4d2015-09-05 13:34:34 -0500551 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorValue.Changed">"Changed"</link> is received.
Norman Jamese2765102015-08-19 22:00:55 -0500552 *
553 * 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.
554 */
555 g_signal_new ("changed",
556 G_TYPE_FROM_INTERFACE (iface),
557 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -0500558 G_STRUCT_OFFSET (SensorValueIface, changed),
Norman Jamese2765102015-08-19 22:00:55 -0500559 NULL,
560 NULL,
561 g_cclosure_marshal_generic,
562 G_TYPE_NONE,
Norman James5d78b4d2015-09-05 13:34:34 -0500563 2, G_TYPE_VARIANT, G_TYPE_STRING);
Norman Jamese2765102015-08-19 22:00:55 -0500564
Norman James3f97c5d2015-08-26 17:44:14 -0500565 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500566 * SensorValue::heartbeat:
567 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -0500568 * @arg_bus_name: Argument.
Norman James3f97c5d2015-08-26 17:44:14 -0500569 *
Norman James5d78b4d2015-09-05 13:34:34 -0500570 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorValue.Heartbeat">"Heartbeat"</link> is received.
Norman James3f97c5d2015-08-26 17:44:14 -0500571 *
572 * 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.
573 */
Norman James90baede2015-09-02 20:32:49 -0500574 g_signal_new ("heartbeat",
Norman James3f97c5d2015-08-26 17:44:14 -0500575 G_TYPE_FROM_INTERFACE (iface),
576 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -0500577 G_STRUCT_OFFSET (SensorValueIface, heartbeat),
Norman James3f97c5d2015-08-26 17:44:14 -0500578 NULL,
579 NULL,
580 g_cclosure_marshal_generic,
581 G_TYPE_NONE,
Norman James90baede2015-09-02 20:32:49 -0500582 1, G_TYPE_STRING);
Norman James3f97c5d2015-08-26 17:44:14 -0500583
Norman Jamese2765102015-08-19 22:00:55 -0500584 /* GObject properties for D-Bus properties: */
585 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500586 * SensorValue:value:
Norman Jamese2765102015-08-19 22:00:55 -0500587 *
Norman James5d78b4d2015-09-05 13:34:34 -0500588 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorValue.value">"value"</link>.
Norman Jamese2765102015-08-19 22:00:55 -0500589 *
Norman James9e6acf92015-09-08 07:00:04 -0500590 * 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.
Norman Jamese2765102015-08-19 22:00:55 -0500591 */
592 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -0500593 g_param_spec_variant ("value", "value", "value", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamese2765102015-08-19 22:00:55 -0500594 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500595 * SensorValue:units:
Norman Jamese2765102015-08-19 22:00:55 -0500596 *
Norman James5d78b4d2015-09-05 13:34:34 -0500597 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorValue.units">"units"</link>.
Norman Jamese2765102015-08-19 22:00:55 -0500598 *
599 * 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.
600 */
601 g_object_interface_install_property (iface,
602 g_param_spec_string ("units", "units", "units", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -0500603 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500604 * SensorValue:poll-interval:
Norman Jamescc7ae122015-08-24 14:26:09 -0500605 *
Norman James5d78b4d2015-09-05 13:34:34 -0500606 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorValue.poll_interval">"poll_interval"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -0500607 *
Norman James9e6acf92015-09-08 07:00:04 -0500608 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
Norman Jamescc7ae122015-08-24 14:26:09 -0500609 */
610 g_object_interface_install_property (iface,
611 g_param_spec_int ("poll-interval", "poll_interval", "poll_interval", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
612 /**
Norman James5d78b4d2015-09-05 13:34:34 -0500613 * SensorValue:heatbeat:
Norman Jamescc7ae122015-08-24 14:26:09 -0500614 *
Norman James5d78b4d2015-09-05 13:34:34 -0500615 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorValue.heatbeat">"heatbeat"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -0500616 *
617 * 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.
618 */
619 g_object_interface_install_property (iface,
Norman James90baede2015-09-02 20:32:49 -0500620 g_param_spec_int ("heatbeat", "heatbeat", "heatbeat", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman James9e6acf92015-09-08 07:00:04 -0500621 /**
622 * SensorValue:settable:
623 *
624 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorValue.settable">"settable"</link>.
625 *
626 * 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.
627 */
628 g_object_interface_install_property (iface,
629 g_param_spec_boolean ("settable", "settable", "settable", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamese2765102015-08-19 22:00:55 -0500630}
631
632/**
Norman James5d78b4d2015-09-05 13:34:34 -0500633 * sensor_value_get_value: (skip)
634 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500635 *
Norman James5d78b4d2015-09-05 13:34:34 -0500636 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorValue.value">"value"</link> D-Bus property.
Norman Jamese2765102015-08-19 22:00:55 -0500637 *
Norman James9e6acf92015-09-08 07:00:04 -0500638 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
Norman Jamese2765102015-08-19 22:00:55 -0500639 *
Norman James5d78b4d2015-09-05 13:34:34 -0500640 * <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_value_dup_value() if on another thread.</warning>
641 *
642 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
Norman Jamese2765102015-08-19 22:00:55 -0500643 */
Norman James5d78b4d2015-09-05 13:34:34 -0500644GVariant *
645sensor_value_get_value (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -0500646{
Norman James5d78b4d2015-09-05 13:34:34 -0500647 return SENSOR_VALUE_GET_IFACE (object)->get_value (object);
Norman Jamese2765102015-08-19 22:00:55 -0500648}
649
650/**
Norman James5d78b4d2015-09-05 13:34:34 -0500651 * sensor_value_dup_value: (skip)
652 * @object: A #SensorValue.
653 *
654 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorValue.value">"value"</link> D-Bus property.
655 *
Norman James9e6acf92015-09-08 07:00:04 -0500656 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
Norman James5d78b4d2015-09-05 13:34:34 -0500657 *
658 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
659 */
660GVariant *
661sensor_value_dup_value (SensorValue *object)
662{
663 GVariant *value;
664 g_object_get (G_OBJECT (object), "value", &value, NULL);
665 return value;
666}
667
668/**
669 * sensor_value_set_value: (skip)
670 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500671 * @value: The value to set.
672 *
Norman James5d78b4d2015-09-05 13:34:34 -0500673 * Sets the <link linkend="gdbus-property-org-openbmc-SensorValue.value">"value"</link> D-Bus property to @value.
Norman Jamese2765102015-08-19 22:00:55 -0500674 *
Norman James9e6acf92015-09-08 07:00:04 -0500675 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
Norman Jamese2765102015-08-19 22:00:55 -0500676 */
677void
Norman James5d78b4d2015-09-05 13:34:34 -0500678sensor_value_set_value (SensorValue *object, GVariant *value)
Norman Jamese2765102015-08-19 22:00:55 -0500679{
680 g_object_set (G_OBJECT (object), "value", value, NULL);
681}
682
683/**
Norman James5d78b4d2015-09-05 13:34:34 -0500684 * sensor_value_get_units: (skip)
685 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500686 *
Norman James5d78b4d2015-09-05 13:34:34 -0500687 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorValue.units">"units"</link> D-Bus property.
Norman Jamese2765102015-08-19 22:00:55 -0500688 *
689 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
690 *
Norman James5d78b4d2015-09-05 13:34:34 -0500691 * <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_value_dup_units() if on another thread.</warning>
Norman Jamese2765102015-08-19 22:00:55 -0500692 *
693 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
694 */
695const gchar *
Norman James5d78b4d2015-09-05 13:34:34 -0500696sensor_value_get_units (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -0500697{
Norman James5d78b4d2015-09-05 13:34:34 -0500698 return SENSOR_VALUE_GET_IFACE (object)->get_units (object);
Norman Jamese2765102015-08-19 22:00:55 -0500699}
700
701/**
Norman James5d78b4d2015-09-05 13:34:34 -0500702 * sensor_value_dup_units: (skip)
703 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500704 *
Norman James5d78b4d2015-09-05 13:34:34 -0500705 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorValue.units">"units"</link> D-Bus property.
Norman Jamese2765102015-08-19 22:00:55 -0500706 *
707 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
708 *
709 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
710 */
711gchar *
Norman James5d78b4d2015-09-05 13:34:34 -0500712sensor_value_dup_units (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -0500713{
714 gchar *value;
715 g_object_get (G_OBJECT (object), "units", &value, NULL);
716 return value;
717}
718
719/**
Norman James5d78b4d2015-09-05 13:34:34 -0500720 * sensor_value_set_units: (skip)
721 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500722 * @value: The value to set.
723 *
Norman James5d78b4d2015-09-05 13:34:34 -0500724 * Sets the <link linkend="gdbus-property-org-openbmc-SensorValue.units">"units"</link> D-Bus property to @value.
Norman Jamese2765102015-08-19 22:00:55 -0500725 *
726 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
727 */
728void
Norman James5d78b4d2015-09-05 13:34:34 -0500729sensor_value_set_units (SensorValue *object, const gchar *value)
Norman Jamese2765102015-08-19 22:00:55 -0500730{
731 g_object_set (G_OBJECT (object), "units", value, NULL);
732}
733
734/**
Norman James5d78b4d2015-09-05 13:34:34 -0500735 * sensor_value_get_poll_interval: (skip)
736 * @object: A #SensorValue.
Norman Jamescc7ae122015-08-24 14:26:09 -0500737 *
Norman James5d78b4d2015-09-05 13:34:34 -0500738 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorValue.poll_interval">"poll_interval"</link> D-Bus property.
Norman Jamescc7ae122015-08-24 14:26:09 -0500739 *
Norman James9e6acf92015-09-08 07:00:04 -0500740 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
Norman Jamescc7ae122015-08-24 14:26:09 -0500741 *
742 * Returns: The property value.
743 */
744gint
Norman James5d78b4d2015-09-05 13:34:34 -0500745sensor_value_get_poll_interval (SensorValue *object)
Norman Jamescc7ae122015-08-24 14:26:09 -0500746{
Norman James5d78b4d2015-09-05 13:34:34 -0500747 return SENSOR_VALUE_GET_IFACE (object)->get_poll_interval (object);
Norman Jamescc7ae122015-08-24 14:26:09 -0500748}
749
750/**
Norman James5d78b4d2015-09-05 13:34:34 -0500751 * sensor_value_set_poll_interval: (skip)
752 * @object: A #SensorValue.
Norman Jamescc7ae122015-08-24 14:26:09 -0500753 * @value: The value to set.
754 *
Norman James5d78b4d2015-09-05 13:34:34 -0500755 * Sets the <link linkend="gdbus-property-org-openbmc-SensorValue.poll_interval">"poll_interval"</link> D-Bus property to @value.
Norman Jamescc7ae122015-08-24 14:26:09 -0500756 *
Norman James9e6acf92015-09-08 07:00:04 -0500757 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
Norman Jamescc7ae122015-08-24 14:26:09 -0500758 */
759void
Norman James5d78b4d2015-09-05 13:34:34 -0500760sensor_value_set_poll_interval (SensorValue *object, gint value)
Norman Jamescc7ae122015-08-24 14:26:09 -0500761{
762 g_object_set (G_OBJECT (object), "poll-interval", value, NULL);
763}
764
765/**
Norman James5d78b4d2015-09-05 13:34:34 -0500766 * sensor_value_get_heatbeat: (skip)
767 * @object: A #SensorValue.
Norman Jamescc7ae122015-08-24 14:26:09 -0500768 *
Norman James5d78b4d2015-09-05 13:34:34 -0500769 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorValue.heatbeat">"heatbeat"</link> D-Bus property.
Norman Jamescc7ae122015-08-24 14:26:09 -0500770 *
771 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
772 *
773 * Returns: The property value.
774 */
775gint
Norman James5d78b4d2015-09-05 13:34:34 -0500776sensor_value_get_heatbeat (SensorValue *object)
Norman Jamescc7ae122015-08-24 14:26:09 -0500777{
Norman James5d78b4d2015-09-05 13:34:34 -0500778 return SENSOR_VALUE_GET_IFACE (object)->get_heatbeat (object);
Norman Jamescc7ae122015-08-24 14:26:09 -0500779}
780
781/**
Norman James5d78b4d2015-09-05 13:34:34 -0500782 * sensor_value_set_heatbeat: (skip)
783 * @object: A #SensorValue.
Norman Jamescc7ae122015-08-24 14:26:09 -0500784 * @value: The value to set.
785 *
Norman James5d78b4d2015-09-05 13:34:34 -0500786 * Sets the <link linkend="gdbus-property-org-openbmc-SensorValue.heatbeat">"heatbeat"</link> D-Bus property to @value.
Norman Jamescc7ae122015-08-24 14:26:09 -0500787 *
788 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
789 */
790void
Norman James5d78b4d2015-09-05 13:34:34 -0500791sensor_value_set_heatbeat (SensorValue *object, gint value)
Norman Jamescc7ae122015-08-24 14:26:09 -0500792{
Norman James90baede2015-09-02 20:32:49 -0500793 g_object_set (G_OBJECT (object), "heatbeat", value, NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -0500794}
795
796/**
Norman James9e6acf92015-09-08 07:00:04 -0500797 * sensor_value_get_settable: (skip)
798 * @object: A #SensorValue.
799 *
800 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorValue.settable">"settable"</link> D-Bus property.
801 *
802 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
803 *
804 * Returns: The property value.
805 */
806gboolean
807sensor_value_get_settable (SensorValue *object)
808{
809 return SENSOR_VALUE_GET_IFACE (object)->get_settable (object);
810}
811
812/**
813 * sensor_value_set_settable: (skip)
814 * @object: A #SensorValue.
815 * @value: The value to set.
816 *
817 * Sets the <link linkend="gdbus-property-org-openbmc-SensorValue.settable">"settable"</link> D-Bus property to @value.
818 *
819 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
820 */
821void
822sensor_value_set_settable (SensorValue *object, gboolean value)
823{
824 g_object_set (G_OBJECT (object), "settable", value, NULL);
825}
826
827/**
Norman James5d78b4d2015-09-05 13:34:34 -0500828 * sensor_value_emit_changed:
829 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -0500830 * @arg_value: Argument to pass with the signal.
Norman James90baede2015-09-02 20:32:49 -0500831 * @arg_units: Argument to pass with the signal.
Norman Jamese2765102015-08-19 22:00:55 -0500832 *
Norman James5d78b4d2015-09-05 13:34:34 -0500833 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorValue.Changed">"Changed"</link> D-Bus signal.
Norman Jamese2765102015-08-19 22:00:55 -0500834 */
835void
Norman James5d78b4d2015-09-05 13:34:34 -0500836sensor_value_emit_changed (
837 SensorValue *object,
838 GVariant *arg_value,
Norman James90baede2015-09-02 20:32:49 -0500839 const gchar *arg_units)
Norman Jamese2765102015-08-19 22:00:55 -0500840{
Norman James90baede2015-09-02 20:32:49 -0500841 g_signal_emit_by_name (object, "changed", arg_value, arg_units);
Norman Jamese2765102015-08-19 22:00:55 -0500842}
843
844/**
Norman James5d78b4d2015-09-05 13:34:34 -0500845 * sensor_value_emit_heartbeat:
846 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -0500847 * @arg_bus_name: Argument to pass with the signal.
Norman James3f97c5d2015-08-26 17:44:14 -0500848 *
Norman James5d78b4d2015-09-05 13:34:34 -0500849 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorValue.Heartbeat">"Heartbeat"</link> D-Bus signal.
Norman James3f97c5d2015-08-26 17:44:14 -0500850 */
851void
Norman James5d78b4d2015-09-05 13:34:34 -0500852sensor_value_emit_heartbeat (
853 SensorValue *object,
Norman James90baede2015-09-02 20:32:49 -0500854 const gchar *arg_bus_name)
Norman James3f97c5d2015-08-26 17:44:14 -0500855{
Norman James90baede2015-09-02 20:32:49 -0500856 g_signal_emit_by_name (object, "heartbeat", arg_bus_name);
Norman James3f97c5d2015-08-26 17:44:14 -0500857}
858
859/**
Norman James5d78b4d2015-09-05 13:34:34 -0500860 * sensor_value_call_init:
861 * @proxy: A #SensorValueProxy.
Norman James90baede2015-09-02 20:32:49 -0500862 * @cancellable: (allow-none): A #GCancellable or %NULL.
863 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
864 * @user_data: User data to pass to @callback.
Norman James3f97c5d2015-08-26 17:44:14 -0500865 *
Norman James5d78b4d2015-09-05 13:34:34 -0500866 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.init">init()</link> D-Bus method on @proxy.
Norman James90baede2015-09-02 20:32:49 -0500867 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -0500868 * You can then call sensor_value_call_init_finish() to get the result of the operation.
Norman James90baede2015-09-02 20:32:49 -0500869 *
Norman James5d78b4d2015-09-05 13:34:34 -0500870 * See sensor_value_call_init_sync() for the synchronous, blocking version of this method.
Norman James3f97c5d2015-08-26 17:44:14 -0500871 */
872void
Norman James5d78b4d2015-09-05 13:34:34 -0500873sensor_value_call_init (
874 SensorValue *proxy,
Norman James90baede2015-09-02 20:32:49 -0500875 GCancellable *cancellable,
876 GAsyncReadyCallback callback,
877 gpointer user_data)
Norman James3f97c5d2015-08-26 17:44:14 -0500878{
Norman James90baede2015-09-02 20:32:49 -0500879 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
880 "init",
881 g_variant_new ("()"),
882 G_DBUS_CALL_FLAGS_NONE,
883 -1,
884 cancellable,
885 callback,
886 user_data);
887}
888
889/**
Norman James5d78b4d2015-09-05 13:34:34 -0500890 * sensor_value_call_init_finish:
891 * @proxy: A #SensorValueProxy.
892 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_value_call_init().
Norman James90baede2015-09-02 20:32:49 -0500893 * @error: Return location for error or %NULL.
894 *
Norman James5d78b4d2015-09-05 13:34:34 -0500895 * Finishes an operation started with sensor_value_call_init().
Norman James90baede2015-09-02 20:32:49 -0500896 *
897 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
898 */
899gboolean
Norman James5d78b4d2015-09-05 13:34:34 -0500900sensor_value_call_init_finish (
901 SensorValue *proxy,
Norman James90baede2015-09-02 20:32:49 -0500902 GAsyncResult *res,
903 GError **error)
904{
905 GVariant *_ret;
906 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
907 if (_ret == NULL)
908 goto _out;
909 g_variant_get (_ret,
910 "()");
911 g_variant_unref (_ret);
912_out:
913 return _ret != NULL;
914}
915
916/**
Norman James5d78b4d2015-09-05 13:34:34 -0500917 * sensor_value_call_init_sync:
918 * @proxy: A #SensorValueProxy.
Norman James90baede2015-09-02 20:32:49 -0500919 * @cancellable: (allow-none): A #GCancellable or %NULL.
920 * @error: Return location for error or %NULL.
921 *
Norman James5d78b4d2015-09-05 13:34:34 -0500922 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.init">init()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
Norman James90baede2015-09-02 20:32:49 -0500923 *
Norman James5d78b4d2015-09-05 13:34:34 -0500924 * See sensor_value_call_init() for the asynchronous version of this method.
Norman James90baede2015-09-02 20:32:49 -0500925 *
926 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
927 */
928gboolean
Norman James5d78b4d2015-09-05 13:34:34 -0500929sensor_value_call_init_sync (
930 SensorValue *proxy,
Norman James90baede2015-09-02 20:32:49 -0500931 GCancellable *cancellable,
932 GError **error)
933{
934 GVariant *_ret;
935 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
936 "init",
937 g_variant_new ("()"),
938 G_DBUS_CALL_FLAGS_NONE,
939 -1,
940 cancellable,
941 error);
942 if (_ret == NULL)
943 goto _out;
944 g_variant_get (_ret,
945 "()");
946 g_variant_unref (_ret);
947_out:
948 return _ret != NULL;
Norman James3f97c5d2015-08-26 17:44:14 -0500949}
950
951/**
Norman James5d78b4d2015-09-05 13:34:34 -0500952 * sensor_value_call_get_value:
953 * @proxy: A #SensorValueProxy.
Norman Jamese2765102015-08-19 22:00:55 -0500954 * @cancellable: (allow-none): A #GCancellable or %NULL.
955 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
956 * @user_data: User data to pass to @callback.
957 *
Norman James5d78b4d2015-09-05 13:34:34 -0500958 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.getValue">getValue()</link> D-Bus method on @proxy.
Norman Jamese2765102015-08-19 22:00:55 -0500959 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -0500960 * You can then call sensor_value_call_get_value_finish() to get the result of the operation.
Norman Jamese2765102015-08-19 22:00:55 -0500961 *
Norman James5d78b4d2015-09-05 13:34:34 -0500962 * See sensor_value_call_get_value_sync() for the synchronous, blocking version of this method.
Norman Jamese2765102015-08-19 22:00:55 -0500963 */
964void
Norman James5d78b4d2015-09-05 13:34:34 -0500965sensor_value_call_get_value (
966 SensorValue *proxy,
Norman Jamese2765102015-08-19 22:00:55 -0500967 GCancellable *cancellable,
968 GAsyncReadyCallback callback,
969 gpointer user_data)
970{
971 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
972 "getValue",
973 g_variant_new ("()"),
974 G_DBUS_CALL_FLAGS_NONE,
975 -1,
976 cancellable,
977 callback,
978 user_data);
979}
980
981/**
Norman James5d78b4d2015-09-05 13:34:34 -0500982 * sensor_value_call_get_value_finish:
983 * @proxy: A #SensorValueProxy.
Norman Jamese2765102015-08-19 22:00:55 -0500984 * @out_value: (out): Return location for return parameter or %NULL to ignore.
Norman James5d78b4d2015-09-05 13:34:34 -0500985 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_value_call_get_value().
Norman Jamese2765102015-08-19 22:00:55 -0500986 * @error: Return location for error or %NULL.
987 *
Norman James5d78b4d2015-09-05 13:34:34 -0500988 * Finishes an operation started with sensor_value_call_get_value().
Norman Jamese2765102015-08-19 22:00:55 -0500989 *
990 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
991 */
992gboolean
Norman James5d78b4d2015-09-05 13:34:34 -0500993sensor_value_call_get_value_finish (
994 SensorValue *proxy,
995 GVariant **out_value,
Norman Jamese2765102015-08-19 22:00:55 -0500996 GAsyncResult *res,
997 GError **error)
998{
999 GVariant *_ret;
1000 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
1001 if (_ret == NULL)
1002 goto _out;
1003 g_variant_get (_ret,
Norman James5d78b4d2015-09-05 13:34:34 -05001004 "(@v)",
Norman Jamese2765102015-08-19 22:00:55 -05001005 out_value);
1006 g_variant_unref (_ret);
1007_out:
1008 return _ret != NULL;
1009}
1010
1011/**
Norman James5d78b4d2015-09-05 13:34:34 -05001012 * sensor_value_call_get_value_sync:
1013 * @proxy: A #SensorValueProxy.
Norman Jamese2765102015-08-19 22:00:55 -05001014 * @out_value: (out): Return location for return parameter or %NULL to ignore.
1015 * @cancellable: (allow-none): A #GCancellable or %NULL.
1016 * @error: Return location for error or %NULL.
1017 *
Norman James5d78b4d2015-09-05 13:34:34 -05001018 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.getValue">getValue()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
Norman Jamese2765102015-08-19 22:00:55 -05001019 *
Norman James5d78b4d2015-09-05 13:34:34 -05001020 * See sensor_value_call_get_value() for the asynchronous version of this method.
Norman Jamese2765102015-08-19 22:00:55 -05001021 *
1022 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
1023 */
1024gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05001025sensor_value_call_get_value_sync (
1026 SensorValue *proxy,
1027 GVariant **out_value,
Norman Jamese2765102015-08-19 22:00:55 -05001028 GCancellable *cancellable,
1029 GError **error)
1030{
1031 GVariant *_ret;
1032 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
1033 "getValue",
1034 g_variant_new ("()"),
1035 G_DBUS_CALL_FLAGS_NONE,
1036 -1,
1037 cancellable,
1038 error);
1039 if (_ret == NULL)
1040 goto _out;
1041 g_variant_get (_ret,
Norman James5d78b4d2015-09-05 13:34:34 -05001042 "(@v)",
Norman Jamese2765102015-08-19 22:00:55 -05001043 out_value);
1044 g_variant_unref (_ret);
1045_out:
1046 return _ret != NULL;
1047}
1048
1049/**
Norman James5d78b4d2015-09-05 13:34:34 -05001050 * sensor_value_call_set_value:
1051 * @proxy: A #SensorValueProxy.
Norman James90baede2015-09-02 20:32:49 -05001052 * @arg_value: Argument to pass with the method invocation.
1053 * @cancellable: (allow-none): A #GCancellable or %NULL.
1054 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
1055 * @user_data: User data to pass to @callback.
1056 *
Norman James5d78b4d2015-09-05 13:34:34 -05001057 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.setValue">setValue()</link> D-Bus method on @proxy.
Norman James90baede2015-09-02 20:32:49 -05001058 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05001059 * You can then call sensor_value_call_set_value_finish() to get the result of the operation.
Norman James90baede2015-09-02 20:32:49 -05001060 *
Norman James5d78b4d2015-09-05 13:34:34 -05001061 * See sensor_value_call_set_value_sync() for the synchronous, blocking version of this method.
Norman James90baede2015-09-02 20:32:49 -05001062 */
1063void
Norman James5d78b4d2015-09-05 13:34:34 -05001064sensor_value_call_set_value (
1065 SensorValue *proxy,
1066 GVariant *arg_value,
Norman James90baede2015-09-02 20:32:49 -05001067 GCancellable *cancellable,
1068 GAsyncReadyCallback callback,
1069 gpointer user_data)
1070{
1071 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
1072 "setValue",
Norman James5d78b4d2015-09-05 13:34:34 -05001073 g_variant_new ("(@v)",
Norman James90baede2015-09-02 20:32:49 -05001074 arg_value),
1075 G_DBUS_CALL_FLAGS_NONE,
1076 -1,
1077 cancellable,
1078 callback,
1079 user_data);
1080}
1081
1082/**
Norman James5d78b4d2015-09-05 13:34:34 -05001083 * sensor_value_call_set_value_finish:
1084 * @proxy: A #SensorValueProxy.
1085 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_value_call_set_value().
Norman James90baede2015-09-02 20:32:49 -05001086 * @error: Return location for error or %NULL.
1087 *
Norman James5d78b4d2015-09-05 13:34:34 -05001088 * Finishes an operation started with sensor_value_call_set_value().
Norman James90baede2015-09-02 20:32:49 -05001089 *
1090 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
1091 */
1092gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05001093sensor_value_call_set_value_finish (
1094 SensorValue *proxy,
Norman James90baede2015-09-02 20:32:49 -05001095 GAsyncResult *res,
1096 GError **error)
1097{
1098 GVariant *_ret;
1099 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
1100 if (_ret == NULL)
1101 goto _out;
1102 g_variant_get (_ret,
1103 "()");
1104 g_variant_unref (_ret);
1105_out:
1106 return _ret != NULL;
1107}
1108
1109/**
Norman James5d78b4d2015-09-05 13:34:34 -05001110 * sensor_value_call_set_value_sync:
1111 * @proxy: A #SensorValueProxy.
Norman James90baede2015-09-02 20:32:49 -05001112 * @arg_value: Argument to pass with the method invocation.
1113 * @cancellable: (allow-none): A #GCancellable or %NULL.
1114 * @error: Return location for error or %NULL.
1115 *
Norman James5d78b4d2015-09-05 13:34:34 -05001116 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorValue.setValue">setValue()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
Norman James90baede2015-09-02 20:32:49 -05001117 *
Norman James5d78b4d2015-09-05 13:34:34 -05001118 * See sensor_value_call_set_value() for the asynchronous version of this method.
Norman James90baede2015-09-02 20:32:49 -05001119 *
1120 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
1121 */
1122gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05001123sensor_value_call_set_value_sync (
1124 SensorValue *proxy,
1125 GVariant *arg_value,
Norman James90baede2015-09-02 20:32:49 -05001126 GCancellable *cancellable,
1127 GError **error)
1128{
1129 GVariant *_ret;
1130 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
1131 "setValue",
Norman James5d78b4d2015-09-05 13:34:34 -05001132 g_variant_new ("(@v)",
Norman James90baede2015-09-02 20:32:49 -05001133 arg_value),
1134 G_DBUS_CALL_FLAGS_NONE,
1135 -1,
1136 cancellable,
1137 error);
1138 if (_ret == NULL)
1139 goto _out;
1140 g_variant_get (_ret,
1141 "()");
1142 g_variant_unref (_ret);
1143_out:
1144 return _ret != NULL;
1145}
1146
1147/**
Norman James5d78b4d2015-09-05 13:34:34 -05001148 * sensor_value_complete_init:
1149 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -05001150 * @invocation: (transfer full): A #GDBusMethodInvocation.
Norman Jamescc7ae122015-08-24 14:26:09 -05001151 *
Norman James5d78b4d2015-09-05 13:34:34 -05001152 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorValue.init">init()</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.
Norman Jamescc7ae122015-08-24 14:26:09 -05001153 *
Norman James90baede2015-09-02 20:32:49 -05001154 * This method will free @invocation, you cannot use it afterwards.
Norman Jamescc7ae122015-08-24 14:26:09 -05001155 */
1156void
Norman James5d78b4d2015-09-05 13:34:34 -05001157sensor_value_complete_init (
1158 SensorValue *object,
Norman James90baede2015-09-02 20:32:49 -05001159 GDBusMethodInvocation *invocation)
Norman Jamescc7ae122015-08-24 14:26:09 -05001160{
Norman James90baede2015-09-02 20:32:49 -05001161 g_dbus_method_invocation_return_value (invocation,
1162 g_variant_new ("()"));
Norman Jamese7594922015-08-27 14:25:24 -05001163}
1164
1165/**
Norman James5d78b4d2015-09-05 13:34:34 -05001166 * sensor_value_complete_get_value:
1167 * @object: A #SensorValue.
Norman Jamese2765102015-08-19 22:00:55 -05001168 * @invocation: (transfer full): A #GDBusMethodInvocation.
1169 * @value: Parameter to return.
1170 *
Norman James5d78b4d2015-09-05 13:34:34 -05001171 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorValue.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.
Norman Jamese2765102015-08-19 22:00:55 -05001172 *
1173 * This method will free @invocation, you cannot use it afterwards.
1174 */
1175void
Norman James5d78b4d2015-09-05 13:34:34 -05001176sensor_value_complete_get_value (
1177 SensorValue *object,
Norman Jamese2765102015-08-19 22:00:55 -05001178 GDBusMethodInvocation *invocation,
Norman James5d78b4d2015-09-05 13:34:34 -05001179 GVariant *value)
Norman Jamese2765102015-08-19 22:00:55 -05001180{
1181 g_dbus_method_invocation_return_value (invocation,
Norman James5d78b4d2015-09-05 13:34:34 -05001182 g_variant_new ("(@v)",
Norman Jamese2765102015-08-19 22:00:55 -05001183 value));
1184}
1185
1186/**
Norman James5d78b4d2015-09-05 13:34:34 -05001187 * sensor_value_complete_set_value:
1188 * @object: A #SensorValue.
Norman James90baede2015-09-02 20:32:49 -05001189 * @invocation: (transfer full): A #GDBusMethodInvocation.
1190 *
Norman James5d78b4d2015-09-05 13:34:34 -05001191 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorValue.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.
Norman James90baede2015-09-02 20:32:49 -05001192 *
1193 * This method will free @invocation, you cannot use it afterwards.
1194 */
1195void
Norman James5d78b4d2015-09-05 13:34:34 -05001196sensor_value_complete_set_value (
1197 SensorValue *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05001198 GDBusMethodInvocation *invocation)
1199{
1200 g_dbus_method_invocation_return_value (invocation,
1201 g_variant_new ("()"));
1202}
1203
Norman Jamese2765102015-08-19 22:00:55 -05001204/* ------------------------------------------------------------------------ */
1205
1206/**
Norman James5d78b4d2015-09-05 13:34:34 -05001207 * SensorValueProxy:
Norman Jamese2765102015-08-19 22:00:55 -05001208 *
Norman James5d78b4d2015-09-05 13:34:34 -05001209 * The #SensorValueProxy structure contains only private data and should only be accessed using the provided API.
Norman Jamese2765102015-08-19 22:00:55 -05001210 */
1211
1212/**
Norman James5d78b4d2015-09-05 13:34:34 -05001213 * SensorValueProxyClass:
Norman Jamese2765102015-08-19 22:00:55 -05001214 * @parent_class: The parent class.
1215 *
Norman James5d78b4d2015-09-05 13:34:34 -05001216 * Class structure for #SensorValueProxy.
Norman Jamese2765102015-08-19 22:00:55 -05001217 */
1218
Norman James5d78b4d2015-09-05 13:34:34 -05001219struct _SensorValueProxyPrivate
Norman Jamese2765102015-08-19 22:00:55 -05001220{
1221 GData *qdata;
1222};
1223
Norman James5d78b4d2015-09-05 13:34:34 -05001224static void sensor_value_proxy_iface_init (SensorValueIface *iface);
Norman Jamese2765102015-08-19 22:00:55 -05001225
1226#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05001227G_DEFINE_TYPE_WITH_CODE (SensorValueProxy, sensor_value_proxy, G_TYPE_DBUS_PROXY,
1228 G_ADD_PRIVATE (SensorValueProxy)
1229 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_VALUE, sensor_value_proxy_iface_init));
Norman Jamese2765102015-08-19 22:00:55 -05001230
1231#else
Norman James5d78b4d2015-09-05 13:34:34 -05001232G_DEFINE_TYPE_WITH_CODE (SensorValueProxy, sensor_value_proxy, G_TYPE_DBUS_PROXY,
1233 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_VALUE, sensor_value_proxy_iface_init));
Norman Jamese2765102015-08-19 22:00:55 -05001234
1235#endif
1236static void
Norman James5d78b4d2015-09-05 13:34:34 -05001237sensor_value_proxy_finalize (GObject *object)
Norman Jamese2765102015-08-19 22:00:55 -05001238{
Norman James5d78b4d2015-09-05 13:34:34 -05001239 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
Norman Jamese2765102015-08-19 22:00:55 -05001240 g_datalist_clear (&proxy->priv->qdata);
Norman James5d78b4d2015-09-05 13:34:34 -05001241 G_OBJECT_CLASS (sensor_value_proxy_parent_class)->finalize (object);
Norman Jamese2765102015-08-19 22:00:55 -05001242}
1243
1244static void
Norman James5d78b4d2015-09-05 13:34:34 -05001245sensor_value_proxy_get_property (GObject *object,
Norman Jamese2765102015-08-19 22:00:55 -05001246 guint prop_id,
1247 GValue *value,
1248 GParamSpec *pspec G_GNUC_UNUSED)
1249{
1250 const _ExtendedGDBusPropertyInfo *info;
1251 GVariant *variant;
Norman James9e6acf92015-09-08 07:00:04 -05001252 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman James5d78b4d2015-09-05 13:34:34 -05001253 info = _sensor_value_property_info_pointers[prop_id - 1];
Norman Jamese2765102015-08-19 22:00:55 -05001254 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
1255 if (info->use_gvariant)
1256 {
1257 g_value_set_variant (value, variant);
1258 }
1259 else
1260 {
1261 if (variant != NULL)
1262 g_dbus_gvariant_to_gvalue (variant, value);
1263 }
1264 if (variant != NULL)
1265 g_variant_unref (variant);
1266}
1267
1268static void
Norman James5d78b4d2015-09-05 13:34:34 -05001269sensor_value_proxy_set_property_cb (GDBusProxy *proxy,
Norman Jamese2765102015-08-19 22:00:55 -05001270 GAsyncResult *res,
1271 gpointer user_data)
1272{
1273 const _ExtendedGDBusPropertyInfo *info = user_data;
1274 GError *error;
1275 GVariant *_ret;
1276 error = NULL;
1277 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
1278 if (!_ret)
1279 {
Norman James5d78b4d2015-09-05 13:34:34 -05001280 g_warning ("Error setting property '%s' on interface org.openbmc.SensorValue: %s (%s, %d)",
Norman Jamese2765102015-08-19 22:00:55 -05001281 info->parent_struct.name,
1282 error->message, g_quark_to_string (error->domain), error->code);
1283 g_error_free (error);
1284 }
1285 else
1286 {
1287 g_variant_unref (_ret);
1288 }
1289}
1290
1291static void
Norman James5d78b4d2015-09-05 13:34:34 -05001292sensor_value_proxy_set_property (GObject *object,
Norman Jamese2765102015-08-19 22:00:55 -05001293 guint prop_id,
1294 const GValue *value,
1295 GParamSpec *pspec G_GNUC_UNUSED)
1296{
1297 const _ExtendedGDBusPropertyInfo *info;
1298 GVariant *variant;
Norman James9e6acf92015-09-08 07:00:04 -05001299 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman James5d78b4d2015-09-05 13:34:34 -05001300 info = _sensor_value_property_info_pointers[prop_id - 1];
Norman Jamese2765102015-08-19 22:00:55 -05001301 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
1302 g_dbus_proxy_call (G_DBUS_PROXY (object),
1303 "org.freedesktop.DBus.Properties.Set",
Norman James5d78b4d2015-09-05 13:34:34 -05001304 g_variant_new ("(ssv)", "org.openbmc.SensorValue", info->parent_struct.name, variant),
Norman Jamese2765102015-08-19 22:00:55 -05001305 G_DBUS_CALL_FLAGS_NONE,
1306 -1,
Norman James5d78b4d2015-09-05 13:34:34 -05001307 NULL, (GAsyncReadyCallback) sensor_value_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
Norman Jamese2765102015-08-19 22:00:55 -05001308 g_variant_unref (variant);
1309}
1310
1311static void
Norman James5d78b4d2015-09-05 13:34:34 -05001312sensor_value_proxy_g_signal (GDBusProxy *proxy,
Norman Jamese2765102015-08-19 22:00:55 -05001313 const gchar *sender_name G_GNUC_UNUSED,
1314 const gchar *signal_name,
1315 GVariant *parameters)
1316{
1317 _ExtendedGDBusSignalInfo *info;
1318 GVariantIter iter;
1319 GVariant *child;
1320 GValue *paramv;
1321 guint num_params;
1322 guint n;
1323 guint signal_id;
Norman James5d78b4d2015-09-05 13:34:34 -05001324 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct, signal_name);
Norman Jamese2765102015-08-19 22:00:55 -05001325 if (info == NULL)
1326 return;
1327 num_params = g_variant_n_children (parameters);
1328 paramv = g_new0 (GValue, num_params + 1);
Norman James5d78b4d2015-09-05 13:34:34 -05001329 g_value_init (&paramv[0], TYPE_SENSOR_VALUE);
Norman Jamese2765102015-08-19 22:00:55 -05001330 g_value_set_object (&paramv[0], proxy);
1331 g_variant_iter_init (&iter, parameters);
1332 n = 1;
1333 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1334 {
1335 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
1336 if (arg_info->use_gvariant)
1337 {
1338 g_value_init (&paramv[n], G_TYPE_VARIANT);
1339 g_value_set_variant (&paramv[n], child);
1340 n++;
1341 }
1342 else
1343 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
1344 g_variant_unref (child);
1345 }
Norman James5d78b4d2015-09-05 13:34:34 -05001346 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_VALUE);
Norman Jamese2765102015-08-19 22:00:55 -05001347 g_signal_emitv (paramv, signal_id, 0, NULL);
1348 for (n = 0; n < num_params + 1; n++)
1349 g_value_unset (&paramv[n]);
1350 g_free (paramv);
1351}
1352
1353static void
Norman James5d78b4d2015-09-05 13:34:34 -05001354sensor_value_proxy_g_properties_changed (GDBusProxy *_proxy,
Norman Jamese2765102015-08-19 22:00:55 -05001355 GVariant *changed_properties,
1356 const gchar *const *invalidated_properties)
1357{
Norman James5d78b4d2015-09-05 13:34:34 -05001358 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (_proxy);
Norman Jamese2765102015-08-19 22:00:55 -05001359 guint n;
1360 const gchar *key;
1361 GVariantIter *iter;
1362 _ExtendedGDBusPropertyInfo *info;
1363 g_variant_get (changed_properties, "a{sv}", &iter);
1364 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
1365 {
Norman James5d78b4d2015-09-05 13:34:34 -05001366 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct, key);
Norman Jamese2765102015-08-19 22:00:55 -05001367 g_datalist_remove_data (&proxy->priv->qdata, key);
1368 if (info != NULL)
1369 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
1370 }
1371 g_variant_iter_free (iter);
1372 for (n = 0; invalidated_properties[n] != NULL; n++)
1373 {
Norman James5d78b4d2015-09-05 13:34:34 -05001374 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct, invalidated_properties[n]);
Norman Jamese2765102015-08-19 22:00:55 -05001375 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
1376 if (info != NULL)
1377 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
1378 }
1379}
1380
Norman James5d78b4d2015-09-05 13:34:34 -05001381static GVariant *
1382sensor_value_proxy_get_value (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -05001383{
Norman James5d78b4d2015-09-05 13:34:34 -05001384 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
Norman Jamese2765102015-08-19 22:00:55 -05001385 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05001386 GVariant *value = NULL;
Norman Jamese2765102015-08-19 22:00:55 -05001387 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "value");
Norman James5d78b4d2015-09-05 13:34:34 -05001388 value = variant;
Norman Jamese2765102015-08-19 22:00:55 -05001389 if (variant != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05001390 g_variant_unref (variant);
Norman Jamese2765102015-08-19 22:00:55 -05001391 return value;
1392}
1393
1394static const gchar *
Norman James5d78b4d2015-09-05 13:34:34 -05001395sensor_value_proxy_get_units (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -05001396{
Norman James5d78b4d2015-09-05 13:34:34 -05001397 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
Norman Jamese2765102015-08-19 22:00:55 -05001398 GVariant *variant;
1399 const gchar *value = NULL;
1400 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "units");
1401 if (variant != NULL)
1402 {
1403 value = g_variant_get_string (variant, NULL);
1404 g_variant_unref (variant);
1405 }
1406 return value;
1407}
1408
Norman Jamescc7ae122015-08-24 14:26:09 -05001409static gint
Norman James5d78b4d2015-09-05 13:34:34 -05001410sensor_value_proxy_get_poll_interval (SensorValue *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05001411{
Norman James5d78b4d2015-09-05 13:34:34 -05001412 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05001413 GVariant *variant;
1414 gint value = 0;
1415 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "poll_interval");
1416 if (variant != NULL)
1417 {
1418 value = g_variant_get_int32 (variant);
1419 g_variant_unref (variant);
1420 }
1421 return value;
1422}
1423
Norman Jamescc7ae122015-08-24 14:26:09 -05001424static gint
Norman James5d78b4d2015-09-05 13:34:34 -05001425sensor_value_proxy_get_heatbeat (SensorValue *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05001426{
Norman James5d78b4d2015-09-05 13:34:34 -05001427 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05001428 GVariant *variant;
1429 gint value = 0;
Norman James90baede2015-09-02 20:32:49 -05001430 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "heatbeat");
Norman Jamescc7ae122015-08-24 14:26:09 -05001431 if (variant != NULL)
1432 {
1433 value = g_variant_get_int32 (variant);
1434 g_variant_unref (variant);
1435 }
1436 return value;
1437}
1438
Norman James9e6acf92015-09-08 07:00:04 -05001439static gboolean
1440sensor_value_proxy_get_settable (SensorValue *object)
1441{
1442 SensorValueProxy *proxy = SENSOR_VALUE_PROXY (object);
1443 GVariant *variant;
1444 gboolean value = 0;
1445 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "settable");
1446 if (variant != NULL)
1447 {
1448 value = g_variant_get_boolean (variant);
1449 g_variant_unref (variant);
1450 }
1451 return value;
1452}
1453
Norman Jamese2765102015-08-19 22:00:55 -05001454static void
Norman James5d78b4d2015-09-05 13:34:34 -05001455sensor_value_proxy_init (SensorValueProxy *proxy)
Norman Jamese2765102015-08-19 22:00:55 -05001456{
1457#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05001458 proxy->priv = sensor_value_proxy_get_instance_private (proxy);
Norman Jamese2765102015-08-19 22:00:55 -05001459#else
Norman James5d78b4d2015-09-05 13:34:34 -05001460 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_VALUE_PROXY, SensorValueProxyPrivate);
Norman Jamese2765102015-08-19 22:00:55 -05001461#endif
1462
Norman James5d78b4d2015-09-05 13:34:34 -05001463 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_value_interface_info ());
Norman Jamese2765102015-08-19 22:00:55 -05001464}
1465
1466static void
Norman James5d78b4d2015-09-05 13:34:34 -05001467sensor_value_proxy_class_init (SensorValueProxyClass *klass)
Norman Jamese2765102015-08-19 22:00:55 -05001468{
1469 GObjectClass *gobject_class;
1470 GDBusProxyClass *proxy_class;
1471
1472 gobject_class = G_OBJECT_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05001473 gobject_class->finalize = sensor_value_proxy_finalize;
1474 gobject_class->get_property = sensor_value_proxy_get_property;
1475 gobject_class->set_property = sensor_value_proxy_set_property;
Norman Jamese2765102015-08-19 22:00:55 -05001476
1477 proxy_class = G_DBUS_PROXY_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05001478 proxy_class->g_signal = sensor_value_proxy_g_signal;
1479 proxy_class->g_properties_changed = sensor_value_proxy_g_properties_changed;
Norman Jamese2765102015-08-19 22:00:55 -05001480
Norman James5d78b4d2015-09-05 13:34:34 -05001481 sensor_value_override_properties (gobject_class, 1);
Norman Jamese2765102015-08-19 22:00:55 -05001482
1483#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05001484 g_type_class_add_private (klass, sizeof (SensorValueProxyPrivate));
Norman Jamese2765102015-08-19 22:00:55 -05001485#endif
1486}
1487
1488static void
Norman James5d78b4d2015-09-05 13:34:34 -05001489sensor_value_proxy_iface_init (SensorValueIface *iface)
Norman Jamese2765102015-08-19 22:00:55 -05001490{
Norman James5d78b4d2015-09-05 13:34:34 -05001491 iface->get_value = sensor_value_proxy_get_value;
1492 iface->get_units = sensor_value_proxy_get_units;
1493 iface->get_poll_interval = sensor_value_proxy_get_poll_interval;
1494 iface->get_heatbeat = sensor_value_proxy_get_heatbeat;
Norman James9e6acf92015-09-08 07:00:04 -05001495 iface->get_settable = sensor_value_proxy_get_settable;
Norman Jamese2765102015-08-19 22:00:55 -05001496}
1497
1498/**
Norman James5d78b4d2015-09-05 13:34:34 -05001499 * sensor_value_proxy_new:
Norman Jamese2765102015-08-19 22:00:55 -05001500 * @connection: A #GDBusConnection.
1501 * @flags: Flags from the #GDBusProxyFlags enumeration.
1502 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1503 * @object_path: An object path.
1504 * @cancellable: (allow-none): A #GCancellable or %NULL.
1505 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1506 * @user_data: User data to pass to @callback.
1507 *
Norman James5d78b4d2015-09-05 13:34:34 -05001508 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>. See g_dbus_proxy_new() for more details.
Norman Jamese2765102015-08-19 22:00:55 -05001509 *
1510 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05001511 * You can then call sensor_value_proxy_new_finish() to get the result of the operation.
Norman Jamese2765102015-08-19 22:00:55 -05001512 *
Norman James5d78b4d2015-09-05 13:34:34 -05001513 * See sensor_value_proxy_new_sync() for the synchronous, blocking version of this constructor.
Norman Jamese2765102015-08-19 22:00:55 -05001514 */
1515void
Norman James5d78b4d2015-09-05 13:34:34 -05001516sensor_value_proxy_new (
Norman Jamese2765102015-08-19 22:00:55 -05001517 GDBusConnection *connection,
1518 GDBusProxyFlags flags,
1519 const gchar *name,
1520 const gchar *object_path,
1521 GCancellable *cancellable,
1522 GAsyncReadyCallback callback,
1523 gpointer user_data)
1524{
Norman James5d78b4d2015-09-05 13:34:34 -05001525 g_async_initable_new_async (TYPE_SENSOR_VALUE_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.SensorValue", NULL);
Norman Jamese2765102015-08-19 22:00:55 -05001526}
1527
1528/**
Norman James5d78b4d2015-09-05 13:34:34 -05001529 * sensor_value_proxy_new_finish:
1530 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_value_proxy_new().
Norman Jamese2765102015-08-19 22:00:55 -05001531 * @error: Return location for error or %NULL
1532 *
Norman James5d78b4d2015-09-05 13:34:34 -05001533 * Finishes an operation started with sensor_value_proxy_new().
Norman Jamese2765102015-08-19 22:00:55 -05001534 *
Norman James5d78b4d2015-09-05 13:34:34 -05001535 * Returns: (transfer full) (type SensorValueProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamese2765102015-08-19 22:00:55 -05001536 */
Norman James5d78b4d2015-09-05 13:34:34 -05001537SensorValue *
1538sensor_value_proxy_new_finish (
Norman Jamese2765102015-08-19 22:00:55 -05001539 GAsyncResult *res,
1540 GError **error)
1541{
1542 GObject *ret;
1543 GObject *source_object;
1544 source_object = g_async_result_get_source_object (res);
1545 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1546 g_object_unref (source_object);
1547 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05001548 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05001549 else
1550 return NULL;
1551}
1552
1553/**
Norman James5d78b4d2015-09-05 13:34:34 -05001554 * sensor_value_proxy_new_sync:
Norman Jamese2765102015-08-19 22:00:55 -05001555 * @connection: A #GDBusConnection.
1556 * @flags: Flags from the #GDBusProxyFlags enumeration.
1557 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
1558 * @object_path: An object path.
1559 * @cancellable: (allow-none): A #GCancellable or %NULL.
1560 * @error: Return location for error or %NULL
1561 *
Norman James5d78b4d2015-09-05 13:34:34 -05001562 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>. See g_dbus_proxy_new_sync() for more details.
Norman Jamese2765102015-08-19 22:00:55 -05001563 *
1564 * The calling thread is blocked until a reply is received.
1565 *
Norman James5d78b4d2015-09-05 13:34:34 -05001566 * See sensor_value_proxy_new() for the asynchronous version of this constructor.
Norman Jamese2765102015-08-19 22:00:55 -05001567 *
Norman James5d78b4d2015-09-05 13:34:34 -05001568 * Returns: (transfer full) (type SensorValueProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamese2765102015-08-19 22:00:55 -05001569 */
Norman James5d78b4d2015-09-05 13:34:34 -05001570SensorValue *
1571sensor_value_proxy_new_sync (
Norman Jamese2765102015-08-19 22:00:55 -05001572 GDBusConnection *connection,
1573 GDBusProxyFlags flags,
1574 const gchar *name,
1575 const gchar *object_path,
1576 GCancellable *cancellable,
1577 GError **error)
1578{
1579 GInitable *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05001580 ret = g_initable_new (TYPE_SENSOR_VALUE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorValue", NULL);
Norman Jamese2765102015-08-19 22:00:55 -05001581 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05001582 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05001583 else
1584 return NULL;
1585}
1586
1587
1588/**
Norman James5d78b4d2015-09-05 13:34:34 -05001589 * sensor_value_proxy_new_for_bus:
Norman Jamese2765102015-08-19 22:00:55 -05001590 * @bus_type: A #GBusType.
1591 * @flags: Flags from the #GDBusProxyFlags enumeration.
1592 * @name: A bus name (well-known or unique).
1593 * @object_path: An object path.
1594 * @cancellable: (allow-none): A #GCancellable or %NULL.
1595 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
1596 * @user_data: User data to pass to @callback.
1597 *
Norman James5d78b4d2015-09-05 13:34:34 -05001598 * Like sensor_value_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
Norman Jamese2765102015-08-19 22:00:55 -05001599 *
1600 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05001601 * You can then call sensor_value_proxy_new_for_bus_finish() to get the result of the operation.
Norman Jamese2765102015-08-19 22:00:55 -05001602 *
Norman James5d78b4d2015-09-05 13:34:34 -05001603 * See sensor_value_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
Norman Jamese2765102015-08-19 22:00:55 -05001604 */
1605void
Norman James5d78b4d2015-09-05 13:34:34 -05001606sensor_value_proxy_new_for_bus (
Norman Jamese2765102015-08-19 22:00:55 -05001607 GBusType bus_type,
1608 GDBusProxyFlags flags,
1609 const gchar *name,
1610 const gchar *object_path,
1611 GCancellable *cancellable,
1612 GAsyncReadyCallback callback,
1613 gpointer user_data)
1614{
Norman James5d78b4d2015-09-05 13:34:34 -05001615 g_async_initable_new_async (TYPE_SENSOR_VALUE_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.SensorValue", NULL);
Norman Jamese2765102015-08-19 22:00:55 -05001616}
1617
1618/**
Norman James5d78b4d2015-09-05 13:34:34 -05001619 * sensor_value_proxy_new_for_bus_finish:
1620 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_value_proxy_new_for_bus().
Norman Jamese2765102015-08-19 22:00:55 -05001621 * @error: Return location for error or %NULL
1622 *
Norman James5d78b4d2015-09-05 13:34:34 -05001623 * Finishes an operation started with sensor_value_proxy_new_for_bus().
Norman Jamese2765102015-08-19 22:00:55 -05001624 *
Norman James5d78b4d2015-09-05 13:34:34 -05001625 * Returns: (transfer full) (type SensorValueProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamese2765102015-08-19 22:00:55 -05001626 */
Norman James5d78b4d2015-09-05 13:34:34 -05001627SensorValue *
1628sensor_value_proxy_new_for_bus_finish (
Norman Jamese2765102015-08-19 22:00:55 -05001629 GAsyncResult *res,
1630 GError **error)
1631{
1632 GObject *ret;
1633 GObject *source_object;
1634 source_object = g_async_result_get_source_object (res);
1635 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
1636 g_object_unref (source_object);
1637 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05001638 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05001639 else
1640 return NULL;
1641}
1642
1643/**
Norman James5d78b4d2015-09-05 13:34:34 -05001644 * sensor_value_proxy_new_for_bus_sync:
Norman Jamese2765102015-08-19 22:00:55 -05001645 * @bus_type: A #GBusType.
1646 * @flags: Flags from the #GDBusProxyFlags enumeration.
1647 * @name: A bus name (well-known or unique).
1648 * @object_path: An object path.
1649 * @cancellable: (allow-none): A #GCancellable or %NULL.
1650 * @error: Return location for error or %NULL
1651 *
Norman James5d78b4d2015-09-05 13:34:34 -05001652 * Like sensor_value_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
Norman Jamese2765102015-08-19 22:00:55 -05001653 *
1654 * The calling thread is blocked until a reply is received.
1655 *
Norman James5d78b4d2015-09-05 13:34:34 -05001656 * See sensor_value_proxy_new_for_bus() for the asynchronous version of this constructor.
Norman Jamese2765102015-08-19 22:00:55 -05001657 *
Norman James5d78b4d2015-09-05 13:34:34 -05001658 * Returns: (transfer full) (type SensorValueProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamese2765102015-08-19 22:00:55 -05001659 */
Norman James5d78b4d2015-09-05 13:34:34 -05001660SensorValue *
1661sensor_value_proxy_new_for_bus_sync (
Norman Jamese2765102015-08-19 22:00:55 -05001662 GBusType bus_type,
1663 GDBusProxyFlags flags,
1664 const gchar *name,
1665 const gchar *object_path,
1666 GCancellable *cancellable,
1667 GError **error)
1668{
1669 GInitable *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05001670 ret = g_initable_new (TYPE_SENSOR_VALUE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorValue", NULL);
Norman Jamese2765102015-08-19 22:00:55 -05001671 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05001672 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05001673 else
1674 return NULL;
1675}
1676
1677
1678/* ------------------------------------------------------------------------ */
1679
1680/**
Norman James5d78b4d2015-09-05 13:34:34 -05001681 * SensorValueSkeleton:
Norman Jamese2765102015-08-19 22:00:55 -05001682 *
Norman James5d78b4d2015-09-05 13:34:34 -05001683 * The #SensorValueSkeleton structure contains only private data and should only be accessed using the provided API.
Norman Jamese2765102015-08-19 22:00:55 -05001684 */
1685
1686/**
Norman James5d78b4d2015-09-05 13:34:34 -05001687 * SensorValueSkeletonClass:
Norman Jamese2765102015-08-19 22:00:55 -05001688 * @parent_class: The parent class.
1689 *
Norman James5d78b4d2015-09-05 13:34:34 -05001690 * Class structure for #SensorValueSkeleton.
Norman Jamese2765102015-08-19 22:00:55 -05001691 */
1692
Norman James5d78b4d2015-09-05 13:34:34 -05001693struct _SensorValueSkeletonPrivate
Norman Jamese2765102015-08-19 22:00:55 -05001694{
1695 GValue *properties;
1696 GList *changed_properties;
1697 GSource *changed_properties_idle_source;
1698 GMainContext *context;
1699 GMutex lock;
1700};
1701
1702static void
Norman James5d78b4d2015-09-05 13:34:34 -05001703_sensor_value_skeleton_handle_method_call (
Norman Jamese2765102015-08-19 22:00:55 -05001704 GDBusConnection *connection G_GNUC_UNUSED,
1705 const gchar *sender G_GNUC_UNUSED,
1706 const gchar *object_path G_GNUC_UNUSED,
1707 const gchar *interface_name,
1708 const gchar *method_name,
1709 GVariant *parameters,
1710 GDBusMethodInvocation *invocation,
1711 gpointer user_data)
1712{
Norman James5d78b4d2015-09-05 13:34:34 -05001713 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (user_data);
Norman Jamese2765102015-08-19 22:00:55 -05001714 _ExtendedGDBusMethodInfo *info;
1715 GVariantIter iter;
1716 GVariant *child;
1717 GValue *paramv;
1718 guint num_params;
1719 guint num_extra;
1720 guint n;
1721 guint signal_id;
1722 GValue return_value = G_VALUE_INIT;
1723 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
1724 g_assert (info != NULL);
1725 num_params = g_variant_n_children (parameters);
1726 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
1727 n = 0;
Norman James5d78b4d2015-09-05 13:34:34 -05001728 g_value_init (&paramv[n], TYPE_SENSOR_VALUE);
Norman Jamese2765102015-08-19 22:00:55 -05001729 g_value_set_object (&paramv[n++], skeleton);
1730 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
1731 g_value_set_object (&paramv[n++], invocation);
1732 if (info->pass_fdlist)
1733 {
1734#ifdef G_OS_UNIX
1735 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
1736 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
1737#else
1738 g_assert_not_reached ();
1739#endif
1740 }
1741 g_variant_iter_init (&iter, parameters);
1742 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1743 {
1744 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
1745 if (arg_info->use_gvariant)
1746 {
1747 g_value_init (&paramv[n], G_TYPE_VARIANT);
1748 g_value_set_variant (&paramv[n], child);
1749 n++;
1750 }
1751 else
1752 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
1753 g_variant_unref (child);
1754 }
Norman James5d78b4d2015-09-05 13:34:34 -05001755 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_VALUE);
Norman Jamese2765102015-08-19 22:00:55 -05001756 g_value_init (&return_value, G_TYPE_BOOLEAN);
1757 g_signal_emitv (paramv, signal_id, 0, &return_value);
1758 if (!g_value_get_boolean (&return_value))
1759 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);
1760 g_value_unset (&return_value);
1761 for (n = 0; n < num_params + num_extra; n++)
1762 g_value_unset (&paramv[n]);
1763 g_free (paramv);
1764}
1765
1766static GVariant *
Norman James5d78b4d2015-09-05 13:34:34 -05001767_sensor_value_skeleton_handle_get_property (
Norman Jamese2765102015-08-19 22:00:55 -05001768 GDBusConnection *connection G_GNUC_UNUSED,
1769 const gchar *sender G_GNUC_UNUSED,
1770 const gchar *object_path G_GNUC_UNUSED,
1771 const gchar *interface_name G_GNUC_UNUSED,
1772 const gchar *property_name,
1773 GError **error,
1774 gpointer user_data)
1775{
Norman James5d78b4d2015-09-05 13:34:34 -05001776 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (user_data);
Norman Jamese2765102015-08-19 22:00:55 -05001777 GValue value = G_VALUE_INIT;
1778 GParamSpec *pspec;
1779 _ExtendedGDBusPropertyInfo *info;
1780 GVariant *ret;
1781 ret = NULL;
Norman James5d78b4d2015-09-05 13:34:34 -05001782 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct, property_name);
Norman Jamese2765102015-08-19 22:00:55 -05001783 g_assert (info != NULL);
1784 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1785 if (pspec == NULL)
1786 {
1787 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1788 }
1789 else
1790 {
1791 g_value_init (&value, pspec->value_type);
1792 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1793 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
1794 g_value_unset (&value);
1795 }
1796 return ret;
1797}
1798
1799static gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05001800_sensor_value_skeleton_handle_set_property (
Norman Jamese2765102015-08-19 22:00:55 -05001801 GDBusConnection *connection G_GNUC_UNUSED,
1802 const gchar *sender G_GNUC_UNUSED,
1803 const gchar *object_path G_GNUC_UNUSED,
1804 const gchar *interface_name G_GNUC_UNUSED,
1805 const gchar *property_name,
1806 GVariant *variant,
1807 GError **error,
1808 gpointer user_data)
1809{
Norman James5d78b4d2015-09-05 13:34:34 -05001810 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (user_data);
Norman Jamese2765102015-08-19 22:00:55 -05001811 GValue value = G_VALUE_INIT;
1812 GParamSpec *pspec;
1813 _ExtendedGDBusPropertyInfo *info;
1814 gboolean ret;
1815 ret = FALSE;
Norman James5d78b4d2015-09-05 13:34:34 -05001816 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_value_interface_info.parent_struct, property_name);
Norman Jamese2765102015-08-19 22:00:55 -05001817 g_assert (info != NULL);
1818 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1819 if (pspec == NULL)
1820 {
1821 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1822 }
1823 else
1824 {
1825 if (info->use_gvariant)
1826 g_value_set_variant (&value, variant);
1827 else
1828 g_dbus_gvariant_to_gvalue (variant, &value);
1829 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1830 g_value_unset (&value);
1831 ret = TRUE;
1832 }
1833 return ret;
1834}
1835
Norman James5d78b4d2015-09-05 13:34:34 -05001836static const GDBusInterfaceVTable _sensor_value_skeleton_vtable =
Norman Jamese2765102015-08-19 22:00:55 -05001837{
Norman James5d78b4d2015-09-05 13:34:34 -05001838 _sensor_value_skeleton_handle_method_call,
1839 _sensor_value_skeleton_handle_get_property,
1840 _sensor_value_skeleton_handle_set_property,
Norman Jamese2765102015-08-19 22:00:55 -05001841 {NULL}
1842};
1843
1844static GDBusInterfaceInfo *
Norman James5d78b4d2015-09-05 13:34:34 -05001845sensor_value_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
Norman Jamese2765102015-08-19 22:00:55 -05001846{
Norman James5d78b4d2015-09-05 13:34:34 -05001847 return sensor_value_interface_info ();
Norman Jamese2765102015-08-19 22:00:55 -05001848}
1849
1850static GDBusInterfaceVTable *
Norman James5d78b4d2015-09-05 13:34:34 -05001851sensor_value_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
Norman Jamese2765102015-08-19 22:00:55 -05001852{
Norman James5d78b4d2015-09-05 13:34:34 -05001853 return (GDBusInterfaceVTable *) &_sensor_value_skeleton_vtable;
Norman Jamese2765102015-08-19 22:00:55 -05001854}
1855
1856static GVariant *
Norman James5d78b4d2015-09-05 13:34:34 -05001857sensor_value_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
Norman Jamese2765102015-08-19 22:00:55 -05001858{
Norman James5d78b4d2015-09-05 13:34:34 -05001859 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (_skeleton);
Norman Jamese2765102015-08-19 22:00:55 -05001860
1861 GVariantBuilder builder;
1862 guint n;
1863 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
Norman James5d78b4d2015-09-05 13:34:34 -05001864 if (_sensor_value_interface_info.parent_struct.properties == NULL)
Norman Jamese2765102015-08-19 22:00:55 -05001865 goto out;
Norman James5d78b4d2015-09-05 13:34:34 -05001866 for (n = 0; _sensor_value_interface_info.parent_struct.properties[n] != NULL; n++)
Norman Jamese2765102015-08-19 22:00:55 -05001867 {
Norman James5d78b4d2015-09-05 13:34:34 -05001868 GDBusPropertyInfo *info = _sensor_value_interface_info.parent_struct.properties[n];
Norman Jamese2765102015-08-19 22:00:55 -05001869 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
1870 {
1871 GVariant *value;
Norman James5d78b4d2015-09-05 13:34:34 -05001872 value = _sensor_value_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.SensorValue", info->name, NULL, skeleton);
Norman Jamese2765102015-08-19 22:00:55 -05001873 if (value != NULL)
1874 {
1875 g_variant_take_ref (value);
1876 g_variant_builder_add (&builder, "{sv}", info->name, value);
1877 g_variant_unref (value);
1878 }
1879 }
1880 }
1881out:
1882 return g_variant_builder_end (&builder);
1883}
1884
Norman James5d78b4d2015-09-05 13:34:34 -05001885static gboolean _sensor_value_emit_changed (gpointer user_data);
Norman Jamese2765102015-08-19 22:00:55 -05001886
1887static void
Norman James5d78b4d2015-09-05 13:34:34 -05001888sensor_value_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
Norman Jamese2765102015-08-19 22:00:55 -05001889{
Norman James5d78b4d2015-09-05 13:34:34 -05001890 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (_skeleton);
Norman Jamese2765102015-08-19 22:00:55 -05001891 gboolean emit_changed = FALSE;
1892
1893 g_mutex_lock (&skeleton->priv->lock);
1894 if (skeleton->priv->changed_properties_idle_source != NULL)
1895 {
1896 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1897 skeleton->priv->changed_properties_idle_source = NULL;
1898 emit_changed = TRUE;
1899 }
1900 g_mutex_unlock (&skeleton->priv->lock);
1901
1902 if (emit_changed)
Norman James5d78b4d2015-09-05 13:34:34 -05001903 _sensor_value_emit_changed (skeleton);
Norman Jamese2765102015-08-19 22:00:55 -05001904}
1905
1906static void
Norman James5d78b4d2015-09-05 13:34:34 -05001907_sensor_value_on_signal_changed (
1908 SensorValue *object,
1909 GVariant *arg_value,
Norman James90baede2015-09-02 20:32:49 -05001910 const gchar *arg_units)
Norman Jamese2765102015-08-19 22:00:55 -05001911{
Norman James5d78b4d2015-09-05 13:34:34 -05001912 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman Jamese2765102015-08-19 22:00:55 -05001913
1914 GList *connections, *l;
1915 GVariant *signal_variant;
1916 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1917
Norman James5d78b4d2015-09-05 13:34:34 -05001918 signal_variant = g_variant_ref_sink (g_variant_new ("(@vs)",
Norman James90baede2015-09-02 20:32:49 -05001919 arg_value,
1920 arg_units));
Norman Jamese2765102015-08-19 22:00:55 -05001921 for (l = connections; l != NULL; l = l->next)
1922 {
1923 GDBusConnection *connection = l->data;
1924 g_dbus_connection_emit_signal (connection,
Norman James5d78b4d2015-09-05 13:34:34 -05001925 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorValue", "Changed",
Norman Jamese2765102015-08-19 22:00:55 -05001926 signal_variant, NULL);
1927 }
1928 g_variant_unref (signal_variant);
1929 g_list_free_full (connections, g_object_unref);
1930}
1931
Norman James3f97c5d2015-08-26 17:44:14 -05001932static void
Norman James5d78b4d2015-09-05 13:34:34 -05001933_sensor_value_on_signal_heartbeat (
1934 SensorValue *object,
Norman James90baede2015-09-02 20:32:49 -05001935 const gchar *arg_bus_name)
Norman James3f97c5d2015-08-26 17:44:14 -05001936{
Norman James5d78b4d2015-09-05 13:34:34 -05001937 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman James3f97c5d2015-08-26 17:44:14 -05001938
1939 GList *connections, *l;
1940 GVariant *signal_variant;
1941 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1942
Norman James90baede2015-09-02 20:32:49 -05001943 signal_variant = g_variant_ref_sink (g_variant_new ("(s)",
1944 arg_bus_name));
Norman James3f97c5d2015-08-26 17:44:14 -05001945 for (l = connections; l != NULL; l = l->next)
1946 {
1947 GDBusConnection *connection = l->data;
1948 g_dbus_connection_emit_signal (connection,
Norman James5d78b4d2015-09-05 13:34:34 -05001949 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorValue", "Heartbeat",
Norman James3f97c5d2015-08-26 17:44:14 -05001950 signal_variant, NULL);
1951 }
1952 g_variant_unref (signal_variant);
1953 g_list_free_full (connections, g_object_unref);
1954}
1955
Norman James5d78b4d2015-09-05 13:34:34 -05001956static void sensor_value_skeleton_iface_init (SensorValueIface *iface);
Norman Jamese2765102015-08-19 22:00:55 -05001957#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05001958G_DEFINE_TYPE_WITH_CODE (SensorValueSkeleton, sensor_value_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1959 G_ADD_PRIVATE (SensorValueSkeleton)
1960 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_VALUE, sensor_value_skeleton_iface_init));
Norman Jamese2765102015-08-19 22:00:55 -05001961
1962#else
Norman James5d78b4d2015-09-05 13:34:34 -05001963G_DEFINE_TYPE_WITH_CODE (SensorValueSkeleton, sensor_value_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1964 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_VALUE, sensor_value_skeleton_iface_init));
Norman Jamese2765102015-08-19 22:00:55 -05001965
1966#endif
1967static void
Norman James5d78b4d2015-09-05 13:34:34 -05001968sensor_value_skeleton_finalize (GObject *object)
Norman Jamese2765102015-08-19 22:00:55 -05001969{
Norman James5d78b4d2015-09-05 13:34:34 -05001970 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman Jamese2765102015-08-19 22:00:55 -05001971 guint n;
Norman James9e6acf92015-09-08 07:00:04 -05001972 for (n = 0; n < 5; n++)
Norman Jamese2765102015-08-19 22:00:55 -05001973 g_value_unset (&skeleton->priv->properties[n]);
1974 g_free (skeleton->priv->properties);
1975 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1976 if (skeleton->priv->changed_properties_idle_source != NULL)
1977 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1978 g_main_context_unref (skeleton->priv->context);
1979 g_mutex_clear (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05001980 G_OBJECT_CLASS (sensor_value_skeleton_parent_class)->finalize (object);
Norman Jamese2765102015-08-19 22:00:55 -05001981}
1982
1983static void
Norman James5d78b4d2015-09-05 13:34:34 -05001984sensor_value_skeleton_get_property (GObject *object,
Norman Jamese2765102015-08-19 22:00:55 -05001985 guint prop_id,
1986 GValue *value,
1987 GParamSpec *pspec G_GNUC_UNUSED)
1988{
Norman James5d78b4d2015-09-05 13:34:34 -05001989 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman James9e6acf92015-09-08 07:00:04 -05001990 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman Jamese2765102015-08-19 22:00:55 -05001991 g_mutex_lock (&skeleton->priv->lock);
1992 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
1993 g_mutex_unlock (&skeleton->priv->lock);
1994}
1995
1996static gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05001997_sensor_value_emit_changed (gpointer user_data)
Norman Jamese2765102015-08-19 22:00:55 -05001998{
Norman James5d78b4d2015-09-05 13:34:34 -05001999 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (user_data);
Norman Jamese2765102015-08-19 22:00:55 -05002000 GList *l;
2001 GVariantBuilder builder;
2002 GVariantBuilder invalidated_builder;
2003 guint num_changes;
2004
2005 g_mutex_lock (&skeleton->priv->lock);
2006 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
2007 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
2008 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
2009 {
2010 ChangedProperty *cp = l->data;
2011 GVariant *variant;
2012 const GValue *cur_value;
2013
2014 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
2015 if (!_g_value_equal (cur_value, &cp->orig_value))
2016 {
2017 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
2018 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
2019 g_variant_unref (variant);
2020 num_changes++;
2021 }
2022 }
2023 if (num_changes > 0)
2024 {
2025 GList *connections, *ll;
2026 GVariant *signal_variant;
Norman James5d78b4d2015-09-05 13:34:34 -05002027 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorValue",
Norman Jamese2765102015-08-19 22:00:55 -05002028 &builder, &invalidated_builder));
2029 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
2030 for (ll = connections; ll != NULL; ll = ll->next)
2031 {
2032 GDBusConnection *connection = ll->data;
2033
2034 g_dbus_connection_emit_signal (connection,
2035 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
2036 "org.freedesktop.DBus.Properties",
2037 "PropertiesChanged",
2038 signal_variant,
2039 NULL);
2040 }
2041 g_variant_unref (signal_variant);
2042 g_list_free_full (connections, g_object_unref);
2043 }
2044 else
2045 {
2046 g_variant_builder_clear (&builder);
2047 g_variant_builder_clear (&invalidated_builder);
2048 }
2049 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
2050 skeleton->priv->changed_properties = NULL;
2051 skeleton->priv->changed_properties_idle_source = NULL;
2052 g_mutex_unlock (&skeleton->priv->lock);
2053 return FALSE;
2054}
2055
2056static void
Norman James5d78b4d2015-09-05 13:34:34 -05002057_sensor_value_schedule_emit_changed (SensorValueSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
Norman Jamese2765102015-08-19 22:00:55 -05002058{
2059 ChangedProperty *cp;
2060 GList *l;
2061 cp = NULL;
2062 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
2063 {
2064 ChangedProperty *i_cp = l->data;
2065 if (i_cp->info == info)
2066 {
2067 cp = i_cp;
2068 break;
2069 }
2070 }
2071 if (cp == NULL)
2072 {
2073 cp = g_new0 (ChangedProperty, 1);
2074 cp->prop_id = prop_id;
2075 cp->info = info;
2076 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
2077 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
2078 g_value_copy (orig_value, &cp->orig_value);
2079 }
2080}
2081
2082static void
Norman James5d78b4d2015-09-05 13:34:34 -05002083sensor_value_skeleton_notify (GObject *object,
Norman Jamese2765102015-08-19 22:00:55 -05002084 GParamSpec *pspec G_GNUC_UNUSED)
2085{
Norman James5d78b4d2015-09-05 13:34:34 -05002086 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman Jamese2765102015-08-19 22:00:55 -05002087 g_mutex_lock (&skeleton->priv->lock);
2088 if (skeleton->priv->changed_properties != NULL &&
2089 skeleton->priv->changed_properties_idle_source == NULL)
2090 {
2091 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
2092 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
Norman James5d78b4d2015-09-05 13:34:34 -05002093 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_value_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
Norman Jamese2765102015-08-19 22:00:55 -05002094 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
2095 g_source_unref (skeleton->priv->changed_properties_idle_source);
2096 }
2097 g_mutex_unlock (&skeleton->priv->lock);
2098}
2099
2100static void
Norman James5d78b4d2015-09-05 13:34:34 -05002101sensor_value_skeleton_set_property (GObject *object,
Norman Jamese2765102015-08-19 22:00:55 -05002102 guint prop_id,
2103 const GValue *value,
2104 GParamSpec *pspec)
2105{
Norman James5d78b4d2015-09-05 13:34:34 -05002106 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman James9e6acf92015-09-08 07:00:04 -05002107 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman Jamese2765102015-08-19 22:00:55 -05002108 g_mutex_lock (&skeleton->priv->lock);
2109 g_object_freeze_notify (object);
2110 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
2111 {
2112 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05002113 _sensor_value_schedule_emit_changed (skeleton, _sensor_value_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
Norman Jamese2765102015-08-19 22:00:55 -05002114 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
2115 g_object_notify_by_pspec (object, pspec);
2116 }
2117 g_mutex_unlock (&skeleton->priv->lock);
2118 g_object_thaw_notify (object);
2119}
2120
2121static void
Norman James5d78b4d2015-09-05 13:34:34 -05002122sensor_value_skeleton_init (SensorValueSkeleton *skeleton)
Norman Jamese2765102015-08-19 22:00:55 -05002123{
2124#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05002125 skeleton->priv = sensor_value_skeleton_get_instance_private (skeleton);
Norman Jamese2765102015-08-19 22:00:55 -05002126#else
Norman James5d78b4d2015-09-05 13:34:34 -05002127 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_VALUE_SKELETON, SensorValueSkeletonPrivate);
Norman Jamese2765102015-08-19 22:00:55 -05002128#endif
2129
2130 g_mutex_init (&skeleton->priv->lock);
2131 skeleton->priv->context = g_main_context_ref_thread_default ();
Norman James9e6acf92015-09-08 07:00:04 -05002132 skeleton->priv->properties = g_new0 (GValue, 5);
Norman James5d78b4d2015-09-05 13:34:34 -05002133 g_value_init (&skeleton->priv->properties[0], G_TYPE_VARIANT);
Norman Jamese2765102015-08-19 22:00:55 -05002134 g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING);
Norman Jamescc7ae122015-08-24 14:26:09 -05002135 g_value_init (&skeleton->priv->properties[2], G_TYPE_INT);
Norman James3f97c5d2015-08-26 17:44:14 -05002136 g_value_init (&skeleton->priv->properties[3], G_TYPE_INT);
Norman James9e6acf92015-09-08 07:00:04 -05002137 g_value_init (&skeleton->priv->properties[4], G_TYPE_BOOLEAN);
Norman Jamese2765102015-08-19 22:00:55 -05002138}
2139
Norman James5d78b4d2015-09-05 13:34:34 -05002140static GVariant *
2141sensor_value_skeleton_get_value (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -05002142{
Norman James5d78b4d2015-09-05 13:34:34 -05002143 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
2144 GVariant *value;
Norman Jamese2765102015-08-19 22:00:55 -05002145 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05002146 value = g_value_get_variant (&(skeleton->priv->properties[0]));
Norman Jamese2765102015-08-19 22:00:55 -05002147 g_mutex_unlock (&skeleton->priv->lock);
2148 return value;
2149}
2150
2151static const gchar *
Norman James5d78b4d2015-09-05 13:34:34 -05002152sensor_value_skeleton_get_units (SensorValue *object)
Norman Jamese2765102015-08-19 22:00:55 -05002153{
Norman James5d78b4d2015-09-05 13:34:34 -05002154 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman Jamese2765102015-08-19 22:00:55 -05002155 const gchar *value;
2156 g_mutex_lock (&skeleton->priv->lock);
2157 value = g_value_get_string (&(skeleton->priv->properties[1]));
2158 g_mutex_unlock (&skeleton->priv->lock);
2159 return value;
2160}
2161
Norman Jamescc7ae122015-08-24 14:26:09 -05002162static gint
Norman James5d78b4d2015-09-05 13:34:34 -05002163sensor_value_skeleton_get_poll_interval (SensorValue *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05002164{
Norman James5d78b4d2015-09-05 13:34:34 -05002165 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05002166 gint value;
2167 g_mutex_lock (&skeleton->priv->lock);
2168 value = g_value_get_int (&(skeleton->priv->properties[2]));
2169 g_mutex_unlock (&skeleton->priv->lock);
2170 return value;
2171}
2172
Norman James3f97c5d2015-08-26 17:44:14 -05002173static gint
Norman James5d78b4d2015-09-05 13:34:34 -05002174sensor_value_skeleton_get_heatbeat (SensorValue *object)
Norman James3f97c5d2015-08-26 17:44:14 -05002175{
Norman James5d78b4d2015-09-05 13:34:34 -05002176 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
Norman James3f97c5d2015-08-26 17:44:14 -05002177 gint value;
2178 g_mutex_lock (&skeleton->priv->lock);
2179 value = g_value_get_int (&(skeleton->priv->properties[3]));
2180 g_mutex_unlock (&skeleton->priv->lock);
2181 return value;
2182}
2183
Norman James9e6acf92015-09-08 07:00:04 -05002184static gboolean
2185sensor_value_skeleton_get_settable (SensorValue *object)
2186{
2187 SensorValueSkeleton *skeleton = SENSOR_VALUE_SKELETON (object);
2188 gboolean value;
2189 g_mutex_lock (&skeleton->priv->lock);
2190 value = g_value_get_boolean (&(skeleton->priv->properties[4]));
2191 g_mutex_unlock (&skeleton->priv->lock);
2192 return value;
2193}
2194
Norman Jamese2765102015-08-19 22:00:55 -05002195static void
Norman James5d78b4d2015-09-05 13:34:34 -05002196sensor_value_skeleton_class_init (SensorValueSkeletonClass *klass)
Norman Jamese2765102015-08-19 22:00:55 -05002197{
2198 GObjectClass *gobject_class;
2199 GDBusInterfaceSkeletonClass *skeleton_class;
2200
2201 gobject_class = G_OBJECT_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05002202 gobject_class->finalize = sensor_value_skeleton_finalize;
2203 gobject_class->get_property = sensor_value_skeleton_get_property;
2204 gobject_class->set_property = sensor_value_skeleton_set_property;
2205 gobject_class->notify = sensor_value_skeleton_notify;
Norman Jamese2765102015-08-19 22:00:55 -05002206
2207
Norman James5d78b4d2015-09-05 13:34:34 -05002208 sensor_value_override_properties (gobject_class, 1);
Norman Jamese2765102015-08-19 22:00:55 -05002209
2210 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05002211 skeleton_class->get_info = sensor_value_skeleton_dbus_interface_get_info;
2212 skeleton_class->get_properties = sensor_value_skeleton_dbus_interface_get_properties;
2213 skeleton_class->flush = sensor_value_skeleton_dbus_interface_flush;
2214 skeleton_class->get_vtable = sensor_value_skeleton_dbus_interface_get_vtable;
Norman Jamese2765102015-08-19 22:00:55 -05002215
2216#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05002217 g_type_class_add_private (klass, sizeof (SensorValueSkeletonPrivate));
Norman Jamese2765102015-08-19 22:00:55 -05002218#endif
2219}
2220
2221static void
Norman James5d78b4d2015-09-05 13:34:34 -05002222sensor_value_skeleton_iface_init (SensorValueIface *iface)
Norman Jamese2765102015-08-19 22:00:55 -05002223{
Norman James5d78b4d2015-09-05 13:34:34 -05002224 iface->changed = _sensor_value_on_signal_changed;
2225 iface->heartbeat = _sensor_value_on_signal_heartbeat;
2226 iface->get_value = sensor_value_skeleton_get_value;
2227 iface->get_units = sensor_value_skeleton_get_units;
2228 iface->get_poll_interval = sensor_value_skeleton_get_poll_interval;
2229 iface->get_heatbeat = sensor_value_skeleton_get_heatbeat;
Norman James9e6acf92015-09-08 07:00:04 -05002230 iface->get_settable = sensor_value_skeleton_get_settable;
Norman Jamese2765102015-08-19 22:00:55 -05002231}
2232
2233/**
Norman James5d78b4d2015-09-05 13:34:34 -05002234 * sensor_value_skeleton_new:
Norman Jamese2765102015-08-19 22:00:55 -05002235 *
Norman James5d78b4d2015-09-05 13:34:34 -05002236 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>.
Norman Jamese2765102015-08-19 22:00:55 -05002237 *
Norman James5d78b4d2015-09-05 13:34:34 -05002238 * Returns: (transfer full) (type SensorValueSkeleton): The skeleton object.
Norman Jamese2765102015-08-19 22:00:55 -05002239 */
Norman James5d78b4d2015-09-05 13:34:34 -05002240SensorValue *
2241sensor_value_skeleton_new (void)
Norman Jamese2765102015-08-19 22:00:55 -05002242{
Norman James5d78b4d2015-09-05 13:34:34 -05002243 return SENSOR_VALUE (g_object_new (TYPE_SENSOR_VALUE_SKELETON, NULL));
Norman Jamese2765102015-08-19 22:00:55 -05002244}
2245
2246/* ------------------------------------------------------------------------
Norman James5d78b4d2015-09-05 13:34:34 -05002247 * Code for interface org.openbmc.SensorThreshold
Norman Jamese2765102015-08-19 22:00:55 -05002248 * ------------------------------------------------------------------------
2249 */
2250
2251/**
Norman James5d78b4d2015-09-05 13:34:34 -05002252 * SECTION:SensorThreshold
2253 * @title: SensorThreshold
2254 * @short_description: Generated C code for the org.openbmc.SensorThreshold D-Bus interface
Norman Jamese2765102015-08-19 22:00:55 -05002255 *
Norman James5d78b4d2015-09-05 13:34:34 -05002256 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link> D-Bus interface in C.
Norman Jamese2765102015-08-19 22:00:55 -05002257 */
2258
Norman James5d78b4d2015-09-05 13:34:34 -05002259/* ---- Introspection data for org.openbmc.SensorThreshold ---- */
Norman Jamese2765102015-08-19 22:00:55 -05002260
Norman James5d78b4d2015-09-05 13:34:34 -05002261static const _ExtendedGDBusArgInfo _sensor_threshold_method_info_get_state_OUT_ARG_state =
Norman Jamescc7ae122015-08-24 14:26:09 -05002262{
2263 {
2264 -1,
Norman James90baede2015-09-02 20:32:49 -05002265 (gchar *) "state",
Norman James5d78b4d2015-09-05 13:34:34 -05002266 (gchar *) "y",
Norman Jamescc7ae122015-08-24 14:26:09 -05002267 NULL
2268 },
2269 FALSE
2270};
2271
Norman James5d78b4d2015-09-05 13:34:34 -05002272static const _ExtendedGDBusArgInfo * const _sensor_threshold_method_info_get_state_OUT_ARG_pointers[] =
Norman Jamescc7ae122015-08-24 14:26:09 -05002273{
Norman James5d78b4d2015-09-05 13:34:34 -05002274 &_sensor_threshold_method_info_get_state_OUT_ARG_state,
Norman Jamescc7ae122015-08-24 14:26:09 -05002275 NULL
2276};
2277
Norman James5d78b4d2015-09-05 13:34:34 -05002278static const _ExtendedGDBusMethodInfo _sensor_threshold_method_info_get_state =
Norman Jamescc7ae122015-08-24 14:26:09 -05002279{
2280 {
2281 -1,
Norman James90baede2015-09-02 20:32:49 -05002282 (gchar *) "getState",
Norman Jamescc7ae122015-08-24 14:26:09 -05002283 NULL,
Norman James5d78b4d2015-09-05 13:34:34 -05002284 (GDBusArgInfo **) &_sensor_threshold_method_info_get_state_OUT_ARG_pointers,
Norman Jamescc7ae122015-08-24 14:26:09 -05002285 NULL
2286 },
Norman James90baede2015-09-02 20:32:49 -05002287 "handle-get-state",
Norman Jamescc7ae122015-08-24 14:26:09 -05002288 FALSE
2289};
2290
Norman James5d78b4d2015-09-05 13:34:34 -05002291static const _ExtendedGDBusMethodInfo * const _sensor_threshold_method_info_pointers[] =
Norman Jamescc7ae122015-08-24 14:26:09 -05002292{
Norman James5d78b4d2015-09-05 13:34:34 -05002293 &_sensor_threshold_method_info_get_state,
Norman Jamescc7ae122015-08-24 14:26:09 -05002294 NULL
2295};
2296
Norman James5d78b4d2015-09-05 13:34:34 -05002297static const _ExtendedGDBusSignalInfo _sensor_threshold_signal_info_warning =
Norman Jamescc7ae122015-08-24 14:26:09 -05002298{
2299 {
2300 -1,
Norman James90baede2015-09-02 20:32:49 -05002301 (gchar *) "Warning",
2302 NULL,
Norman Jamescc7ae122015-08-24 14:26:09 -05002303 NULL
2304 },
2305 "warning"
2306};
2307
Norman James5d78b4d2015-09-05 13:34:34 -05002308static const _ExtendedGDBusSignalInfo _sensor_threshold_signal_info_critical =
Norman James90baede2015-09-02 20:32:49 -05002309{
2310 {
2311 -1,
2312 (gchar *) "Critical",
2313 NULL,
2314 NULL
2315 },
2316 "critical"
2317};
2318
Norman James5d78b4d2015-09-05 13:34:34 -05002319static const _ExtendedGDBusSignalInfo _sensor_threshold_signal_info_normal =
Norman James90baede2015-09-02 20:32:49 -05002320{
2321 {
2322 -1,
2323 (gchar *) "Normal",
2324 NULL,
2325 NULL
2326 },
2327 "normal"
2328};
2329
Norman James5d78b4d2015-09-05 13:34:34 -05002330static const _ExtendedGDBusSignalInfo * const _sensor_threshold_signal_info_pointers[] =
Norman Jamescc7ae122015-08-24 14:26:09 -05002331{
Norman James5d78b4d2015-09-05 13:34:34 -05002332 &_sensor_threshold_signal_info_warning,
2333 &_sensor_threshold_signal_info_critical,
2334 &_sensor_threshold_signal_info_normal,
Norman Jamescc7ae122015-08-24 14:26:09 -05002335 NULL
2336};
2337
Norman James5d78b4d2015-09-05 13:34:34 -05002338static const _ExtendedGDBusPropertyInfo _sensor_threshold_property_info_lower_critical =
Norman Jamescc7ae122015-08-24 14:26:09 -05002339{
2340 {
2341 -1,
Norman James90baede2015-09-02 20:32:49 -05002342 (gchar *) "lower_critical",
Norman James5d78b4d2015-09-05 13:34:34 -05002343 (gchar *) "v",
Norman James90baede2015-09-02 20:32:49 -05002344 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
Norman Jamescc7ae122015-08-24 14:26:09 -05002345 NULL
2346 },
Norman James90baede2015-09-02 20:32:49 -05002347 "lower-critical",
Norman Jamescc7ae122015-08-24 14:26:09 -05002348 FALSE
2349};
2350
Norman James5d78b4d2015-09-05 13:34:34 -05002351static const _ExtendedGDBusPropertyInfo _sensor_threshold_property_info_lower_warning =
Norman Jamescc7ae122015-08-24 14:26:09 -05002352{
2353 {
2354 -1,
Norman James90baede2015-09-02 20:32:49 -05002355 (gchar *) "lower_warning",
Norman James5d78b4d2015-09-05 13:34:34 -05002356 (gchar *) "v",
Norman James90baede2015-09-02 20:32:49 -05002357 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
Norman Jamescc7ae122015-08-24 14:26:09 -05002358 NULL
2359 },
Norman James90baede2015-09-02 20:32:49 -05002360 "lower-warning",
Norman Jamescc7ae122015-08-24 14:26:09 -05002361 FALSE
2362};
2363
Norman James5d78b4d2015-09-05 13:34:34 -05002364static const _ExtendedGDBusPropertyInfo _sensor_threshold_property_info_upper_warning =
Norman Jamescc7ae122015-08-24 14:26:09 -05002365{
2366 {
2367 -1,
Norman James90baede2015-09-02 20:32:49 -05002368 (gchar *) "upper_warning",
Norman James5d78b4d2015-09-05 13:34:34 -05002369 (gchar *) "v",
Norman James90baede2015-09-02 20:32:49 -05002370 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
Norman Jamescc7ae122015-08-24 14:26:09 -05002371 NULL
2372 },
Norman James90baede2015-09-02 20:32:49 -05002373 "upper-warning",
Norman Jamescc7ae122015-08-24 14:26:09 -05002374 FALSE
2375};
2376
Norman James5d78b4d2015-09-05 13:34:34 -05002377static const _ExtendedGDBusPropertyInfo _sensor_threshold_property_info_upper_critical =
Norman Jamescc7ae122015-08-24 14:26:09 -05002378{
2379 {
2380 -1,
Norman James90baede2015-09-02 20:32:49 -05002381 (gchar *) "upper_critical",
Norman James5d78b4d2015-09-05 13:34:34 -05002382 (gchar *) "v",
Norman James90baede2015-09-02 20:32:49 -05002383 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
2384 NULL
2385 },
2386 "upper-critical",
2387 FALSE
2388};
2389
Norman James5d78b4d2015-09-05 13:34:34 -05002390static const _ExtendedGDBusPropertyInfo _sensor_threshold_property_info_state =
Norman James90baede2015-09-02 20:32:49 -05002391{
2392 {
2393 -1,
2394 (gchar *) "state",
Norman James5d78b4d2015-09-05 13:34:34 -05002395 (gchar *) "y",
Norman Jamescc7ae122015-08-24 14:26:09 -05002396 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
2397 NULL
2398 },
Norman James90baede2015-09-02 20:32:49 -05002399 "state",
Norman Jamescc7ae122015-08-24 14:26:09 -05002400 FALSE
2401};
2402
Norman James5d78b4d2015-09-05 13:34:34 -05002403static const _ExtendedGDBusPropertyInfo * const _sensor_threshold_property_info_pointers[] =
Norman Jamescc7ae122015-08-24 14:26:09 -05002404{
Norman James5d78b4d2015-09-05 13:34:34 -05002405 &_sensor_threshold_property_info_lower_critical,
2406 &_sensor_threshold_property_info_lower_warning,
2407 &_sensor_threshold_property_info_upper_warning,
2408 &_sensor_threshold_property_info_upper_critical,
2409 &_sensor_threshold_property_info_state,
Norman Jamescc7ae122015-08-24 14:26:09 -05002410 NULL
2411};
2412
Norman James5d78b4d2015-09-05 13:34:34 -05002413static const _ExtendedGDBusInterfaceInfo _sensor_threshold_interface_info =
Norman Jamescc7ae122015-08-24 14:26:09 -05002414{
2415 {
2416 -1,
Norman James5d78b4d2015-09-05 13:34:34 -05002417 (gchar *) "org.openbmc.SensorThreshold",
2418 (GDBusMethodInfo **) &_sensor_threshold_method_info_pointers,
2419 (GDBusSignalInfo **) &_sensor_threshold_signal_info_pointers,
2420 (GDBusPropertyInfo **) &_sensor_threshold_property_info_pointers,
Norman Jamescc7ae122015-08-24 14:26:09 -05002421 NULL
2422 },
Norman James5d78b4d2015-09-05 13:34:34 -05002423 "sensor-threshold",
Norman Jamescc7ae122015-08-24 14:26:09 -05002424};
2425
2426
2427/**
Norman James5d78b4d2015-09-05 13:34:34 -05002428 * sensor_threshold_interface_info:
Norman Jamescc7ae122015-08-24 14:26:09 -05002429 *
Norman James5d78b4d2015-09-05 13:34:34 -05002430 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link> D-Bus interface.
Norman Jamescc7ae122015-08-24 14:26:09 -05002431 *
2432 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
2433 */
2434GDBusInterfaceInfo *
Norman James5d78b4d2015-09-05 13:34:34 -05002435sensor_threshold_interface_info (void)
Norman Jamescc7ae122015-08-24 14:26:09 -05002436{
Norman James5d78b4d2015-09-05 13:34:34 -05002437 return (GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct;
Norman Jamescc7ae122015-08-24 14:26:09 -05002438}
2439
2440/**
Norman James5d78b4d2015-09-05 13:34:34 -05002441 * sensor_threshold_override_properties:
Norman Jamescc7ae122015-08-24 14:26:09 -05002442 * @klass: The class structure for a #GObject<!-- -->-derived class.
2443 * @property_id_begin: The property id to assign to the first overridden property.
2444 *
Norman James5d78b4d2015-09-05 13:34:34 -05002445 * Overrides all #GObject properties in the #SensorThreshold interface for a concrete class.
Norman Jamescc7ae122015-08-24 14:26:09 -05002446 * The properties are overridden in the order they are defined.
2447 *
2448 * Returns: The last property id.
2449 */
2450guint
Norman James5d78b4d2015-09-05 13:34:34 -05002451sensor_threshold_override_properties (GObjectClass *klass, guint property_id_begin)
Norman Jamescc7ae122015-08-24 14:26:09 -05002452{
Norman James90baede2015-09-02 20:32:49 -05002453 g_object_class_override_property (klass, property_id_begin++, "lower-critical");
2454 g_object_class_override_property (klass, property_id_begin++, "lower-warning");
2455 g_object_class_override_property (klass, property_id_begin++, "upper-warning");
2456 g_object_class_override_property (klass, property_id_begin++, "upper-critical");
2457 g_object_class_override_property (klass, property_id_begin++, "state");
Norman Jamescc7ae122015-08-24 14:26:09 -05002458 return property_id_begin - 1;
2459}
2460
2461
2462
2463/**
Norman James5d78b4d2015-09-05 13:34:34 -05002464 * SensorThreshold:
Norman Jamescc7ae122015-08-24 14:26:09 -05002465 *
Norman James5d78b4d2015-09-05 13:34:34 -05002466 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002467 */
2468
2469/**
Norman James5d78b4d2015-09-05 13:34:34 -05002470 * SensorThresholdIface:
Norman Jamescc7ae122015-08-24 14:26:09 -05002471 * @parent_iface: The parent interface.
Norman James5d78b4d2015-09-05 13:34:34 -05002472 * @handle_get_state: Handler for the #SensorThreshold::handle-get-state signal.
2473 * @get_lower_critical: Getter for the #SensorThreshold:lower-critical property.
2474 * @get_lower_warning: Getter for the #SensorThreshold:lower-warning property.
2475 * @get_state: Getter for the #SensorThreshold:state property.
2476 * @get_upper_critical: Getter for the #SensorThreshold:upper-critical property.
2477 * @get_upper_warning: Getter for the #SensorThreshold:upper-warning property.
2478 * @critical: Handler for the #SensorThreshold::critical signal.
2479 * @normal: Handler for the #SensorThreshold::normal signal.
2480 * @warning: Handler for the #SensorThreshold::warning signal.
Norman Jamescc7ae122015-08-24 14:26:09 -05002481 *
Norman James5d78b4d2015-09-05 13:34:34 -05002482 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002483 */
2484
Norman James5d78b4d2015-09-05 13:34:34 -05002485typedef SensorThresholdIface SensorThresholdInterface;
2486G_DEFINE_INTERFACE (SensorThreshold, sensor_threshold, G_TYPE_OBJECT);
Norman Jamescc7ae122015-08-24 14:26:09 -05002487
2488static void
Norman James5d78b4d2015-09-05 13:34:34 -05002489sensor_threshold_default_init (SensorThresholdIface *iface)
Norman Jamescc7ae122015-08-24 14:26:09 -05002490{
2491 /* GObject signals for incoming D-Bus method calls: */
2492 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002493 * SensorThreshold::handle-get-state:
2494 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002495 * @invocation: A #GDBusMethodInvocation.
Norman Jamescc7ae122015-08-24 14:26:09 -05002496 *
Norman James5d78b4d2015-09-05 13:34:34 -05002497 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorThreshold.getState">getState()</link> D-Bus method.
Norman Jamescc7ae122015-08-24 14:26:09 -05002498 *
Norman James5d78b4d2015-09-05 13:34:34 -05002499 * 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_threshold_complete_get_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
Norman James90baede2015-09-02 20:32:49 -05002500 *
2501 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
Norman Jamescc7ae122015-08-24 14:26:09 -05002502 */
Norman James90baede2015-09-02 20:32:49 -05002503 g_signal_new ("handle-get-state",
Norman Jamescc7ae122015-08-24 14:26:09 -05002504 G_TYPE_FROM_INTERFACE (iface),
2505 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -05002506 G_STRUCT_OFFSET (SensorThresholdIface, handle_get_state),
Norman James90baede2015-09-02 20:32:49 -05002507 g_signal_accumulator_true_handled,
Norman Jamescc7ae122015-08-24 14:26:09 -05002508 NULL,
2509 g_cclosure_marshal_generic,
Norman James90baede2015-09-02 20:32:49 -05002510 G_TYPE_BOOLEAN,
2511 1,
2512 G_TYPE_DBUS_METHOD_INVOCATION);
Norman Jamescc7ae122015-08-24 14:26:09 -05002513
Norman James90baede2015-09-02 20:32:49 -05002514 /* GObject signals for received D-Bus signals: */
Norman Jamescc7ae122015-08-24 14:26:09 -05002515 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002516 * SensorThreshold::warning:
2517 * @object: A #SensorThreshold.
Norman Jamescc7ae122015-08-24 14:26:09 -05002518 *
Norman James5d78b4d2015-09-05 13:34:34 -05002519 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Warning">"Warning"</link> is received.
Norman Jamescc7ae122015-08-24 14:26:09 -05002520 *
2521 * 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.
2522 */
2523 g_signal_new ("warning",
2524 G_TYPE_FROM_INTERFACE (iface),
2525 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -05002526 G_STRUCT_OFFSET (SensorThresholdIface, warning),
Norman Jamescc7ae122015-08-24 14:26:09 -05002527 NULL,
2528 NULL,
2529 g_cclosure_marshal_generic,
2530 G_TYPE_NONE,
Norman James90baede2015-09-02 20:32:49 -05002531 0);
2532
2533 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002534 * SensorThreshold::critical:
2535 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002536 *
Norman James5d78b4d2015-09-05 13:34:34 -05002537 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Critical">"Critical"</link> is received.
Norman James90baede2015-09-02 20:32:49 -05002538 *
2539 * 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.
2540 */
2541 g_signal_new ("critical",
2542 G_TYPE_FROM_INTERFACE (iface),
2543 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -05002544 G_STRUCT_OFFSET (SensorThresholdIface, critical),
Norman James90baede2015-09-02 20:32:49 -05002545 NULL,
2546 NULL,
2547 g_cclosure_marshal_generic,
2548 G_TYPE_NONE,
2549 0);
2550
2551 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002552 * SensorThreshold::normal:
2553 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002554 *
Norman James5d78b4d2015-09-05 13:34:34 -05002555 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Normal">"Normal"</link> is received.
Norman James90baede2015-09-02 20:32:49 -05002556 *
2557 * 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.
2558 */
2559 g_signal_new ("normal",
2560 G_TYPE_FROM_INTERFACE (iface),
2561 G_SIGNAL_RUN_LAST,
Norman James5d78b4d2015-09-05 13:34:34 -05002562 G_STRUCT_OFFSET (SensorThresholdIface, normal),
Norman James90baede2015-09-02 20:32:49 -05002563 NULL,
2564 NULL,
2565 g_cclosure_marshal_generic,
2566 G_TYPE_NONE,
2567 0);
Norman Jamescc7ae122015-08-24 14:26:09 -05002568
2569 /* GObject properties for D-Bus properties: */
2570 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002571 * SensorThreshold:lower-critical:
Norman Jamescc7ae122015-08-24 14:26:09 -05002572 *
Norman James5d78b4d2015-09-05 13:34:34 -05002573 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_critical">"lower_critical"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002574 *
Norman James90baede2015-09-02 20:32:49 -05002575 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
Norman Jamescc7ae122015-08-24 14:26:09 -05002576 */
2577 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -05002578 g_param_spec_variant ("lower-critical", "lower_critical", "lower_critical", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -05002579 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002580 * SensorThreshold:lower-warning:
Norman Jamescc7ae122015-08-24 14:26:09 -05002581 *
Norman James5d78b4d2015-09-05 13:34:34 -05002582 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_warning">"lower_warning"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002583 *
Norman James90baede2015-09-02 20:32:49 -05002584 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
Norman Jamescc7ae122015-08-24 14:26:09 -05002585 */
2586 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -05002587 g_param_spec_variant ("lower-warning", "lower_warning", "lower_warning", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -05002588 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002589 * SensorThreshold:upper-warning:
Norman Jamescc7ae122015-08-24 14:26:09 -05002590 *
Norman James5d78b4d2015-09-05 13:34:34 -05002591 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_warning">"upper_warning"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002592 *
Norman James90baede2015-09-02 20:32:49 -05002593 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
Norman Jamescc7ae122015-08-24 14:26:09 -05002594 */
2595 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -05002596 g_param_spec_variant ("upper-warning", "upper_warning", "upper_warning", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -05002597 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002598 * SensorThreshold:upper-critical:
Norman Jamescc7ae122015-08-24 14:26:09 -05002599 *
Norman James5d78b4d2015-09-05 13:34:34 -05002600 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_critical">"upper_critical"</link>.
Norman James90baede2015-09-02 20:32:49 -05002601 *
2602 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
2603 */
2604 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -05002605 g_param_spec_variant ("upper-critical", "upper_critical", "upper_critical", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman James90baede2015-09-02 20:32:49 -05002606 /**
Norman James5d78b4d2015-09-05 13:34:34 -05002607 * SensorThreshold:state:
Norman James90baede2015-09-02 20:32:49 -05002608 *
Norman James5d78b4d2015-09-05 13:34:34 -05002609 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorThreshold.state">"state"</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05002610 *
2611 * 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.
2612 */
2613 g_object_interface_install_property (iface,
Norman James5d78b4d2015-09-05 13:34:34 -05002614 g_param_spec_uchar ("state", "state", "state", 0, 255, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -05002615}
2616
2617/**
Norman James5d78b4d2015-09-05 13:34:34 -05002618 * sensor_threshold_get_lower_critical: (skip)
2619 * @object: A #SensorThreshold.
Norman Jamescc7ae122015-08-24 14:26:09 -05002620 *
Norman James5d78b4d2015-09-05 13:34:34 -05002621 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_critical">"lower_critical"</link> D-Bus property.
Norman James90baede2015-09-02 20:32:49 -05002622 *
2623 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2624 *
Norman James5d78b4d2015-09-05 13:34:34 -05002625 * <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_threshold_dup_lower_critical() if on another thread.</warning>
2626 *
2627 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
Norman James90baede2015-09-02 20:32:49 -05002628 */
Norman James5d78b4d2015-09-05 13:34:34 -05002629GVariant *
2630sensor_threshold_get_lower_critical (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002631{
Norman James5d78b4d2015-09-05 13:34:34 -05002632 return SENSOR_THRESHOLD_GET_IFACE (object)->get_lower_critical (object);
Norman James90baede2015-09-02 20:32:49 -05002633}
2634
2635/**
Norman James5d78b4d2015-09-05 13:34:34 -05002636 * sensor_threshold_dup_lower_critical: (skip)
2637 * @object: A #SensorThreshold.
2638 *
2639 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_critical">"lower_critical"</link> D-Bus property.
2640 *
2641 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2642 *
2643 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
2644 */
2645GVariant *
2646sensor_threshold_dup_lower_critical (SensorThreshold *object)
2647{
2648 GVariant *value;
2649 g_object_get (G_OBJECT (object), "lower-critical", &value, NULL);
2650 return value;
2651}
2652
2653/**
2654 * sensor_threshold_set_lower_critical: (skip)
2655 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002656 * @value: The value to set.
2657 *
Norman James5d78b4d2015-09-05 13:34:34 -05002658 * Sets the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_critical">"lower_critical"</link> D-Bus property to @value.
Norman James90baede2015-09-02 20:32:49 -05002659 *
2660 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2661 */
2662void
Norman James5d78b4d2015-09-05 13:34:34 -05002663sensor_threshold_set_lower_critical (SensorThreshold *object, GVariant *value)
Norman James90baede2015-09-02 20:32:49 -05002664{
2665 g_object_set (G_OBJECT (object), "lower-critical", value, NULL);
2666}
2667
2668/**
Norman James5d78b4d2015-09-05 13:34:34 -05002669 * sensor_threshold_get_lower_warning: (skip)
2670 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002671 *
Norman James5d78b4d2015-09-05 13:34:34 -05002672 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_warning">"lower_warning"</link> D-Bus property.
Norman James90baede2015-09-02 20:32:49 -05002673 *
2674 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2675 *
Norman James5d78b4d2015-09-05 13:34:34 -05002676 * <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_threshold_dup_lower_warning() if on another thread.</warning>
2677 *
2678 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
Norman James90baede2015-09-02 20:32:49 -05002679 */
Norman James5d78b4d2015-09-05 13:34:34 -05002680GVariant *
2681sensor_threshold_get_lower_warning (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002682{
Norman James5d78b4d2015-09-05 13:34:34 -05002683 return SENSOR_THRESHOLD_GET_IFACE (object)->get_lower_warning (object);
Norman James90baede2015-09-02 20:32:49 -05002684}
2685
2686/**
Norman James5d78b4d2015-09-05 13:34:34 -05002687 * sensor_threshold_dup_lower_warning: (skip)
2688 * @object: A #SensorThreshold.
2689 *
2690 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_warning">"lower_warning"</link> D-Bus property.
2691 *
2692 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2693 *
2694 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
2695 */
2696GVariant *
2697sensor_threshold_dup_lower_warning (SensorThreshold *object)
2698{
2699 GVariant *value;
2700 g_object_get (G_OBJECT (object), "lower-warning", &value, NULL);
2701 return value;
2702}
2703
2704/**
2705 * sensor_threshold_set_lower_warning: (skip)
2706 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002707 * @value: The value to set.
2708 *
Norman James5d78b4d2015-09-05 13:34:34 -05002709 * Sets the <link linkend="gdbus-property-org-openbmc-SensorThreshold.lower_warning">"lower_warning"</link> D-Bus property to @value.
Norman James90baede2015-09-02 20:32:49 -05002710 *
2711 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2712 */
2713void
Norman James5d78b4d2015-09-05 13:34:34 -05002714sensor_threshold_set_lower_warning (SensorThreshold *object, GVariant *value)
Norman James90baede2015-09-02 20:32:49 -05002715{
2716 g_object_set (G_OBJECT (object), "lower-warning", value, NULL);
2717}
2718
2719/**
Norman James5d78b4d2015-09-05 13:34:34 -05002720 * sensor_threshold_get_upper_warning: (skip)
2721 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002722 *
Norman James5d78b4d2015-09-05 13:34:34 -05002723 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_warning">"upper_warning"</link> D-Bus property.
Norman James90baede2015-09-02 20:32:49 -05002724 *
2725 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2726 *
Norman James5d78b4d2015-09-05 13:34:34 -05002727 * <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_threshold_dup_upper_warning() if on another thread.</warning>
2728 *
2729 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
Norman James90baede2015-09-02 20:32:49 -05002730 */
Norman James5d78b4d2015-09-05 13:34:34 -05002731GVariant *
2732sensor_threshold_get_upper_warning (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002733{
Norman James5d78b4d2015-09-05 13:34:34 -05002734 return SENSOR_THRESHOLD_GET_IFACE (object)->get_upper_warning (object);
Norman James90baede2015-09-02 20:32:49 -05002735}
2736
2737/**
Norman James5d78b4d2015-09-05 13:34:34 -05002738 * sensor_threshold_dup_upper_warning: (skip)
2739 * @object: A #SensorThreshold.
2740 *
2741 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_warning">"upper_warning"</link> D-Bus property.
2742 *
2743 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2744 *
2745 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
2746 */
2747GVariant *
2748sensor_threshold_dup_upper_warning (SensorThreshold *object)
2749{
2750 GVariant *value;
2751 g_object_get (G_OBJECT (object), "upper-warning", &value, NULL);
2752 return value;
2753}
2754
2755/**
2756 * sensor_threshold_set_upper_warning: (skip)
2757 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002758 * @value: The value to set.
2759 *
Norman James5d78b4d2015-09-05 13:34:34 -05002760 * Sets the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_warning">"upper_warning"</link> D-Bus property to @value.
Norman James90baede2015-09-02 20:32:49 -05002761 *
2762 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2763 */
2764void
Norman James5d78b4d2015-09-05 13:34:34 -05002765sensor_threshold_set_upper_warning (SensorThreshold *object, GVariant *value)
Norman James90baede2015-09-02 20:32:49 -05002766{
2767 g_object_set (G_OBJECT (object), "upper-warning", value, NULL);
2768}
2769
2770/**
Norman James5d78b4d2015-09-05 13:34:34 -05002771 * sensor_threshold_get_upper_critical: (skip)
2772 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002773 *
Norman James5d78b4d2015-09-05 13:34:34 -05002774 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_critical">"upper_critical"</link> D-Bus property.
Norman James90baede2015-09-02 20:32:49 -05002775 *
2776 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2777 *
Norman James5d78b4d2015-09-05 13:34:34 -05002778 * <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_threshold_dup_upper_critical() if on another thread.</warning>
2779 *
2780 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
Norman James90baede2015-09-02 20:32:49 -05002781 */
Norman James5d78b4d2015-09-05 13:34:34 -05002782GVariant *
2783sensor_threshold_get_upper_critical (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002784{
Norman James5d78b4d2015-09-05 13:34:34 -05002785 return SENSOR_THRESHOLD_GET_IFACE (object)->get_upper_critical (object);
Norman James90baede2015-09-02 20:32:49 -05002786}
2787
2788/**
Norman James5d78b4d2015-09-05 13:34:34 -05002789 * sensor_threshold_dup_upper_critical: (skip)
2790 * @object: A #SensorThreshold.
2791 *
2792 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_critical">"upper_critical"</link> D-Bus property.
2793 *
2794 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2795 *
2796 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
2797 */
2798GVariant *
2799sensor_threshold_dup_upper_critical (SensorThreshold *object)
2800{
2801 GVariant *value;
2802 g_object_get (G_OBJECT (object), "upper-critical", &value, NULL);
2803 return value;
2804}
2805
2806/**
2807 * sensor_threshold_set_upper_critical: (skip)
2808 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002809 * @value: The value to set.
2810 *
Norman James5d78b4d2015-09-05 13:34:34 -05002811 * Sets the <link linkend="gdbus-property-org-openbmc-SensorThreshold.upper_critical">"upper_critical"</link> D-Bus property to @value.
Norman James90baede2015-09-02 20:32:49 -05002812 *
2813 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
2814 */
2815void
Norman James5d78b4d2015-09-05 13:34:34 -05002816sensor_threshold_set_upper_critical (SensorThreshold *object, GVariant *value)
Norman James90baede2015-09-02 20:32:49 -05002817{
2818 g_object_set (G_OBJECT (object), "upper-critical", value, NULL);
2819}
2820
2821/**
Norman James5d78b4d2015-09-05 13:34:34 -05002822 * sensor_threshold_get_state: (skip)
2823 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002824 *
Norman James5d78b4d2015-09-05 13:34:34 -05002825 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorThreshold.state">"state"</link> D-Bus property.
Norman Jamescc7ae122015-08-24 14:26:09 -05002826 *
2827 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
2828 *
2829 * Returns: The property value.
2830 */
Norman James5d78b4d2015-09-05 13:34:34 -05002831guchar
2832sensor_threshold_get_state (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05002833{
Norman James5d78b4d2015-09-05 13:34:34 -05002834 return SENSOR_THRESHOLD_GET_IFACE (object)->get_state (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05002835}
2836
2837/**
Norman James5d78b4d2015-09-05 13:34:34 -05002838 * sensor_threshold_set_state: (skip)
2839 * @object: A #SensorThreshold.
Norman Jamescc7ae122015-08-24 14:26:09 -05002840 * @value: The value to set.
2841 *
Norman James5d78b4d2015-09-05 13:34:34 -05002842 * Sets the <link linkend="gdbus-property-org-openbmc-SensorThreshold.state">"state"</link> D-Bus property to @value.
Norman Jamescc7ae122015-08-24 14:26:09 -05002843 *
2844 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
2845 */
2846void
Norman James5d78b4d2015-09-05 13:34:34 -05002847sensor_threshold_set_state (SensorThreshold *object, guchar value)
Norman Jamescc7ae122015-08-24 14:26:09 -05002848{
Norman James90baede2015-09-02 20:32:49 -05002849 g_object_set (G_OBJECT (object), "state", value, NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05002850}
2851
2852/**
Norman James5d78b4d2015-09-05 13:34:34 -05002853 * sensor_threshold_emit_warning:
2854 * @object: A #SensorThreshold.
Norman Jamescc7ae122015-08-24 14:26:09 -05002855 *
Norman James5d78b4d2015-09-05 13:34:34 -05002856 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Warning">"Warning"</link> D-Bus signal.
Norman Jamescc7ae122015-08-24 14:26:09 -05002857 */
2858void
Norman James5d78b4d2015-09-05 13:34:34 -05002859sensor_threshold_emit_warning (
2860 SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05002861{
Norman James90baede2015-09-02 20:32:49 -05002862 g_signal_emit_by_name (object, "warning");
Norman Jamescc7ae122015-08-24 14:26:09 -05002863}
2864
2865/**
Norman James5d78b4d2015-09-05 13:34:34 -05002866 * sensor_threshold_emit_critical:
2867 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002868 *
Norman James5d78b4d2015-09-05 13:34:34 -05002869 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Critical">"Critical"</link> D-Bus signal.
Norman James90baede2015-09-02 20:32:49 -05002870 */
2871void
Norman James5d78b4d2015-09-05 13:34:34 -05002872sensor_threshold_emit_critical (
2873 SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002874{
2875 g_signal_emit_by_name (object, "critical");
2876}
2877
2878/**
Norman James5d78b4d2015-09-05 13:34:34 -05002879 * sensor_threshold_emit_normal:
2880 * @object: A #SensorThreshold.
Norman James90baede2015-09-02 20:32:49 -05002881 *
Norman James5d78b4d2015-09-05 13:34:34 -05002882 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorThreshold.Normal">"Normal"</link> D-Bus signal.
Norman James90baede2015-09-02 20:32:49 -05002883 */
2884void
Norman James5d78b4d2015-09-05 13:34:34 -05002885sensor_threshold_emit_normal (
2886 SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05002887{
2888 g_signal_emit_by_name (object, "normal");
2889}
2890
2891/**
Norman James5d78b4d2015-09-05 13:34:34 -05002892 * sensor_threshold_call_get_state:
2893 * @proxy: A #SensorThresholdProxy.
Norman Jamescc7ae122015-08-24 14:26:09 -05002894 * @cancellable: (allow-none): A #GCancellable or %NULL.
2895 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
2896 * @user_data: User data to pass to @callback.
2897 *
Norman James5d78b4d2015-09-05 13:34:34 -05002898 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorThreshold.getState">getState()</link> D-Bus method on @proxy.
Norman Jamescc7ae122015-08-24 14:26:09 -05002899 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05002900 * You can then call sensor_threshold_call_get_state_finish() to get the result of the operation.
Norman Jamescc7ae122015-08-24 14:26:09 -05002901 *
Norman James5d78b4d2015-09-05 13:34:34 -05002902 * See sensor_threshold_call_get_state_sync() for the synchronous, blocking version of this method.
Norman Jamescc7ae122015-08-24 14:26:09 -05002903 */
2904void
Norman James5d78b4d2015-09-05 13:34:34 -05002905sensor_threshold_call_get_state (
2906 SensorThreshold *proxy,
Norman Jamescc7ae122015-08-24 14:26:09 -05002907 GCancellable *cancellable,
2908 GAsyncReadyCallback callback,
2909 gpointer user_data)
2910{
2911 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
Norman James90baede2015-09-02 20:32:49 -05002912 "getState",
2913 g_variant_new ("()"),
Norman Jamescc7ae122015-08-24 14:26:09 -05002914 G_DBUS_CALL_FLAGS_NONE,
2915 -1,
2916 cancellable,
2917 callback,
2918 user_data);
2919}
2920
2921/**
Norman James5d78b4d2015-09-05 13:34:34 -05002922 * sensor_threshold_call_get_state_finish:
2923 * @proxy: A #SensorThresholdProxy.
Norman James90baede2015-09-02 20:32:49 -05002924 * @out_state: (out): Return location for return parameter or %NULL to ignore.
Norman James5d78b4d2015-09-05 13:34:34 -05002925 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_threshold_call_get_state().
Norman Jamescc7ae122015-08-24 14:26:09 -05002926 * @error: Return location for error or %NULL.
2927 *
Norman James5d78b4d2015-09-05 13:34:34 -05002928 * Finishes an operation started with sensor_threshold_call_get_state().
Norman Jamescc7ae122015-08-24 14:26:09 -05002929 *
2930 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
2931 */
2932gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05002933sensor_threshold_call_get_state_finish (
2934 SensorThreshold *proxy,
2935 guchar *out_state,
Norman Jamescc7ae122015-08-24 14:26:09 -05002936 GAsyncResult *res,
2937 GError **error)
2938{
2939 GVariant *_ret;
2940 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
2941 if (_ret == NULL)
2942 goto _out;
2943 g_variant_get (_ret,
Norman James5d78b4d2015-09-05 13:34:34 -05002944 "(y)",
Norman James90baede2015-09-02 20:32:49 -05002945 out_state);
Norman Jamescc7ae122015-08-24 14:26:09 -05002946 g_variant_unref (_ret);
2947_out:
2948 return _ret != NULL;
2949}
2950
2951/**
Norman James5d78b4d2015-09-05 13:34:34 -05002952 * sensor_threshold_call_get_state_sync:
2953 * @proxy: A #SensorThresholdProxy.
Norman James90baede2015-09-02 20:32:49 -05002954 * @out_state: (out): Return location for return parameter or %NULL to ignore.
Norman Jamescc7ae122015-08-24 14:26:09 -05002955 * @cancellable: (allow-none): A #GCancellable or %NULL.
2956 * @error: Return location for error or %NULL.
2957 *
Norman James5d78b4d2015-09-05 13:34:34 -05002958 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorThreshold.getState">getState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
Norman Jamescc7ae122015-08-24 14:26:09 -05002959 *
Norman James5d78b4d2015-09-05 13:34:34 -05002960 * See sensor_threshold_call_get_state() for the asynchronous version of this method.
Norman Jamescc7ae122015-08-24 14:26:09 -05002961 *
2962 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
2963 */
2964gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05002965sensor_threshold_call_get_state_sync (
2966 SensorThreshold *proxy,
2967 guchar *out_state,
Norman Jamescc7ae122015-08-24 14:26:09 -05002968 GCancellable *cancellable,
2969 GError **error)
2970{
2971 GVariant *_ret;
2972 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
Norman James90baede2015-09-02 20:32:49 -05002973 "getState",
2974 g_variant_new ("()"),
Norman Jamescc7ae122015-08-24 14:26:09 -05002975 G_DBUS_CALL_FLAGS_NONE,
2976 -1,
2977 cancellable,
2978 error);
2979 if (_ret == NULL)
2980 goto _out;
2981 g_variant_get (_ret,
Norman James5d78b4d2015-09-05 13:34:34 -05002982 "(y)",
Norman James90baede2015-09-02 20:32:49 -05002983 out_state);
Norman Jamescc7ae122015-08-24 14:26:09 -05002984 g_variant_unref (_ret);
2985_out:
2986 return _ret != NULL;
2987}
2988
2989/**
Norman James5d78b4d2015-09-05 13:34:34 -05002990 * sensor_threshold_complete_get_state:
2991 * @object: A #SensorThreshold.
Norman Jamescc7ae122015-08-24 14:26:09 -05002992 * @invocation: (transfer full): A #GDBusMethodInvocation.
Norman James90baede2015-09-02 20:32:49 -05002993 * @state: Parameter to return.
Norman Jamescc7ae122015-08-24 14:26:09 -05002994 *
Norman James5d78b4d2015-09-05 13:34:34 -05002995 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorThreshold.getState">getState()</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.
Norman Jamescc7ae122015-08-24 14:26:09 -05002996 *
2997 * This method will free @invocation, you cannot use it afterwards.
2998 */
2999void
Norman James5d78b4d2015-09-05 13:34:34 -05003000sensor_threshold_complete_get_state (
3001 SensorThreshold *object,
Norman James90baede2015-09-02 20:32:49 -05003002 GDBusMethodInvocation *invocation,
Norman James5d78b4d2015-09-05 13:34:34 -05003003 guchar state)
Norman Jamescc7ae122015-08-24 14:26:09 -05003004{
3005 g_dbus_method_invocation_return_value (invocation,
Norman James5d78b4d2015-09-05 13:34:34 -05003006 g_variant_new ("(y)",
Norman James90baede2015-09-02 20:32:49 -05003007 state));
Norman Jamescc7ae122015-08-24 14:26:09 -05003008}
3009
3010/* ------------------------------------------------------------------------ */
3011
3012/**
Norman James5d78b4d2015-09-05 13:34:34 -05003013 * SensorThresholdProxy:
Norman Jamescc7ae122015-08-24 14:26:09 -05003014 *
Norman James5d78b4d2015-09-05 13:34:34 -05003015 * The #SensorThresholdProxy structure contains only private data and should only be accessed using the provided API.
Norman Jamescc7ae122015-08-24 14:26:09 -05003016 */
3017
3018/**
Norman James5d78b4d2015-09-05 13:34:34 -05003019 * SensorThresholdProxyClass:
Norman Jamescc7ae122015-08-24 14:26:09 -05003020 * @parent_class: The parent class.
3021 *
Norman James5d78b4d2015-09-05 13:34:34 -05003022 * Class structure for #SensorThresholdProxy.
Norman Jamescc7ae122015-08-24 14:26:09 -05003023 */
3024
Norman James5d78b4d2015-09-05 13:34:34 -05003025struct _SensorThresholdProxyPrivate
Norman Jamescc7ae122015-08-24 14:26:09 -05003026{
3027 GData *qdata;
3028};
3029
Norman James5d78b4d2015-09-05 13:34:34 -05003030static void sensor_threshold_proxy_iface_init (SensorThresholdIface *iface);
Norman Jamescc7ae122015-08-24 14:26:09 -05003031
3032#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05003033G_DEFINE_TYPE_WITH_CODE (SensorThresholdProxy, sensor_threshold_proxy, G_TYPE_DBUS_PROXY,
3034 G_ADD_PRIVATE (SensorThresholdProxy)
3035 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_THRESHOLD, sensor_threshold_proxy_iface_init));
Norman Jamescc7ae122015-08-24 14:26:09 -05003036
3037#else
Norman James5d78b4d2015-09-05 13:34:34 -05003038G_DEFINE_TYPE_WITH_CODE (SensorThresholdProxy, sensor_threshold_proxy, G_TYPE_DBUS_PROXY,
3039 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_THRESHOLD, sensor_threshold_proxy_iface_init));
Norman Jamescc7ae122015-08-24 14:26:09 -05003040
3041#endif
3042static void
Norman James5d78b4d2015-09-05 13:34:34 -05003043sensor_threshold_proxy_finalize (GObject *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003044{
Norman James5d78b4d2015-09-05 13:34:34 -05003045 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003046 g_datalist_clear (&proxy->priv->qdata);
Norman James5d78b4d2015-09-05 13:34:34 -05003047 G_OBJECT_CLASS (sensor_threshold_proxy_parent_class)->finalize (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003048}
3049
3050static void
Norman James5d78b4d2015-09-05 13:34:34 -05003051sensor_threshold_proxy_get_property (GObject *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05003052 guint prop_id,
3053 GValue *value,
3054 GParamSpec *pspec G_GNUC_UNUSED)
3055{
3056 const _ExtendedGDBusPropertyInfo *info;
3057 GVariant *variant;
Norman James90baede2015-09-02 20:32:49 -05003058 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman James5d78b4d2015-09-05 13:34:34 -05003059 info = _sensor_threshold_property_info_pointers[prop_id - 1];
Norman Jamescc7ae122015-08-24 14:26:09 -05003060 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
3061 if (info->use_gvariant)
3062 {
3063 g_value_set_variant (value, variant);
3064 }
3065 else
3066 {
3067 if (variant != NULL)
3068 g_dbus_gvariant_to_gvalue (variant, value);
3069 }
3070 if (variant != NULL)
3071 g_variant_unref (variant);
3072}
3073
3074static void
Norman James5d78b4d2015-09-05 13:34:34 -05003075sensor_threshold_proxy_set_property_cb (GDBusProxy *proxy,
Norman Jamescc7ae122015-08-24 14:26:09 -05003076 GAsyncResult *res,
3077 gpointer user_data)
3078{
3079 const _ExtendedGDBusPropertyInfo *info = user_data;
3080 GError *error;
3081 GVariant *_ret;
3082 error = NULL;
3083 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
3084 if (!_ret)
3085 {
Norman James5d78b4d2015-09-05 13:34:34 -05003086 g_warning ("Error setting property '%s' on interface org.openbmc.SensorThreshold: %s (%s, %d)",
Norman Jamescc7ae122015-08-24 14:26:09 -05003087 info->parent_struct.name,
3088 error->message, g_quark_to_string (error->domain), error->code);
3089 g_error_free (error);
3090 }
3091 else
3092 {
3093 g_variant_unref (_ret);
3094 }
3095}
3096
3097static void
Norman James5d78b4d2015-09-05 13:34:34 -05003098sensor_threshold_proxy_set_property (GObject *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05003099 guint prop_id,
3100 const GValue *value,
3101 GParamSpec *pspec G_GNUC_UNUSED)
3102{
3103 const _ExtendedGDBusPropertyInfo *info;
3104 GVariant *variant;
Norman James90baede2015-09-02 20:32:49 -05003105 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman James5d78b4d2015-09-05 13:34:34 -05003106 info = _sensor_threshold_property_info_pointers[prop_id - 1];
Norman Jamescc7ae122015-08-24 14:26:09 -05003107 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
3108 g_dbus_proxy_call (G_DBUS_PROXY (object),
3109 "org.freedesktop.DBus.Properties.Set",
Norman James5d78b4d2015-09-05 13:34:34 -05003110 g_variant_new ("(ssv)", "org.openbmc.SensorThreshold", info->parent_struct.name, variant),
Norman Jamescc7ae122015-08-24 14:26:09 -05003111 G_DBUS_CALL_FLAGS_NONE,
3112 -1,
Norman James5d78b4d2015-09-05 13:34:34 -05003113 NULL, (GAsyncReadyCallback) sensor_threshold_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
Norman Jamescc7ae122015-08-24 14:26:09 -05003114 g_variant_unref (variant);
3115}
3116
3117static void
Norman James5d78b4d2015-09-05 13:34:34 -05003118sensor_threshold_proxy_g_signal (GDBusProxy *proxy,
Norman Jamescc7ae122015-08-24 14:26:09 -05003119 const gchar *sender_name G_GNUC_UNUSED,
3120 const gchar *signal_name,
3121 GVariant *parameters)
3122{
3123 _ExtendedGDBusSignalInfo *info;
3124 GVariantIter iter;
3125 GVariant *child;
3126 GValue *paramv;
3127 guint num_params;
3128 guint n;
3129 guint signal_id;
Norman James5d78b4d2015-09-05 13:34:34 -05003130 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct, signal_name);
Norman Jamescc7ae122015-08-24 14:26:09 -05003131 if (info == NULL)
3132 return;
3133 num_params = g_variant_n_children (parameters);
3134 paramv = g_new0 (GValue, num_params + 1);
Norman James5d78b4d2015-09-05 13:34:34 -05003135 g_value_init (&paramv[0], TYPE_SENSOR_THRESHOLD);
Norman Jamescc7ae122015-08-24 14:26:09 -05003136 g_value_set_object (&paramv[0], proxy);
3137 g_variant_iter_init (&iter, parameters);
3138 n = 1;
3139 while ((child = g_variant_iter_next_value (&iter)) != NULL)
3140 {
3141 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
3142 if (arg_info->use_gvariant)
3143 {
3144 g_value_init (&paramv[n], G_TYPE_VARIANT);
3145 g_value_set_variant (&paramv[n], child);
3146 n++;
3147 }
3148 else
3149 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
3150 g_variant_unref (child);
3151 }
Norman James5d78b4d2015-09-05 13:34:34 -05003152 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_THRESHOLD);
Norman Jamescc7ae122015-08-24 14:26:09 -05003153 g_signal_emitv (paramv, signal_id, 0, NULL);
3154 for (n = 0; n < num_params + 1; n++)
3155 g_value_unset (&paramv[n]);
3156 g_free (paramv);
3157}
3158
3159static void
Norman James5d78b4d2015-09-05 13:34:34 -05003160sensor_threshold_proxy_g_properties_changed (GDBusProxy *_proxy,
Norman Jamescc7ae122015-08-24 14:26:09 -05003161 GVariant *changed_properties,
3162 const gchar *const *invalidated_properties)
3163{
Norman James5d78b4d2015-09-05 13:34:34 -05003164 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (_proxy);
Norman Jamescc7ae122015-08-24 14:26:09 -05003165 guint n;
3166 const gchar *key;
3167 GVariantIter *iter;
3168 _ExtendedGDBusPropertyInfo *info;
3169 g_variant_get (changed_properties, "a{sv}", &iter);
3170 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
3171 {
Norman James5d78b4d2015-09-05 13:34:34 -05003172 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct, key);
Norman Jamescc7ae122015-08-24 14:26:09 -05003173 g_datalist_remove_data (&proxy->priv->qdata, key);
3174 if (info != NULL)
3175 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
3176 }
3177 g_variant_iter_free (iter);
3178 for (n = 0; invalidated_properties[n] != NULL; n++)
3179 {
Norman James5d78b4d2015-09-05 13:34:34 -05003180 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct, invalidated_properties[n]);
Norman Jamescc7ae122015-08-24 14:26:09 -05003181 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
3182 if (info != NULL)
3183 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
3184 }
3185}
3186
Norman James5d78b4d2015-09-05 13:34:34 -05003187static GVariant *
3188sensor_threshold_proxy_get_lower_critical (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003189{
Norman James5d78b4d2015-09-05 13:34:34 -05003190 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003191 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003192 GVariant *value = NULL;
Norman James90baede2015-09-02 20:32:49 -05003193 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "lower_critical");
Norman James5d78b4d2015-09-05 13:34:34 -05003194 value = variant;
Norman Jamescc7ae122015-08-24 14:26:09 -05003195 if (variant != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003196 g_variant_unref (variant);
Norman Jamescc7ae122015-08-24 14:26:09 -05003197 return value;
3198}
3199
Norman James5d78b4d2015-09-05 13:34:34 -05003200static GVariant *
3201sensor_threshold_proxy_get_lower_warning (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003202{
Norman James5d78b4d2015-09-05 13:34:34 -05003203 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003204 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003205 GVariant *value = NULL;
Norman James90baede2015-09-02 20:32:49 -05003206 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "lower_warning");
Norman James5d78b4d2015-09-05 13:34:34 -05003207 value = variant;
Norman Jamescc7ae122015-08-24 14:26:09 -05003208 if (variant != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003209 g_variant_unref (variant);
Norman Jamescc7ae122015-08-24 14:26:09 -05003210 return value;
3211}
3212
Norman James5d78b4d2015-09-05 13:34:34 -05003213static GVariant *
3214sensor_threshold_proxy_get_upper_warning (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003215{
Norman James5d78b4d2015-09-05 13:34:34 -05003216 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003217 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003218 GVariant *value = NULL;
Norman James90baede2015-09-02 20:32:49 -05003219 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "upper_warning");
Norman James5d78b4d2015-09-05 13:34:34 -05003220 value = variant;
Norman Jamescc7ae122015-08-24 14:26:09 -05003221 if (variant != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003222 g_variant_unref (variant);
Norman Jamescc7ae122015-08-24 14:26:09 -05003223 return value;
3224}
3225
Norman James5d78b4d2015-09-05 13:34:34 -05003226static GVariant *
3227sensor_threshold_proxy_get_upper_critical (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003228{
Norman James5d78b4d2015-09-05 13:34:34 -05003229 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003230 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003231 GVariant *value = NULL;
Norman James90baede2015-09-02 20:32:49 -05003232 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "upper_critical");
Norman James5d78b4d2015-09-05 13:34:34 -05003233 value = variant;
Norman James90baede2015-09-02 20:32:49 -05003234 if (variant != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003235 g_variant_unref (variant);
Norman James90baede2015-09-02 20:32:49 -05003236 return value;
3237}
3238
Norman James5d78b4d2015-09-05 13:34:34 -05003239static guchar
3240sensor_threshold_proxy_get_state (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05003241{
Norman James5d78b4d2015-09-05 13:34:34 -05003242 SensorThresholdProxy *proxy = SENSOR_THRESHOLD_PROXY (object);
Norman James90baede2015-09-02 20:32:49 -05003243 GVariant *variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003244 guchar value = 0;
Norman James90baede2015-09-02 20:32:49 -05003245 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "state");
Norman Jamescc7ae122015-08-24 14:26:09 -05003246 if (variant != NULL)
3247 {
Norman James5d78b4d2015-09-05 13:34:34 -05003248 value = g_variant_get_byte (variant);
Norman Jamescc7ae122015-08-24 14:26:09 -05003249 g_variant_unref (variant);
3250 }
3251 return value;
3252}
3253
3254static void
Norman James5d78b4d2015-09-05 13:34:34 -05003255sensor_threshold_proxy_init (SensorThresholdProxy *proxy)
Norman Jamescc7ae122015-08-24 14:26:09 -05003256{
3257#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05003258 proxy->priv = sensor_threshold_proxy_get_instance_private (proxy);
Norman Jamescc7ae122015-08-24 14:26:09 -05003259#else
Norman James5d78b4d2015-09-05 13:34:34 -05003260 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_THRESHOLD_PROXY, SensorThresholdProxyPrivate);
Norman Jamescc7ae122015-08-24 14:26:09 -05003261#endif
3262
Norman James5d78b4d2015-09-05 13:34:34 -05003263 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_threshold_interface_info ());
Norman Jamescc7ae122015-08-24 14:26:09 -05003264}
3265
3266static void
Norman James5d78b4d2015-09-05 13:34:34 -05003267sensor_threshold_proxy_class_init (SensorThresholdProxyClass *klass)
Norman Jamescc7ae122015-08-24 14:26:09 -05003268{
3269 GObjectClass *gobject_class;
3270 GDBusProxyClass *proxy_class;
3271
3272 gobject_class = G_OBJECT_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05003273 gobject_class->finalize = sensor_threshold_proxy_finalize;
3274 gobject_class->get_property = sensor_threshold_proxy_get_property;
3275 gobject_class->set_property = sensor_threshold_proxy_set_property;
Norman Jamescc7ae122015-08-24 14:26:09 -05003276
3277 proxy_class = G_DBUS_PROXY_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05003278 proxy_class->g_signal = sensor_threshold_proxy_g_signal;
3279 proxy_class->g_properties_changed = sensor_threshold_proxy_g_properties_changed;
Norman Jamescc7ae122015-08-24 14:26:09 -05003280
Norman James5d78b4d2015-09-05 13:34:34 -05003281 sensor_threshold_override_properties (gobject_class, 1);
Norman Jamescc7ae122015-08-24 14:26:09 -05003282
3283#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05003284 g_type_class_add_private (klass, sizeof (SensorThresholdProxyPrivate));
Norman Jamescc7ae122015-08-24 14:26:09 -05003285#endif
3286}
3287
3288static void
Norman James5d78b4d2015-09-05 13:34:34 -05003289sensor_threshold_proxy_iface_init (SensorThresholdIface *iface)
Norman Jamescc7ae122015-08-24 14:26:09 -05003290{
Norman James5d78b4d2015-09-05 13:34:34 -05003291 iface->get_lower_critical = sensor_threshold_proxy_get_lower_critical;
3292 iface->get_lower_warning = sensor_threshold_proxy_get_lower_warning;
3293 iface->get_upper_warning = sensor_threshold_proxy_get_upper_warning;
3294 iface->get_upper_critical = sensor_threshold_proxy_get_upper_critical;
3295 iface->get_state = sensor_threshold_proxy_get_state;
Norman Jamescc7ae122015-08-24 14:26:09 -05003296}
3297
3298/**
Norman James5d78b4d2015-09-05 13:34:34 -05003299 * sensor_threshold_proxy_new:
Norman Jamescc7ae122015-08-24 14:26:09 -05003300 * @connection: A #GDBusConnection.
3301 * @flags: Flags from the #GDBusProxyFlags enumeration.
3302 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
3303 * @object_path: An object path.
3304 * @cancellable: (allow-none): A #GCancellable or %NULL.
3305 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
3306 * @user_data: User data to pass to @callback.
3307 *
Norman James5d78b4d2015-09-05 13:34:34 -05003308 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>. See g_dbus_proxy_new() for more details.
Norman Jamescc7ae122015-08-24 14:26:09 -05003309 *
3310 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05003311 * You can then call sensor_threshold_proxy_new_finish() to get the result of the operation.
Norman Jamescc7ae122015-08-24 14:26:09 -05003312 *
Norman James5d78b4d2015-09-05 13:34:34 -05003313 * See sensor_threshold_proxy_new_sync() for the synchronous, blocking version of this constructor.
Norman Jamescc7ae122015-08-24 14:26:09 -05003314 */
3315void
Norman James5d78b4d2015-09-05 13:34:34 -05003316sensor_threshold_proxy_new (
Norman Jamescc7ae122015-08-24 14:26:09 -05003317 GDBusConnection *connection,
3318 GDBusProxyFlags flags,
3319 const gchar *name,
3320 const gchar *object_path,
3321 GCancellable *cancellable,
3322 GAsyncReadyCallback callback,
3323 gpointer user_data)
3324{
Norman James5d78b4d2015-09-05 13:34:34 -05003325 g_async_initable_new_async (TYPE_SENSOR_THRESHOLD_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.SensorThreshold", NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05003326}
3327
3328/**
Norman James5d78b4d2015-09-05 13:34:34 -05003329 * sensor_threshold_proxy_new_finish:
3330 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_threshold_proxy_new().
Norman Jamescc7ae122015-08-24 14:26:09 -05003331 * @error: Return location for error or %NULL
3332 *
Norman James5d78b4d2015-09-05 13:34:34 -05003333 * Finishes an operation started with sensor_threshold_proxy_new().
Norman Jamescc7ae122015-08-24 14:26:09 -05003334 *
Norman James5d78b4d2015-09-05 13:34:34 -05003335 * Returns: (transfer full) (type SensorThresholdProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamescc7ae122015-08-24 14:26:09 -05003336 */
Norman James5d78b4d2015-09-05 13:34:34 -05003337SensorThreshold *
3338sensor_threshold_proxy_new_finish (
Norman Jamescc7ae122015-08-24 14:26:09 -05003339 GAsyncResult *res,
3340 GError **error)
3341{
3342 GObject *ret;
3343 GObject *source_object;
3344 source_object = g_async_result_get_source_object (res);
3345 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
3346 g_object_unref (source_object);
3347 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003348 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05003349 else
3350 return NULL;
3351}
3352
3353/**
Norman James5d78b4d2015-09-05 13:34:34 -05003354 * sensor_threshold_proxy_new_sync:
Norman Jamescc7ae122015-08-24 14:26:09 -05003355 * @connection: A #GDBusConnection.
3356 * @flags: Flags from the #GDBusProxyFlags enumeration.
3357 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
3358 * @object_path: An object path.
3359 * @cancellable: (allow-none): A #GCancellable or %NULL.
3360 * @error: Return location for error or %NULL
3361 *
Norman James5d78b4d2015-09-05 13:34:34 -05003362 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>. See g_dbus_proxy_new_sync() for more details.
Norman Jamescc7ae122015-08-24 14:26:09 -05003363 *
3364 * The calling thread is blocked until a reply is received.
3365 *
Norman James5d78b4d2015-09-05 13:34:34 -05003366 * See sensor_threshold_proxy_new() for the asynchronous version of this constructor.
Norman Jamescc7ae122015-08-24 14:26:09 -05003367 *
Norman James5d78b4d2015-09-05 13:34:34 -05003368 * Returns: (transfer full) (type SensorThresholdProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamescc7ae122015-08-24 14:26:09 -05003369 */
Norman James5d78b4d2015-09-05 13:34:34 -05003370SensorThreshold *
3371sensor_threshold_proxy_new_sync (
Norman Jamescc7ae122015-08-24 14:26:09 -05003372 GDBusConnection *connection,
3373 GDBusProxyFlags flags,
3374 const gchar *name,
3375 const gchar *object_path,
3376 GCancellable *cancellable,
3377 GError **error)
3378{
3379 GInitable *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05003380 ret = g_initable_new (TYPE_SENSOR_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorThreshold", NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05003381 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003382 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05003383 else
3384 return NULL;
3385}
3386
3387
3388/**
Norman James5d78b4d2015-09-05 13:34:34 -05003389 * sensor_threshold_proxy_new_for_bus:
Norman Jamescc7ae122015-08-24 14:26:09 -05003390 * @bus_type: A #GBusType.
3391 * @flags: Flags from the #GDBusProxyFlags enumeration.
3392 * @name: A bus name (well-known or unique).
3393 * @object_path: An object path.
3394 * @cancellable: (allow-none): A #GCancellable or %NULL.
3395 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
3396 * @user_data: User data to pass to @callback.
3397 *
Norman James5d78b4d2015-09-05 13:34:34 -05003398 * Like sensor_threshold_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
Norman Jamescc7ae122015-08-24 14:26:09 -05003399 *
3400 * 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.
Norman James5d78b4d2015-09-05 13:34:34 -05003401 * You can then call sensor_threshold_proxy_new_for_bus_finish() to get the result of the operation.
Norman Jamescc7ae122015-08-24 14:26:09 -05003402 *
Norman James5d78b4d2015-09-05 13:34:34 -05003403 * See sensor_threshold_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
Norman Jamescc7ae122015-08-24 14:26:09 -05003404 */
3405void
Norman James5d78b4d2015-09-05 13:34:34 -05003406sensor_threshold_proxy_new_for_bus (
Norman Jamescc7ae122015-08-24 14:26:09 -05003407 GBusType bus_type,
3408 GDBusProxyFlags flags,
3409 const gchar *name,
3410 const gchar *object_path,
3411 GCancellable *cancellable,
3412 GAsyncReadyCallback callback,
3413 gpointer user_data)
3414{
Norman James5d78b4d2015-09-05 13:34:34 -05003415 g_async_initable_new_async (TYPE_SENSOR_THRESHOLD_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.SensorThreshold", NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05003416}
3417
3418/**
Norman James5d78b4d2015-09-05 13:34:34 -05003419 * sensor_threshold_proxy_new_for_bus_finish:
3420 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_threshold_proxy_new_for_bus().
Norman Jamescc7ae122015-08-24 14:26:09 -05003421 * @error: Return location for error or %NULL
3422 *
Norman James5d78b4d2015-09-05 13:34:34 -05003423 * Finishes an operation started with sensor_threshold_proxy_new_for_bus().
Norman Jamescc7ae122015-08-24 14:26:09 -05003424 *
Norman James5d78b4d2015-09-05 13:34:34 -05003425 * Returns: (transfer full) (type SensorThresholdProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamescc7ae122015-08-24 14:26:09 -05003426 */
Norman James5d78b4d2015-09-05 13:34:34 -05003427SensorThreshold *
3428sensor_threshold_proxy_new_for_bus_finish (
Norman Jamescc7ae122015-08-24 14:26:09 -05003429 GAsyncResult *res,
3430 GError **error)
3431{
3432 GObject *ret;
3433 GObject *source_object;
3434 source_object = g_async_result_get_source_object (res);
3435 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
3436 g_object_unref (source_object);
3437 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003438 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05003439 else
3440 return NULL;
3441}
3442
3443/**
Norman James5d78b4d2015-09-05 13:34:34 -05003444 * sensor_threshold_proxy_new_for_bus_sync:
Norman Jamescc7ae122015-08-24 14:26:09 -05003445 * @bus_type: A #GBusType.
3446 * @flags: Flags from the #GDBusProxyFlags enumeration.
3447 * @name: A bus name (well-known or unique).
3448 * @object_path: An object path.
3449 * @cancellable: (allow-none): A #GCancellable or %NULL.
3450 * @error: Return location for error or %NULL
3451 *
Norman James5d78b4d2015-09-05 13:34:34 -05003452 * Like sensor_threshold_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
Norman Jamescc7ae122015-08-24 14:26:09 -05003453 *
3454 * The calling thread is blocked until a reply is received.
3455 *
Norman James5d78b4d2015-09-05 13:34:34 -05003456 * See sensor_threshold_proxy_new_for_bus() for the asynchronous version of this constructor.
Norman Jamescc7ae122015-08-24 14:26:09 -05003457 *
Norman James5d78b4d2015-09-05 13:34:34 -05003458 * Returns: (transfer full) (type SensorThresholdProxy): The constructed proxy object or %NULL if @error is set.
Norman Jamescc7ae122015-08-24 14:26:09 -05003459 */
Norman James5d78b4d2015-09-05 13:34:34 -05003460SensorThreshold *
3461sensor_threshold_proxy_new_for_bus_sync (
Norman Jamescc7ae122015-08-24 14:26:09 -05003462 GBusType bus_type,
3463 GDBusProxyFlags flags,
3464 const gchar *name,
3465 const gchar *object_path,
3466 GCancellable *cancellable,
3467 GError **error)
3468{
3469 GInitable *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05003470 ret = g_initable_new (TYPE_SENSOR_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorThreshold", NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05003471 if (ret != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003472 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05003473 else
3474 return NULL;
3475}
3476
3477
3478/* ------------------------------------------------------------------------ */
3479
3480/**
Norman James5d78b4d2015-09-05 13:34:34 -05003481 * SensorThresholdSkeleton:
Norman Jamescc7ae122015-08-24 14:26:09 -05003482 *
Norman James5d78b4d2015-09-05 13:34:34 -05003483 * The #SensorThresholdSkeleton structure contains only private data and should only be accessed using the provided API.
Norman Jamescc7ae122015-08-24 14:26:09 -05003484 */
3485
3486/**
Norman James5d78b4d2015-09-05 13:34:34 -05003487 * SensorThresholdSkeletonClass:
Norman Jamescc7ae122015-08-24 14:26:09 -05003488 * @parent_class: The parent class.
3489 *
Norman James5d78b4d2015-09-05 13:34:34 -05003490 * Class structure for #SensorThresholdSkeleton.
Norman Jamescc7ae122015-08-24 14:26:09 -05003491 */
3492
Norman James5d78b4d2015-09-05 13:34:34 -05003493struct _SensorThresholdSkeletonPrivate
Norman Jamescc7ae122015-08-24 14:26:09 -05003494{
3495 GValue *properties;
3496 GList *changed_properties;
3497 GSource *changed_properties_idle_source;
3498 GMainContext *context;
3499 GMutex lock;
3500};
3501
3502static void
Norman James5d78b4d2015-09-05 13:34:34 -05003503_sensor_threshold_skeleton_handle_method_call (
Norman Jamescc7ae122015-08-24 14:26:09 -05003504 GDBusConnection *connection G_GNUC_UNUSED,
3505 const gchar *sender G_GNUC_UNUSED,
3506 const gchar *object_path G_GNUC_UNUSED,
3507 const gchar *interface_name,
3508 const gchar *method_name,
3509 GVariant *parameters,
3510 GDBusMethodInvocation *invocation,
3511 gpointer user_data)
3512{
Norman James5d78b4d2015-09-05 13:34:34 -05003513 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (user_data);
Norman Jamescc7ae122015-08-24 14:26:09 -05003514 _ExtendedGDBusMethodInfo *info;
3515 GVariantIter iter;
3516 GVariant *child;
3517 GValue *paramv;
3518 guint num_params;
3519 guint num_extra;
3520 guint n;
3521 guint signal_id;
3522 GValue return_value = G_VALUE_INIT;
3523 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
3524 g_assert (info != NULL);
3525 num_params = g_variant_n_children (parameters);
3526 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
3527 n = 0;
Norman James5d78b4d2015-09-05 13:34:34 -05003528 g_value_init (&paramv[n], TYPE_SENSOR_THRESHOLD);
Norman Jamescc7ae122015-08-24 14:26:09 -05003529 g_value_set_object (&paramv[n++], skeleton);
3530 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
3531 g_value_set_object (&paramv[n++], invocation);
3532 if (info->pass_fdlist)
3533 {
3534#ifdef G_OS_UNIX
3535 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
3536 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
3537#else
3538 g_assert_not_reached ();
3539#endif
3540 }
3541 g_variant_iter_init (&iter, parameters);
3542 while ((child = g_variant_iter_next_value (&iter)) != NULL)
3543 {
3544 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
3545 if (arg_info->use_gvariant)
3546 {
3547 g_value_init (&paramv[n], G_TYPE_VARIANT);
3548 g_value_set_variant (&paramv[n], child);
3549 n++;
3550 }
3551 else
3552 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
3553 g_variant_unref (child);
3554 }
Norman James5d78b4d2015-09-05 13:34:34 -05003555 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_THRESHOLD);
Norman Jamescc7ae122015-08-24 14:26:09 -05003556 g_value_init (&return_value, G_TYPE_BOOLEAN);
3557 g_signal_emitv (paramv, signal_id, 0, &return_value);
3558 if (!g_value_get_boolean (&return_value))
3559 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);
3560 g_value_unset (&return_value);
3561 for (n = 0; n < num_params + num_extra; n++)
3562 g_value_unset (&paramv[n]);
3563 g_free (paramv);
3564}
3565
3566static GVariant *
Norman James5d78b4d2015-09-05 13:34:34 -05003567_sensor_threshold_skeleton_handle_get_property (
Norman Jamescc7ae122015-08-24 14:26:09 -05003568 GDBusConnection *connection G_GNUC_UNUSED,
3569 const gchar *sender G_GNUC_UNUSED,
3570 const gchar *object_path G_GNUC_UNUSED,
3571 const gchar *interface_name G_GNUC_UNUSED,
3572 const gchar *property_name,
3573 GError **error,
3574 gpointer user_data)
3575{
Norman James5d78b4d2015-09-05 13:34:34 -05003576 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (user_data);
Norman Jamescc7ae122015-08-24 14:26:09 -05003577 GValue value = G_VALUE_INIT;
3578 GParamSpec *pspec;
3579 _ExtendedGDBusPropertyInfo *info;
3580 GVariant *ret;
3581 ret = NULL;
Norman James5d78b4d2015-09-05 13:34:34 -05003582 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct, property_name);
Norman Jamescc7ae122015-08-24 14:26:09 -05003583 g_assert (info != NULL);
3584 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
3585 if (pspec == NULL)
3586 {
3587 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
3588 }
3589 else
3590 {
3591 g_value_init (&value, pspec->value_type);
3592 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
3593 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
3594 g_value_unset (&value);
3595 }
3596 return ret;
3597}
3598
3599static gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05003600_sensor_threshold_skeleton_handle_set_property (
Norman Jamescc7ae122015-08-24 14:26:09 -05003601 GDBusConnection *connection G_GNUC_UNUSED,
3602 const gchar *sender G_GNUC_UNUSED,
3603 const gchar *object_path G_GNUC_UNUSED,
3604 const gchar *interface_name G_GNUC_UNUSED,
3605 const gchar *property_name,
3606 GVariant *variant,
3607 GError **error,
3608 gpointer user_data)
3609{
Norman James5d78b4d2015-09-05 13:34:34 -05003610 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (user_data);
Norman Jamescc7ae122015-08-24 14:26:09 -05003611 GValue value = G_VALUE_INIT;
3612 GParamSpec *pspec;
3613 _ExtendedGDBusPropertyInfo *info;
3614 gboolean ret;
3615 ret = FALSE;
Norman James5d78b4d2015-09-05 13:34:34 -05003616 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_threshold_interface_info.parent_struct, property_name);
Norman Jamescc7ae122015-08-24 14:26:09 -05003617 g_assert (info != NULL);
3618 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
3619 if (pspec == NULL)
3620 {
3621 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
3622 }
3623 else
3624 {
3625 if (info->use_gvariant)
3626 g_value_set_variant (&value, variant);
3627 else
3628 g_dbus_gvariant_to_gvalue (variant, &value);
3629 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
3630 g_value_unset (&value);
3631 ret = TRUE;
3632 }
3633 return ret;
3634}
3635
Norman James5d78b4d2015-09-05 13:34:34 -05003636static const GDBusInterfaceVTable _sensor_threshold_skeleton_vtable =
Norman Jamescc7ae122015-08-24 14:26:09 -05003637{
Norman James5d78b4d2015-09-05 13:34:34 -05003638 _sensor_threshold_skeleton_handle_method_call,
3639 _sensor_threshold_skeleton_handle_get_property,
3640 _sensor_threshold_skeleton_handle_set_property,
Norman Jamescc7ae122015-08-24 14:26:09 -05003641 {NULL}
3642};
3643
3644static GDBusInterfaceInfo *
Norman James5d78b4d2015-09-05 13:34:34 -05003645sensor_threshold_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
Norman Jamescc7ae122015-08-24 14:26:09 -05003646{
Norman James5d78b4d2015-09-05 13:34:34 -05003647 return sensor_threshold_interface_info ();
Norman Jamescc7ae122015-08-24 14:26:09 -05003648}
3649
3650static GDBusInterfaceVTable *
Norman James5d78b4d2015-09-05 13:34:34 -05003651sensor_threshold_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
Norman Jamescc7ae122015-08-24 14:26:09 -05003652{
Norman James5d78b4d2015-09-05 13:34:34 -05003653 return (GDBusInterfaceVTable *) &_sensor_threshold_skeleton_vtable;
Norman Jamescc7ae122015-08-24 14:26:09 -05003654}
3655
3656static GVariant *
Norman James5d78b4d2015-09-05 13:34:34 -05003657sensor_threshold_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
Norman Jamescc7ae122015-08-24 14:26:09 -05003658{
Norman James5d78b4d2015-09-05 13:34:34 -05003659 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (_skeleton);
Norman Jamescc7ae122015-08-24 14:26:09 -05003660
3661 GVariantBuilder builder;
3662 guint n;
3663 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
Norman James5d78b4d2015-09-05 13:34:34 -05003664 if (_sensor_threshold_interface_info.parent_struct.properties == NULL)
Norman Jamescc7ae122015-08-24 14:26:09 -05003665 goto out;
Norman James5d78b4d2015-09-05 13:34:34 -05003666 for (n = 0; _sensor_threshold_interface_info.parent_struct.properties[n] != NULL; n++)
Norman Jamescc7ae122015-08-24 14:26:09 -05003667 {
Norman James5d78b4d2015-09-05 13:34:34 -05003668 GDBusPropertyInfo *info = _sensor_threshold_interface_info.parent_struct.properties[n];
Norman Jamescc7ae122015-08-24 14:26:09 -05003669 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
3670 {
3671 GVariant *value;
Norman James5d78b4d2015-09-05 13:34:34 -05003672 value = _sensor_threshold_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.SensorThreshold", info->name, NULL, skeleton);
Norman Jamescc7ae122015-08-24 14:26:09 -05003673 if (value != NULL)
3674 {
3675 g_variant_take_ref (value);
3676 g_variant_builder_add (&builder, "{sv}", info->name, value);
3677 g_variant_unref (value);
3678 }
3679 }
3680 }
3681out:
3682 return g_variant_builder_end (&builder);
3683}
3684
Norman James5d78b4d2015-09-05 13:34:34 -05003685static gboolean _sensor_threshold_emit_changed (gpointer user_data);
Norman Jamescc7ae122015-08-24 14:26:09 -05003686
3687static void
Norman James5d78b4d2015-09-05 13:34:34 -05003688sensor_threshold_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
Norman Jamescc7ae122015-08-24 14:26:09 -05003689{
Norman James5d78b4d2015-09-05 13:34:34 -05003690 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (_skeleton);
Norman Jamescc7ae122015-08-24 14:26:09 -05003691 gboolean emit_changed = FALSE;
3692
3693 g_mutex_lock (&skeleton->priv->lock);
3694 if (skeleton->priv->changed_properties_idle_source != NULL)
3695 {
3696 g_source_destroy (skeleton->priv->changed_properties_idle_source);
3697 skeleton->priv->changed_properties_idle_source = NULL;
3698 emit_changed = TRUE;
3699 }
3700 g_mutex_unlock (&skeleton->priv->lock);
3701
3702 if (emit_changed)
Norman James5d78b4d2015-09-05 13:34:34 -05003703 _sensor_threshold_emit_changed (skeleton);
Norman Jamescc7ae122015-08-24 14:26:09 -05003704}
3705
3706static void
Norman James5d78b4d2015-09-05 13:34:34 -05003707_sensor_threshold_on_signal_warning (
3708 SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003709{
Norman James5d78b4d2015-09-05 13:34:34 -05003710 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003711
3712 GList *connections, *l;
3713 GVariant *signal_variant;
3714 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
3715
Norman James90baede2015-09-02 20:32:49 -05003716 signal_variant = g_variant_ref_sink (g_variant_new ("()"));
Norman Jamescc7ae122015-08-24 14:26:09 -05003717 for (l = connections; l != NULL; l = l->next)
3718 {
3719 GDBusConnection *connection = l->data;
3720 g_dbus_connection_emit_signal (connection,
Norman James5d78b4d2015-09-05 13:34:34 -05003721 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorThreshold", "Warning",
Norman Jamescc7ae122015-08-24 14:26:09 -05003722 signal_variant, NULL);
3723 }
3724 g_variant_unref (signal_variant);
3725 g_list_free_full (connections, g_object_unref);
3726}
3727
3728static void
Norman James5d78b4d2015-09-05 13:34:34 -05003729_sensor_threshold_on_signal_critical (
3730 SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003731{
Norman James5d78b4d2015-09-05 13:34:34 -05003732 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003733
3734 GList *connections, *l;
3735 GVariant *signal_variant;
3736 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
3737
Norman James90baede2015-09-02 20:32:49 -05003738 signal_variant = g_variant_ref_sink (g_variant_new ("()"));
Norman Jamescc7ae122015-08-24 14:26:09 -05003739 for (l = connections; l != NULL; l = l->next)
3740 {
3741 GDBusConnection *connection = l->data;
3742 g_dbus_connection_emit_signal (connection,
Norman James5d78b4d2015-09-05 13:34:34 -05003743 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorThreshold", "Critical",
Norman James90baede2015-09-02 20:32:49 -05003744 signal_variant, NULL);
3745 }
3746 g_variant_unref (signal_variant);
3747 g_list_free_full (connections, g_object_unref);
3748}
3749
3750static void
Norman James5d78b4d2015-09-05 13:34:34 -05003751_sensor_threshold_on_signal_normal (
3752 SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05003753{
Norman James5d78b4d2015-09-05 13:34:34 -05003754 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman James90baede2015-09-02 20:32:49 -05003755
3756 GList *connections, *l;
3757 GVariant *signal_variant;
3758 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
3759
3760 signal_variant = g_variant_ref_sink (g_variant_new ("()"));
3761 for (l = connections; l != NULL; l = l->next)
3762 {
3763 GDBusConnection *connection = l->data;
3764 g_dbus_connection_emit_signal (connection,
Norman James5d78b4d2015-09-05 13:34:34 -05003765 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorThreshold", "Normal",
Norman Jamescc7ae122015-08-24 14:26:09 -05003766 signal_variant, NULL);
3767 }
3768 g_variant_unref (signal_variant);
3769 g_list_free_full (connections, g_object_unref);
3770}
3771
Norman James5d78b4d2015-09-05 13:34:34 -05003772static void sensor_threshold_skeleton_iface_init (SensorThresholdIface *iface);
Norman Jamescc7ae122015-08-24 14:26:09 -05003773#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05003774G_DEFINE_TYPE_WITH_CODE (SensorThresholdSkeleton, sensor_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
3775 G_ADD_PRIVATE (SensorThresholdSkeleton)
3776 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_THRESHOLD, sensor_threshold_skeleton_iface_init));
Norman Jamescc7ae122015-08-24 14:26:09 -05003777
3778#else
Norman James5d78b4d2015-09-05 13:34:34 -05003779G_DEFINE_TYPE_WITH_CODE (SensorThresholdSkeleton, sensor_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
3780 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_THRESHOLD, sensor_threshold_skeleton_iface_init));
Norman Jamescc7ae122015-08-24 14:26:09 -05003781
3782#endif
3783static void
Norman James5d78b4d2015-09-05 13:34:34 -05003784sensor_threshold_skeleton_finalize (GObject *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003785{
Norman James5d78b4d2015-09-05 13:34:34 -05003786 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003787 guint n;
Norman James90baede2015-09-02 20:32:49 -05003788 for (n = 0; n < 5; n++)
Norman Jamescc7ae122015-08-24 14:26:09 -05003789 g_value_unset (&skeleton->priv->properties[n]);
3790 g_free (skeleton->priv->properties);
3791 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
3792 if (skeleton->priv->changed_properties_idle_source != NULL)
3793 g_source_destroy (skeleton->priv->changed_properties_idle_source);
3794 g_main_context_unref (skeleton->priv->context);
3795 g_mutex_clear (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05003796 G_OBJECT_CLASS (sensor_threshold_skeleton_parent_class)->finalize (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003797}
3798
3799static void
Norman James5d78b4d2015-09-05 13:34:34 -05003800sensor_threshold_skeleton_get_property (GObject *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05003801 guint prop_id,
3802 GValue *value,
3803 GParamSpec *pspec G_GNUC_UNUSED)
3804{
Norman James5d78b4d2015-09-05 13:34:34 -05003805 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman James90baede2015-09-02 20:32:49 -05003806 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman Jamescc7ae122015-08-24 14:26:09 -05003807 g_mutex_lock (&skeleton->priv->lock);
3808 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
3809 g_mutex_unlock (&skeleton->priv->lock);
3810}
3811
3812static gboolean
Norman James5d78b4d2015-09-05 13:34:34 -05003813_sensor_threshold_emit_changed (gpointer user_data)
Norman Jamescc7ae122015-08-24 14:26:09 -05003814{
Norman James5d78b4d2015-09-05 13:34:34 -05003815 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (user_data);
Norman Jamescc7ae122015-08-24 14:26:09 -05003816 GList *l;
3817 GVariantBuilder builder;
3818 GVariantBuilder invalidated_builder;
3819 guint num_changes;
3820
3821 g_mutex_lock (&skeleton->priv->lock);
3822 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
3823 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
3824 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
3825 {
3826 ChangedProperty *cp = l->data;
3827 GVariant *variant;
3828 const GValue *cur_value;
3829
3830 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
3831 if (!_g_value_equal (cur_value, &cp->orig_value))
3832 {
3833 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
3834 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
3835 g_variant_unref (variant);
3836 num_changes++;
3837 }
3838 }
3839 if (num_changes > 0)
3840 {
3841 GList *connections, *ll;
3842 GVariant *signal_variant;
Norman James5d78b4d2015-09-05 13:34:34 -05003843 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorThreshold",
Norman Jamescc7ae122015-08-24 14:26:09 -05003844 &builder, &invalidated_builder));
3845 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
3846 for (ll = connections; ll != NULL; ll = ll->next)
3847 {
3848 GDBusConnection *connection = ll->data;
3849
3850 g_dbus_connection_emit_signal (connection,
3851 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
3852 "org.freedesktop.DBus.Properties",
3853 "PropertiesChanged",
3854 signal_variant,
3855 NULL);
3856 }
3857 g_variant_unref (signal_variant);
3858 g_list_free_full (connections, g_object_unref);
3859 }
3860 else
3861 {
3862 g_variant_builder_clear (&builder);
3863 g_variant_builder_clear (&invalidated_builder);
3864 }
3865 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
3866 skeleton->priv->changed_properties = NULL;
3867 skeleton->priv->changed_properties_idle_source = NULL;
3868 g_mutex_unlock (&skeleton->priv->lock);
3869 return FALSE;
3870}
3871
3872static void
Norman James5d78b4d2015-09-05 13:34:34 -05003873_sensor_threshold_schedule_emit_changed (SensorThresholdSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
Norman Jamescc7ae122015-08-24 14:26:09 -05003874{
3875 ChangedProperty *cp;
3876 GList *l;
3877 cp = NULL;
3878 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
3879 {
3880 ChangedProperty *i_cp = l->data;
3881 if (i_cp->info == info)
3882 {
3883 cp = i_cp;
3884 break;
3885 }
3886 }
3887 if (cp == NULL)
3888 {
3889 cp = g_new0 (ChangedProperty, 1);
3890 cp->prop_id = prop_id;
3891 cp->info = info;
3892 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
3893 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
3894 g_value_copy (orig_value, &cp->orig_value);
3895 }
3896}
3897
3898static void
Norman James5d78b4d2015-09-05 13:34:34 -05003899sensor_threshold_skeleton_notify (GObject *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05003900 GParamSpec *pspec G_GNUC_UNUSED)
3901{
Norman James5d78b4d2015-09-05 13:34:34 -05003902 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman Jamescc7ae122015-08-24 14:26:09 -05003903 g_mutex_lock (&skeleton->priv->lock);
3904 if (skeleton->priv->changed_properties != NULL &&
3905 skeleton->priv->changed_properties_idle_source == NULL)
3906 {
3907 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
3908 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
Norman James5d78b4d2015-09-05 13:34:34 -05003909 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_threshold_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
Norman Jamescc7ae122015-08-24 14:26:09 -05003910 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
3911 g_source_unref (skeleton->priv->changed_properties_idle_source);
3912 }
3913 g_mutex_unlock (&skeleton->priv->lock);
3914}
3915
3916static void
Norman James5d78b4d2015-09-05 13:34:34 -05003917sensor_threshold_skeleton_set_property (GObject *object,
Norman Jamescc7ae122015-08-24 14:26:09 -05003918 guint prop_id,
3919 const GValue *value,
3920 GParamSpec *pspec)
3921{
Norman James5d78b4d2015-09-05 13:34:34 -05003922 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
Norman James90baede2015-09-02 20:32:49 -05003923 g_assert (prop_id != 0 && prop_id - 1 < 5);
Norman Jamescc7ae122015-08-24 14:26:09 -05003924 g_mutex_lock (&skeleton->priv->lock);
3925 g_object_freeze_notify (object);
3926 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
3927 {
3928 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
Norman James5d78b4d2015-09-05 13:34:34 -05003929 _sensor_threshold_schedule_emit_changed (skeleton, _sensor_threshold_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
Norman Jamescc7ae122015-08-24 14:26:09 -05003930 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
3931 g_object_notify_by_pspec (object, pspec);
3932 }
3933 g_mutex_unlock (&skeleton->priv->lock);
3934 g_object_thaw_notify (object);
3935}
3936
3937static void
Norman James5d78b4d2015-09-05 13:34:34 -05003938sensor_threshold_skeleton_init (SensorThresholdSkeleton *skeleton)
Norman Jamescc7ae122015-08-24 14:26:09 -05003939{
3940#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05003941 skeleton->priv = sensor_threshold_skeleton_get_instance_private (skeleton);
Norman Jamescc7ae122015-08-24 14:26:09 -05003942#else
Norman James5d78b4d2015-09-05 13:34:34 -05003943 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_THRESHOLD_SKELETON, SensorThresholdSkeletonPrivate);
Norman Jamescc7ae122015-08-24 14:26:09 -05003944#endif
3945
3946 g_mutex_init (&skeleton->priv->lock);
3947 skeleton->priv->context = g_main_context_ref_thread_default ();
Norman James90baede2015-09-02 20:32:49 -05003948 skeleton->priv->properties = g_new0 (GValue, 5);
Norman James5d78b4d2015-09-05 13:34:34 -05003949 g_value_init (&skeleton->priv->properties[0], G_TYPE_VARIANT);
3950 g_value_init (&skeleton->priv->properties[1], G_TYPE_VARIANT);
3951 g_value_init (&skeleton->priv->properties[2], G_TYPE_VARIANT);
3952 g_value_init (&skeleton->priv->properties[3], G_TYPE_VARIANT);
3953 g_value_init (&skeleton->priv->properties[4], G_TYPE_UCHAR);
Norman Jamescc7ae122015-08-24 14:26:09 -05003954}
3955
Norman James5d78b4d2015-09-05 13:34:34 -05003956static GVariant *
3957sensor_threshold_skeleton_get_lower_critical (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003958{
Norman James5d78b4d2015-09-05 13:34:34 -05003959 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
3960 GVariant *value;
Norman Jamescc7ae122015-08-24 14:26:09 -05003961 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05003962 value = g_value_get_variant (&(skeleton->priv->properties[0]));
Norman Jamescc7ae122015-08-24 14:26:09 -05003963 g_mutex_unlock (&skeleton->priv->lock);
3964 return value;
3965}
3966
Norman James5d78b4d2015-09-05 13:34:34 -05003967static GVariant *
3968sensor_threshold_skeleton_get_lower_warning (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003969{
Norman James5d78b4d2015-09-05 13:34:34 -05003970 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
3971 GVariant *value;
Norman Jamescc7ae122015-08-24 14:26:09 -05003972 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05003973 value = g_value_get_variant (&(skeleton->priv->properties[1]));
Norman Jamescc7ae122015-08-24 14:26:09 -05003974 g_mutex_unlock (&skeleton->priv->lock);
3975 return value;
3976}
3977
Norman James5d78b4d2015-09-05 13:34:34 -05003978static GVariant *
3979sensor_threshold_skeleton_get_upper_warning (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003980{
Norman James5d78b4d2015-09-05 13:34:34 -05003981 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
3982 GVariant *value;
Norman Jamescc7ae122015-08-24 14:26:09 -05003983 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05003984 value = g_value_get_variant (&(skeleton->priv->properties[2]));
Norman Jamescc7ae122015-08-24 14:26:09 -05003985 g_mutex_unlock (&skeleton->priv->lock);
3986 return value;
3987}
3988
Norman James5d78b4d2015-09-05 13:34:34 -05003989static GVariant *
3990sensor_threshold_skeleton_get_upper_critical (SensorThreshold *object)
Norman Jamescc7ae122015-08-24 14:26:09 -05003991{
Norman James5d78b4d2015-09-05 13:34:34 -05003992 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
3993 GVariant *value;
Norman Jamescc7ae122015-08-24 14:26:09 -05003994 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05003995 value = g_value_get_variant (&(skeleton->priv->properties[3]));
Norman Jamescc7ae122015-08-24 14:26:09 -05003996 g_mutex_unlock (&skeleton->priv->lock);
3997 return value;
3998}
3999
Norman James5d78b4d2015-09-05 13:34:34 -05004000static guchar
4001sensor_threshold_skeleton_get_state (SensorThreshold *object)
Norman James90baede2015-09-02 20:32:49 -05004002{
Norman James5d78b4d2015-09-05 13:34:34 -05004003 SensorThresholdSkeleton *skeleton = SENSOR_THRESHOLD_SKELETON (object);
4004 guchar value;
Norman James90baede2015-09-02 20:32:49 -05004005 g_mutex_lock (&skeleton->priv->lock);
Norman James5d78b4d2015-09-05 13:34:34 -05004006 value = g_value_get_uchar (&(skeleton->priv->properties[4]));
Norman James90baede2015-09-02 20:32:49 -05004007 g_mutex_unlock (&skeleton->priv->lock);
4008 return value;
4009}
4010
Norman Jamescc7ae122015-08-24 14:26:09 -05004011static void
Norman James5d78b4d2015-09-05 13:34:34 -05004012sensor_threshold_skeleton_class_init (SensorThresholdSkeletonClass *klass)
Norman Jamescc7ae122015-08-24 14:26:09 -05004013{
4014 GObjectClass *gobject_class;
4015 GDBusInterfaceSkeletonClass *skeleton_class;
4016
4017 gobject_class = G_OBJECT_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05004018 gobject_class->finalize = sensor_threshold_skeleton_finalize;
4019 gobject_class->get_property = sensor_threshold_skeleton_get_property;
4020 gobject_class->set_property = sensor_threshold_skeleton_set_property;
4021 gobject_class->notify = sensor_threshold_skeleton_notify;
Norman Jamescc7ae122015-08-24 14:26:09 -05004022
4023
Norman James5d78b4d2015-09-05 13:34:34 -05004024 sensor_threshold_override_properties (gobject_class, 1);
Norman Jamescc7ae122015-08-24 14:26:09 -05004025
4026 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
Norman James5d78b4d2015-09-05 13:34:34 -05004027 skeleton_class->get_info = sensor_threshold_skeleton_dbus_interface_get_info;
4028 skeleton_class->get_properties = sensor_threshold_skeleton_dbus_interface_get_properties;
4029 skeleton_class->flush = sensor_threshold_skeleton_dbus_interface_flush;
4030 skeleton_class->get_vtable = sensor_threshold_skeleton_dbus_interface_get_vtable;
Norman Jamescc7ae122015-08-24 14:26:09 -05004031
4032#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
Norman James5d78b4d2015-09-05 13:34:34 -05004033 g_type_class_add_private (klass, sizeof (SensorThresholdSkeletonPrivate));
Norman Jamescc7ae122015-08-24 14:26:09 -05004034#endif
4035}
4036
4037static void
Norman James5d78b4d2015-09-05 13:34:34 -05004038sensor_threshold_skeleton_iface_init (SensorThresholdIface *iface)
Norman Jamescc7ae122015-08-24 14:26:09 -05004039{
Norman James5d78b4d2015-09-05 13:34:34 -05004040 iface->warning = _sensor_threshold_on_signal_warning;
4041 iface->critical = _sensor_threshold_on_signal_critical;
4042 iface->normal = _sensor_threshold_on_signal_normal;
4043 iface->get_lower_critical = sensor_threshold_skeleton_get_lower_critical;
4044 iface->get_lower_warning = sensor_threshold_skeleton_get_lower_warning;
4045 iface->get_upper_warning = sensor_threshold_skeleton_get_upper_warning;
4046 iface->get_upper_critical = sensor_threshold_skeleton_get_upper_critical;
4047 iface->get_state = sensor_threshold_skeleton_get_state;
Norman Jamescc7ae122015-08-24 14:26:09 -05004048}
4049
4050/**
Norman James5d78b4d2015-09-05 13:34:34 -05004051 * sensor_threshold_skeleton_new:
Norman Jamescc7ae122015-08-24 14:26:09 -05004052 *
Norman James5d78b4d2015-09-05 13:34:34 -05004053 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>.
Norman Jamescc7ae122015-08-24 14:26:09 -05004054 *
Norman James5d78b4d2015-09-05 13:34:34 -05004055 * Returns: (transfer full) (type SensorThresholdSkeleton): The skeleton object.
Norman Jamescc7ae122015-08-24 14:26:09 -05004056 */
Norman James5d78b4d2015-09-05 13:34:34 -05004057SensorThreshold *
4058sensor_threshold_skeleton_new (void)
Norman Jamescc7ae122015-08-24 14:26:09 -05004059{
Norman James5d78b4d2015-09-05 13:34:34 -05004060 return SENSOR_THRESHOLD (g_object_new (TYPE_SENSOR_THRESHOLD_SKELETON, NULL));
Norman Jamescc7ae122015-08-24 14:26:09 -05004061}
4062
4063/* ------------------------------------------------------------------------
Norman James90baede2015-09-02 20:32:49 -05004064 * Code for interface org.openbmc.SensorI2c
4065 * ------------------------------------------------------------------------
4066 */
4067
4068/**
4069 * SECTION:SensorI2c
4070 * @title: SensorI2c
4071 * @short_description: Generated C code for the org.openbmc.SensorI2c D-Bus interface
4072 *
4073 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link> D-Bus interface in C.
4074 */
4075
4076/* ---- Introspection data for org.openbmc.SensorI2c ---- */
4077
4078static const _ExtendedGDBusPropertyInfo _sensor_i2c_property_info_dev_path =
4079{
4080 {
4081 -1,
4082 (gchar *) "dev_path",
4083 (gchar *) "s",
4084 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
4085 NULL
4086 },
4087 "dev-path",
4088 FALSE
4089};
4090
4091static const _ExtendedGDBusPropertyInfo _sensor_i2c_property_info_address =
4092{
4093 {
4094 -1,
4095 (gchar *) "address",
4096 (gchar *) "s",
4097 G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE,
4098 NULL
4099 },
4100 "address",
4101 FALSE
4102};
4103
4104static const _ExtendedGDBusPropertyInfo * const _sensor_i2c_property_info_pointers[] =
4105{
4106 &_sensor_i2c_property_info_dev_path,
4107 &_sensor_i2c_property_info_address,
4108 NULL
4109};
4110
4111static const _ExtendedGDBusInterfaceInfo _sensor_i2c_interface_info =
4112{
4113 {
4114 -1,
4115 (gchar *) "org.openbmc.SensorI2c",
4116 NULL,
4117 NULL,
4118 (GDBusPropertyInfo **) &_sensor_i2c_property_info_pointers,
4119 NULL
4120 },
4121 "sensor-i2c",
4122};
4123
4124
4125/**
4126 * sensor_i2c_interface_info:
4127 *
4128 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link> D-Bus interface.
4129 *
4130 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
4131 */
4132GDBusInterfaceInfo *
4133sensor_i2c_interface_info (void)
4134{
4135 return (GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct;
4136}
4137
4138/**
4139 * sensor_i2c_override_properties:
4140 * @klass: The class structure for a #GObject<!-- -->-derived class.
4141 * @property_id_begin: The property id to assign to the first overridden property.
4142 *
4143 * Overrides all #GObject properties in the #SensorI2c interface for a concrete class.
4144 * The properties are overridden in the order they are defined.
4145 *
4146 * Returns: The last property id.
4147 */
4148guint
4149sensor_i2c_override_properties (GObjectClass *klass, guint property_id_begin)
4150{
4151 g_object_class_override_property (klass, property_id_begin++, "dev-path");
4152 g_object_class_override_property (klass, property_id_begin++, "address");
4153 return property_id_begin - 1;
4154}
4155
4156
4157
4158/**
4159 * SensorI2c:
4160 *
4161 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>.
4162 */
4163
4164/**
4165 * SensorI2cIface:
4166 * @parent_iface: The parent interface.
4167 * @get_address: Getter for the #SensorI2c:address property.
4168 * @get_dev_path: Getter for the #SensorI2c:dev-path property.
4169 *
4170 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>.
4171 */
4172
4173typedef SensorI2cIface SensorI2cInterface;
4174G_DEFINE_INTERFACE (SensorI2c, sensor_i2c, G_TYPE_OBJECT);
4175
4176static void
4177sensor_i2c_default_init (SensorI2cIface *iface)
4178{
4179 /* GObject properties for D-Bus properties: */
4180 /**
4181 * SensorI2c:dev-path:
4182 *
4183 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorI2c.dev_path">"dev_path"</link>.
4184 *
4185 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
4186 */
4187 g_object_interface_install_property (iface,
4188 g_param_spec_string ("dev-path", "dev_path", "dev_path", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4189 /**
4190 * SensorI2c:address:
4191 *
4192 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorI2c.address">"address"</link>.
4193 *
4194 * Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.
4195 */
4196 g_object_interface_install_property (iface,
4197 g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4198}
4199
4200/**
4201 * sensor_i2c_get_dev_path: (skip)
4202 * @object: A #SensorI2c.
4203 *
4204 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorI2c.dev_path">"dev_path"</link> D-Bus property.
4205 *
4206 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4207 *
4208 * <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_i2c_dup_dev_path() if on another thread.</warning>
4209 *
4210 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
4211 */
4212const gchar *
4213sensor_i2c_get_dev_path (SensorI2c *object)
4214{
4215 return SENSOR_I2C_GET_IFACE (object)->get_dev_path (object);
4216}
4217
4218/**
4219 * sensor_i2c_dup_dev_path: (skip)
4220 * @object: A #SensorI2c.
4221 *
4222 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorI2c.dev_path">"dev_path"</link> D-Bus property.
4223 *
4224 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4225 *
4226 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
4227 */
4228gchar *
4229sensor_i2c_dup_dev_path (SensorI2c *object)
4230{
4231 gchar *value;
4232 g_object_get (G_OBJECT (object), "dev-path", &value, NULL);
4233 return value;
4234}
4235
4236/**
4237 * sensor_i2c_set_dev_path: (skip)
4238 * @object: A #SensorI2c.
4239 * @value: The value to set.
4240 *
4241 * Sets the <link linkend="gdbus-property-org-openbmc-SensorI2c.dev_path">"dev_path"</link> D-Bus property to @value.
4242 *
4243 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4244 */
4245void
4246sensor_i2c_set_dev_path (SensorI2c *object, const gchar *value)
4247{
4248 g_object_set (G_OBJECT (object), "dev-path", value, NULL);
4249}
4250
4251/**
4252 * sensor_i2c_get_address: (skip)
4253 * @object: A #SensorI2c.
4254 *
4255 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorI2c.address">"address"</link> D-Bus property.
4256 *
4257 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4258 *
4259 * <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_i2c_dup_address() if on another thread.</warning>
4260 *
4261 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
4262 */
4263const gchar *
4264sensor_i2c_get_address (SensorI2c *object)
4265{
4266 return SENSOR_I2C_GET_IFACE (object)->get_address (object);
4267}
4268
4269/**
4270 * sensor_i2c_dup_address: (skip)
4271 * @object: A #SensorI2c.
4272 *
4273 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorI2c.address">"address"</link> D-Bus property.
4274 *
4275 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4276 *
4277 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
4278 */
4279gchar *
4280sensor_i2c_dup_address (SensorI2c *object)
4281{
4282 gchar *value;
4283 g_object_get (G_OBJECT (object), "address", &value, NULL);
4284 return value;
4285}
4286
4287/**
4288 * sensor_i2c_set_address: (skip)
4289 * @object: A #SensorI2c.
4290 * @value: The value to set.
4291 *
4292 * Sets the <link linkend="gdbus-property-org-openbmc-SensorI2c.address">"address"</link> D-Bus property to @value.
4293 *
4294 * Since this D-Bus property is both readable and writable, it is meaningful to use this function on both the client- and service-side.
4295 */
4296void
4297sensor_i2c_set_address (SensorI2c *object, const gchar *value)
4298{
4299 g_object_set (G_OBJECT (object), "address", value, NULL);
4300}
4301
4302/* ------------------------------------------------------------------------ */
4303
4304/**
4305 * SensorI2cProxy:
4306 *
4307 * The #SensorI2cProxy structure contains only private data and should only be accessed using the provided API.
4308 */
4309
4310/**
4311 * SensorI2cProxyClass:
4312 * @parent_class: The parent class.
4313 *
4314 * Class structure for #SensorI2cProxy.
4315 */
4316
4317struct _SensorI2cProxyPrivate
4318{
4319 GData *qdata;
4320};
4321
4322static void sensor_i2c_proxy_iface_init (SensorI2cIface *iface);
4323
4324#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
4325G_DEFINE_TYPE_WITH_CODE (SensorI2cProxy, sensor_i2c_proxy, G_TYPE_DBUS_PROXY,
4326 G_ADD_PRIVATE (SensorI2cProxy)
4327 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_I2C, sensor_i2c_proxy_iface_init));
4328
4329#else
4330G_DEFINE_TYPE_WITH_CODE (SensorI2cProxy, sensor_i2c_proxy, G_TYPE_DBUS_PROXY,
4331 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_I2C, sensor_i2c_proxy_iface_init));
4332
4333#endif
4334static void
4335sensor_i2c_proxy_finalize (GObject *object)
4336{
4337 SensorI2cProxy *proxy = SENSOR_I2C_PROXY (object);
4338 g_datalist_clear (&proxy->priv->qdata);
4339 G_OBJECT_CLASS (sensor_i2c_proxy_parent_class)->finalize (object);
4340}
4341
4342static void
4343sensor_i2c_proxy_get_property (GObject *object,
4344 guint prop_id,
4345 GValue *value,
4346 GParamSpec *pspec G_GNUC_UNUSED)
4347{
4348 const _ExtendedGDBusPropertyInfo *info;
4349 GVariant *variant;
4350 g_assert (prop_id != 0 && prop_id - 1 < 2);
4351 info = _sensor_i2c_property_info_pointers[prop_id - 1];
4352 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
4353 if (info->use_gvariant)
4354 {
4355 g_value_set_variant (value, variant);
4356 }
4357 else
4358 {
4359 if (variant != NULL)
4360 g_dbus_gvariant_to_gvalue (variant, value);
4361 }
4362 if (variant != NULL)
4363 g_variant_unref (variant);
4364}
4365
4366static void
4367sensor_i2c_proxy_set_property_cb (GDBusProxy *proxy,
4368 GAsyncResult *res,
4369 gpointer user_data)
4370{
4371 const _ExtendedGDBusPropertyInfo *info = user_data;
4372 GError *error;
4373 GVariant *_ret;
4374 error = NULL;
4375 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
4376 if (!_ret)
4377 {
4378 g_warning ("Error setting property '%s' on interface org.openbmc.SensorI2c: %s (%s, %d)",
4379 info->parent_struct.name,
4380 error->message, g_quark_to_string (error->domain), error->code);
4381 g_error_free (error);
4382 }
4383 else
4384 {
4385 g_variant_unref (_ret);
4386 }
4387}
4388
4389static void
4390sensor_i2c_proxy_set_property (GObject *object,
4391 guint prop_id,
4392 const GValue *value,
4393 GParamSpec *pspec G_GNUC_UNUSED)
4394{
4395 const _ExtendedGDBusPropertyInfo *info;
4396 GVariant *variant;
4397 g_assert (prop_id != 0 && prop_id - 1 < 2);
4398 info = _sensor_i2c_property_info_pointers[prop_id - 1];
4399 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
4400 g_dbus_proxy_call (G_DBUS_PROXY (object),
4401 "org.freedesktop.DBus.Properties.Set",
4402 g_variant_new ("(ssv)", "org.openbmc.SensorI2c", info->parent_struct.name, variant),
4403 G_DBUS_CALL_FLAGS_NONE,
4404 -1,
4405 NULL, (GAsyncReadyCallback) sensor_i2c_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
4406 g_variant_unref (variant);
4407}
4408
4409static void
4410sensor_i2c_proxy_g_signal (GDBusProxy *proxy,
4411 const gchar *sender_name G_GNUC_UNUSED,
4412 const gchar *signal_name,
4413 GVariant *parameters)
4414{
4415 _ExtendedGDBusSignalInfo *info;
4416 GVariantIter iter;
4417 GVariant *child;
4418 GValue *paramv;
4419 guint num_params;
4420 guint n;
4421 guint signal_id;
4422 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct, signal_name);
4423 if (info == NULL)
4424 return;
4425 num_params = g_variant_n_children (parameters);
4426 paramv = g_new0 (GValue, num_params + 1);
4427 g_value_init (&paramv[0], TYPE_SENSOR_I2C);
4428 g_value_set_object (&paramv[0], proxy);
4429 g_variant_iter_init (&iter, parameters);
4430 n = 1;
4431 while ((child = g_variant_iter_next_value (&iter)) != NULL)
4432 {
4433 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
4434 if (arg_info->use_gvariant)
4435 {
4436 g_value_init (&paramv[n], G_TYPE_VARIANT);
4437 g_value_set_variant (&paramv[n], child);
4438 n++;
4439 }
4440 else
4441 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
4442 g_variant_unref (child);
4443 }
4444 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_I2C);
4445 g_signal_emitv (paramv, signal_id, 0, NULL);
4446 for (n = 0; n < num_params + 1; n++)
4447 g_value_unset (&paramv[n]);
4448 g_free (paramv);
4449}
4450
4451static void
4452sensor_i2c_proxy_g_properties_changed (GDBusProxy *_proxy,
4453 GVariant *changed_properties,
4454 const gchar *const *invalidated_properties)
4455{
4456 SensorI2cProxy *proxy = SENSOR_I2C_PROXY (_proxy);
4457 guint n;
4458 const gchar *key;
4459 GVariantIter *iter;
4460 _ExtendedGDBusPropertyInfo *info;
4461 g_variant_get (changed_properties, "a{sv}", &iter);
4462 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
4463 {
4464 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct, key);
4465 g_datalist_remove_data (&proxy->priv->qdata, key);
4466 if (info != NULL)
4467 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
4468 }
4469 g_variant_iter_free (iter);
4470 for (n = 0; invalidated_properties[n] != NULL; n++)
4471 {
4472 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct, invalidated_properties[n]);
4473 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
4474 if (info != NULL)
4475 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
4476 }
4477}
4478
4479static const gchar *
4480sensor_i2c_proxy_get_dev_path (SensorI2c *object)
4481{
4482 SensorI2cProxy *proxy = SENSOR_I2C_PROXY (object);
4483 GVariant *variant;
4484 const gchar *value = NULL;
4485 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "dev_path");
4486 if (variant != NULL)
4487 {
4488 value = g_variant_get_string (variant, NULL);
4489 g_variant_unref (variant);
4490 }
4491 return value;
4492}
4493
4494static const gchar *
4495sensor_i2c_proxy_get_address (SensorI2c *object)
4496{
4497 SensorI2cProxy *proxy = SENSOR_I2C_PROXY (object);
4498 GVariant *variant;
4499 const gchar *value = NULL;
4500 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "address");
4501 if (variant != NULL)
4502 {
4503 value = g_variant_get_string (variant, NULL);
4504 g_variant_unref (variant);
4505 }
4506 return value;
4507}
4508
4509static void
4510sensor_i2c_proxy_init (SensorI2cProxy *proxy)
4511{
4512#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
4513 proxy->priv = sensor_i2c_proxy_get_instance_private (proxy);
4514#else
4515 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_I2C_PROXY, SensorI2cProxyPrivate);
4516#endif
4517
4518 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_i2c_interface_info ());
4519}
4520
4521static void
4522sensor_i2c_proxy_class_init (SensorI2cProxyClass *klass)
4523{
4524 GObjectClass *gobject_class;
4525 GDBusProxyClass *proxy_class;
4526
4527 gobject_class = G_OBJECT_CLASS (klass);
4528 gobject_class->finalize = sensor_i2c_proxy_finalize;
4529 gobject_class->get_property = sensor_i2c_proxy_get_property;
4530 gobject_class->set_property = sensor_i2c_proxy_set_property;
4531
4532 proxy_class = G_DBUS_PROXY_CLASS (klass);
4533 proxy_class->g_signal = sensor_i2c_proxy_g_signal;
4534 proxy_class->g_properties_changed = sensor_i2c_proxy_g_properties_changed;
4535
4536 sensor_i2c_override_properties (gobject_class, 1);
4537
4538#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
4539 g_type_class_add_private (klass, sizeof (SensorI2cProxyPrivate));
4540#endif
4541}
4542
4543static void
4544sensor_i2c_proxy_iface_init (SensorI2cIface *iface)
4545{
4546 iface->get_dev_path = sensor_i2c_proxy_get_dev_path;
4547 iface->get_address = sensor_i2c_proxy_get_address;
4548}
4549
4550/**
4551 * sensor_i2c_proxy_new:
4552 * @connection: A #GDBusConnection.
4553 * @flags: Flags from the #GDBusProxyFlags enumeration.
4554 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
4555 * @object_path: An object path.
4556 * @cancellable: (allow-none): A #GCancellable or %NULL.
4557 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
4558 * @user_data: User data to pass to @callback.
4559 *
4560 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>. See g_dbus_proxy_new() for more details.
4561 *
4562 * 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.
4563 * You can then call sensor_i2c_proxy_new_finish() to get the result of the operation.
4564 *
4565 * See sensor_i2c_proxy_new_sync() for the synchronous, blocking version of this constructor.
4566 */
4567void
4568sensor_i2c_proxy_new (
4569 GDBusConnection *connection,
4570 GDBusProxyFlags flags,
4571 const gchar *name,
4572 const gchar *object_path,
4573 GCancellable *cancellable,
4574 GAsyncReadyCallback callback,
4575 gpointer user_data)
4576{
4577 g_async_initable_new_async (TYPE_SENSOR_I2C_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.SensorI2c", NULL);
4578}
4579
4580/**
4581 * sensor_i2c_proxy_new_finish:
4582 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_i2c_proxy_new().
4583 * @error: Return location for error or %NULL
4584 *
4585 * Finishes an operation started with sensor_i2c_proxy_new().
4586 *
4587 * Returns: (transfer full) (type SensorI2cProxy): The constructed proxy object or %NULL if @error is set.
4588 */
4589SensorI2c *
4590sensor_i2c_proxy_new_finish (
4591 GAsyncResult *res,
4592 GError **error)
4593{
4594 GObject *ret;
4595 GObject *source_object;
4596 source_object = g_async_result_get_source_object (res);
4597 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
4598 g_object_unref (source_object);
4599 if (ret != NULL)
4600 return SENSOR_I2C (ret);
4601 else
4602 return NULL;
4603}
4604
4605/**
4606 * sensor_i2c_proxy_new_sync:
4607 * @connection: A #GDBusConnection.
4608 * @flags: Flags from the #GDBusProxyFlags enumeration.
4609 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
4610 * @object_path: An object path.
4611 * @cancellable: (allow-none): A #GCancellable or %NULL.
4612 * @error: Return location for error or %NULL
4613 *
4614 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>. See g_dbus_proxy_new_sync() for more details.
4615 *
4616 * The calling thread is blocked until a reply is received.
4617 *
4618 * See sensor_i2c_proxy_new() for the asynchronous version of this constructor.
4619 *
4620 * Returns: (transfer full) (type SensorI2cProxy): The constructed proxy object or %NULL if @error is set.
4621 */
4622SensorI2c *
4623sensor_i2c_proxy_new_sync (
4624 GDBusConnection *connection,
4625 GDBusProxyFlags flags,
4626 const gchar *name,
4627 const gchar *object_path,
4628 GCancellable *cancellable,
4629 GError **error)
4630{
4631 GInitable *ret;
4632 ret = g_initable_new (TYPE_SENSOR_I2C_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorI2c", NULL);
4633 if (ret != NULL)
4634 return SENSOR_I2C (ret);
4635 else
4636 return NULL;
4637}
4638
4639
4640/**
4641 * sensor_i2c_proxy_new_for_bus:
4642 * @bus_type: A #GBusType.
4643 * @flags: Flags from the #GDBusProxyFlags enumeration.
4644 * @name: A bus name (well-known or unique).
4645 * @object_path: An object path.
4646 * @cancellable: (allow-none): A #GCancellable or %NULL.
4647 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
4648 * @user_data: User data to pass to @callback.
4649 *
4650 * Like sensor_i2c_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
4651 *
4652 * 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.
4653 * You can then call sensor_i2c_proxy_new_for_bus_finish() to get the result of the operation.
4654 *
4655 * See sensor_i2c_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
4656 */
4657void
4658sensor_i2c_proxy_new_for_bus (
4659 GBusType bus_type,
4660 GDBusProxyFlags flags,
4661 const gchar *name,
4662 const gchar *object_path,
4663 GCancellable *cancellable,
4664 GAsyncReadyCallback callback,
4665 gpointer user_data)
4666{
4667 g_async_initable_new_async (TYPE_SENSOR_I2C_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.SensorI2c", NULL);
4668}
4669
4670/**
4671 * sensor_i2c_proxy_new_for_bus_finish:
4672 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_i2c_proxy_new_for_bus().
4673 * @error: Return location for error or %NULL
4674 *
4675 * Finishes an operation started with sensor_i2c_proxy_new_for_bus().
4676 *
4677 * Returns: (transfer full) (type SensorI2cProxy): The constructed proxy object or %NULL if @error is set.
4678 */
4679SensorI2c *
4680sensor_i2c_proxy_new_for_bus_finish (
4681 GAsyncResult *res,
4682 GError **error)
4683{
4684 GObject *ret;
4685 GObject *source_object;
4686 source_object = g_async_result_get_source_object (res);
4687 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
4688 g_object_unref (source_object);
4689 if (ret != NULL)
4690 return SENSOR_I2C (ret);
4691 else
4692 return NULL;
4693}
4694
4695/**
4696 * sensor_i2c_proxy_new_for_bus_sync:
4697 * @bus_type: A #GBusType.
4698 * @flags: Flags from the #GDBusProxyFlags enumeration.
4699 * @name: A bus name (well-known or unique).
4700 * @object_path: An object path.
4701 * @cancellable: (allow-none): A #GCancellable or %NULL.
4702 * @error: Return location for error or %NULL
4703 *
4704 * Like sensor_i2c_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
4705 *
4706 * The calling thread is blocked until a reply is received.
4707 *
4708 * See sensor_i2c_proxy_new_for_bus() for the asynchronous version of this constructor.
4709 *
4710 * Returns: (transfer full) (type SensorI2cProxy): The constructed proxy object or %NULL if @error is set.
4711 */
4712SensorI2c *
4713sensor_i2c_proxy_new_for_bus_sync (
4714 GBusType bus_type,
4715 GDBusProxyFlags flags,
4716 const gchar *name,
4717 const gchar *object_path,
4718 GCancellable *cancellable,
4719 GError **error)
4720{
4721 GInitable *ret;
4722 ret = g_initable_new (TYPE_SENSOR_I2C_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorI2c", NULL);
4723 if (ret != NULL)
4724 return SENSOR_I2C (ret);
4725 else
4726 return NULL;
4727}
4728
4729
4730/* ------------------------------------------------------------------------ */
4731
4732/**
4733 * SensorI2cSkeleton:
4734 *
4735 * The #SensorI2cSkeleton structure contains only private data and should only be accessed using the provided API.
4736 */
4737
4738/**
4739 * SensorI2cSkeletonClass:
4740 * @parent_class: The parent class.
4741 *
4742 * Class structure for #SensorI2cSkeleton.
4743 */
4744
4745struct _SensorI2cSkeletonPrivate
4746{
4747 GValue *properties;
4748 GList *changed_properties;
4749 GSource *changed_properties_idle_source;
4750 GMainContext *context;
4751 GMutex lock;
4752};
4753
4754static void
4755_sensor_i2c_skeleton_handle_method_call (
4756 GDBusConnection *connection G_GNUC_UNUSED,
4757 const gchar *sender G_GNUC_UNUSED,
4758 const gchar *object_path G_GNUC_UNUSED,
4759 const gchar *interface_name,
4760 const gchar *method_name,
4761 GVariant *parameters,
4762 GDBusMethodInvocation *invocation,
4763 gpointer user_data)
4764{
4765 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (user_data);
4766 _ExtendedGDBusMethodInfo *info;
4767 GVariantIter iter;
4768 GVariant *child;
4769 GValue *paramv;
4770 guint num_params;
4771 guint num_extra;
4772 guint n;
4773 guint signal_id;
4774 GValue return_value = G_VALUE_INIT;
4775 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
4776 g_assert (info != NULL);
4777 num_params = g_variant_n_children (parameters);
4778 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
4779 n = 0;
4780 g_value_init (&paramv[n], TYPE_SENSOR_I2C);
4781 g_value_set_object (&paramv[n++], skeleton);
4782 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
4783 g_value_set_object (&paramv[n++], invocation);
4784 if (info->pass_fdlist)
4785 {
4786#ifdef G_OS_UNIX
4787 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
4788 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
4789#else
4790 g_assert_not_reached ();
4791#endif
4792 }
4793 g_variant_iter_init (&iter, parameters);
4794 while ((child = g_variant_iter_next_value (&iter)) != NULL)
4795 {
4796 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
4797 if (arg_info->use_gvariant)
4798 {
4799 g_value_init (&paramv[n], G_TYPE_VARIANT);
4800 g_value_set_variant (&paramv[n], child);
4801 n++;
4802 }
4803 else
4804 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
4805 g_variant_unref (child);
4806 }
4807 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_I2C);
4808 g_value_init (&return_value, G_TYPE_BOOLEAN);
4809 g_signal_emitv (paramv, signal_id, 0, &return_value);
4810 if (!g_value_get_boolean (&return_value))
4811 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);
4812 g_value_unset (&return_value);
4813 for (n = 0; n < num_params + num_extra; n++)
4814 g_value_unset (&paramv[n]);
4815 g_free (paramv);
4816}
4817
4818static GVariant *
4819_sensor_i2c_skeleton_handle_get_property (
4820 GDBusConnection *connection G_GNUC_UNUSED,
4821 const gchar *sender G_GNUC_UNUSED,
4822 const gchar *object_path G_GNUC_UNUSED,
4823 const gchar *interface_name G_GNUC_UNUSED,
4824 const gchar *property_name,
4825 GError **error,
4826 gpointer user_data)
4827{
4828 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (user_data);
4829 GValue value = G_VALUE_INIT;
4830 GParamSpec *pspec;
4831 _ExtendedGDBusPropertyInfo *info;
4832 GVariant *ret;
4833 ret = NULL;
4834 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct, property_name);
4835 g_assert (info != NULL);
4836 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
4837 if (pspec == NULL)
4838 {
4839 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
4840 }
4841 else
4842 {
4843 g_value_init (&value, pspec->value_type);
4844 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
4845 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
4846 g_value_unset (&value);
4847 }
4848 return ret;
4849}
4850
4851static gboolean
4852_sensor_i2c_skeleton_handle_set_property (
4853 GDBusConnection *connection G_GNUC_UNUSED,
4854 const gchar *sender G_GNUC_UNUSED,
4855 const gchar *object_path G_GNUC_UNUSED,
4856 const gchar *interface_name G_GNUC_UNUSED,
4857 const gchar *property_name,
4858 GVariant *variant,
4859 GError **error,
4860 gpointer user_data)
4861{
4862 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (user_data);
4863 GValue value = G_VALUE_INIT;
4864 GParamSpec *pspec;
4865 _ExtendedGDBusPropertyInfo *info;
4866 gboolean ret;
4867 ret = FALSE;
4868 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_i2c_interface_info.parent_struct, property_name);
4869 g_assert (info != NULL);
4870 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
4871 if (pspec == NULL)
4872 {
4873 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
4874 }
4875 else
4876 {
4877 if (info->use_gvariant)
4878 g_value_set_variant (&value, variant);
4879 else
4880 g_dbus_gvariant_to_gvalue (variant, &value);
4881 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
4882 g_value_unset (&value);
4883 ret = TRUE;
4884 }
4885 return ret;
4886}
4887
4888static const GDBusInterfaceVTable _sensor_i2c_skeleton_vtable =
4889{
4890 _sensor_i2c_skeleton_handle_method_call,
4891 _sensor_i2c_skeleton_handle_get_property,
4892 _sensor_i2c_skeleton_handle_set_property,
4893 {NULL}
4894};
4895
4896static GDBusInterfaceInfo *
4897sensor_i2c_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
4898{
4899 return sensor_i2c_interface_info ();
4900}
4901
4902static GDBusInterfaceVTable *
4903sensor_i2c_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
4904{
4905 return (GDBusInterfaceVTable *) &_sensor_i2c_skeleton_vtable;
4906}
4907
4908static GVariant *
4909sensor_i2c_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
4910{
4911 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (_skeleton);
4912
4913 GVariantBuilder builder;
4914 guint n;
4915 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
4916 if (_sensor_i2c_interface_info.parent_struct.properties == NULL)
4917 goto out;
4918 for (n = 0; _sensor_i2c_interface_info.parent_struct.properties[n] != NULL; n++)
4919 {
4920 GDBusPropertyInfo *info = _sensor_i2c_interface_info.parent_struct.properties[n];
4921 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
4922 {
4923 GVariant *value;
4924 value = _sensor_i2c_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.SensorI2c", info->name, NULL, skeleton);
4925 if (value != NULL)
4926 {
4927 g_variant_take_ref (value);
4928 g_variant_builder_add (&builder, "{sv}", info->name, value);
4929 g_variant_unref (value);
4930 }
4931 }
4932 }
4933out:
4934 return g_variant_builder_end (&builder);
4935}
4936
4937static gboolean _sensor_i2c_emit_changed (gpointer user_data);
4938
4939static void
4940sensor_i2c_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
4941{
4942 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (_skeleton);
4943 gboolean emit_changed = FALSE;
4944
4945 g_mutex_lock (&skeleton->priv->lock);
4946 if (skeleton->priv->changed_properties_idle_source != NULL)
4947 {
4948 g_source_destroy (skeleton->priv->changed_properties_idle_source);
4949 skeleton->priv->changed_properties_idle_source = NULL;
4950 emit_changed = TRUE;
4951 }
4952 g_mutex_unlock (&skeleton->priv->lock);
4953
4954 if (emit_changed)
4955 _sensor_i2c_emit_changed (skeleton);
4956}
4957
4958static void sensor_i2c_skeleton_iface_init (SensorI2cIface *iface);
4959#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
4960G_DEFINE_TYPE_WITH_CODE (SensorI2cSkeleton, sensor_i2c_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
4961 G_ADD_PRIVATE (SensorI2cSkeleton)
4962 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_I2C, sensor_i2c_skeleton_iface_init));
4963
4964#else
4965G_DEFINE_TYPE_WITH_CODE (SensorI2cSkeleton, sensor_i2c_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
4966 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_I2C, sensor_i2c_skeleton_iface_init));
4967
4968#endif
4969static void
4970sensor_i2c_skeleton_finalize (GObject *object)
4971{
4972 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
4973 guint n;
4974 for (n = 0; n < 2; n++)
4975 g_value_unset (&skeleton->priv->properties[n]);
4976 g_free (skeleton->priv->properties);
4977 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
4978 if (skeleton->priv->changed_properties_idle_source != NULL)
4979 g_source_destroy (skeleton->priv->changed_properties_idle_source);
4980 g_main_context_unref (skeleton->priv->context);
4981 g_mutex_clear (&skeleton->priv->lock);
4982 G_OBJECT_CLASS (sensor_i2c_skeleton_parent_class)->finalize (object);
4983}
4984
4985static void
4986sensor_i2c_skeleton_get_property (GObject *object,
4987 guint prop_id,
4988 GValue *value,
4989 GParamSpec *pspec G_GNUC_UNUSED)
4990{
4991 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
4992 g_assert (prop_id != 0 && prop_id - 1 < 2);
4993 g_mutex_lock (&skeleton->priv->lock);
4994 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
4995 g_mutex_unlock (&skeleton->priv->lock);
4996}
4997
4998static gboolean
4999_sensor_i2c_emit_changed (gpointer user_data)
5000{
5001 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (user_data);
5002 GList *l;
5003 GVariantBuilder builder;
5004 GVariantBuilder invalidated_builder;
5005 guint num_changes;
5006
5007 g_mutex_lock (&skeleton->priv->lock);
5008 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
5009 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
5010 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
5011 {
5012 ChangedProperty *cp = l->data;
5013 GVariant *variant;
5014 const GValue *cur_value;
5015
5016 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
5017 if (!_g_value_equal (cur_value, &cp->orig_value))
5018 {
5019 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
5020 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
5021 g_variant_unref (variant);
5022 num_changes++;
5023 }
5024 }
5025 if (num_changes > 0)
5026 {
5027 GList *connections, *ll;
5028 GVariant *signal_variant;
5029 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorI2c",
5030 &builder, &invalidated_builder));
5031 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
5032 for (ll = connections; ll != NULL; ll = ll->next)
5033 {
5034 GDBusConnection *connection = ll->data;
5035
5036 g_dbus_connection_emit_signal (connection,
5037 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
5038 "org.freedesktop.DBus.Properties",
5039 "PropertiesChanged",
5040 signal_variant,
5041 NULL);
5042 }
5043 g_variant_unref (signal_variant);
5044 g_list_free_full (connections, g_object_unref);
5045 }
5046 else
5047 {
5048 g_variant_builder_clear (&builder);
5049 g_variant_builder_clear (&invalidated_builder);
5050 }
5051 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
5052 skeleton->priv->changed_properties = NULL;
5053 skeleton->priv->changed_properties_idle_source = NULL;
5054 g_mutex_unlock (&skeleton->priv->lock);
5055 return FALSE;
5056}
5057
5058static void
5059_sensor_i2c_schedule_emit_changed (SensorI2cSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
5060{
5061 ChangedProperty *cp;
5062 GList *l;
5063 cp = NULL;
5064 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
5065 {
5066 ChangedProperty *i_cp = l->data;
5067 if (i_cp->info == info)
5068 {
5069 cp = i_cp;
5070 break;
5071 }
5072 }
5073 if (cp == NULL)
5074 {
5075 cp = g_new0 (ChangedProperty, 1);
5076 cp->prop_id = prop_id;
5077 cp->info = info;
5078 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
5079 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
5080 g_value_copy (orig_value, &cp->orig_value);
5081 }
5082}
5083
5084static void
5085sensor_i2c_skeleton_notify (GObject *object,
5086 GParamSpec *pspec G_GNUC_UNUSED)
5087{
5088 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
5089 g_mutex_lock (&skeleton->priv->lock);
5090 if (skeleton->priv->changed_properties != NULL &&
5091 skeleton->priv->changed_properties_idle_source == NULL)
5092 {
5093 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
5094 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
5095 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_i2c_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
5096 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
5097 g_source_unref (skeleton->priv->changed_properties_idle_source);
5098 }
5099 g_mutex_unlock (&skeleton->priv->lock);
5100}
5101
5102static void
5103sensor_i2c_skeleton_set_property (GObject *object,
5104 guint prop_id,
5105 const GValue *value,
5106 GParamSpec *pspec)
5107{
5108 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
5109 g_assert (prop_id != 0 && prop_id - 1 < 2);
5110 g_mutex_lock (&skeleton->priv->lock);
5111 g_object_freeze_notify (object);
5112 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
5113 {
5114 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
5115 _sensor_i2c_schedule_emit_changed (skeleton, _sensor_i2c_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
5116 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
5117 g_object_notify_by_pspec (object, pspec);
5118 }
5119 g_mutex_unlock (&skeleton->priv->lock);
5120 g_object_thaw_notify (object);
5121}
5122
5123static void
5124sensor_i2c_skeleton_init (SensorI2cSkeleton *skeleton)
5125{
5126#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
5127 skeleton->priv = sensor_i2c_skeleton_get_instance_private (skeleton);
5128#else
5129 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_I2C_SKELETON, SensorI2cSkeletonPrivate);
5130#endif
5131
5132 g_mutex_init (&skeleton->priv->lock);
5133 skeleton->priv->context = g_main_context_ref_thread_default ();
5134 skeleton->priv->properties = g_new0 (GValue, 2);
5135 g_value_init (&skeleton->priv->properties[0], G_TYPE_STRING);
5136 g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING);
5137}
5138
5139static const gchar *
5140sensor_i2c_skeleton_get_dev_path (SensorI2c *object)
5141{
5142 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
5143 const gchar *value;
5144 g_mutex_lock (&skeleton->priv->lock);
5145 value = g_value_get_string (&(skeleton->priv->properties[0]));
5146 g_mutex_unlock (&skeleton->priv->lock);
5147 return value;
5148}
5149
5150static const gchar *
5151sensor_i2c_skeleton_get_address (SensorI2c *object)
5152{
5153 SensorI2cSkeleton *skeleton = SENSOR_I2C_SKELETON (object);
5154 const gchar *value;
5155 g_mutex_lock (&skeleton->priv->lock);
5156 value = g_value_get_string (&(skeleton->priv->properties[1]));
5157 g_mutex_unlock (&skeleton->priv->lock);
5158 return value;
5159}
5160
5161static void
5162sensor_i2c_skeleton_class_init (SensorI2cSkeletonClass *klass)
5163{
5164 GObjectClass *gobject_class;
5165 GDBusInterfaceSkeletonClass *skeleton_class;
5166
5167 gobject_class = G_OBJECT_CLASS (klass);
5168 gobject_class->finalize = sensor_i2c_skeleton_finalize;
5169 gobject_class->get_property = sensor_i2c_skeleton_get_property;
5170 gobject_class->set_property = sensor_i2c_skeleton_set_property;
5171 gobject_class->notify = sensor_i2c_skeleton_notify;
5172
5173
5174 sensor_i2c_override_properties (gobject_class, 1);
5175
5176 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
5177 skeleton_class->get_info = sensor_i2c_skeleton_dbus_interface_get_info;
5178 skeleton_class->get_properties = sensor_i2c_skeleton_dbus_interface_get_properties;
5179 skeleton_class->flush = sensor_i2c_skeleton_dbus_interface_flush;
5180 skeleton_class->get_vtable = sensor_i2c_skeleton_dbus_interface_get_vtable;
5181
5182#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
5183 g_type_class_add_private (klass, sizeof (SensorI2cSkeletonPrivate));
5184#endif
5185}
5186
5187static void
5188sensor_i2c_skeleton_iface_init (SensorI2cIface *iface)
5189{
5190 iface->get_dev_path = sensor_i2c_skeleton_get_dev_path;
5191 iface->get_address = sensor_i2c_skeleton_get_address;
5192}
5193
5194/**
5195 * sensor_i2c_skeleton_new:
5196 *
5197 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>.
5198 *
5199 * Returns: (transfer full) (type SensorI2cSkeleton): The skeleton object.
5200 */
5201SensorI2c *
5202sensor_i2c_skeleton_new (void)
5203{
5204 return SENSOR_I2C (g_object_new (TYPE_SENSOR_I2C_SKELETON, NULL));
5205}
5206
5207/* ------------------------------------------------------------------------
Norman James9e6acf92015-09-08 07:00:04 -05005208 * Code for interface org.openbmc.SensorMatch
5209 * ------------------------------------------------------------------------
5210 */
5211
5212/**
5213 * SECTION:SensorMatch
5214 * @title: SensorMatch
5215 * @short_description: Generated C code for the org.openbmc.SensorMatch D-Bus interface
5216 *
5217 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link> D-Bus interface in C.
5218 */
5219
5220/* ---- Introspection data for org.openbmc.SensorMatch ---- */
5221
5222static const _ExtendedGDBusArgInfo _sensor_match_signal_info_sensor_match_ARG_state =
5223{
5224 {
5225 -1,
5226 (gchar *) "state",
5227 (gchar *) "y",
5228 NULL
5229 },
5230 FALSE
5231};
5232
5233static const _ExtendedGDBusArgInfo * const _sensor_match_signal_info_sensor_match_ARG_pointers[] =
5234{
5235 &_sensor_match_signal_info_sensor_match_ARG_state,
5236 NULL
5237};
5238
5239static const _ExtendedGDBusSignalInfo _sensor_match_signal_info_sensor_match =
5240{
5241 {
5242 -1,
5243 (gchar *) "SensorMatch",
5244 (GDBusArgInfo **) &_sensor_match_signal_info_sensor_match_ARG_pointers,
5245 NULL
5246 },
5247 "sensor-match"
5248};
5249
5250static const _ExtendedGDBusSignalInfo * const _sensor_match_signal_info_pointers[] =
5251{
5252 &_sensor_match_signal_info_sensor_match,
5253 NULL
5254};
5255
5256static const _ExtendedGDBusPropertyInfo _sensor_match_property_info_match_value =
5257{
5258 {
5259 -1,
5260 (gchar *) "match_value",
5261 (gchar *) "v",
5262 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
5263 NULL
5264 },
5265 "match-value",
5266 FALSE
5267};
5268
5269static const _ExtendedGDBusPropertyInfo _sensor_match_property_info_state =
5270{
5271 {
5272 -1,
5273 (gchar *) "state",
5274 (gchar *) "y",
5275 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
5276 NULL
5277 },
5278 "state",
5279 FALSE
5280};
5281
5282static const _ExtendedGDBusPropertyInfo * const _sensor_match_property_info_pointers[] =
5283{
5284 &_sensor_match_property_info_match_value,
5285 &_sensor_match_property_info_state,
5286 NULL
5287};
5288
5289static const _ExtendedGDBusInterfaceInfo _sensor_match_interface_info =
5290{
5291 {
5292 -1,
5293 (gchar *) "org.openbmc.SensorMatch",
5294 NULL,
5295 (GDBusSignalInfo **) &_sensor_match_signal_info_pointers,
5296 (GDBusPropertyInfo **) &_sensor_match_property_info_pointers,
5297 NULL
5298 },
5299 "sensor-match",
5300};
5301
5302
5303/**
5304 * sensor_match_interface_info:
5305 *
5306 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link> D-Bus interface.
5307 *
5308 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
5309 */
5310GDBusInterfaceInfo *
5311sensor_match_interface_info (void)
5312{
5313 return (GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct;
5314}
5315
5316/**
5317 * sensor_match_override_properties:
5318 * @klass: The class structure for a #GObject<!-- -->-derived class.
5319 * @property_id_begin: The property id to assign to the first overridden property.
5320 *
5321 * Overrides all #GObject properties in the #SensorMatch interface for a concrete class.
5322 * The properties are overridden in the order they are defined.
5323 *
5324 * Returns: The last property id.
5325 */
5326guint
5327sensor_match_override_properties (GObjectClass *klass, guint property_id_begin)
5328{
5329 g_object_class_override_property (klass, property_id_begin++, "match-value");
5330 g_object_class_override_property (klass, property_id_begin++, "state");
5331 return property_id_begin - 1;
5332}
5333
5334
5335
5336/**
5337 * SensorMatch:
5338 *
5339 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>.
5340 */
5341
5342/**
5343 * SensorMatchIface:
5344 * @parent_iface: The parent interface.
5345 * @get_match_value: Getter for the #SensorMatch:match-value property.
5346 * @get_state: Getter for the #SensorMatch:state property.
5347 * @sensor_match: Handler for the #SensorMatch::sensor-match signal.
5348 *
5349 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>.
5350 */
5351
5352typedef SensorMatchIface SensorMatchInterface;
5353G_DEFINE_INTERFACE (SensorMatch, sensor_match, G_TYPE_OBJECT);
5354
5355static void
5356sensor_match_default_init (SensorMatchIface *iface)
5357{
5358 /* GObject signals for received D-Bus signals: */
5359 /**
5360 * SensorMatch::sensor-match:
5361 * @object: A #SensorMatch.
5362 * @arg_state: Argument.
5363 *
5364 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorMatch.SensorMatch">"SensorMatch"</link> is received.
5365 *
5366 * 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.
5367 */
5368 g_signal_new ("sensor-match",
5369 G_TYPE_FROM_INTERFACE (iface),
5370 G_SIGNAL_RUN_LAST,
5371 G_STRUCT_OFFSET (SensorMatchIface, sensor_match),
5372 NULL,
5373 NULL,
5374 g_cclosure_marshal_generic,
5375 G_TYPE_NONE,
5376 1, G_TYPE_UCHAR);
5377
5378 /* GObject properties for D-Bus properties: */
5379 /**
5380 * SensorMatch:match-value:
5381 *
5382 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorMatch.match_value">"match_value"</link>.
5383 *
5384 * 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.
5385 */
5386 g_object_interface_install_property (iface,
5387 g_param_spec_variant ("match-value", "match_value", "match_value", G_VARIANT_TYPE ("v"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
5388 /**
5389 * SensorMatch:state:
5390 *
5391 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorMatch.state">"state"</link>.
5392 *
5393 * 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.
5394 */
5395 g_object_interface_install_property (iface,
5396 g_param_spec_uchar ("state", "state", "state", 0, 255, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
5397}
5398
5399/**
5400 * sensor_match_get_match_value: (skip)
5401 * @object: A #SensorMatch.
5402 *
5403 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorMatch.match_value">"match_value"</link> D-Bus property.
5404 *
5405 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
5406 *
5407 * <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_match_dup_match_value() if on another thread.</warning>
5408 *
5409 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
5410 */
5411GVariant *
5412sensor_match_get_match_value (SensorMatch *object)
5413{
5414 return SENSOR_MATCH_GET_IFACE (object)->get_match_value (object);
5415}
5416
5417/**
5418 * sensor_match_dup_match_value: (skip)
5419 * @object: A #SensorMatch.
5420 *
5421 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorMatch.match_value">"match_value"</link> D-Bus property.
5422 *
5423 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
5424 *
5425 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
5426 */
5427GVariant *
5428sensor_match_dup_match_value (SensorMatch *object)
5429{
5430 GVariant *value;
5431 g_object_get (G_OBJECT (object), "match-value", &value, NULL);
5432 return value;
5433}
5434
5435/**
5436 * sensor_match_set_match_value: (skip)
5437 * @object: A #SensorMatch.
5438 * @value: The value to set.
5439 *
5440 * Sets the <link linkend="gdbus-property-org-openbmc-SensorMatch.match_value">"match_value"</link> D-Bus property to @value.
5441 *
5442 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
5443 */
5444void
5445sensor_match_set_match_value (SensorMatch *object, GVariant *value)
5446{
5447 g_object_set (G_OBJECT (object), "match-value", value, NULL);
5448}
5449
5450/**
5451 * sensor_match_get_state: (skip)
5452 * @object: A #SensorMatch.
5453 *
5454 * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorMatch.state">"state"</link> D-Bus property.
5455 *
5456 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
5457 *
5458 * Returns: The property value.
5459 */
5460guchar
5461sensor_match_get_state (SensorMatch *object)
5462{
5463 return SENSOR_MATCH_GET_IFACE (object)->get_state (object);
5464}
5465
5466/**
5467 * sensor_match_set_state: (skip)
5468 * @object: A #SensorMatch.
5469 * @value: The value to set.
5470 *
5471 * Sets the <link linkend="gdbus-property-org-openbmc-SensorMatch.state">"state"</link> D-Bus property to @value.
5472 *
5473 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
5474 */
5475void
5476sensor_match_set_state (SensorMatch *object, guchar value)
5477{
5478 g_object_set (G_OBJECT (object), "state", value, NULL);
5479}
5480
5481/**
5482 * sensor_match_emit_sensor_match:
5483 * @object: A #SensorMatch.
5484 * @arg_state: Argument to pass with the signal.
5485 *
5486 * Emits the <link linkend="gdbus-signal-org-openbmc-SensorMatch.SensorMatch">"SensorMatch"</link> D-Bus signal.
5487 */
5488void
5489sensor_match_emit_sensor_match (
5490 SensorMatch *object,
5491 guchar arg_state)
5492{
5493 g_signal_emit_by_name (object, "sensor-match", arg_state);
5494}
5495
5496/* ------------------------------------------------------------------------ */
5497
5498/**
5499 * SensorMatchProxy:
5500 *
5501 * The #SensorMatchProxy structure contains only private data and should only be accessed using the provided API.
5502 */
5503
5504/**
5505 * SensorMatchProxyClass:
5506 * @parent_class: The parent class.
5507 *
5508 * Class structure for #SensorMatchProxy.
5509 */
5510
5511struct _SensorMatchProxyPrivate
5512{
5513 GData *qdata;
5514};
5515
5516static void sensor_match_proxy_iface_init (SensorMatchIface *iface);
5517
5518#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
5519G_DEFINE_TYPE_WITH_CODE (SensorMatchProxy, sensor_match_proxy, G_TYPE_DBUS_PROXY,
5520 G_ADD_PRIVATE (SensorMatchProxy)
5521 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_MATCH, sensor_match_proxy_iface_init));
5522
5523#else
5524G_DEFINE_TYPE_WITH_CODE (SensorMatchProxy, sensor_match_proxy, G_TYPE_DBUS_PROXY,
5525 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_MATCH, sensor_match_proxy_iface_init));
5526
5527#endif
5528static void
5529sensor_match_proxy_finalize (GObject *object)
5530{
5531 SensorMatchProxy *proxy = SENSOR_MATCH_PROXY (object);
5532 g_datalist_clear (&proxy->priv->qdata);
5533 G_OBJECT_CLASS (sensor_match_proxy_parent_class)->finalize (object);
5534}
5535
5536static void
5537sensor_match_proxy_get_property (GObject *object,
5538 guint prop_id,
5539 GValue *value,
5540 GParamSpec *pspec G_GNUC_UNUSED)
5541{
5542 const _ExtendedGDBusPropertyInfo *info;
5543 GVariant *variant;
5544 g_assert (prop_id != 0 && prop_id - 1 < 2);
5545 info = _sensor_match_property_info_pointers[prop_id - 1];
5546 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
5547 if (info->use_gvariant)
5548 {
5549 g_value_set_variant (value, variant);
5550 }
5551 else
5552 {
5553 if (variant != NULL)
5554 g_dbus_gvariant_to_gvalue (variant, value);
5555 }
5556 if (variant != NULL)
5557 g_variant_unref (variant);
5558}
5559
5560static void
5561sensor_match_proxy_set_property_cb (GDBusProxy *proxy,
5562 GAsyncResult *res,
5563 gpointer user_data)
5564{
5565 const _ExtendedGDBusPropertyInfo *info = user_data;
5566 GError *error;
5567 GVariant *_ret;
5568 error = NULL;
5569 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
5570 if (!_ret)
5571 {
5572 g_warning ("Error setting property '%s' on interface org.openbmc.SensorMatch: %s (%s, %d)",
5573 info->parent_struct.name,
5574 error->message, g_quark_to_string (error->domain), error->code);
5575 g_error_free (error);
5576 }
5577 else
5578 {
5579 g_variant_unref (_ret);
5580 }
5581}
5582
5583static void
5584sensor_match_proxy_set_property (GObject *object,
5585 guint prop_id,
5586 const GValue *value,
5587 GParamSpec *pspec G_GNUC_UNUSED)
5588{
5589 const _ExtendedGDBusPropertyInfo *info;
5590 GVariant *variant;
5591 g_assert (prop_id != 0 && prop_id - 1 < 2);
5592 info = _sensor_match_property_info_pointers[prop_id - 1];
5593 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
5594 g_dbus_proxy_call (G_DBUS_PROXY (object),
5595 "org.freedesktop.DBus.Properties.Set",
5596 g_variant_new ("(ssv)", "org.openbmc.SensorMatch", info->parent_struct.name, variant),
5597 G_DBUS_CALL_FLAGS_NONE,
5598 -1,
5599 NULL, (GAsyncReadyCallback) sensor_match_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
5600 g_variant_unref (variant);
5601}
5602
5603static void
5604sensor_match_proxy_g_signal (GDBusProxy *proxy,
5605 const gchar *sender_name G_GNUC_UNUSED,
5606 const gchar *signal_name,
5607 GVariant *parameters)
5608{
5609 _ExtendedGDBusSignalInfo *info;
5610 GVariantIter iter;
5611 GVariant *child;
5612 GValue *paramv;
5613 guint num_params;
5614 guint n;
5615 guint signal_id;
5616 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct, signal_name);
5617 if (info == NULL)
5618 return;
5619 num_params = g_variant_n_children (parameters);
5620 paramv = g_new0 (GValue, num_params + 1);
5621 g_value_init (&paramv[0], TYPE_SENSOR_MATCH);
5622 g_value_set_object (&paramv[0], proxy);
5623 g_variant_iter_init (&iter, parameters);
5624 n = 1;
5625 while ((child = g_variant_iter_next_value (&iter)) != NULL)
5626 {
5627 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
5628 if (arg_info->use_gvariant)
5629 {
5630 g_value_init (&paramv[n], G_TYPE_VARIANT);
5631 g_value_set_variant (&paramv[n], child);
5632 n++;
5633 }
5634 else
5635 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
5636 g_variant_unref (child);
5637 }
5638 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_MATCH);
5639 g_signal_emitv (paramv, signal_id, 0, NULL);
5640 for (n = 0; n < num_params + 1; n++)
5641 g_value_unset (&paramv[n]);
5642 g_free (paramv);
5643}
5644
5645static void
5646sensor_match_proxy_g_properties_changed (GDBusProxy *_proxy,
5647 GVariant *changed_properties,
5648 const gchar *const *invalidated_properties)
5649{
5650 SensorMatchProxy *proxy = SENSOR_MATCH_PROXY (_proxy);
5651 guint n;
5652 const gchar *key;
5653 GVariantIter *iter;
5654 _ExtendedGDBusPropertyInfo *info;
5655 g_variant_get (changed_properties, "a{sv}", &iter);
5656 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
5657 {
5658 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct, key);
5659 g_datalist_remove_data (&proxy->priv->qdata, key);
5660 if (info != NULL)
5661 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
5662 }
5663 g_variant_iter_free (iter);
5664 for (n = 0; invalidated_properties[n] != NULL; n++)
5665 {
5666 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct, invalidated_properties[n]);
5667 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
5668 if (info != NULL)
5669 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
5670 }
5671}
5672
5673static GVariant *
5674sensor_match_proxy_get_match_value (SensorMatch *object)
5675{
5676 SensorMatchProxy *proxy = SENSOR_MATCH_PROXY (object);
5677 GVariant *variant;
5678 GVariant *value = NULL;
5679 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "match_value");
5680 value = variant;
5681 if (variant != NULL)
5682 g_variant_unref (variant);
5683 return value;
5684}
5685
5686static guchar
5687sensor_match_proxy_get_state (SensorMatch *object)
5688{
5689 SensorMatchProxy *proxy = SENSOR_MATCH_PROXY (object);
5690 GVariant *variant;
5691 guchar value = 0;
5692 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "state");
5693 if (variant != NULL)
5694 {
5695 value = g_variant_get_byte (variant);
5696 g_variant_unref (variant);
5697 }
5698 return value;
5699}
5700
5701static void
5702sensor_match_proxy_init (SensorMatchProxy *proxy)
5703{
5704#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
5705 proxy->priv = sensor_match_proxy_get_instance_private (proxy);
5706#else
5707 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_MATCH_PROXY, SensorMatchProxyPrivate);
5708#endif
5709
5710 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_match_interface_info ());
5711}
5712
5713static void
5714sensor_match_proxy_class_init (SensorMatchProxyClass *klass)
5715{
5716 GObjectClass *gobject_class;
5717 GDBusProxyClass *proxy_class;
5718
5719 gobject_class = G_OBJECT_CLASS (klass);
5720 gobject_class->finalize = sensor_match_proxy_finalize;
5721 gobject_class->get_property = sensor_match_proxy_get_property;
5722 gobject_class->set_property = sensor_match_proxy_set_property;
5723
5724 proxy_class = G_DBUS_PROXY_CLASS (klass);
5725 proxy_class->g_signal = sensor_match_proxy_g_signal;
5726 proxy_class->g_properties_changed = sensor_match_proxy_g_properties_changed;
5727
5728 sensor_match_override_properties (gobject_class, 1);
5729
5730#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
5731 g_type_class_add_private (klass, sizeof (SensorMatchProxyPrivate));
5732#endif
5733}
5734
5735static void
5736sensor_match_proxy_iface_init (SensorMatchIface *iface)
5737{
5738 iface->get_match_value = sensor_match_proxy_get_match_value;
5739 iface->get_state = sensor_match_proxy_get_state;
5740}
5741
5742/**
5743 * sensor_match_proxy_new:
5744 * @connection: A #GDBusConnection.
5745 * @flags: Flags from the #GDBusProxyFlags enumeration.
5746 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
5747 * @object_path: An object path.
5748 * @cancellable: (allow-none): A #GCancellable or %NULL.
5749 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
5750 * @user_data: User data to pass to @callback.
5751 *
5752 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>. See g_dbus_proxy_new() for more details.
5753 *
5754 * 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.
5755 * You can then call sensor_match_proxy_new_finish() to get the result of the operation.
5756 *
5757 * See sensor_match_proxy_new_sync() for the synchronous, blocking version of this constructor.
5758 */
5759void
5760sensor_match_proxy_new (
5761 GDBusConnection *connection,
5762 GDBusProxyFlags flags,
5763 const gchar *name,
5764 const gchar *object_path,
5765 GCancellable *cancellable,
5766 GAsyncReadyCallback callback,
5767 gpointer user_data)
5768{
5769 g_async_initable_new_async (TYPE_SENSOR_MATCH_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.SensorMatch", NULL);
5770}
5771
5772/**
5773 * sensor_match_proxy_new_finish:
5774 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_match_proxy_new().
5775 * @error: Return location for error or %NULL
5776 *
5777 * Finishes an operation started with sensor_match_proxy_new().
5778 *
5779 * Returns: (transfer full) (type SensorMatchProxy): The constructed proxy object or %NULL if @error is set.
5780 */
5781SensorMatch *
5782sensor_match_proxy_new_finish (
5783 GAsyncResult *res,
5784 GError **error)
5785{
5786 GObject *ret;
5787 GObject *source_object;
5788 source_object = g_async_result_get_source_object (res);
5789 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
5790 g_object_unref (source_object);
5791 if (ret != NULL)
5792 return SENSOR_MATCH (ret);
5793 else
5794 return NULL;
5795}
5796
5797/**
5798 * sensor_match_proxy_new_sync:
5799 * @connection: A #GDBusConnection.
5800 * @flags: Flags from the #GDBusProxyFlags enumeration.
5801 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
5802 * @object_path: An object path.
5803 * @cancellable: (allow-none): A #GCancellable or %NULL.
5804 * @error: Return location for error or %NULL
5805 *
5806 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>. See g_dbus_proxy_new_sync() for more details.
5807 *
5808 * The calling thread is blocked until a reply is received.
5809 *
5810 * See sensor_match_proxy_new() for the asynchronous version of this constructor.
5811 *
5812 * Returns: (transfer full) (type SensorMatchProxy): The constructed proxy object or %NULL if @error is set.
5813 */
5814SensorMatch *
5815sensor_match_proxy_new_sync (
5816 GDBusConnection *connection,
5817 GDBusProxyFlags flags,
5818 const gchar *name,
5819 const gchar *object_path,
5820 GCancellable *cancellable,
5821 GError **error)
5822{
5823 GInitable *ret;
5824 ret = g_initable_new (TYPE_SENSOR_MATCH_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorMatch", NULL);
5825 if (ret != NULL)
5826 return SENSOR_MATCH (ret);
5827 else
5828 return NULL;
5829}
5830
5831
5832/**
5833 * sensor_match_proxy_new_for_bus:
5834 * @bus_type: A #GBusType.
5835 * @flags: Flags from the #GDBusProxyFlags enumeration.
5836 * @name: A bus name (well-known or unique).
5837 * @object_path: An object path.
5838 * @cancellable: (allow-none): A #GCancellable or %NULL.
5839 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
5840 * @user_data: User data to pass to @callback.
5841 *
5842 * Like sensor_match_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
5843 *
5844 * 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.
5845 * You can then call sensor_match_proxy_new_for_bus_finish() to get the result of the operation.
5846 *
5847 * See sensor_match_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
5848 */
5849void
5850sensor_match_proxy_new_for_bus (
5851 GBusType bus_type,
5852 GDBusProxyFlags flags,
5853 const gchar *name,
5854 const gchar *object_path,
5855 GCancellable *cancellable,
5856 GAsyncReadyCallback callback,
5857 gpointer user_data)
5858{
5859 g_async_initable_new_async (TYPE_SENSOR_MATCH_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.SensorMatch", NULL);
5860}
5861
5862/**
5863 * sensor_match_proxy_new_for_bus_finish:
5864 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_match_proxy_new_for_bus().
5865 * @error: Return location for error or %NULL
5866 *
5867 * Finishes an operation started with sensor_match_proxy_new_for_bus().
5868 *
5869 * Returns: (transfer full) (type SensorMatchProxy): The constructed proxy object or %NULL if @error is set.
5870 */
5871SensorMatch *
5872sensor_match_proxy_new_for_bus_finish (
5873 GAsyncResult *res,
5874 GError **error)
5875{
5876 GObject *ret;
5877 GObject *source_object;
5878 source_object = g_async_result_get_source_object (res);
5879 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
5880 g_object_unref (source_object);
5881 if (ret != NULL)
5882 return SENSOR_MATCH (ret);
5883 else
5884 return NULL;
5885}
5886
5887/**
5888 * sensor_match_proxy_new_for_bus_sync:
5889 * @bus_type: A #GBusType.
5890 * @flags: Flags from the #GDBusProxyFlags enumeration.
5891 * @name: A bus name (well-known or unique).
5892 * @object_path: An object path.
5893 * @cancellable: (allow-none): A #GCancellable or %NULL.
5894 * @error: Return location for error or %NULL
5895 *
5896 * Like sensor_match_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
5897 *
5898 * The calling thread is blocked until a reply is received.
5899 *
5900 * See sensor_match_proxy_new_for_bus() for the asynchronous version of this constructor.
5901 *
5902 * Returns: (transfer full) (type SensorMatchProxy): The constructed proxy object or %NULL if @error is set.
5903 */
5904SensorMatch *
5905sensor_match_proxy_new_for_bus_sync (
5906 GBusType bus_type,
5907 GDBusProxyFlags flags,
5908 const gchar *name,
5909 const gchar *object_path,
5910 GCancellable *cancellable,
5911 GError **error)
5912{
5913 GInitable *ret;
5914 ret = g_initable_new (TYPE_SENSOR_MATCH_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorMatch", NULL);
5915 if (ret != NULL)
5916 return SENSOR_MATCH (ret);
5917 else
5918 return NULL;
5919}
5920
5921
5922/* ------------------------------------------------------------------------ */
5923
5924/**
5925 * SensorMatchSkeleton:
5926 *
5927 * The #SensorMatchSkeleton structure contains only private data and should only be accessed using the provided API.
5928 */
5929
5930/**
5931 * SensorMatchSkeletonClass:
5932 * @parent_class: The parent class.
5933 *
5934 * Class structure for #SensorMatchSkeleton.
5935 */
5936
5937struct _SensorMatchSkeletonPrivate
5938{
5939 GValue *properties;
5940 GList *changed_properties;
5941 GSource *changed_properties_idle_source;
5942 GMainContext *context;
5943 GMutex lock;
5944};
5945
5946static void
5947_sensor_match_skeleton_handle_method_call (
5948 GDBusConnection *connection G_GNUC_UNUSED,
5949 const gchar *sender G_GNUC_UNUSED,
5950 const gchar *object_path G_GNUC_UNUSED,
5951 const gchar *interface_name,
5952 const gchar *method_name,
5953 GVariant *parameters,
5954 GDBusMethodInvocation *invocation,
5955 gpointer user_data)
5956{
5957 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (user_data);
5958 _ExtendedGDBusMethodInfo *info;
5959 GVariantIter iter;
5960 GVariant *child;
5961 GValue *paramv;
5962 guint num_params;
5963 guint num_extra;
5964 guint n;
5965 guint signal_id;
5966 GValue return_value = G_VALUE_INIT;
5967 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
5968 g_assert (info != NULL);
5969 num_params = g_variant_n_children (parameters);
5970 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
5971 n = 0;
5972 g_value_init (&paramv[n], TYPE_SENSOR_MATCH);
5973 g_value_set_object (&paramv[n++], skeleton);
5974 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
5975 g_value_set_object (&paramv[n++], invocation);
5976 if (info->pass_fdlist)
5977 {
5978#ifdef G_OS_UNIX
5979 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
5980 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
5981#else
5982 g_assert_not_reached ();
5983#endif
5984 }
5985 g_variant_iter_init (&iter, parameters);
5986 while ((child = g_variant_iter_next_value (&iter)) != NULL)
5987 {
5988 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
5989 if (arg_info->use_gvariant)
5990 {
5991 g_value_init (&paramv[n], G_TYPE_VARIANT);
5992 g_value_set_variant (&paramv[n], child);
5993 n++;
5994 }
5995 else
5996 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
5997 g_variant_unref (child);
5998 }
5999 signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_MATCH);
6000 g_value_init (&return_value, G_TYPE_BOOLEAN);
6001 g_signal_emitv (paramv, signal_id, 0, &return_value);
6002 if (!g_value_get_boolean (&return_value))
6003 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);
6004 g_value_unset (&return_value);
6005 for (n = 0; n < num_params + num_extra; n++)
6006 g_value_unset (&paramv[n]);
6007 g_free (paramv);
6008}
6009
6010static GVariant *
6011_sensor_match_skeleton_handle_get_property (
6012 GDBusConnection *connection G_GNUC_UNUSED,
6013 const gchar *sender G_GNUC_UNUSED,
6014 const gchar *object_path G_GNUC_UNUSED,
6015 const gchar *interface_name G_GNUC_UNUSED,
6016 const gchar *property_name,
6017 GError **error,
6018 gpointer user_data)
6019{
6020 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (user_data);
6021 GValue value = G_VALUE_INIT;
6022 GParamSpec *pspec;
6023 _ExtendedGDBusPropertyInfo *info;
6024 GVariant *ret;
6025 ret = NULL;
6026 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct, property_name);
6027 g_assert (info != NULL);
6028 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
6029 if (pspec == NULL)
6030 {
6031 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
6032 }
6033 else
6034 {
6035 g_value_init (&value, pspec->value_type);
6036 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
6037 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
6038 g_value_unset (&value);
6039 }
6040 return ret;
6041}
6042
6043static gboolean
6044_sensor_match_skeleton_handle_set_property (
6045 GDBusConnection *connection G_GNUC_UNUSED,
6046 const gchar *sender G_GNUC_UNUSED,
6047 const gchar *object_path G_GNUC_UNUSED,
6048 const gchar *interface_name G_GNUC_UNUSED,
6049 const gchar *property_name,
6050 GVariant *variant,
6051 GError **error,
6052 gpointer user_data)
6053{
6054 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (user_data);
6055 GValue value = G_VALUE_INIT;
6056 GParamSpec *pspec;
6057 _ExtendedGDBusPropertyInfo *info;
6058 gboolean ret;
6059 ret = FALSE;
6060 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_match_interface_info.parent_struct, property_name);
6061 g_assert (info != NULL);
6062 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
6063 if (pspec == NULL)
6064 {
6065 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
6066 }
6067 else
6068 {
6069 if (info->use_gvariant)
6070 g_value_set_variant (&value, variant);
6071 else
6072 g_dbus_gvariant_to_gvalue (variant, &value);
6073 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
6074 g_value_unset (&value);
6075 ret = TRUE;
6076 }
6077 return ret;
6078}
6079
6080static const GDBusInterfaceVTable _sensor_match_skeleton_vtable =
6081{
6082 _sensor_match_skeleton_handle_method_call,
6083 _sensor_match_skeleton_handle_get_property,
6084 _sensor_match_skeleton_handle_set_property,
6085 {NULL}
6086};
6087
6088static GDBusInterfaceInfo *
6089sensor_match_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
6090{
6091 return sensor_match_interface_info ();
6092}
6093
6094static GDBusInterfaceVTable *
6095sensor_match_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
6096{
6097 return (GDBusInterfaceVTable *) &_sensor_match_skeleton_vtable;
6098}
6099
6100static GVariant *
6101sensor_match_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
6102{
6103 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (_skeleton);
6104
6105 GVariantBuilder builder;
6106 guint n;
6107 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
6108 if (_sensor_match_interface_info.parent_struct.properties == NULL)
6109 goto out;
6110 for (n = 0; _sensor_match_interface_info.parent_struct.properties[n] != NULL; n++)
6111 {
6112 GDBusPropertyInfo *info = _sensor_match_interface_info.parent_struct.properties[n];
6113 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
6114 {
6115 GVariant *value;
6116 value = _sensor_match_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.SensorMatch", info->name, NULL, skeleton);
6117 if (value != NULL)
6118 {
6119 g_variant_take_ref (value);
6120 g_variant_builder_add (&builder, "{sv}", info->name, value);
6121 g_variant_unref (value);
6122 }
6123 }
6124 }
6125out:
6126 return g_variant_builder_end (&builder);
6127}
6128
6129static gboolean _sensor_match_emit_changed (gpointer user_data);
6130
6131static void
6132sensor_match_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
6133{
6134 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (_skeleton);
6135 gboolean emit_changed = FALSE;
6136
6137 g_mutex_lock (&skeleton->priv->lock);
6138 if (skeleton->priv->changed_properties_idle_source != NULL)
6139 {
6140 g_source_destroy (skeleton->priv->changed_properties_idle_source);
6141 skeleton->priv->changed_properties_idle_source = NULL;
6142 emit_changed = TRUE;
6143 }
6144 g_mutex_unlock (&skeleton->priv->lock);
6145
6146 if (emit_changed)
6147 _sensor_match_emit_changed (skeleton);
6148}
6149
6150static void
6151_sensor_match_on_signal_sensor_match (
6152 SensorMatch *object,
6153 guchar arg_state)
6154{
6155 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6156
6157 GList *connections, *l;
6158 GVariant *signal_variant;
6159 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
6160
6161 signal_variant = g_variant_ref_sink (g_variant_new ("(y)",
6162 arg_state));
6163 for (l = connections; l != NULL; l = l->next)
6164 {
6165 GDBusConnection *connection = l->data;
6166 g_dbus_connection_emit_signal (connection,
6167 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorMatch", "SensorMatch",
6168 signal_variant, NULL);
6169 }
6170 g_variant_unref (signal_variant);
6171 g_list_free_full (connections, g_object_unref);
6172}
6173
6174static void sensor_match_skeleton_iface_init (SensorMatchIface *iface);
6175#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
6176G_DEFINE_TYPE_WITH_CODE (SensorMatchSkeleton, sensor_match_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
6177 G_ADD_PRIVATE (SensorMatchSkeleton)
6178 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_MATCH, sensor_match_skeleton_iface_init));
6179
6180#else
6181G_DEFINE_TYPE_WITH_CODE (SensorMatchSkeleton, sensor_match_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
6182 G_IMPLEMENT_INTERFACE (TYPE_SENSOR_MATCH, sensor_match_skeleton_iface_init));
6183
6184#endif
6185static void
6186sensor_match_skeleton_finalize (GObject *object)
6187{
6188 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6189 guint n;
6190 for (n = 0; n < 2; n++)
6191 g_value_unset (&skeleton->priv->properties[n]);
6192 g_free (skeleton->priv->properties);
6193 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
6194 if (skeleton->priv->changed_properties_idle_source != NULL)
6195 g_source_destroy (skeleton->priv->changed_properties_idle_source);
6196 g_main_context_unref (skeleton->priv->context);
6197 g_mutex_clear (&skeleton->priv->lock);
6198 G_OBJECT_CLASS (sensor_match_skeleton_parent_class)->finalize (object);
6199}
6200
6201static void
6202sensor_match_skeleton_get_property (GObject *object,
6203 guint prop_id,
6204 GValue *value,
6205 GParamSpec *pspec G_GNUC_UNUSED)
6206{
6207 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6208 g_assert (prop_id != 0 && prop_id - 1 < 2);
6209 g_mutex_lock (&skeleton->priv->lock);
6210 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
6211 g_mutex_unlock (&skeleton->priv->lock);
6212}
6213
6214static gboolean
6215_sensor_match_emit_changed (gpointer user_data)
6216{
6217 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (user_data);
6218 GList *l;
6219 GVariantBuilder builder;
6220 GVariantBuilder invalidated_builder;
6221 guint num_changes;
6222
6223 g_mutex_lock (&skeleton->priv->lock);
6224 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
6225 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
6226 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
6227 {
6228 ChangedProperty *cp = l->data;
6229 GVariant *variant;
6230 const GValue *cur_value;
6231
6232 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
6233 if (!_g_value_equal (cur_value, &cp->orig_value))
6234 {
6235 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
6236 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
6237 g_variant_unref (variant);
6238 num_changes++;
6239 }
6240 }
6241 if (num_changes > 0)
6242 {
6243 GList *connections, *ll;
6244 GVariant *signal_variant;
6245 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorMatch",
6246 &builder, &invalidated_builder));
6247 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
6248 for (ll = connections; ll != NULL; ll = ll->next)
6249 {
6250 GDBusConnection *connection = ll->data;
6251
6252 g_dbus_connection_emit_signal (connection,
6253 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
6254 "org.freedesktop.DBus.Properties",
6255 "PropertiesChanged",
6256 signal_variant,
6257 NULL);
6258 }
6259 g_variant_unref (signal_variant);
6260 g_list_free_full (connections, g_object_unref);
6261 }
6262 else
6263 {
6264 g_variant_builder_clear (&builder);
6265 g_variant_builder_clear (&invalidated_builder);
6266 }
6267 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
6268 skeleton->priv->changed_properties = NULL;
6269 skeleton->priv->changed_properties_idle_source = NULL;
6270 g_mutex_unlock (&skeleton->priv->lock);
6271 return FALSE;
6272}
6273
6274static void
6275_sensor_match_schedule_emit_changed (SensorMatchSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
6276{
6277 ChangedProperty *cp;
6278 GList *l;
6279 cp = NULL;
6280 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
6281 {
6282 ChangedProperty *i_cp = l->data;
6283 if (i_cp->info == info)
6284 {
6285 cp = i_cp;
6286 break;
6287 }
6288 }
6289 if (cp == NULL)
6290 {
6291 cp = g_new0 (ChangedProperty, 1);
6292 cp->prop_id = prop_id;
6293 cp->info = info;
6294 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
6295 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
6296 g_value_copy (orig_value, &cp->orig_value);
6297 }
6298}
6299
6300static void
6301sensor_match_skeleton_notify (GObject *object,
6302 GParamSpec *pspec G_GNUC_UNUSED)
6303{
6304 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6305 g_mutex_lock (&skeleton->priv->lock);
6306 if (skeleton->priv->changed_properties != NULL &&
6307 skeleton->priv->changed_properties_idle_source == NULL)
6308 {
6309 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
6310 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
6311 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_match_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
6312 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
6313 g_source_unref (skeleton->priv->changed_properties_idle_source);
6314 }
6315 g_mutex_unlock (&skeleton->priv->lock);
6316}
6317
6318static void
6319sensor_match_skeleton_set_property (GObject *object,
6320 guint prop_id,
6321 const GValue *value,
6322 GParamSpec *pspec)
6323{
6324 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6325 g_assert (prop_id != 0 && prop_id - 1 < 2);
6326 g_mutex_lock (&skeleton->priv->lock);
6327 g_object_freeze_notify (object);
6328 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
6329 {
6330 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
6331 _sensor_match_schedule_emit_changed (skeleton, _sensor_match_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
6332 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
6333 g_object_notify_by_pspec (object, pspec);
6334 }
6335 g_mutex_unlock (&skeleton->priv->lock);
6336 g_object_thaw_notify (object);
6337}
6338
6339static void
6340sensor_match_skeleton_init (SensorMatchSkeleton *skeleton)
6341{
6342#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
6343 skeleton->priv = sensor_match_skeleton_get_instance_private (skeleton);
6344#else
6345 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_MATCH_SKELETON, SensorMatchSkeletonPrivate);
6346#endif
6347
6348 g_mutex_init (&skeleton->priv->lock);
6349 skeleton->priv->context = g_main_context_ref_thread_default ();
6350 skeleton->priv->properties = g_new0 (GValue, 2);
6351 g_value_init (&skeleton->priv->properties[0], G_TYPE_VARIANT);
6352 g_value_init (&skeleton->priv->properties[1], G_TYPE_UCHAR);
6353}
6354
6355static GVariant *
6356sensor_match_skeleton_get_match_value (SensorMatch *object)
6357{
6358 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6359 GVariant *value;
6360 g_mutex_lock (&skeleton->priv->lock);
6361 value = g_value_get_variant (&(skeleton->priv->properties[0]));
6362 g_mutex_unlock (&skeleton->priv->lock);
6363 return value;
6364}
6365
6366static guchar
6367sensor_match_skeleton_get_state (SensorMatch *object)
6368{
6369 SensorMatchSkeleton *skeleton = SENSOR_MATCH_SKELETON (object);
6370 guchar value;
6371 g_mutex_lock (&skeleton->priv->lock);
6372 value = g_value_get_uchar (&(skeleton->priv->properties[1]));
6373 g_mutex_unlock (&skeleton->priv->lock);
6374 return value;
6375}
6376
6377static void
6378sensor_match_skeleton_class_init (SensorMatchSkeletonClass *klass)
6379{
6380 GObjectClass *gobject_class;
6381 GDBusInterfaceSkeletonClass *skeleton_class;
6382
6383 gobject_class = G_OBJECT_CLASS (klass);
6384 gobject_class->finalize = sensor_match_skeleton_finalize;
6385 gobject_class->get_property = sensor_match_skeleton_get_property;
6386 gobject_class->set_property = sensor_match_skeleton_set_property;
6387 gobject_class->notify = sensor_match_skeleton_notify;
6388
6389
6390 sensor_match_override_properties (gobject_class, 1);
6391
6392 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
6393 skeleton_class->get_info = sensor_match_skeleton_dbus_interface_get_info;
6394 skeleton_class->get_properties = sensor_match_skeleton_dbus_interface_get_properties;
6395 skeleton_class->flush = sensor_match_skeleton_dbus_interface_flush;
6396 skeleton_class->get_vtable = sensor_match_skeleton_dbus_interface_get_vtable;
6397
6398#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
6399 g_type_class_add_private (klass, sizeof (SensorMatchSkeletonPrivate));
6400#endif
6401}
6402
6403static void
6404sensor_match_skeleton_iface_init (SensorMatchIface *iface)
6405{
6406 iface->sensor_match = _sensor_match_on_signal_sensor_match;
6407 iface->get_match_value = sensor_match_skeleton_get_match_value;
6408 iface->get_state = sensor_match_skeleton_get_state;
6409}
6410
6411/**
6412 * sensor_match_skeleton_new:
6413 *
6414 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>.
6415 *
6416 * Returns: (transfer full) (type SensorMatchSkeleton): The skeleton object.
6417 */
6418SensorMatch *
6419sensor_match_skeleton_new (void)
6420{
6421 return SENSOR_MATCH (g_object_new (TYPE_SENSOR_MATCH_SKELETON, NULL));
6422}
6423
6424/* ------------------------------------------------------------------------
Norman Jamese2765102015-08-19 22:00:55 -05006425 * Code for Object, ObjectProxy and ObjectSkeleton
6426 * ------------------------------------------------------------------------
6427 */
6428
6429/**
6430 * SECTION:Object
6431 * @title: Object
6432 * @short_description: Specialized GDBusObject types
6433 *
6434 * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
6435 */
6436
6437/**
6438 * Object:
6439 *
6440 * The #Object type is a specialized container of interfaces.
6441 */
6442
6443/**
6444 * ObjectIface:
6445 * @parent_iface: The parent interface.
6446 *
6447 * Virtual table for the #Object interface.
6448 */
6449
6450typedef ObjectIface ObjectInterface;
6451G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
6452
6453static void
6454object_default_init (ObjectIface *iface)
6455{
6456 /**
Norman James5d78b4d2015-09-05 13:34:34 -05006457 * Object:sensor-value:
Norman Jamese2765102015-08-19 22:00:55 -05006458 *
Norman James5d78b4d2015-09-05 13:34:34 -05006459 * The #SensorValue instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link>, if any.
Norman Jamese2765102015-08-19 22:00:55 -05006460 *
6461 * Connect to the #GObject::notify signal to get informed of property changes.
6462 */
Norman James5d78b4d2015-09-05 13:34:34 -05006463 g_object_interface_install_property (iface, g_param_spec_object ("sensor-value", "sensor-value", "sensor-value", TYPE_SENSOR_VALUE, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
Norman Jamese2765102015-08-19 22:00:55 -05006464
6465 /**
Norman James5d78b4d2015-09-05 13:34:34 -05006466 * Object:sensor-threshold:
Norman Jamese2765102015-08-19 22:00:55 -05006467 *
Norman James5d78b4d2015-09-05 13:34:34 -05006468 * The #SensorThreshold instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link>, if any.
Norman Jamese2765102015-08-19 22:00:55 -05006469 *
6470 * Connect to the #GObject::notify signal to get informed of property changes.
6471 */
Norman James5d78b4d2015-09-05 13:34:34 -05006472 g_object_interface_install_property (iface, g_param_spec_object ("sensor-threshold", "sensor-threshold", "sensor-threshold", TYPE_SENSOR_THRESHOLD, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
Norman Jamescc7ae122015-08-24 14:26:09 -05006473
Norman James90baede2015-09-02 20:32:49 -05006474 /**
6475 * Object:sensor-i2c:
6476 *
6477 * The #SensorI2c instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link>, if any.
6478 *
6479 * Connect to the #GObject::notify signal to get informed of property changes.
6480 */
6481 g_object_interface_install_property (iface, g_param_spec_object ("sensor-i2c", "sensor-i2c", "sensor-i2c", TYPE_SENSOR_I2C, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
6482
Norman James9e6acf92015-09-08 07:00:04 -05006483 /**
6484 * Object:sensor-match:
6485 *
6486 * The #SensorMatch instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link>, if any.
6487 *
6488 * Connect to the #GObject::notify signal to get informed of property changes.
6489 */
6490 g_object_interface_install_property (iface, g_param_spec_object ("sensor-match", "sensor-match", "sensor-match", TYPE_SENSOR_MATCH, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
6491
Norman Jamese2765102015-08-19 22:00:55 -05006492}
6493
6494/**
Norman James5d78b4d2015-09-05 13:34:34 -05006495 * object_get_sensor_value:
Norman Jamese2765102015-08-19 22:00:55 -05006496 * @object: A #Object.
6497 *
Norman James5d78b4d2015-09-05 13:34:34 -05006498 * Gets the #SensorValue instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link> on @object, if any.
Norman Jamese2765102015-08-19 22:00:55 -05006499 *
Norman James5d78b4d2015-09-05 13:34:34 -05006500 * Returns: (transfer full): A #SensorValue that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
Norman Jamese2765102015-08-19 22:00:55 -05006501 */
Norman James5d78b4d2015-09-05 13:34:34 -05006502SensorValue *object_get_sensor_value (Object *object)
Norman Jamese2765102015-08-19 22:00:55 -05006503{
6504 GDBusInterface *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05006505 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorValue");
Norman Jamese2765102015-08-19 22:00:55 -05006506 if (ret == NULL)
6507 return NULL;
Norman James5d78b4d2015-09-05 13:34:34 -05006508 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05006509}
6510
6511/**
Norman James5d78b4d2015-09-05 13:34:34 -05006512 * object_get_sensor_threshold:
Norman Jamese2765102015-08-19 22:00:55 -05006513 * @object: A #Object.
6514 *
Norman James5d78b4d2015-09-05 13:34:34 -05006515 * Gets the #SensorThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link> on @object, if any.
Norman Jamese2765102015-08-19 22:00:55 -05006516 *
Norman James5d78b4d2015-09-05 13:34:34 -05006517 * Returns: (transfer full): A #SensorThreshold that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
Norman Jamese2765102015-08-19 22:00:55 -05006518 */
Norman James5d78b4d2015-09-05 13:34:34 -05006519SensorThreshold *object_get_sensor_threshold (Object *object)
Norman Jamese2765102015-08-19 22:00:55 -05006520{
6521 GDBusInterface *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05006522 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorThreshold");
Norman Jamese2765102015-08-19 22:00:55 -05006523 if (ret == NULL)
6524 return NULL;
Norman James5d78b4d2015-09-05 13:34:34 -05006525 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05006526}
6527
Norman James90baede2015-09-02 20:32:49 -05006528/**
6529 * object_get_sensor_i2c:
6530 * @object: A #Object.
6531 *
6532 * Gets the #SensorI2c instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link> on @object, if any.
6533 *
6534 * Returns: (transfer full): A #SensorI2c that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
6535 */
6536SensorI2c *object_get_sensor_i2c (Object *object)
6537{
6538 GDBusInterface *ret;
6539 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorI2c");
6540 if (ret == NULL)
6541 return NULL;
6542 return SENSOR_I2C (ret);
6543}
6544
Norman James9e6acf92015-09-08 07:00:04 -05006545/**
6546 * object_get_sensor_match:
6547 * @object: A #Object.
6548 *
6549 * Gets the #SensorMatch instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link> on @object, if any.
6550 *
6551 * Returns: (transfer full): A #SensorMatch that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
6552 */
6553SensorMatch *object_get_sensor_match (Object *object)
6554{
6555 GDBusInterface *ret;
6556 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorMatch");
6557 if (ret == NULL)
6558 return NULL;
6559 return SENSOR_MATCH (ret);
6560}
6561
Norman Jamese2765102015-08-19 22:00:55 -05006562
6563/**
Norman James5d78b4d2015-09-05 13:34:34 -05006564 * object_peek_sensor_value: (skip)
Norman Jamese2765102015-08-19 22:00:55 -05006565 * @object: A #Object.
6566 *
Norman James5d78b4d2015-09-05 13:34:34 -05006567 * Like object_get_sensor_value() but doesn't increase the reference count on the returned object.
Norman Jamese2765102015-08-19 22:00:55 -05006568 *
6569 * <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>
6570 *
Norman James5d78b4d2015-09-05 13:34:34 -05006571 * Returns: (transfer none): A #SensorValue or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
Norman Jamese2765102015-08-19 22:00:55 -05006572 */
Norman James5d78b4d2015-09-05 13:34:34 -05006573SensorValue *object_peek_sensor_value (Object *object)
Norman Jamese2765102015-08-19 22:00:55 -05006574{
6575 GDBusInterface *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05006576 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorValue");
Norman Jamese2765102015-08-19 22:00:55 -05006577 if (ret == NULL)
6578 return NULL;
6579 g_object_unref (ret);
Norman James5d78b4d2015-09-05 13:34:34 -05006580 return SENSOR_VALUE (ret);
Norman Jamese2765102015-08-19 22:00:55 -05006581}
6582
6583/**
Norman James5d78b4d2015-09-05 13:34:34 -05006584 * object_peek_sensor_threshold: (skip)
Norman Jamese2765102015-08-19 22:00:55 -05006585 * @object: A #Object.
6586 *
Norman James5d78b4d2015-09-05 13:34:34 -05006587 * Like object_get_sensor_threshold() but doesn't increase the reference count on the returned object.
Norman Jamese2765102015-08-19 22:00:55 -05006588 *
6589 * <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>
6590 *
Norman James5d78b4d2015-09-05 13:34:34 -05006591 * Returns: (transfer none): A #SensorThreshold or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
Norman Jamese2765102015-08-19 22:00:55 -05006592 */
Norman James5d78b4d2015-09-05 13:34:34 -05006593SensorThreshold *object_peek_sensor_threshold (Object *object)
Norman Jamese2765102015-08-19 22:00:55 -05006594{
6595 GDBusInterface *ret;
Norman James5d78b4d2015-09-05 13:34:34 -05006596 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorThreshold");
Norman Jamese2765102015-08-19 22:00:55 -05006597 if (ret == NULL)
6598 return NULL;
6599 g_object_unref (ret);
Norman James5d78b4d2015-09-05 13:34:34 -05006600 return SENSOR_THRESHOLD (ret);
Norman Jamescc7ae122015-08-24 14:26:09 -05006601}
6602
Norman James90baede2015-09-02 20:32:49 -05006603/**
6604 * object_peek_sensor_i2c: (skip)
6605 * @object: A #Object.
6606 *
6607 * Like object_get_sensor_i2c() but doesn't increase the reference count on the returned object.
6608 *
6609 * <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>
6610 *
6611 * Returns: (transfer none): A #SensorI2c or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
6612 */
6613SensorI2c *object_peek_sensor_i2c (Object *object)
6614{
6615 GDBusInterface *ret;
6616 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorI2c");
6617 if (ret == NULL)
6618 return NULL;
6619 g_object_unref (ret);
6620 return SENSOR_I2C (ret);
6621}
6622
Norman James9e6acf92015-09-08 07:00:04 -05006623/**
6624 * object_peek_sensor_match: (skip)
6625 * @object: A #Object.
6626 *
6627 * Like object_get_sensor_match() but doesn't increase the reference count on the returned object.
6628 *
6629 * <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>
6630 *
6631 * Returns: (transfer none): A #SensorMatch or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
6632 */
6633SensorMatch *object_peek_sensor_match (Object *object)
6634{
6635 GDBusInterface *ret;
6636 ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorMatch");
6637 if (ret == NULL)
6638 return NULL;
6639 g_object_unref (ret);
6640 return SENSOR_MATCH (ret);
6641}
6642
Norman Jamese2765102015-08-19 22:00:55 -05006643
6644static void
6645object_notify (GDBusObject *object, GDBusInterface *interface)
6646{
6647 _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
6648 /* info can be NULL if the other end is using a D-Bus interface we don't know
6649 * anything about, for example old generated code in this process talking to
6650 * newer generated code in the other process. */
6651 if (info != NULL)
6652 g_object_notify (G_OBJECT (object), info->hyphen_name);
6653}
6654
6655/**
6656 * ObjectProxy:
6657 *
6658 * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
6659 */
6660
6661/**
6662 * ObjectProxyClass:
6663 * @parent_class: The parent class.
6664 *
6665 * Class structure for #ObjectProxy.
6666 */
6667
6668static void
6669object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
6670{
6671}
6672
6673static void
6674object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
6675{
6676 iface->interface_added = object_notify;
6677 iface->interface_removed = object_notify;
6678}
6679
6680
6681G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
6682 G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
6683 G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
6684
6685static void
6686object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
6687{
6688}
6689
6690static void
6691object_proxy_set_property (GObject *gobject,
6692 guint prop_id,
6693 const GValue *value G_GNUC_UNUSED,
6694 GParamSpec *pspec)
6695{
6696 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
6697}
6698
6699static void
6700object_proxy_get_property (GObject *gobject,
6701 guint prop_id,
6702 GValue *value,
6703 GParamSpec *pspec)
6704{
6705 ObjectProxy *object = OBJECT_PROXY (gobject);
6706 GDBusInterface *interface;
6707
6708 switch (prop_id)
6709 {
6710 case 1:
Norman James5d78b4d2015-09-05 13:34:34 -05006711 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorValue");
Norman Jamese2765102015-08-19 22:00:55 -05006712 g_value_take_object (value, interface);
6713 break;
6714
6715 case 2:
Norman James5d78b4d2015-09-05 13:34:34 -05006716 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorThreshold");
Norman Jamese2765102015-08-19 22:00:55 -05006717 g_value_take_object (value, interface);
6718 break;
6719
6720 case 3:
Norman James90baede2015-09-02 20:32:49 -05006721 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorI2c");
Norman Jamescc7ae122015-08-24 14:26:09 -05006722 g_value_take_object (value, interface);
6723 break;
6724
Norman James9e6acf92015-09-08 07:00:04 -05006725 case 4:
6726 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorMatch");
6727 g_value_take_object (value, interface);
6728 break;
6729
Norman Jamese2765102015-08-19 22:00:55 -05006730 default:
6731 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
6732 break;
6733 }
6734}
6735
6736static void
6737object_proxy_class_init (ObjectProxyClass *klass)
6738{
6739 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
6740
6741 gobject_class->set_property = object_proxy_set_property;
6742 gobject_class->get_property = object_proxy_get_property;
6743
Norman James5d78b4d2015-09-05 13:34:34 -05006744 g_object_class_override_property (gobject_class, 1, "sensor-value");
6745 g_object_class_override_property (gobject_class, 2, "sensor-threshold");
6746 g_object_class_override_property (gobject_class, 3, "sensor-i2c");
Norman James9e6acf92015-09-08 07:00:04 -05006747 g_object_class_override_property (gobject_class, 4, "sensor-match");
Norman Jamese2765102015-08-19 22:00:55 -05006748}
6749
6750/**
6751 * object_proxy_new:
6752 * @connection: A #GDBusConnection.
6753 * @object_path: An object path.
6754 *
6755 * Creates a new proxy object.
6756 *
6757 * Returns: (transfer full): The proxy object.
6758 */
6759ObjectProxy *
6760object_proxy_new (GDBusConnection *connection,
6761 const gchar *object_path)
6762{
6763 g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
6764 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
6765 return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
6766}
6767
6768/**
6769 * ObjectSkeleton:
6770 *
6771 * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
6772 */
6773
6774/**
6775 * ObjectSkeletonClass:
6776 * @parent_class: The parent class.
6777 *
6778 * Class structure for #ObjectSkeleton.
6779 */
6780
6781static void
6782object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
6783{
6784}
6785
6786
6787static void
6788object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
6789{
6790 iface->interface_added = object_notify;
6791 iface->interface_removed = object_notify;
6792}
6793
6794G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
6795 G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
6796 G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
6797
6798static void
6799object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
6800{
6801}
6802
6803static void
6804object_skeleton_set_property (GObject *gobject,
6805 guint prop_id,
6806 const GValue *value,
6807 GParamSpec *pspec)
6808{
6809 ObjectSkeleton *object = OBJECT_SKELETON (gobject);
6810 GDBusInterfaceSkeleton *interface;
6811
6812 switch (prop_id)
6813 {
6814 case 1:
6815 interface = g_value_get_object (value);
6816 if (interface != NULL)
6817 {
Norman James5d78b4d2015-09-05 13:34:34 -05006818 g_warn_if_fail (IS_SENSOR_VALUE (interface));
Norman Jamese2765102015-08-19 22:00:55 -05006819 g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
6820 }
6821 else
6822 {
Norman James5d78b4d2015-09-05 13:34:34 -05006823 g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorValue");
Norman Jamese2765102015-08-19 22:00:55 -05006824 }
6825 break;
6826
6827 case 2:
6828 interface = g_value_get_object (value);
6829 if (interface != NULL)
6830 {
Norman James5d78b4d2015-09-05 13:34:34 -05006831 g_warn_if_fail (IS_SENSOR_THRESHOLD (interface));
Norman Jamese2765102015-08-19 22:00:55 -05006832 g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
6833 }
6834 else
6835 {
Norman James5d78b4d2015-09-05 13:34:34 -05006836 g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorThreshold");
Norman Jamese2765102015-08-19 22:00:55 -05006837 }
6838 break;
6839
6840 case 3:
6841 interface = g_value_get_object (value);
6842 if (interface != NULL)
6843 {
Norman James90baede2015-09-02 20:32:49 -05006844 g_warn_if_fail (IS_SENSOR_I2C (interface));
Norman Jamescc7ae122015-08-24 14:26:09 -05006845 g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
6846 }
6847 else
6848 {
Norman James90baede2015-09-02 20:32:49 -05006849 g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorI2c");
Norman Jamescc7ae122015-08-24 14:26:09 -05006850 }
6851 break;
6852
Norman James9e6acf92015-09-08 07:00:04 -05006853 case 4:
6854 interface = g_value_get_object (value);
6855 if (interface != NULL)
6856 {
6857 g_warn_if_fail (IS_SENSOR_MATCH (interface));
6858 g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
6859 }
6860 else
6861 {
6862 g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorMatch");
6863 }
6864 break;
6865
Norman Jamese2765102015-08-19 22:00:55 -05006866 default:
6867 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
6868 break;
6869 }
6870}
6871
6872static void
6873object_skeleton_get_property (GObject *gobject,
6874 guint prop_id,
6875 GValue *value,
6876 GParamSpec *pspec)
6877{
6878 ObjectSkeleton *object = OBJECT_SKELETON (gobject);
6879 GDBusInterface *interface;
6880
6881 switch (prop_id)
6882 {
6883 case 1:
Norman James5d78b4d2015-09-05 13:34:34 -05006884 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorValue");
Norman Jamese2765102015-08-19 22:00:55 -05006885 g_value_take_object (value, interface);
6886 break;
6887
6888 case 2:
Norman James5d78b4d2015-09-05 13:34:34 -05006889 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorThreshold");
Norman Jamese2765102015-08-19 22:00:55 -05006890 g_value_take_object (value, interface);
6891 break;
6892
6893 case 3:
Norman James90baede2015-09-02 20:32:49 -05006894 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorI2c");
Norman Jamescc7ae122015-08-24 14:26:09 -05006895 g_value_take_object (value, interface);
6896 break;
6897
Norman James9e6acf92015-09-08 07:00:04 -05006898 case 4:
6899 interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorMatch");
6900 g_value_take_object (value, interface);
6901 break;
6902
Norman Jamese2765102015-08-19 22:00:55 -05006903 default:
6904 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
6905 break;
6906 }
6907}
6908
6909static void
6910object_skeleton_class_init (ObjectSkeletonClass *klass)
6911{
6912 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
6913
6914 gobject_class->set_property = object_skeleton_set_property;
6915 gobject_class->get_property = object_skeleton_get_property;
6916
Norman James5d78b4d2015-09-05 13:34:34 -05006917 g_object_class_override_property (gobject_class, 1, "sensor-value");
6918 g_object_class_override_property (gobject_class, 2, "sensor-threshold");
6919 g_object_class_override_property (gobject_class, 3, "sensor-i2c");
Norman James9e6acf92015-09-08 07:00:04 -05006920 g_object_class_override_property (gobject_class, 4, "sensor-match");
Norman Jamese2765102015-08-19 22:00:55 -05006921}
6922
6923/**
6924 * object_skeleton_new:
6925 * @object_path: An object path.
6926 *
6927 * Creates a new skeleton object.
6928 *
6929 * Returns: (transfer full): The skeleton object.
6930 */
6931ObjectSkeleton *
6932object_skeleton_new (const gchar *object_path)
6933{
6934 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
6935 return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
6936}
6937
6938/**
Norman James5d78b4d2015-09-05 13:34:34 -05006939 * object_skeleton_set_sensor_value:
Norman Jamese2765102015-08-19 22:00:55 -05006940 * @object: A #ObjectSkeleton.
Norman James5d78b4d2015-09-05 13:34:34 -05006941 * @interface_: (allow-none): A #SensorValue or %NULL to clear the interface.
Norman Jamese2765102015-08-19 22:00:55 -05006942 *
Norman James5d78b4d2015-09-05 13:34:34 -05006943 * Sets the #SensorValue instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorValue.top_of_page">org.openbmc.SensorValue</link> on @object.
Norman Jamese2765102015-08-19 22:00:55 -05006944 */
Norman James5d78b4d2015-09-05 13:34:34 -05006945void object_skeleton_set_sensor_value (ObjectSkeleton *object, SensorValue *interface_)
Norman Jamese2765102015-08-19 22:00:55 -05006946{
Norman James5d78b4d2015-09-05 13:34:34 -05006947 g_object_set (G_OBJECT (object), "sensor-value", interface_, NULL);
Norman Jamese2765102015-08-19 22:00:55 -05006948}
6949
6950/**
Norman James5d78b4d2015-09-05 13:34:34 -05006951 * object_skeleton_set_sensor_threshold:
Norman Jamese2765102015-08-19 22:00:55 -05006952 * @object: A #ObjectSkeleton.
Norman James5d78b4d2015-09-05 13:34:34 -05006953 * @interface_: (allow-none): A #SensorThreshold or %NULL to clear the interface.
Norman Jamese2765102015-08-19 22:00:55 -05006954 *
Norman James5d78b4d2015-09-05 13:34:34 -05006955 * Sets the #SensorThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorThreshold.top_of_page">org.openbmc.SensorThreshold</link> on @object.
Norman Jamese2765102015-08-19 22:00:55 -05006956 */
Norman James5d78b4d2015-09-05 13:34:34 -05006957void object_skeleton_set_sensor_threshold (ObjectSkeleton *object, SensorThreshold *interface_)
Norman Jamese2765102015-08-19 22:00:55 -05006958{
Norman James5d78b4d2015-09-05 13:34:34 -05006959 g_object_set (G_OBJECT (object), "sensor-threshold", interface_, NULL);
Norman Jamescc7ae122015-08-24 14:26:09 -05006960}
6961
Norman James90baede2015-09-02 20:32:49 -05006962/**
6963 * object_skeleton_set_sensor_i2c:
6964 * @object: A #ObjectSkeleton.
6965 * @interface_: (allow-none): A #SensorI2c or %NULL to clear the interface.
6966 *
6967 * Sets the #SensorI2c instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorI2c.top_of_page">org.openbmc.SensorI2c</link> on @object.
6968 */
6969void object_skeleton_set_sensor_i2c (ObjectSkeleton *object, SensorI2c *interface_)
6970{
6971 g_object_set (G_OBJECT (object), "sensor-i2c", interface_, NULL);
6972}
6973
Norman James9e6acf92015-09-08 07:00:04 -05006974/**
6975 * object_skeleton_set_sensor_match:
6976 * @object: A #ObjectSkeleton.
6977 * @interface_: (allow-none): A #SensorMatch or %NULL to clear the interface.
6978 *
6979 * Sets the #SensorMatch instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorMatch.top_of_page">org.openbmc.SensorMatch</link> on @object.
6980 */
6981void object_skeleton_set_sensor_match (ObjectSkeleton *object, SensorMatch *interface_)
6982{
6983 g_object_set (G_OBJECT (object), "sensor-match", interface_, NULL);
6984}
6985
Norman Jamese2765102015-08-19 22:00:55 -05006986
6987/* ------------------------------------------------------------------------
6988 * Code for ObjectManager client
6989 * ------------------------------------------------------------------------
6990 */
6991
6992/**
6993 * SECTION:ObjectManagerClient
6994 * @title: ObjectManagerClient
6995 * @short_description: Generated GDBusObjectManagerClient type
6996 *
6997 * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
6998 */
6999
7000/**
7001 * ObjectManagerClient:
7002 *
7003 * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
7004 */
7005
7006/**
7007 * ObjectManagerClientClass:
7008 * @parent_class: The parent class.
7009 *
7010 * Class structure for #ObjectManagerClient.
7011 */
7012
7013G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
7014
7015static void
7016object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
7017{
7018}
7019
7020static void
7021object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
7022{
7023}
7024
7025/**
7026 * object_manager_client_get_proxy_type:
7027 * @manager: A #GDBusObjectManagerClient.
7028 * @object_path: The object path of the remote object (unused).
7029 * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
7030 * @user_data: User data (unused).
7031 *
7032 * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
7033 *
7034 * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
7035 */
7036GType
7037object_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)
7038{
7039 static gsize once_init_value = 0;
7040 static GHashTable *lookup_hash;
7041 GType ret;
7042
7043 if (interface_name == NULL)
7044 return TYPE_OBJECT_PROXY;
7045 if (g_once_init_enter (&once_init_value))
7046 {
7047 lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
Norman James5d78b4d2015-09-05 13:34:34 -05007048 g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorValue", GSIZE_TO_POINTER (TYPE_SENSOR_VALUE_PROXY));
7049 g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorThreshold", GSIZE_TO_POINTER (TYPE_SENSOR_THRESHOLD_PROXY));
Norman James90baede2015-09-02 20:32:49 -05007050 g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorI2c", GSIZE_TO_POINTER (TYPE_SENSOR_I2C_PROXY));
Norman James9e6acf92015-09-08 07:00:04 -05007051 g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorMatch", GSIZE_TO_POINTER (TYPE_SENSOR_MATCH_PROXY));
Norman Jamese2765102015-08-19 22:00:55 -05007052 g_once_init_leave (&once_init_value, 1);
7053 }
7054 ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
7055 if (ret == (GType) 0)
7056 ret = G_TYPE_DBUS_PROXY;
7057 return ret;
7058}
7059
7060/**
7061 * object_manager_client_new:
7062 * @connection: A #GDBusConnection.
7063 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
7064 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
7065 * @object_path: An object path.
7066 * @cancellable: (allow-none): A #GCancellable or %NULL.
7067 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
7068 * @user_data: User data to pass to @callback.
7069 *
7070 * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
7071 *
7072 * 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.
7073 * You can then call object_manager_client_new_finish() to get the result of the operation.
7074 *
7075 * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
7076 */
7077void
7078object_manager_client_new (
7079 GDBusConnection *connection,
7080 GDBusObjectManagerClientFlags flags,
7081 const gchar *name,
7082 const gchar *object_path,
7083 GCancellable *cancellable,
7084 GAsyncReadyCallback callback,
7085 gpointer user_data)
7086{
7087 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);
7088}
7089
7090/**
7091 * object_manager_client_new_finish:
7092 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
7093 * @error: Return location for error or %NULL
7094 *
7095 * Finishes an operation started with object_manager_client_new().
7096 *
7097 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
7098 */
7099GDBusObjectManager *
7100object_manager_client_new_finish (
7101 GAsyncResult *res,
7102 GError **error)
7103{
7104 GObject *ret;
7105 GObject *source_object;
7106 source_object = g_async_result_get_source_object (res);
7107 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
7108 g_object_unref (source_object);
7109 if (ret != NULL)
7110 return G_DBUS_OBJECT_MANAGER (ret);
7111 else
7112 return NULL;
7113}
7114
7115/**
7116 * object_manager_client_new_sync:
7117 * @connection: A #GDBusConnection.
7118 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
7119 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
7120 * @object_path: An object path.
7121 * @cancellable: (allow-none): A #GCancellable or %NULL.
7122 * @error: Return location for error or %NULL
7123 *
7124 * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
7125 *
7126 * The calling thread is blocked until a reply is received.
7127 *
7128 * See object_manager_client_new() for the asynchronous version of this constructor.
7129 *
7130 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
7131 */
7132GDBusObjectManager *
7133object_manager_client_new_sync (
7134 GDBusConnection *connection,
7135 GDBusObjectManagerClientFlags flags,
7136 const gchar *name,
7137 const gchar *object_path,
7138 GCancellable *cancellable,
7139 GError **error)
7140{
7141 GInitable *ret;
7142 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);
7143 if (ret != NULL)
7144 return G_DBUS_OBJECT_MANAGER (ret);
7145 else
7146 return NULL;
7147}
7148
7149
7150/**
7151 * object_manager_client_new_for_bus:
7152 * @bus_type: A #GBusType.
7153 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
7154 * @name: A bus name (well-known or unique).
7155 * @object_path: An object path.
7156 * @cancellable: (allow-none): A #GCancellable or %NULL.
7157 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
7158 * @user_data: User data to pass to @callback.
7159 *
7160 * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
7161 *
7162 * 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.
7163 * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
7164 *
7165 * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
7166 */
7167void
7168object_manager_client_new_for_bus (
7169 GBusType bus_type,
7170 GDBusObjectManagerClientFlags flags,
7171 const gchar *name,
7172 const gchar *object_path,
7173 GCancellable *cancellable,
7174 GAsyncReadyCallback callback,
7175 gpointer user_data)
7176{
7177 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);
7178}
7179
7180/**
7181 * object_manager_client_new_for_bus_finish:
7182 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
7183 * @error: Return location for error or %NULL
7184 *
7185 * Finishes an operation started with object_manager_client_new_for_bus().
7186 *
7187 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
7188 */
7189GDBusObjectManager *
7190object_manager_client_new_for_bus_finish (
7191 GAsyncResult *res,
7192 GError **error)
7193{
7194 GObject *ret;
7195 GObject *source_object;
7196 source_object = g_async_result_get_source_object (res);
7197 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
7198 g_object_unref (source_object);
7199 if (ret != NULL)
7200 return G_DBUS_OBJECT_MANAGER (ret);
7201 else
7202 return NULL;
7203}
7204
7205/**
7206 * object_manager_client_new_for_bus_sync:
7207 * @bus_type: A #GBusType.
7208 * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
7209 * @name: A bus name (well-known or unique).
7210 * @object_path: An object path.
7211 * @cancellable: (allow-none): A #GCancellable or %NULL.
7212 * @error: Return location for error or %NULL
7213 *
7214 * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
7215 *
7216 * The calling thread is blocked until a reply is received.
7217 *
7218 * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
7219 *
7220 * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
7221 */
7222GDBusObjectManager *
7223object_manager_client_new_for_bus_sync (
7224 GBusType bus_type,
7225 GDBusObjectManagerClientFlags flags,
7226 const gchar *name,
7227 const gchar *object_path,
7228 GCancellable *cancellable,
7229 GError **error)
7230{
7231 GInitable *ret;
7232 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);
7233 if (ret != NULL)
7234 return G_DBUS_OBJECT_MANAGER (ret);
7235 else
7236 return NULL;
7237}
7238
7239