blob: b12979a820b16e17c14e0171524fb87fdcba83ce [file] [log] [blame]
Norman James471ab592015-08-30 22:29:40 -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/eventlog.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/* ------------------------------------------------------------------------
152 * Code for interface org.openbmc.EventLog
153 * ------------------------------------------------------------------------
154 */
155
156/**
157 * SECTION:EventLog
158 * @title: EventLog
159 * @short_description: Generated C code for the org.openbmc.EventLog D-Bus interface
160 *
161 * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> D-Bus interface in C.
162 */
163
164/* ---- Introspection data for org.openbmc.EventLog ---- */
165
166static const _ExtendedGDBusArgInfo _event_log_method_info_get_message_OUT_ARG_message =
167{
168 {
169 -1,
170 (gchar *) "message",
171 (gchar *) "a{ss}",
172 NULL
173 },
174 FALSE
175};
176
177static const _ExtendedGDBusArgInfo * const _event_log_method_info_get_message_OUT_ARG_pointers[] =
178{
179 &_event_log_method_info_get_message_OUT_ARG_message,
180 NULL
181};
182
183static const _ExtendedGDBusMethodInfo _event_log_method_info_get_message =
184{
185 {
186 -1,
187 (gchar *) "getMessage",
188 NULL,
189 (GDBusArgInfo **) &_event_log_method_info_get_message_OUT_ARG_pointers,
190 NULL
191 },
192 "handle-get-message",
193 FALSE
194};
195
196static const _ExtendedGDBusMethodInfo * const _event_log_method_info_pointers[] =
197{
198 &_event_log_method_info_get_message,
199 NULL
200};
201
202static const _ExtendedGDBusArgInfo _event_log_signal_info_event_ARG_message =
203{
204 {
205 -1,
206 (gchar *) "message",
207 (gchar *) "a{ss}",
208 NULL
209 },
210 FALSE
211};
212
213static const _ExtendedGDBusArgInfo * const _event_log_signal_info_event_ARG_pointers[] =
214{
215 &_event_log_signal_info_event_ARG_message,
216 NULL
217};
218
219static const _ExtendedGDBusSignalInfo _event_log_signal_info_event =
220{
221 {
222 -1,
223 (gchar *) "Event",
224 (GDBusArgInfo **) &_event_log_signal_info_event_ARG_pointers,
225 NULL
226 },
227 "event"
228};
229
230static const _ExtendedGDBusSignalInfo * const _event_log_signal_info_pointers[] =
231{
232 &_event_log_signal_info_event,
233 NULL
234};
235
236static const _ExtendedGDBusPropertyInfo _event_log_property_info_message =
237{
238 {
239 -1,
240 (gchar *) "message",
241 (gchar *) "a{ss}",
242 G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
243 NULL
244 },
245 "message",
246 FALSE
247};
248
249static const _ExtendedGDBusPropertyInfo * const _event_log_property_info_pointers[] =
250{
251 &_event_log_property_info_message,
252 NULL
253};
254
255static const _ExtendedGDBusInterfaceInfo _event_log_interface_info =
256{
257 {
258 -1,
259 (gchar *) "org.openbmc.EventLog",
260 (GDBusMethodInfo **) &_event_log_method_info_pointers,
261 (GDBusSignalInfo **) &_event_log_signal_info_pointers,
262 (GDBusPropertyInfo **) &_event_log_property_info_pointers,
263 NULL
264 },
265 "event-log",
266};
267
268
269/**
270 * event_log_interface_info:
271 *
272 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link> D-Bus interface.
273 *
274 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
275 */
276GDBusInterfaceInfo *
277event_log_interface_info (void)
278{
279 return (GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct;
280}
281
282/**
283 * event_log_override_properties:
284 * @klass: The class structure for a #GObject<!-- -->-derived class.
285 * @property_id_begin: The property id to assign to the first overridden property.
286 *
287 * Overrides all #GObject properties in the #EventLog interface for a concrete class.
288 * The properties are overridden in the order they are defined.
289 *
290 * Returns: The last property id.
291 */
292guint
293event_log_override_properties (GObjectClass *klass, guint property_id_begin)
294{
295 g_object_class_override_property (klass, property_id_begin++, "message");
296 return property_id_begin - 1;
297}
298
299
300
301/**
302 * EventLog:
303 *
304 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>.
305 */
306
307/**
308 * EventLogIface:
309 * @parent_iface: The parent interface.
310 * @handle_get_message: Handler for the #EventLog::handle-get-message signal.
311 * @get_message: Getter for the #EventLog:message property.
312 * @event: Handler for the #EventLog::event signal.
313 *
314 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>.
315 */
316
317typedef EventLogIface EventLogInterface;
318G_DEFINE_INTERFACE (EventLog, event_log, G_TYPE_OBJECT);
319
320static void
321event_log_default_init (EventLogIface *iface)
322{
323 /* GObject signals for incoming D-Bus method calls: */
324 /**
325 * EventLog::handle-get-message:
326 * @object: A #EventLog.
327 * @invocation: A #GDBusMethodInvocation.
328 *
329 * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-EventLog.getMessage">getMessage()</link> D-Bus method.
330 *
331 * 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 event_log_complete_get_message() 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.
332 *
333 * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
334 */
335 g_signal_new ("handle-get-message",
336 G_TYPE_FROM_INTERFACE (iface),
337 G_SIGNAL_RUN_LAST,
338 G_STRUCT_OFFSET (EventLogIface, handle_get_message),
339 g_signal_accumulator_true_handled,
340 NULL,
341 g_cclosure_marshal_generic,
342 G_TYPE_BOOLEAN,
343 1,
344 G_TYPE_DBUS_METHOD_INVOCATION);
345
346 /* GObject signals for received D-Bus signals: */
347 /**
348 * EventLog::event:
349 * @object: A #EventLog.
350 * @arg_message: Argument.
351 *
352 * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-EventLog.Event">"Event"</link> is received.
353 *
354 * 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.
355 */
356 g_signal_new ("event",
357 G_TYPE_FROM_INTERFACE (iface),
358 G_SIGNAL_RUN_LAST,
359 G_STRUCT_OFFSET (EventLogIface, event),
360 NULL,
361 NULL,
362 g_cclosure_marshal_generic,
363 G_TYPE_NONE,
364 1, G_TYPE_VARIANT);
365
366 /* GObject properties for D-Bus properties: */
367 /**
368 * EventLog:message:
369 *
370 * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-EventLog.message">"message"</link>.
371 *
372 * 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.
373 */
374 g_object_interface_install_property (iface,
375 g_param_spec_variant ("message", "message", "message", G_VARIANT_TYPE ("a{ss}"), NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
376}
377
378/**
379 * event_log_get_message: (skip)
380 * @object: A #EventLog.
381 *
382 * Gets the value of the <link linkend="gdbus-property-org-openbmc-EventLog.message">"message"</link> D-Bus property.
383 *
384 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
385 *
386 * <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 event_log_dup_message() if on another thread.</warning>
387 *
388 * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
389 */
390GVariant *
391event_log_get_message (EventLog *object)
392{
393 return EVENT_LOG_GET_IFACE (object)->get_message (object);
394}
395
396/**
397 * event_log_dup_message: (skip)
398 * @object: A #EventLog.
399 *
400 * Gets a copy of the <link linkend="gdbus-property-org-openbmc-EventLog.message">"message"</link> D-Bus property.
401 *
402 * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
403 *
404 * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_variant_unref().
405 */
406GVariant *
407event_log_dup_message (EventLog *object)
408{
409 GVariant *value;
410 g_object_get (G_OBJECT (object), "message", &value, NULL);
411 return value;
412}
413
414/**
415 * event_log_set_message: (skip)
416 * @object: A #EventLog.
417 * @value: The value to set.
418 *
419 * Sets the <link linkend="gdbus-property-org-openbmc-EventLog.message">"message"</link> D-Bus property to @value.
420 *
421 * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
422 */
423void
424event_log_set_message (EventLog *object, GVariant *value)
425{
426 g_object_set (G_OBJECT (object), "message", value, NULL);
427}
428
429/**
430 * event_log_emit_event:
431 * @object: A #EventLog.
432 * @arg_message: Argument to pass with the signal.
433 *
434 * Emits the <link linkend="gdbus-signal-org-openbmc-EventLog.Event">"Event"</link> D-Bus signal.
435 */
436void
437event_log_emit_event (
438 EventLog *object,
439 GVariant *arg_message)
440{
441 g_signal_emit_by_name (object, "event", arg_message);
442}
443
444/**
445 * event_log_call_get_message:
446 * @proxy: A #EventLogProxy.
447 * @cancellable: (allow-none): A #GCancellable or %NULL.
448 * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
449 * @user_data: User data to pass to @callback.
450 *
451 * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-EventLog.getMessage">getMessage()</link> D-Bus method on @proxy.
452 * 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.
453 * You can then call event_log_call_get_message_finish() to get the result of the operation.
454 *
455 * See event_log_call_get_message_sync() for the synchronous, blocking version of this method.
456 */
457void
458event_log_call_get_message (
459 EventLog *proxy,
460 GCancellable *cancellable,
461 GAsyncReadyCallback callback,
462 gpointer user_data)
463{
464 g_dbus_proxy_call (G_DBUS_PROXY (proxy),
465 "getMessage",
466 g_variant_new ("()"),
467 G_DBUS_CALL_FLAGS_NONE,
468 -1,
469 cancellable,
470 callback,
471 user_data);
472}
473
474/**
475 * event_log_call_get_message_finish:
476 * @proxy: A #EventLogProxy.
477 * @out_message: (out): Return location for return parameter or %NULL to ignore.
478 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to event_log_call_get_message().
479 * @error: Return location for error or %NULL.
480 *
481 * Finishes an operation started with event_log_call_get_message().
482 *
483 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
484 */
485gboolean
486event_log_call_get_message_finish (
487 EventLog *proxy,
488 GVariant **out_message,
489 GAsyncResult *res,
490 GError **error)
491{
492 GVariant *_ret;
493 _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
494 if (_ret == NULL)
495 goto _out;
496 g_variant_get (_ret,
497 "(@a{ss})",
498 out_message);
499 g_variant_unref (_ret);
500_out:
501 return _ret != NULL;
502}
503
504/**
505 * event_log_call_get_message_sync:
506 * @proxy: A #EventLogProxy.
507 * @out_message: (out): Return location for return parameter or %NULL to ignore.
508 * @cancellable: (allow-none): A #GCancellable or %NULL.
509 * @error: Return location for error or %NULL.
510 *
511 * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-EventLog.getMessage">getMessage()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
512 *
513 * See event_log_call_get_message() for the asynchronous version of this method.
514 *
515 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
516 */
517gboolean
518event_log_call_get_message_sync (
519 EventLog *proxy,
520 GVariant **out_message,
521 GCancellable *cancellable,
522 GError **error)
523{
524 GVariant *_ret;
525 _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
526 "getMessage",
527 g_variant_new ("()"),
528 G_DBUS_CALL_FLAGS_NONE,
529 -1,
530 cancellable,
531 error);
532 if (_ret == NULL)
533 goto _out;
534 g_variant_get (_ret,
535 "(@a{ss})",
536 out_message);
537 g_variant_unref (_ret);
538_out:
539 return _ret != NULL;
540}
541
542/**
543 * event_log_complete_get_message:
544 * @object: A #EventLog.
545 * @invocation: (transfer full): A #GDBusMethodInvocation.
546 * @message: Parameter to return.
547 *
548 * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-EventLog.getMessage">getMessage()</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.
549 *
550 * This method will free @invocation, you cannot use it afterwards.
551 */
552void
553event_log_complete_get_message (
554 EventLog *object,
555 GDBusMethodInvocation *invocation,
556 GVariant *message)
557{
558 g_dbus_method_invocation_return_value (invocation,
559 g_variant_new ("(@a{ss})",
560 message));
561}
562
563/* ------------------------------------------------------------------------ */
564
565/**
566 * EventLogProxy:
567 *
568 * The #EventLogProxy structure contains only private data and should only be accessed using the provided API.
569 */
570
571/**
572 * EventLogProxyClass:
573 * @parent_class: The parent class.
574 *
575 * Class structure for #EventLogProxy.
576 */
577
578struct _EventLogProxyPrivate
579{
580 GData *qdata;
581};
582
583static void event_log_proxy_iface_init (EventLogIface *iface);
584
585#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
586G_DEFINE_TYPE_WITH_CODE (EventLogProxy, event_log_proxy, G_TYPE_DBUS_PROXY,
587 G_ADD_PRIVATE (EventLogProxy)
588 G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_proxy_iface_init));
589
590#else
591G_DEFINE_TYPE_WITH_CODE (EventLogProxy, event_log_proxy, G_TYPE_DBUS_PROXY,
592 G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_proxy_iface_init));
593
594#endif
595static void
596event_log_proxy_finalize (GObject *object)
597{
598 EventLogProxy *proxy = EVENT_LOG_PROXY (object);
599 g_datalist_clear (&proxy->priv->qdata);
600 G_OBJECT_CLASS (event_log_proxy_parent_class)->finalize (object);
601}
602
603static void
604event_log_proxy_get_property (GObject *object,
605 guint prop_id,
606 GValue *value,
607 GParamSpec *pspec G_GNUC_UNUSED)
608{
609 const _ExtendedGDBusPropertyInfo *info;
610 GVariant *variant;
611 g_assert (prop_id != 0 && prop_id - 1 < 1);
612 info = _event_log_property_info_pointers[prop_id - 1];
613 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
614 if (info->use_gvariant)
615 {
616 g_value_set_variant (value, variant);
617 }
618 else
619 {
620 if (variant != NULL)
621 g_dbus_gvariant_to_gvalue (variant, value);
622 }
623 if (variant != NULL)
624 g_variant_unref (variant);
625}
626
627static void
628event_log_proxy_set_property_cb (GDBusProxy *proxy,
629 GAsyncResult *res,
630 gpointer user_data)
631{
632 const _ExtendedGDBusPropertyInfo *info = user_data;
633 GError *error;
634 GVariant *_ret;
635 error = NULL;
636 _ret = g_dbus_proxy_call_finish (proxy, res, &error);
637 if (!_ret)
638 {
639 g_warning ("Error setting property '%s' on interface org.openbmc.EventLog: %s (%s, %d)",
640 info->parent_struct.name,
641 error->message, g_quark_to_string (error->domain), error->code);
642 g_error_free (error);
643 }
644 else
645 {
646 g_variant_unref (_ret);
647 }
648}
649
650static void
651event_log_proxy_set_property (GObject *object,
652 guint prop_id,
653 const GValue *value,
654 GParamSpec *pspec G_GNUC_UNUSED)
655{
656 const _ExtendedGDBusPropertyInfo *info;
657 GVariant *variant;
658 g_assert (prop_id != 0 && prop_id - 1 < 1);
659 info = _event_log_property_info_pointers[prop_id - 1];
660 variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
661 g_dbus_proxy_call (G_DBUS_PROXY (object),
662 "org.freedesktop.DBus.Properties.Set",
663 g_variant_new ("(ssv)", "org.openbmc.EventLog", info->parent_struct.name, variant),
664 G_DBUS_CALL_FLAGS_NONE,
665 -1,
666 NULL, (GAsyncReadyCallback) event_log_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
667 g_variant_unref (variant);
668}
669
670static void
671event_log_proxy_g_signal (GDBusProxy *proxy,
672 const gchar *sender_name G_GNUC_UNUSED,
673 const gchar *signal_name,
674 GVariant *parameters)
675{
676 _ExtendedGDBusSignalInfo *info;
677 GVariantIter iter;
678 GVariant *child;
679 GValue *paramv;
680 guint num_params;
681 guint n;
682 guint signal_id;
683 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, signal_name);
684 if (info == NULL)
685 return;
686 num_params = g_variant_n_children (parameters);
687 paramv = g_new0 (GValue, num_params + 1);
688 g_value_init (&paramv[0], TYPE_EVENT_LOG);
689 g_value_set_object (&paramv[0], proxy);
690 g_variant_iter_init (&iter, parameters);
691 n = 1;
692 while ((child = g_variant_iter_next_value (&iter)) != NULL)
693 {
694 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
695 if (arg_info->use_gvariant)
696 {
697 g_value_init (&paramv[n], G_TYPE_VARIANT);
698 g_value_set_variant (&paramv[n], child);
699 n++;
700 }
701 else
702 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
703 g_variant_unref (child);
704 }
705 signal_id = g_signal_lookup (info->signal_name, TYPE_EVENT_LOG);
706 g_signal_emitv (paramv, signal_id, 0, NULL);
707 for (n = 0; n < num_params + 1; n++)
708 g_value_unset (&paramv[n]);
709 g_free (paramv);
710}
711
712static void
713event_log_proxy_g_properties_changed (GDBusProxy *_proxy,
714 GVariant *changed_properties,
715 const gchar *const *invalidated_properties)
716{
717 EventLogProxy *proxy = EVENT_LOG_PROXY (_proxy);
718 guint n;
719 const gchar *key;
720 GVariantIter *iter;
721 _ExtendedGDBusPropertyInfo *info;
722 g_variant_get (changed_properties, "a{sv}", &iter);
723 while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
724 {
725 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, key);
726 g_datalist_remove_data (&proxy->priv->qdata, key);
727 if (info != NULL)
728 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
729 }
730 g_variant_iter_free (iter);
731 for (n = 0; invalidated_properties[n] != NULL; n++)
732 {
733 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, invalidated_properties[n]);
734 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
735 if (info != NULL)
736 g_object_notify (G_OBJECT (proxy), info->hyphen_name);
737 }
738}
739
740static GVariant *
741event_log_proxy_get_message (EventLog *object)
742{
743 EventLogProxy *proxy = EVENT_LOG_PROXY (object);
744 GVariant *variant;
745 GVariant *value = NULL;
746 variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "message");
747 value = variant;
748 if (variant != NULL)
749 g_variant_unref (variant);
750 return value;
751}
752
753static void
754event_log_proxy_init (EventLogProxy *proxy)
755{
756#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
757 proxy->priv = event_log_proxy_get_instance_private (proxy);
758#else
759 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_EVENT_LOG_PROXY, EventLogProxyPrivate);
760#endif
761
762 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), event_log_interface_info ());
763}
764
765static void
766event_log_proxy_class_init (EventLogProxyClass *klass)
767{
768 GObjectClass *gobject_class;
769 GDBusProxyClass *proxy_class;
770
771 gobject_class = G_OBJECT_CLASS (klass);
772 gobject_class->finalize = event_log_proxy_finalize;
773 gobject_class->get_property = event_log_proxy_get_property;
774 gobject_class->set_property = event_log_proxy_set_property;
775
776 proxy_class = G_DBUS_PROXY_CLASS (klass);
777 proxy_class->g_signal = event_log_proxy_g_signal;
778 proxy_class->g_properties_changed = event_log_proxy_g_properties_changed;
779
780 event_log_override_properties (gobject_class, 1);
781
782#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
783 g_type_class_add_private (klass, sizeof (EventLogProxyPrivate));
784#endif
785}
786
787static void
788event_log_proxy_iface_init (EventLogIface *iface)
789{
790 iface->get_message = event_log_proxy_get_message;
791}
792
793/**
794 * event_log_proxy_new:
795 * @connection: A #GDBusConnection.
796 * @flags: Flags from the #GDBusProxyFlags enumeration.
797 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
798 * @object_path: An object path.
799 * @cancellable: (allow-none): A #GCancellable or %NULL.
800 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
801 * @user_data: User data to pass to @callback.
802 *
803 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. See g_dbus_proxy_new() for more details.
804 *
805 * 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.
806 * You can then call event_log_proxy_new_finish() to get the result of the operation.
807 *
808 * See event_log_proxy_new_sync() for the synchronous, blocking version of this constructor.
809 */
810void
811event_log_proxy_new (
812 GDBusConnection *connection,
813 GDBusProxyFlags flags,
814 const gchar *name,
815 const gchar *object_path,
816 GCancellable *cancellable,
817 GAsyncReadyCallback callback,
818 gpointer user_data)
819{
820 g_async_initable_new_async (TYPE_EVENT_LOG_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL);
821}
822
823/**
824 * event_log_proxy_new_finish:
825 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to event_log_proxy_new().
826 * @error: Return location for error or %NULL
827 *
828 * Finishes an operation started with event_log_proxy_new().
829 *
830 * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set.
831 */
832EventLog *
833event_log_proxy_new_finish (
834 GAsyncResult *res,
835 GError **error)
836{
837 GObject *ret;
838 GObject *source_object;
839 source_object = g_async_result_get_source_object (res);
840 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
841 g_object_unref (source_object);
842 if (ret != NULL)
843 return EVENT_LOG (ret);
844 else
845 return NULL;
846}
847
848/**
849 * event_log_proxy_new_sync:
850 * @connection: A #GDBusConnection.
851 * @flags: Flags from the #GDBusProxyFlags enumeration.
852 * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
853 * @object_path: An object path.
854 * @cancellable: (allow-none): A #GCancellable or %NULL.
855 * @error: Return location for error or %NULL
856 *
857 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>. See g_dbus_proxy_new_sync() for more details.
858 *
859 * The calling thread is blocked until a reply is received.
860 *
861 * See event_log_proxy_new() for the asynchronous version of this constructor.
862 *
863 * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set.
864 */
865EventLog *
866event_log_proxy_new_sync (
867 GDBusConnection *connection,
868 GDBusProxyFlags flags,
869 const gchar *name,
870 const gchar *object_path,
871 GCancellable *cancellable,
872 GError **error)
873{
874 GInitable *ret;
875 ret = g_initable_new (TYPE_EVENT_LOG_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL);
876 if (ret != NULL)
877 return EVENT_LOG (ret);
878 else
879 return NULL;
880}
881
882
883/**
884 * event_log_proxy_new_for_bus:
885 * @bus_type: A #GBusType.
886 * @flags: Flags from the #GDBusProxyFlags enumeration.
887 * @name: A bus name (well-known or unique).
888 * @object_path: An object path.
889 * @cancellable: (allow-none): A #GCancellable or %NULL.
890 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
891 * @user_data: User data to pass to @callback.
892 *
893 * Like event_log_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
894 *
895 * 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.
896 * You can then call event_log_proxy_new_for_bus_finish() to get the result of the operation.
897 *
898 * See event_log_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
899 */
900void
901event_log_proxy_new_for_bus (
902 GBusType bus_type,
903 GDBusProxyFlags flags,
904 const gchar *name,
905 const gchar *object_path,
906 GCancellable *cancellable,
907 GAsyncReadyCallback callback,
908 gpointer user_data)
909{
910 g_async_initable_new_async (TYPE_EVENT_LOG_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL);
911}
912
913/**
914 * event_log_proxy_new_for_bus_finish:
915 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to event_log_proxy_new_for_bus().
916 * @error: Return location for error or %NULL
917 *
918 * Finishes an operation started with event_log_proxy_new_for_bus().
919 *
920 * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set.
921 */
922EventLog *
923event_log_proxy_new_for_bus_finish (
924 GAsyncResult *res,
925 GError **error)
926{
927 GObject *ret;
928 GObject *source_object;
929 source_object = g_async_result_get_source_object (res);
930 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
931 g_object_unref (source_object);
932 if (ret != NULL)
933 return EVENT_LOG (ret);
934 else
935 return NULL;
936}
937
938/**
939 * event_log_proxy_new_for_bus_sync:
940 * @bus_type: A #GBusType.
941 * @flags: Flags from the #GDBusProxyFlags enumeration.
942 * @name: A bus name (well-known or unique).
943 * @object_path: An object path.
944 * @cancellable: (allow-none): A #GCancellable or %NULL.
945 * @error: Return location for error or %NULL
946 *
947 * Like event_log_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
948 *
949 * The calling thread is blocked until a reply is received.
950 *
951 * See event_log_proxy_new_for_bus() for the asynchronous version of this constructor.
952 *
953 * Returns: (transfer full) (type EventLogProxy): The constructed proxy object or %NULL if @error is set.
954 */
955EventLog *
956event_log_proxy_new_for_bus_sync (
957 GBusType bus_type,
958 GDBusProxyFlags flags,
959 const gchar *name,
960 const gchar *object_path,
961 GCancellable *cancellable,
962 GError **error)
963{
964 GInitable *ret;
965 ret = g_initable_new (TYPE_EVENT_LOG_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.EventLog", NULL);
966 if (ret != NULL)
967 return EVENT_LOG (ret);
968 else
969 return NULL;
970}
971
972
973/* ------------------------------------------------------------------------ */
974
975/**
976 * EventLogSkeleton:
977 *
978 * The #EventLogSkeleton structure contains only private data and should only be accessed using the provided API.
979 */
980
981/**
982 * EventLogSkeletonClass:
983 * @parent_class: The parent class.
984 *
985 * Class structure for #EventLogSkeleton.
986 */
987
988struct _EventLogSkeletonPrivate
989{
990 GValue *properties;
991 GList *changed_properties;
992 GSource *changed_properties_idle_source;
993 GMainContext *context;
994 GMutex lock;
995};
996
997static void
998_event_log_skeleton_handle_method_call (
999 GDBusConnection *connection G_GNUC_UNUSED,
1000 const gchar *sender G_GNUC_UNUSED,
1001 const gchar *object_path G_GNUC_UNUSED,
1002 const gchar *interface_name,
1003 const gchar *method_name,
1004 GVariant *parameters,
1005 GDBusMethodInvocation *invocation,
1006 gpointer user_data)
1007{
1008 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data);
1009 _ExtendedGDBusMethodInfo *info;
1010 GVariantIter iter;
1011 GVariant *child;
1012 GValue *paramv;
1013 guint num_params;
1014 guint num_extra;
1015 guint n;
1016 guint signal_id;
1017 GValue return_value = G_VALUE_INIT;
1018 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
1019 g_assert (info != NULL);
1020 num_params = g_variant_n_children (parameters);
1021 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
1022 n = 0;
1023 g_value_init (&paramv[n], TYPE_EVENT_LOG);
1024 g_value_set_object (&paramv[n++], skeleton);
1025 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
1026 g_value_set_object (&paramv[n++], invocation);
1027 if (info->pass_fdlist)
1028 {
1029#ifdef G_OS_UNIX
1030 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
1031 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
1032#else
1033 g_assert_not_reached ();
1034#endif
1035 }
1036 g_variant_iter_init (&iter, parameters);
1037 while ((child = g_variant_iter_next_value (&iter)) != NULL)
1038 {
1039 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
1040 if (arg_info->use_gvariant)
1041 {
1042 g_value_init (&paramv[n], G_TYPE_VARIANT);
1043 g_value_set_variant (&paramv[n], child);
1044 n++;
1045 }
1046 else
1047 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
1048 g_variant_unref (child);
1049 }
1050 signal_id = g_signal_lookup (info->signal_name, TYPE_EVENT_LOG);
1051 g_value_init (&return_value, G_TYPE_BOOLEAN);
1052 g_signal_emitv (paramv, signal_id, 0, &return_value);
1053 if (!g_value_get_boolean (&return_value))
1054 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);
1055 g_value_unset (&return_value);
1056 for (n = 0; n < num_params + num_extra; n++)
1057 g_value_unset (&paramv[n]);
1058 g_free (paramv);
1059}
1060
1061static GVariant *
1062_event_log_skeleton_handle_get_property (
1063 GDBusConnection *connection G_GNUC_UNUSED,
1064 const gchar *sender G_GNUC_UNUSED,
1065 const gchar *object_path G_GNUC_UNUSED,
1066 const gchar *interface_name G_GNUC_UNUSED,
1067 const gchar *property_name,
1068 GError **error,
1069 gpointer user_data)
1070{
1071 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data);
1072 GValue value = G_VALUE_INIT;
1073 GParamSpec *pspec;
1074 _ExtendedGDBusPropertyInfo *info;
1075 GVariant *ret;
1076 ret = NULL;
1077 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, property_name);
1078 g_assert (info != NULL);
1079 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1080 if (pspec == NULL)
1081 {
1082 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1083 }
1084 else
1085 {
1086 g_value_init (&value, pspec->value_type);
1087 g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1088 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
1089 g_value_unset (&value);
1090 }
1091 return ret;
1092}
1093
1094static gboolean
1095_event_log_skeleton_handle_set_property (
1096 GDBusConnection *connection G_GNUC_UNUSED,
1097 const gchar *sender G_GNUC_UNUSED,
1098 const gchar *object_path G_GNUC_UNUSED,
1099 const gchar *interface_name G_GNUC_UNUSED,
1100 const gchar *property_name,
1101 GVariant *variant,
1102 GError **error,
1103 gpointer user_data)
1104{
1105 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data);
1106 GValue value = G_VALUE_INIT;
1107 GParamSpec *pspec;
1108 _ExtendedGDBusPropertyInfo *info;
1109 gboolean ret;
1110 ret = FALSE;
1111 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_event_log_interface_info.parent_struct, property_name);
1112 g_assert (info != NULL);
1113 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
1114 if (pspec == NULL)
1115 {
1116 g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
1117 }
1118 else
1119 {
1120 if (info->use_gvariant)
1121 g_value_set_variant (&value, variant);
1122 else
1123 g_dbus_gvariant_to_gvalue (variant, &value);
1124 g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
1125 g_value_unset (&value);
1126 ret = TRUE;
1127 }
1128 return ret;
1129}
1130
1131static const GDBusInterfaceVTable _event_log_skeleton_vtable =
1132{
1133 _event_log_skeleton_handle_method_call,
1134 _event_log_skeleton_handle_get_property,
1135 _event_log_skeleton_handle_set_property,
1136 {NULL}
1137};
1138
1139static GDBusInterfaceInfo *
1140event_log_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1141{
1142 return event_log_interface_info ();
1143}
1144
1145static GDBusInterfaceVTable *
1146event_log_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
1147{
1148 return (GDBusInterfaceVTable *) &_event_log_skeleton_vtable;
1149}
1150
1151static GVariant *
1152event_log_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
1153{
1154 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (_skeleton);
1155
1156 GVariantBuilder builder;
1157 guint n;
1158 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1159 if (_event_log_interface_info.parent_struct.properties == NULL)
1160 goto out;
1161 for (n = 0; _event_log_interface_info.parent_struct.properties[n] != NULL; n++)
1162 {
1163 GDBusPropertyInfo *info = _event_log_interface_info.parent_struct.properties[n];
1164 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
1165 {
1166 GVariant *value;
1167 value = _event_log_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.EventLog", info->name, NULL, skeleton);
1168 if (value != NULL)
1169 {
1170 g_variant_take_ref (value);
1171 g_variant_builder_add (&builder, "{sv}", info->name, value);
1172 g_variant_unref (value);
1173 }
1174 }
1175 }
1176out:
1177 return g_variant_builder_end (&builder);
1178}
1179
1180static gboolean _event_log_emit_changed (gpointer user_data);
1181
1182static void
1183event_log_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
1184{
1185 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (_skeleton);
1186 gboolean emit_changed = FALSE;
1187
1188 g_mutex_lock (&skeleton->priv->lock);
1189 if (skeleton->priv->changed_properties_idle_source != NULL)
1190 {
1191 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1192 skeleton->priv->changed_properties_idle_source = NULL;
1193 emit_changed = TRUE;
1194 }
1195 g_mutex_unlock (&skeleton->priv->lock);
1196
1197 if (emit_changed)
1198 _event_log_emit_changed (skeleton);
1199}
1200
1201static void
1202_event_log_on_signal_event (
1203 EventLog *object,
1204 GVariant *arg_message)
1205{
1206 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1207
1208 GList *connections, *l;
1209 GVariant *signal_variant;
1210 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1211
1212 signal_variant = g_variant_ref_sink (g_variant_new ("(@a{ss})",
1213 arg_message));
1214 for (l = connections; l != NULL; l = l->next)
1215 {
1216 GDBusConnection *connection = l->data;
1217 g_dbus_connection_emit_signal (connection,
1218 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.EventLog", "Event",
1219 signal_variant, NULL);
1220 }
1221 g_variant_unref (signal_variant);
1222 g_list_free_full (connections, g_object_unref);
1223}
1224
1225static void event_log_skeleton_iface_init (EventLogIface *iface);
1226#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1227G_DEFINE_TYPE_WITH_CODE (EventLogSkeleton, event_log_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1228 G_ADD_PRIVATE (EventLogSkeleton)
1229 G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_skeleton_iface_init));
1230
1231#else
1232G_DEFINE_TYPE_WITH_CODE (EventLogSkeleton, event_log_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
1233 G_IMPLEMENT_INTERFACE (TYPE_EVENT_LOG, event_log_skeleton_iface_init));
1234
1235#endif
1236static void
1237event_log_skeleton_finalize (GObject *object)
1238{
1239 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1240 guint n;
1241 for (n = 0; n < 1; n++)
1242 g_value_unset (&skeleton->priv->properties[n]);
1243 g_free (skeleton->priv->properties);
1244 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1245 if (skeleton->priv->changed_properties_idle_source != NULL)
1246 g_source_destroy (skeleton->priv->changed_properties_idle_source);
1247 g_main_context_unref (skeleton->priv->context);
1248 g_mutex_clear (&skeleton->priv->lock);
1249 G_OBJECT_CLASS (event_log_skeleton_parent_class)->finalize (object);
1250}
1251
1252static void
1253event_log_skeleton_get_property (GObject *object,
1254 guint prop_id,
1255 GValue *value,
1256 GParamSpec *pspec G_GNUC_UNUSED)
1257{
1258 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1259 g_assert (prop_id != 0 && prop_id - 1 < 1);
1260 g_mutex_lock (&skeleton->priv->lock);
1261 g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
1262 g_mutex_unlock (&skeleton->priv->lock);
1263}
1264
1265static gboolean
1266_event_log_emit_changed (gpointer user_data)
1267{
1268 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (user_data);
1269 GList *l;
1270 GVariantBuilder builder;
1271 GVariantBuilder invalidated_builder;
1272 guint num_changes;
1273
1274 g_mutex_lock (&skeleton->priv->lock);
1275 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
1276 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
1277 for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
1278 {
1279 ChangedProperty *cp = l->data;
1280 GVariant *variant;
1281 const GValue *cur_value;
1282
1283 cur_value = &skeleton->priv->properties[cp->prop_id - 1];
1284 if (!_g_value_equal (cur_value, &cp->orig_value))
1285 {
1286 variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
1287 g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
1288 g_variant_unref (variant);
1289 num_changes++;
1290 }
1291 }
1292 if (num_changes > 0)
1293 {
1294 GList *connections, *ll;
1295 GVariant *signal_variant;
1296 signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.EventLog",
1297 &builder, &invalidated_builder));
1298 connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
1299 for (ll = connections; ll != NULL; ll = ll->next)
1300 {
1301 GDBusConnection *connection = ll->data;
1302
1303 g_dbus_connection_emit_signal (connection,
1304 NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
1305 "org.freedesktop.DBus.Properties",
1306 "PropertiesChanged",
1307 signal_variant,
1308 NULL);
1309 }
1310 g_variant_unref (signal_variant);
1311 g_list_free_full (connections, g_object_unref);
1312 }
1313 else
1314 {
1315 g_variant_builder_clear (&builder);
1316 g_variant_builder_clear (&invalidated_builder);
1317 }
1318 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
1319 skeleton->priv->changed_properties = NULL;
1320 skeleton->priv->changed_properties_idle_source = NULL;
1321 g_mutex_unlock (&skeleton->priv->lock);
1322 return FALSE;
1323}
1324
1325static void
1326_event_log_schedule_emit_changed (EventLogSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
1327{
1328 ChangedProperty *cp;
1329 GList *l;
1330 cp = NULL;
1331 for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
1332 {
1333 ChangedProperty *i_cp = l->data;
1334 if (i_cp->info == info)
1335 {
1336 cp = i_cp;
1337 break;
1338 }
1339 }
1340 if (cp == NULL)
1341 {
1342 cp = g_new0 (ChangedProperty, 1);
1343 cp->prop_id = prop_id;
1344 cp->info = info;
1345 skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
1346 g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
1347 g_value_copy (orig_value, &cp->orig_value);
1348 }
1349}
1350
1351static void
1352event_log_skeleton_notify (GObject *object,
1353 GParamSpec *pspec G_GNUC_UNUSED)
1354{
1355 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1356 g_mutex_lock (&skeleton->priv->lock);
1357 if (skeleton->priv->changed_properties != NULL &&
1358 skeleton->priv->changed_properties_idle_source == NULL)
1359 {
1360 skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
1361 g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
1362 g_source_set_callback (skeleton->priv->changed_properties_idle_source, _event_log_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
1363 g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
1364 g_source_unref (skeleton->priv->changed_properties_idle_source);
1365 }
1366 g_mutex_unlock (&skeleton->priv->lock);
1367}
1368
1369static void
1370event_log_skeleton_set_property (GObject *object,
1371 guint prop_id,
1372 const GValue *value,
1373 GParamSpec *pspec)
1374{
1375 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1376 g_assert (prop_id != 0 && prop_id - 1 < 1);
1377 g_mutex_lock (&skeleton->priv->lock);
1378 g_object_freeze_notify (object);
1379 if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
1380 {
1381 if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
1382 _event_log_schedule_emit_changed (skeleton, _event_log_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
1383 g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
1384 g_object_notify_by_pspec (object, pspec);
1385 }
1386 g_mutex_unlock (&skeleton->priv->lock);
1387 g_object_thaw_notify (object);
1388}
1389
1390static void
1391event_log_skeleton_init (EventLogSkeleton *skeleton)
1392{
1393#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
1394 skeleton->priv = event_log_skeleton_get_instance_private (skeleton);
1395#else
1396 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_EVENT_LOG_SKELETON, EventLogSkeletonPrivate);
1397#endif
1398
1399 g_mutex_init (&skeleton->priv->lock);
1400 skeleton->priv->context = g_main_context_ref_thread_default ();
1401 skeleton->priv->properties = g_new0 (GValue, 1);
1402 g_value_init (&skeleton->priv->properties[0], G_TYPE_VARIANT);
1403}
1404
1405static GVariant *
1406event_log_skeleton_get_message (EventLog *object)
1407{
1408 EventLogSkeleton *skeleton = EVENT_LOG_SKELETON (object);
1409 GVariant *value;
1410 g_mutex_lock (&skeleton->priv->lock);
1411 value = g_value_get_variant (&(skeleton->priv->properties[0]));
1412 g_mutex_unlock (&skeleton->priv->lock);
1413 return value;
1414}
1415
1416static void
1417event_log_skeleton_class_init (EventLogSkeletonClass *klass)
1418{
1419 GObjectClass *gobject_class;
1420 GDBusInterfaceSkeletonClass *skeleton_class;
1421
1422 gobject_class = G_OBJECT_CLASS (klass);
1423 gobject_class->finalize = event_log_skeleton_finalize;
1424 gobject_class->get_property = event_log_skeleton_get_property;
1425 gobject_class->set_property = event_log_skeleton_set_property;
1426 gobject_class->notify = event_log_skeleton_notify;
1427
1428
1429 event_log_override_properties (gobject_class, 1);
1430
1431 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
1432 skeleton_class->get_info = event_log_skeleton_dbus_interface_get_info;
1433 skeleton_class->get_properties = event_log_skeleton_dbus_interface_get_properties;
1434 skeleton_class->flush = event_log_skeleton_dbus_interface_flush;
1435 skeleton_class->get_vtable = event_log_skeleton_dbus_interface_get_vtable;
1436
1437#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
1438 g_type_class_add_private (klass, sizeof (EventLogSkeletonPrivate));
1439#endif
1440}
1441
1442static void
1443event_log_skeleton_iface_init (EventLogIface *iface)
1444{
1445 iface->event = _event_log_on_signal_event;
1446 iface->get_message = event_log_skeleton_get_message;
1447}
1448
1449/**
1450 * event_log_skeleton_new:
1451 *
1452 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-EventLog.top_of_page">org.openbmc.EventLog</link>.
1453 *
1454 * Returns: (transfer full) (type EventLogSkeleton): The skeleton object.
1455 */
1456EventLog *
1457event_log_skeleton_new (void)
1458{
1459 return EVENT_LOG (g_object_new (TYPE_EVENT_LOG_SKELETON, NULL));
1460}
1461