From: Rico Tzschichholz Date: Sat, 7 Aug 2021 14:43:00 +0000 (+0200) Subject: Update expected C sources X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftintou%2Fgdbus-properties;p=thirdparty%2Fvala.git Update expected C sources --- diff --git a/tests/dbus/arrays_client.c-expected b/tests/dbus/arrays_client.c-expected index 7b0d3ab53..08a264f41 100644 --- a/tests/dbus/arrays_client.c-expected +++ b/tests/dbus/arrays_client.c-expected @@ -36,6 +36,12 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_TEST_PROPERTY_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -77,10 +83,22 @@ VALA_EXTERN void test_set_test_property (Test* self, gchar** value, gint value_length1); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint* test_proxy_test_int (Test* self, gint* i, gint i_length1, @@ -133,6 +151,9 @@ static gboolean test_dbus_interface_set_property (GDBusConnection* connection, gpointer user_data); static void _dbus_test_set_test_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); static void _vala_main (void); static void _vala_array_destroy (gpointer array, @@ -227,6 +248,7 @@ static void test_default_init (TestIface * iface, gpointer iface_data) { + g_object_interface_install_property (iface, g_param_spec_boxed ("test-property", "test-property", "test-property", G_TYPE_STRV, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); } static GType @@ -259,7 +281,66 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; + g_object_class_override_property (object_class, TEST_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + { + int length; + g_value_take_boxed (value, test_dbus_proxy_get_test_property (self, &length)); + } + break; + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + { + gpointer boxed; + boxed = g_value_get_boxed (value); + test_dbus_proxy_set_test_property (self, boxed, (boxed == NULL) ? 0 : g_strv_length (boxed)); + } + break; + default: + return; + } } static void @@ -270,6 +351,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { @@ -850,6 +956,27 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -866,6 +993,7 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -874,6 +1002,7 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/arrays_server.c-expected b/tests/dbus/arrays_server.c-expected index 7544885f1..4e75bac7d 100644 --- a/tests/dbus/arrays_server.c-expected +++ b/tests/dbus/arrays_server.c-expected @@ -140,6 +140,9 @@ static gboolean test_dbus_interface_set_property (GDBusConnection* connection, gpointer user_data); static void _dbus_test_set_test_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); VALA_EXTERN void client_exit (GPid pid, gint status); @@ -739,6 +742,27 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -755,6 +779,7 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -763,6 +788,7 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/async-bus_client.c-expected b/tests/dbus/async-bus_client.c-expected index 51dc999c0..f1d92b2e2 100644 --- a/tests/dbus/async-bus_client.c-expected +++ b/tests/dbus/async-bus_client.c-expected @@ -35,6 +35,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -60,10 +65,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN gint test_get_test (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint test_proxy_get_test (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -160,7 +177,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -171,6 +229,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/async-connection_client.c-expected b/tests/dbus/async-connection_client.c-expected index e97083b1d..08434c0f7 100644 --- a/tests/dbus/async-connection_client.c-expected +++ b/tests/dbus/async-connection_client.c-expected @@ -35,6 +35,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -60,10 +65,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN gint test_get_test (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint test_proxy_get_test (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -160,7 +177,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -171,6 +229,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/async-errors_client.c-expected b/tests/dbus/async-errors_client.c-expected index 7300d7cae..487567bd1 100644 --- a/tests/dbus/async-errors_client.c-expected +++ b/tests/dbus/async-errors_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestTestVoidReadyData TestTestVoidReadyData; typedef struct _TestTestIntReadyData TestTestIntReadyData; typedef struct _TestTestStringReadyData TestTestStringReadyData; @@ -141,10 +146,22 @@ VALA_EXTERN void test_test_cancellable_finish (Test* self, GAsyncResult* _res_, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -399,7 +416,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -410,6 +468,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/async-no-reply_client.c-expected b/tests/dbus/async-no-reply_client.c-expected index 36ff15678..7b7252cd1 100644 --- a/tests/dbus/async-no-reply_client.c-expected +++ b/tests/dbus/async-no-reply_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestListMessagesReadyData TestListMessagesReadyData; typedef struct _TestPostMessageReadyData TestPostMessageReadyData; #define _g_free0(var) (var = (g_free (var), NULL)) @@ -153,10 +158,22 @@ VALA_EXTERN void test_post_message_finish (Test* self, GAsyncResult* _res_, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -339,7 +356,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -350,6 +408,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/async_client.c-expected b/tests/dbus/async_client.c-expected index 049b02190..b29a2ecdb 100644 --- a/tests/dbus/async_client.c-expected +++ b/tests/dbus/async_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestTestVoidReadyData TestTestVoidReadyData; typedef struct _TestTestIntReadyData TestTestIntReadyData; typedef struct _TestTestStringReadyData TestTestStringReadyData; @@ -132,10 +137,22 @@ VALA_EXTERN gchar* test_test_string_finish (Test* self, gchar** t, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -349,7 +366,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -360,6 +418,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/basic-types_client.c-expected b/tests/dbus/basic-types_client.c-expected index d72b2019f..e0e5151ec 100644 --- a/tests/dbus/basic-types_client.c-expected +++ b/tests/dbus/basic-types_client.c-expected @@ -36,6 +36,13 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_TEST_PROPERTY_PROPERTY, + TEST_PROXY_TEST_INT_PROPERTY_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -78,10 +85,22 @@ VALA_EXTERN gint test_get_test_int_property (Test* self); VALA_EXTERN void test_set_test_int_property (Test* self, gint value); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void test_proxy_test_void (Test* self, GError** error); static gint test_proxy_test_int (Test* self, @@ -137,6 +156,12 @@ static void _dbus_test_set_test_property (Test* self, GVariant* _value); static void _dbus_test_set_test_int_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); static void _vala_main (void); @@ -257,6 +282,8 @@ static void test_default_init (TestIface * iface, gpointer iface_data) { + g_object_interface_install_property (iface, g_param_spec_string ("test-property", "test-property", "test-property", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_interface_install_property (iface, g_param_spec_int ("test-int-property", "test-int-property", "test-int-property", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); } static GType @@ -289,7 +316,69 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; + g_object_class_override_property (object_class, TEST_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); + g_object_class_override_property (object_class, TEST_PROXY_TEST_INT_PROPERTY_PROPERTY, "test-int-property"); + test_proxy_properties[TEST_PROXY_TEST_INT_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-int-property"); +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY]; + } else if (g_strcmp0 (dbus_property_name, "TestIntProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_INT_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + g_value_take_string (value, test_dbus_proxy_get_test_property (self)); + break; + case TEST_PROXY_TEST_INT_PROPERTY_PROPERTY: + g_value_set_int (value, test_dbus_proxy_get_test_int_property (self)); + break; + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_property (self, g_value_get_string (value)); + break; + case TEST_PROXY_TEST_INT_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_int_property (self, g_value_get_int (value)); + break; + default: + return; + } } static void @@ -300,6 +389,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { @@ -736,6 +850,48 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +static void +_test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_int_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestIntProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -752,6 +908,8 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); + g_signal_connect (object, "notify::test-int-property", (GCallback) _test_notify_test_int_property, data); return result; } @@ -760,6 +918,8 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_int_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/basic-types_server.c-expected b/tests/dbus/basic-types_server.c-expected index 6693c704f..a45d7c139 100644 --- a/tests/dbus/basic-types_server.c-expected +++ b/tests/dbus/basic-types_server.c-expected @@ -139,6 +139,12 @@ static void _dbus_test_set_test_property (Test* self, GVariant* _value); static void _dbus_test_set_test_int_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); VALA_EXTERN void client_exit (GPid pid, gint status); @@ -585,6 +591,48 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +static void +_test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_int_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestIntProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -601,6 +649,8 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); + g_signal_connect (object, "notify::test-int-property", (GCallback) _test_notify_test_int_property, data); return result; } @@ -609,6 +659,8 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_int_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/bug602003_client.c-expected b/tests/dbus/bug602003_client.c-expected index 44755af0e..1b4c4900f 100644 --- a/tests/dbus/bug602003_client.c-expected +++ b/tests/dbus/bug602003_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -58,10 +63,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN GVariant* test_test_string (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GVariant* test_proxy_test_string (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -161,7 +178,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -172,6 +230,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/bug735437_client.c-expected b/tests/dbus/bug735437_client.c-expected index ca3384d61..f6bc7ee38 100644 --- a/tests/dbus/bug735437_client.c-expected +++ b/tests/dbus/bug735437_client.c-expected @@ -38,6 +38,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -71,10 +76,22 @@ VALA_EXTERN gchar** test_multi_array2 (Test* self, gint* result_length3, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gdouble* test_proxy_array (Test* self, gint* result_length1, GError** error); @@ -228,7 +245,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -239,6 +297,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/bug782719_client.c-expected b/tests/dbus/bug782719_client.c-expected index 332e8a3cb..bbb3020cb 100644 --- a/tests/dbus/bug782719_client.c-expected +++ b/tests/dbus/bug782719_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) @@ -59,10 +64,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN GHashTable* test_test_nested_dict (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GHashTable* test_proxy_test_nested_dict (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -162,7 +179,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -173,6 +231,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/bug783002_client.c-expected b/tests/dbus/bug783002_client.c-expected index fc0c97f85..d40c96659 100644 --- a/tests/dbus/bug783002_client.c-expected +++ b/tests/dbus/bug783002_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestTestArrayLifetimeReadyData TestTestArrayLifetimeReadyData; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) @@ -99,10 +104,22 @@ VALA_EXTERN gchar* test_test_array_lifetime_finish (Test* self, GAsyncResult* _res_, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -235,7 +252,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -246,6 +304,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/bug792277.c-expected b/tests/dbus/bug792277.c-expected index cf2ff0a67..144f6b314 100644 --- a/tests/dbus/bug792277.c-expected +++ b/tests/dbus/bug792277.c-expected @@ -35,6 +35,11 @@ typedef struct _IFooIface IFooIface; #define TYPE_IFOO_PROXY (ifoo_proxy_get_type ()) typedef GDBusProxy IFooProxy; typedef GDBusProxyClass IFooProxyClass; +enum { + IFOO_PROXY_0_PROPERTY, + IFOO_PROXY_NUM_PROPERTIES +}; +static GParamSpec* ifoo_proxy_properties[IFOO_PROXY_NUM_PROPERTIES]; #define TYPE_FOO (foo_get_type ()) #define FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOO, Foo)) @@ -83,10 +88,22 @@ VALA_EXTERN void ifoo_method1 (IFoo* self, GError** error); VALA_EXTERN void ifoo_method2 (IFoo* self); static GType ifoo_get_type_once (void); +static GParamSpec * _vala_ifoo_find_property_from_dbus_name (const gchar * dbus_property_name); +static void ifoo_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void ifoo_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void ifoo_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void ifoo_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void ifoo_proxy_method0 (IFoo* self, GError** error); static void ifoo_proxy_method1 (IFoo* self, @@ -263,7 +280,48 @@ G_DEFINE_TYPE_EXTENDED (IFooProxy, ifoo_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void ifoo_proxy_class_init (IFooProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = ifoo_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = ifoo_proxy_g_signal; + proxy_class->g_properties_changed = ifoo_proxy_g_properties_changed; + object_class->get_property = ifoo_proxy_get_property; + object_class->set_property = ifoo_proxy_set_property; +} + +static GParamSpec * +_vala_ifoo_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +ifoo_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + IFoo * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IFOO, IFoo); + switch (property_id) { + default: + return; + } +} + +static void +ifoo_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + IFoo * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IFOO, IFoo); + switch (property_id) { + default: + return; + } } static void @@ -274,6 +332,31 @@ ifoo_proxy_g_signal (GDBusProxy* proxy, { } +static void +ifoo_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_ifoo_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_ifoo_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void ifoo_proxy_init (IFooProxy* self) { diff --git a/tests/dbus/connection_client.c-expected b/tests/dbus/connection_client.c-expected index 470b09383..ba1c7221c 100644 --- a/tests/dbus/connection_client.c-expected +++ b/tests/dbus/connection_client.c-expected @@ -35,6 +35,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -56,10 +61,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN gint test_get_test (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint test_proxy_get_test (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -151,7 +168,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -162,6 +220,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/dicts_client.c-expected b/tests/dbus/dicts_client.c-expected index 879d30ba3..7f95b7a95 100644 --- a/tests/dbus/dicts_client.c-expected +++ b/tests/dbus/dicts_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) @@ -59,10 +64,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN GHashTable* test_test_dict (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GHashTable* test_proxy_test_dict (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -162,7 +179,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -173,6 +231,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/dicts_server.c-expected b/tests/dbus/dicts_server.c-expected index 2b383a8bb..8f452c4e8 100644 --- a/tests/dbus/dicts_server.c-expected +++ b/tests/dbus/dicts_server.c-expected @@ -53,6 +53,11 @@ typedef struct _TestInterfaceBarIface TestInterfaceBarIface; #define TEST_INTERFACE_TYPE_BAR_PROXY (test_interface_bar_proxy_get_type ()) typedef GDBusProxy TestInterfaceBarProxy; typedef GDBusProxyClass TestInterfaceBarProxyClass; +enum { + TEST_INTERFACE_BAR_PROXY_0_PROPERTY, + TEST_INTERFACE_BAR_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_interface_bar_proxy_properties[TEST_INTERFACE_BAR_PROXY_NUM_PROPERTIES]; #define TEST_INTERFACE_TYPE_FOO (test_interface_foo_get_type ()) #define TEST_INTERFACE_FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_INTERFACE_TYPE_FOO, TestInterfaceFoo)) @@ -157,10 +162,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (TestInterfaceBar, g_object_unref) VALA_EXTERN GHashTable* test_interface_bar_foo (TestInterfaceBar* self, GError** error); static GType test_interface_bar_get_type_once (void); +static GParamSpec * _vala_test_interface_bar_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_interface_bar_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_interface_bar_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_interface_bar_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_interface_bar_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GHashTable* test_interface_bar_proxy_foo (TestInterfaceBar* self, GError** error); static void test_interface_bar_proxy_test_interface_bar_interface_init (TestInterfaceBarIface* iface); @@ -510,7 +527,48 @@ G_DEFINE_TYPE_EXTENDED (TestInterfaceBarProxy, test_interface_bar_proxy, G_TYPE_ static void test_interface_bar_proxy_class_init (TestInterfaceBarProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_interface_bar_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_interface_bar_proxy_g_signal; + proxy_class->g_properties_changed = test_interface_bar_proxy_g_properties_changed; + object_class->get_property = test_interface_bar_proxy_get_property; + object_class->set_property = test_interface_bar_proxy_set_property; +} + +static GParamSpec * +_vala_test_interface_bar_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_interface_bar_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + TestInterfaceBar * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_INTERFACE_TYPE_BAR, TestInterfaceBar); + switch (property_id) { + default: + return; + } +} + +static void +test_interface_bar_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + TestInterfaceBar * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_INTERFACE_TYPE_BAR, TestInterfaceBar); + switch (property_id) { + default: + return; + } } static void @@ -521,6 +579,31 @@ test_interface_bar_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_interface_bar_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_interface_bar_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_interface_bar_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_interface_bar_proxy_init (TestInterfaceBarProxy* self) { diff --git a/tests/dbus/enum-string-marshalling.c-expected b/tests/dbus/enum-string-marshalling.c-expected index 02a44ef61..0ccc1623e 100644 --- a/tests/dbus/enum-string-marshalling.c-expected +++ b/tests/dbus/enum-string-marshalling.c-expected @@ -41,6 +41,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestTest1ReadyData TestTest1ReadyData; typedef struct _TestTest5ReadyData TestTest5ReadyData; @@ -100,10 +105,22 @@ VALA_EXTERN void test_test5 (Test* self, VALA_EXTERN void test_test5_finish (Test* self, GAsyncResult* _res_); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -377,7 +394,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -388,6 +446,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/errors_client.c-expected b/tests/dbus/errors_client.c-expected index c568f8a3d..3b2cede13 100644 --- a/tests/dbus/errors_client.c-expected +++ b/tests/dbus/errors_client.c-expected @@ -38,6 +38,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) @@ -87,10 +92,22 @@ VALA_EXTERN void test_test_cancellable (Test* self, VALA_EXTERN void test_test_custom_error (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void test_proxy_test_void (Test* self, GError** error); static gint test_proxy_test_int (Test* self, @@ -287,7 +304,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -298,6 +356,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/filedescriptor-async_client.c-expected b/tests/dbus/filedescriptor-async_client.c-expected index 4ff425818..606242939 100644 --- a/tests/dbus/filedescriptor-async_client.c-expected +++ b/tests/dbus/filedescriptor-async_client.c-expected @@ -38,6 +38,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; typedef struct _TestTestInReadyData TestTestInReadyData; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) typedef struct _RunData RunData; @@ -135,10 +140,22 @@ VALA_EXTERN GUnixInputStream* test_test_in_finish (Test* self, GUnixInputStream** j, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); @@ -266,7 +283,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -277,6 +335,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/filedescriptor-errors_client.c-expected b/tests/dbus/filedescriptor-errors_client.c-expected index a6101aa23..a5291a3b6 100644 --- a/tests/dbus/filedescriptor-errors_client.c-expected +++ b/tests/dbus/filedescriptor-errors_client.c-expected @@ -40,6 +40,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) @@ -59,10 +64,22 @@ VALA_EXTERN gchar* test_test (Test* self, GUnixOutputStream* output_stream, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gchar* test_proxy_test (Test* self, GUnixOutputStream* output_stream, GError** error); @@ -160,7 +177,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -171,6 +229,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/filedescriptor_client.c-expected b/tests/dbus/filedescriptor_client.c-expected index 5bd5a735f..54ec44166 100644 --- a/tests/dbus/filedescriptor_client.c-expected +++ b/tests/dbus/filedescriptor_client.c-expected @@ -38,6 +38,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -61,10 +66,22 @@ VALA_EXTERN GUnixInputStream* test_test_in (Test* self, GUnixInputStream** j, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GUnixInputStream* test_proxy_test_in (Test* self, GUnixInputStream* i, GUnixInputStream** j, @@ -162,7 +179,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -173,6 +231,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/generics_client.c-expected b/tests/dbus/generics_client.c-expected index 0817ac8fd..6f860f8aa 100644 --- a/tests/dbus/generics_client.c-expected +++ b/tests/dbus/generics_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -57,10 +62,22 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN gint test_get_test (Test* self, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint test_proxy_get_test (Test* self, GError** error); static void test_proxy_test_interface_init (TestIface* iface); @@ -158,7 +175,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -169,6 +227,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/interface-info_client.c-expected b/tests/dbus/interface-info_client.c-expected index a17cb729a..da718bc89 100644 --- a/tests/dbus/interface-info_client.c-expected +++ b/tests/dbus/interface-info_client.c-expected @@ -41,6 +41,11 @@ enum { static guint test_signals[TEST_NUM_SIGNALS] = {0}; typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -63,12 +68,24 @@ VALA_EXTERN guint test_register_object (void* object, const gchar* path, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); static void _dbus_handle_test_bar (Test* self, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void test_proxy_test_interface_init (TestIface* iface); static void test_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, @@ -146,7 +163,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -175,6 +233,31 @@ test_proxy_g_signal (GDBusProxy* proxy, } } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/no-reply_client.c-expected b/tests/dbus/no-reply_client.c-expected index 817e564e3..8688e9799 100644 --- a/tests/dbus/no-reply_client.c-expected +++ b/tests/dbus/no-reply_client.c-expected @@ -36,6 +36,11 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) typedef struct _Block1Data Block1Data; #define _g_async_queue_unref0(var) ((var == NULL) ? NULL : (var = (g_async_queue_unref (var), NULL))) @@ -136,10 +141,22 @@ VALA_EXTERN void test_post_message_no_reply (Test* self, const gchar* message, GError** error); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gchar** test_proxy_list_messages (Test* self, gint* result_length1, GError** error); @@ -304,7 +321,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -315,6 +373,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/properties_client.c-expected b/tests/dbus/properties_client.c-expected new file mode 100644 index 000000000..de9e55682 --- /dev/null +++ b/tests/dbus/properties_client.c-expected @@ -0,0 +1,1266 @@ +/* dbus_properties_client.c generated by valac, the Vala compiler + * generated from dbus_properties_client.vala, do not modify */ + +#include +#include +#include +#include +#include + +#if !defined(VALA_STRICT_C) +#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14) +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" +#elif defined(__clang__) && (__clang_major__ >= 16) +#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types" +#pragma clang diagnostic ignored "-Wincompatible-pointer-types" +#endif +#endif +#if !defined(VALA_EXTERN) +#if defined(_WIN32) || defined(__CYGWIN__) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +#define TYPE_TEST (test_get_type ()) +#define TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST, Test)) +#define IS_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST)) +#define TEST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_TEST, TestIface)) + +typedef struct _Test Test; +typedef struct _TestIface TestIface; + +#define TYPE_TEST_PROXY (test_proxy_get_type ()) +typedef GDBusProxy TestProxy; +typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_TEST_PROPERTY_PROPERTY, + TEST_PROXY_TEST_INT_PROPERTY_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; +#define _g_free0(var) (var = (g_free (var), NULL)) + +#define TYPE_TEST2 (test2_get_type ()) +#define TEST2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST2, Test2)) +#define TEST2_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEST2, Test2Class)) +#define IS_TEST2(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST2)) +#define IS_TEST2_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEST2)) +#define TEST2_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEST2, Test2Class)) + +typedef struct _Test2 Test2; +typedef struct _Test2Class Test2Class; +typedef struct _Test2Private Test2Private; +enum { + TEST2_0_PROPERTY, + TEST2_TEST_PROPERTY_PROPERTY, + TEST2_TEST_INT_PROPERTY_PROPERTY, + TEST2_NUM_PROPERTIES +}; +static GParamSpec* test2_properties[TEST2_NUM_PROPERTIES]; +typedef struct _Block1Data Block1Data; +#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +typedef struct _Block2Data Block2Data; +#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); +#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } +#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } +#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); + +struct _TestIface { + GTypeInterface parent_iface; + void (*change_everything) (Test* self, GError** error); + void (*check_everything) (Test* self, GError** error); + gchar* (*get_test_property) (Test* self); + void (*set_test_property) (Test* self, const gchar* value); + gint (*get_test_int_property) (Test* self); + void (*set_test_int_property) (Test* self, gint value); +}; + +struct _Test2 { + GObject parent_instance; + Test2Private * priv; +}; + +struct _Test2Class { + GObjectClass parent_class; +}; + +struct _Test2Private { + gchar* _test_property; + gint _test_int_property; +}; + +struct _Block1Data { + int _ref_count_; + GMainLoop* main_loop; +}; + +struct _Block2Data { + int _ref_count_; + GMainLoop* main_loop2; +}; + +static gint Test2_private_offset; +static gpointer test2_parent_class = NULL; + +VALA_EXTERN GType test_proxy_get_type (void) G_GNUC_CONST ; +VALA_EXTERN guint test_register_object (void* object, + GDBusConnection* connection, + const gchar* path, + GError** error); +VALA_EXTERN GType test_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) +VALA_EXTERN void test_change_everything (Test* self, + GError** error); +VALA_EXTERN void test_check_everything (Test* self, + GError** error); +VALA_EXTERN gchar* test_get_test_property (Test* self); +VALA_EXTERN void test_set_test_property (Test* self, + const gchar* value); +VALA_EXTERN gint test_get_test_int_property (Test* self); +VALA_EXTERN void test_set_test_int_property (Test* self, + gint value); +static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); +static void test_proxy_g_signal (GDBusProxy* proxy, + const gchar* sender_name, + const gchar* signal_name, + GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); +static void test_proxy_change_everything (Test* self, + GError** error); +static void test_proxy_check_everything (Test* self, + GError** error); +static gchar* test_dbus_proxy_get_test_property (Test* self); +static void test_dbus_proxy_set_test_property (Test* self, + const gchar* value); +static gint test_dbus_proxy_get_test_int_property (Test* self); +static void test_dbus_proxy_set_test_int_property (Test* self, + gint value); +static void test_proxy_test_interface_init (TestIface* iface); +static void _dbus_test_change_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation); +static void _dbus_test_check_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation); +static void test_dbus_interface_method_call (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data); +static GVariant* test_dbus_interface_get_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GError** error, + gpointer user_data); +static GVariant* _dbus_test_get_test_property (Test* self); +static GVariant* _dbus_test_get_test_int_property (Test* self); +static gboolean test_dbus_interface_set_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GVariant* value, + GError** error, + gpointer user_data); +static void _dbus_test_set_test_property (Test* self, + GVariant* _value); +static void _dbus_test_set_test_int_property (Test* self, + GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_unregister_object (gpointer user_data); +VALA_EXTERN GType test2_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test2, g_object_unref) +VALA_EXTERN Test2* test2_new (void); +VALA_EXTERN Test2* test2_construct (GType object_type); +VALA_EXTERN const gchar* test2_get_test_property (Test2* self); +VALA_EXTERN void test2_set_test_property (Test2* self, + const gchar* value); +VALA_EXTERN gint test2_get_test_int_property (Test2* self); +VALA_EXTERN void test2_set_test_int_property (Test2* self, + gint value); +static void test2_finalize (GObject * obj); +static GType test2_get_type_once (void); +static void _vala_test2_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec); +static void _vala_test2_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec); +static void _vala_main (void); +static Block1Data* block1_data_ref (Block1Data* _data1_); +static void block1_data_unref (void * _userdata_); +static void _vala_lambda0_ (Block1Data* _data1_, + GParamSpec* p); +static void __vala_lambda0__g_object_notify (GObject* _sender, + GParamSpec* pspec, + gpointer self); +static Block2Data* block2_data_ref (Block2Data* _data2_); +static void block2_data_unref (void * _userdata_); +static void _vala_lambda1_ (Block2Data* _data2_, + GParamSpec* p); +static void __vala_lambda1__g_object_notify (GObject* _sender, + GParamSpec* pspec, + gpointer self); + +static const GDBusArgInfo * const _test_dbus_arg_info_change_everything_in[] = {NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_change_everything_out[] = {NULL}; +static const GDBusMethodInfo _test_dbus_method_info_change_everything = {-1, "ChangeEverything", (GDBusArgInfo **) (&_test_dbus_arg_info_change_everything_in), (GDBusArgInfo **) (&_test_dbus_arg_info_change_everything_out), NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_check_everything_in[] = {NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_check_everything_out[] = {NULL}; +static const GDBusMethodInfo _test_dbus_method_info_check_everything = {-1, "CheckEverything", (GDBusArgInfo **) (&_test_dbus_arg_info_check_everything_in), (GDBusArgInfo **) (&_test_dbus_arg_info_check_everything_out), NULL}; +static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_change_everything, &_test_dbus_method_info_check_everything, NULL}; +static const GDBusSignalInfo * const _test_dbus_signal_info[] = {NULL}; +static const GDBusPropertyInfo _test_dbus_property_info_test_property = {-1, "TestProperty", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL}; +static const GDBusPropertyInfo _test_dbus_property_info_test_int_property = {-1, "TestIntProperty", "i", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL}; +static const GDBusPropertyInfo * const _test_dbus_property_info[] = {&_test_dbus_property_info_test_property, &_test_dbus_property_info_test_int_property, NULL}; +static const GDBusInterfaceInfo _test_dbus_interface_info = {-1, "org.example.Test", (GDBusMethodInfo **) (&_test_dbus_method_info), (GDBusSignalInfo **) (&_test_dbus_signal_info), (GDBusPropertyInfo **) (&_test_dbus_property_info), NULL}; +static const GDBusInterfaceVTable _test_dbus_interface_vtable = {test_dbus_interface_method_call, test_dbus_interface_get_property, test_dbus_interface_set_property}; + +void +test_change_everything (Test* self, + GError** error) +{ + TestIface* _iface_; + g_return_if_fail (IS_TEST (self)); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->change_everything) { + _iface_->change_everything (self, error); + } +} + +void +test_check_everything (Test* self, + GError** error) +{ + TestIface* _iface_; + g_return_if_fail (IS_TEST (self)); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->check_everything) { + _iface_->check_everything (self, error); + } +} + +gchar* +test_get_test_property (Test* self) +{ + TestIface* _iface_; + g_return_val_if_fail (IS_TEST (self), NULL); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->get_test_property) { + return _iface_->get_test_property (self); + } + return NULL; +} + +void +test_set_test_property (Test* self, + const gchar* value) +{ + TestIface* _iface_; + g_return_if_fail (IS_TEST (self)); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->set_test_property) { + _iface_->set_test_property (self, value); + } +} + +gint +test_get_test_int_property (Test* self) +{ + TestIface* _iface_; + g_return_val_if_fail (IS_TEST (self), 0); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->get_test_int_property) { + return _iface_->get_test_int_property (self); + } + return -1; +} + +void +test_set_test_int_property (Test* self, + gint value) +{ + TestIface* _iface_; + g_return_if_fail (IS_TEST (self)); + _iface_ = TEST_GET_INTERFACE (self); + if (_iface_->set_test_int_property) { + _iface_->set_test_int_property (self, value); + } +} + +static void +test_default_init (TestIface * iface, + gpointer iface_data) +{ + g_object_interface_install_property (iface, g_param_spec_string ("test-property", "test-property", "test-property", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_interface_install_property (iface, g_param_spec_int ("test-int-property", "test-int-property", "test-int-property", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +static GType +test_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (TestIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; + GType test_type_id; + test_type_id = g_type_register_static (G_TYPE_INTERFACE, "Test", &g_define_type_info, 0); + g_type_interface_add_prerequisite (test_type_id, G_TYPE_OBJECT); + g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) test_proxy_get_type); + g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.example.Test"); + g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_test_dbus_interface_info)); + g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) test_register_object); + return test_type_id; +} + +GType +test_get_type (void) +{ + static volatile gsize test_type_id__once = 0; + if (g_once_init_enter (&test_type_id__once)) { + GType test_type_id; + test_type_id = test_get_type_once (); + g_once_init_leave (&test_type_id__once, test_type_id); + } + return test_type_id__once; +} + +G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_TEST, test_proxy_test_interface_init) ) +static void +test_proxy_class_init (TestProxyClass* klass) +{ + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; + g_object_class_override_property (object_class, TEST_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); + g_object_class_override_property (object_class, TEST_PROXY_TEST_INT_PROPERTY_PROPERTY, "test-int-property"); + test_proxy_properties[TEST_PROXY_TEST_INT_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-int-property"); +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY]; + } else if (g_strcmp0 (dbus_property_name, "TestIntProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_INT_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + g_value_take_string (value, test_dbus_proxy_get_test_property (self)); + break; + case TEST_PROXY_TEST_INT_PROPERTY_PROPERTY: + g_value_set_int (value, test_dbus_proxy_get_test_int_property (self)); + break; + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_property (self, g_value_get_string (value)); + break; + case TEST_PROXY_TEST_INT_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_int_property (self, g_value_get_int (value)); + break; + default: + return; + } +} + +static void +test_proxy_g_signal (GDBusProxy* proxy, + const gchar* sender_name, + const gchar* signal_name, + GVariant* parameters) +{ +} + +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + +static void +test_proxy_init (TestProxy* self) +{ + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_test_dbus_interface_info)); +} + +static void +test_proxy_change_everything (Test* self, + GError** error) +{ + GDBusMessage *_message; + GVariant *_arguments; + GVariantBuilder _arguments_builder; + GDBusMessage *_reply_message; + _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.example.Test", "ChangeEverything"); + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + _arguments = g_variant_builder_end (&_arguments_builder); + g_dbus_message_set_body (_message, _arguments); + _reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error); + g_object_unref (_message); + if (!_reply_message) { + return; + } + if (g_dbus_message_to_gerror (_reply_message, error)) { + g_object_unref (_reply_message); + return; + } + g_object_unref (_reply_message); +} + +static void +test_proxy_check_everything (Test* self, + GError** error) +{ + GDBusMessage *_message; + GVariant *_arguments; + GVariantBuilder _arguments_builder; + GDBusMessage *_reply_message; + _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.example.Test", "CheckEverything"); + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + _arguments = g_variant_builder_end (&_arguments_builder); + g_dbus_message_set_body (_message, _arguments); + _reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error); + g_object_unref (_message); + if (!_reply_message) { + return; + } + if (g_dbus_message_to_gerror (_reply_message, error)) { + g_object_unref (_reply_message); + return; + } + g_object_unref (_reply_message); +} + +static gchar* +test_dbus_proxy_get_test_property (Test* self) +{ + GVariant *_inner_reply; + gchar* _result; + _inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "TestProperty"); + if (!_inner_reply) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.example.Test")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("TestProperty")); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return NULL; + } + g_variant_get (_reply, "(v)", &_inner_reply); + g_variant_unref (_reply); + } + _result = g_variant_dup_string (_inner_reply, NULL); + g_variant_unref (_inner_reply); + return _result; +} + +static void +test_dbus_proxy_set_test_property (Test* self, + const gchar* value) +{ + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.example.Test")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("TestProperty")); + g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (value)); + g_variant_builder_close (&_arguments_builder); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_unref (_reply); +} + +static gint +test_dbus_proxy_get_test_int_property (Test* self) +{ + GVariant *_inner_reply; + gint _result; + _inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "TestIntProperty"); + if (!_inner_reply) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.example.Test")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("TestIntProperty")); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + gint _tmp0_ = 0; + return _tmp0_; + } + g_variant_get (_reply, "(v)", &_inner_reply); + g_variant_unref (_reply); + } + _result = g_variant_get_int32 (_inner_reply); + g_variant_unref (_inner_reply); + return _result; +} + +static void +test_dbus_proxy_set_test_int_property (Test* self, + gint value) +{ + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.example.Test")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("TestIntProperty")); + g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_int32 (value)); + g_variant_builder_close (&_arguments_builder); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_unref (_reply); +} + +static void +test_proxy_test_interface_init (TestIface* iface) +{ + iface->change_everything = test_proxy_change_everything; + iface->check_everything = test_proxy_check_everything; + iface->get_test_property = test_dbus_proxy_get_test_property; + iface->set_test_property = test_dbus_proxy_set_test_property; + iface->get_test_int_property = test_dbus_proxy_get_test_int_property; + iface->set_test_int_property = test_dbus_proxy_set_test_int_property; +} + +static void +_dbus_test_change_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation) +{ + GError* error = NULL; + GVariantIter _arguments_iter; + GDBusMessage* _reply_message = NULL; + GVariant* _reply; + GVariantBuilder _reply_builder; + g_variant_iter_init (&_arguments_iter, _parameters_); + test_change_everything (self, &error); + if (error) { + g_dbus_method_invocation_take_error (invocation, error); + return; + } + _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation)); + g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE); + _reply = g_variant_builder_end (&_reply_builder); + g_dbus_message_set_body (_reply_message, _reply); + g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_object_unref (invocation); + g_object_unref (_reply_message); +} + +static void +_dbus_test_check_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation) +{ + GError* error = NULL; + GVariantIter _arguments_iter; + GDBusMessage* _reply_message = NULL; + GVariant* _reply; + GVariantBuilder _reply_builder; + g_variant_iter_init (&_arguments_iter, _parameters_); + test_check_everything (self, &error); + if (error) { + g_dbus_method_invocation_take_error (invocation, error); + return; + } + _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation)); + g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE); + _reply = g_variant_builder_end (&_reply_builder); + g_dbus_message_set_body (_reply_message, _reply); + g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_object_unref (invocation); + g_object_unref (_reply_message); +} + +static void +test_dbus_interface_method_call (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (method_name, "ChangeEverything") == 0) { + _dbus_test_change_everything (object, parameters, invocation); + } else if (strcmp (method_name, "CheckEverything") == 0) { + _dbus_test_check_everything (object, parameters, invocation); + } else { + g_object_unref (invocation); + } +} + +static GVariant* +_dbus_test_get_test_property (Test* self) +{ + gchar* result; + GVariant* _reply; + result = test_get_test_property (self); + _reply = g_variant_new_string (result); + _g_free0 (result); + return _reply; +} + +static GVariant* +_dbus_test_get_test_int_property (Test* self) +{ + gint result; + GVariant* _reply; + result = test_get_test_int_property (self); + _reply = g_variant_new_int32 (result); + return _reply; +} + +static GVariant* +test_dbus_interface_get_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GError** error, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "TestProperty") == 0) { + return _dbus_test_get_test_property (object); + } else if (strcmp (property_name, "TestIntProperty") == 0) { + return _dbus_test_get_test_int_property (object); + } + return NULL; +} + +static void +_dbus_test_set_test_property (Test* self, + GVariant* _value) +{ + gchar* value = NULL; + value = g_variant_dup_string (_value, NULL); + test_set_test_property (self, value); + _g_free0 (value); +} + +static void +_dbus_test_set_test_int_property (Test* self, + GVariant* _value) +{ + gint value = 0; + value = g_variant_get_int32 (_value); + test_set_test_int_property (self, value); +} + +static gboolean +test_dbus_interface_set_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GVariant* value, + GError** error, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "TestProperty") == 0) { + _dbus_test_set_test_property (object, value); + return TRUE; + } else if (strcmp (property_name, "TestIntProperty") == 0) { + _dbus_test_set_test_int_property (object, value); + return TRUE; + } + return FALSE; +} + +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +static void +_test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_int_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestIntProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +guint +test_register_object (gpointer object, + GDBusConnection* connection, + const gchar* path, + GError** error) +{ + guint result; + gpointer *data; + data = g_new (gpointer, 3); + data[0] = g_object_ref (object); + data[1] = g_object_ref (connection); + data[2] = g_strdup (path); + result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_test_dbus_interface_info), &_test_dbus_interface_vtable, data, _test_unregister_object, error); + if (!result) { + return 0; + } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); + g_signal_connect (object, "notify::test-int-property", (GCallback) _test_notify_test_int_property, data); + return result; +} + +static void +_test_unregister_object (gpointer user_data) +{ + gpointer* data; + data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_int_property, data); + g_object_unref (data[0]); + g_object_unref (data[1]); + g_free (data[2]); + g_free (data); +} + +static inline gpointer +test2_get_instance_private (Test2* self) +{ + return G_STRUCT_MEMBER_P (self, Test2_private_offset); +} + +Test2* +test2_construct (GType object_type) +{ + Test2 * self = NULL; + self = (Test2*) g_object_new (object_type, NULL); + return self; +} + +Test2* +test2_new (void) +{ + return test2_construct (TYPE_TEST2); +} + +const gchar* +test2_get_test_property (Test2* self) +{ + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (IS_TEST2 (self), NULL); + _tmp0_ = self->priv->_test_property; + result = _tmp0_; + return result; +} + +void +test2_set_test_property (Test2* self, + const gchar* value) +{ + gchar* old_value; + g_return_if_fail (IS_TEST2 (self)); + old_value = test2_get_test_property (self); + if (g_strcmp0 (value, old_value) != 0) { + gchar* _tmp0_; + _tmp0_ = g_strdup (value); + _g_free0 (self->priv->_test_property); + self->priv->_test_property = _tmp0_; + g_object_notify_by_pspec ((GObject *) self, test2_properties[TEST2_TEST_PROPERTY_PROPERTY]); + } +} + +gint +test2_get_test_int_property (Test2* self) +{ + gint result; + g_return_val_if_fail (IS_TEST2 (self), 0); + result = self->priv->_test_int_property; + return result; +} + +void +test2_set_test_int_property (Test2* self, + gint value) +{ + gint old_value; + g_return_if_fail (IS_TEST2 (self)); + old_value = test2_get_test_int_property (self); + if (old_value != value) { + self->priv->_test_int_property = value; + g_object_notify_by_pspec ((GObject *) self, test2_properties[TEST2_TEST_INT_PROPERTY_PROPERTY]); + } +} + +static void +test2_class_init (Test2Class * klass, + gpointer klass_data) +{ + test2_parent_class = g_type_class_peek_parent (klass); + g_type_class_adjust_private_offset (klass, &Test2_private_offset); + G_OBJECT_CLASS (klass)->get_property = _vala_test2_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_test2_set_property; + G_OBJECT_CLASS (klass)->finalize = test2_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), TEST2_TEST_PROPERTY_PROPERTY, test2_properties[TEST2_TEST_PROPERTY_PROPERTY] = g_param_spec_string ("test-property", "test-property", "test-property", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), TEST2_TEST_INT_PROPERTY_PROPERTY, test2_properties[TEST2_TEST_INT_PROPERTY_PROPERTY] = g_param_spec_int ("test-int-property", "test-int-property", "test-int-property", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +static void +test2_instance_init (Test2 * self, + gpointer klass) +{ + self->priv = test2_get_instance_private (self); +} + +static void +test2_finalize (GObject * obj) +{ + Test2 * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TEST2, Test2); + _g_free0 (self->priv->_test_property); + G_OBJECT_CLASS (test2_parent_class)->finalize (obj); +} + +static GType +test2_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (Test2Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test2_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Test2), 0, (GInstanceInitFunc) test2_instance_init, NULL }; + GType test2_type_id; + test2_type_id = g_type_register_static (G_TYPE_OBJECT, "Test2", &g_define_type_info, 0); + Test2_private_offset = g_type_add_instance_private (test2_type_id, sizeof (Test2Private)); + return test2_type_id; +} + +GType +test2_get_type (void) +{ + static volatile gsize test2_type_id__once = 0; + if (g_once_init_enter (&test2_type_id__once)) { + GType test2_type_id; + test2_type_id = test2_get_type_once (); + g_once_init_leave (&test2_type_id__once, test2_type_id); + } + return test2_type_id__once; +} + +static void +_vala_test2_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec) +{ + Test2 * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST2, Test2); + switch (property_id) { + case TEST2_TEST_PROPERTY_PROPERTY: + g_value_set_string (value, test2_get_test_property (self)); + break; + case TEST2_TEST_INT_PROPERTY_PROPERTY: + g_value_set_int (value, test2_get_test_int_property (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +_vala_test2_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + Test2 * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST2, Test2); + switch (property_id) { + case TEST2_TEST_PROPERTY_PROPERTY: + test2_set_test_property (self, g_value_get_string (value)); + break; + case TEST2_TEST_INT_PROPERTY_PROPERTY: + test2_set_test_int_property (self, g_value_get_int (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static Block1Data* +block1_data_ref (Block1Data* _data1_) +{ + g_atomic_int_inc (&_data1_->_ref_count_); + return _data1_; +} + +static void +block1_data_unref (void * _userdata_) +{ + Block1Data* _data1_; + _data1_ = (Block1Data*) _userdata_; + if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) { + _g_main_loop_unref0 (_data1_->main_loop); + g_slice_free (Block1Data, _data1_); + } +} + +static void +_vala_lambda0_ (Block1Data* _data1_, + GParamSpec* p) +{ + const gchar* _tmp0_; + GMainLoop* _tmp1_; + g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (p, G_TYPE_PARAM)); + _tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (p, G_TYPE_PARAM_INT, GParamSpecInt), G_TYPE_PARAM, GParamSpec)->name; + _vala_assert (g_strcmp0 (_tmp0_, "test-int-property") == 0, "((ParamSpecInt) p).name == \"test-int-property\""); + _tmp1_ = _data1_->main_loop; + g_main_loop_quit (_tmp1_); +} + +static void +__vala_lambda0__g_object_notify (GObject* _sender, + GParamSpec* pspec, + gpointer self) +{ + _vala_lambda0_ (self, pspec); +} + +static Block2Data* +block2_data_ref (Block2Data* _data2_) +{ + g_atomic_int_inc (&_data2_->_ref_count_); + return _data2_; +} + +static void +block2_data_unref (void * _userdata_) +{ + Block2Data* _data2_; + _data2_ = (Block2Data*) _userdata_; + if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) { + _g_main_loop_unref0 (_data2_->main_loop2); + g_slice_free (Block2Data, _data2_); + } +} + +static void +_vala_lambda1_ (Block2Data* _data2_, + GParamSpec* p) +{ + const gchar* _tmp0_; + GMainLoop* _tmp1_; + g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (p, G_TYPE_PARAM)); + _tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (p, G_TYPE_PARAM_STRING, GParamSpecString), G_TYPE_PARAM, GParamSpec)->name; + _vala_assert (g_strcmp0 (_tmp0_, "test-property") == 0, "((ParamSpecString) p).name == \"test-property\""); + _tmp1_ = _data2_->main_loop2; + g_main_loop_quit (_tmp1_); +} + +static void +__vala_lambda1__g_object_notify (GObject* _sender, + GParamSpec* pspec, + gpointer self) +{ + _vala_lambda1_ (self, pspec); +} + +static void +_vala_main (void) +{ + Test* test = NULL; + Test* _tmp0_; + Test* _tmp1_; + gchar* _tmp2_; + gchar* _tmp3_; + gchar* _tmp4_; + Test* _tmp5_; + gint _tmp6_; + gint _tmp7_; + Test2* test2 = NULL; + Test2* _tmp8_; + Test* _tmp9_; + Test2* _tmp10_; + Test* _tmp11_; + Test2* _tmp12_; + GError* _inner_error0_ = NULL; + _tmp0_ = (Test*) g_initable_new (TYPE_TEST_PROXY, NULL, &_inner_error0_, "g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-name", "org.example.Test", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/example/test", "g-interface-name", "org.example.Test", NULL); + test = (Test*) _tmp0_; + if (G_UNLIKELY (_inner_error0_ != NULL)) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + _tmp1_ = test; + _tmp2_ = test_get_test_property (_tmp1_); + _tmp3_ = _tmp2_; + _tmp4_ = _tmp3_; + _vala_assert (g_strcmp0 (_tmp4_, "foo") == 0, "test.test_property == \"foo\""); + _g_free0 (_tmp4_); + _tmp5_ = test; + _tmp6_ = test_get_test_int_property (_tmp5_); + _tmp7_ = _tmp6_; + _vala_assert (_tmp7_ == 17, "test.test_int_property == 17"); + _tmp8_ = test2_new (); + test2 = _tmp8_; + _tmp9_ = test; + _tmp10_ = test2; + g_object_bind_property_with_closures (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, G_TYPE_OBJECT, GObject), "test-property", G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, G_TYPE_OBJECT, GObject), "test-property", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL))); + _tmp11_ = test; + _tmp12_ = test2; + g_object_bind_property_with_closures (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, G_TYPE_OBJECT, GObject), "test-int-property", G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, G_TYPE_OBJECT, GObject), "test-int-property", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL))); + { + Block1Data* _data1_; + GMainLoop* _tmp13_; + Test2* _tmp14_; + const gchar* _tmp15_; + const gchar* _tmp16_; + Test2* _tmp17_; + gint _tmp18_; + gint _tmp19_; + Test2* _tmp20_; + Test* _tmp21_; + GMainLoop* _tmp22_; + Test* _tmp23_; + gchar* _tmp24_; + gchar* _tmp25_; + gchar* _tmp26_; + Test* _tmp27_; + gint _tmp28_; + gint _tmp29_; + _data1_ = g_slice_new0 (Block1Data); + _data1_->_ref_count_ = 1; + _tmp13_ = g_main_loop_new (NULL, FALSE); + _data1_->main_loop = _tmp13_; + _tmp14_ = test2; + _tmp15_ = test2_get_test_property (_tmp14_); + _tmp16_ = _tmp15_; + _vala_assert (g_strcmp0 (_tmp16_, "foo") == 0, "test2.test_property == \"foo\""); + _tmp17_ = test2; + _tmp18_ = test2_get_test_int_property (_tmp17_); + _tmp19_ = _tmp18_; + _vala_assert (_tmp19_ == 17, "test2.test_int_property == 17"); + _tmp20_ = test2; + g_signal_connect_data (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, G_TYPE_OBJECT, GObject), "notify::test-int-property", (GCallback) __vala_lambda0__g_object_notify, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); + _tmp21_ = test; + test_change_everything (_tmp21_, &_inner_error0_); + if (G_UNLIKELY (_inner_error0_ != NULL)) { + block1_data_unref (_data1_); + _data1_ = NULL; + _g_object_unref0 (test2); + _g_object_unref0 (test); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + _tmp22_ = _data1_->main_loop; + g_main_loop_run (_tmp22_); + _tmp23_ = test; + _tmp24_ = test_get_test_property (_tmp23_); + _tmp25_ = _tmp24_; + _tmp26_ = _tmp25_; + _vala_assert (g_strcmp0 (_tmp26_, "bar") == 0, "test.test_property == \"bar\""); + _g_free0 (_tmp26_); + _tmp27_ = test; + _tmp28_ = test_get_test_int_property (_tmp27_); + _tmp29_ = _tmp28_; + _vala_assert (_tmp29_ == 53, "test.test_int_property == 53"); + block1_data_unref (_data1_); + _data1_ = NULL; + } + { + Block2Data* _data2_; + GMainLoop* _tmp30_; + Test2* _tmp31_; + const gchar* _tmp32_; + const gchar* _tmp33_; + Test2* _tmp34_; + gint _tmp35_; + gint _tmp36_; + Test* _tmp37_; + Test2* _tmp38_; + Test2* _tmp39_; + GMainLoop* _tmp40_; + Test2* _tmp41_; + const gchar* _tmp42_; + const gchar* _tmp43_; + Test2* _tmp44_; + gint _tmp45_; + gint _tmp46_; + Test* _tmp47_; + _data2_ = g_slice_new0 (Block2Data); + _data2_->_ref_count_ = 1; + _tmp30_ = g_main_loop_new (NULL, FALSE); + _data2_->main_loop2 = _tmp30_; + _tmp31_ = test2; + _tmp32_ = test2_get_test_property (_tmp31_); + _tmp33_ = _tmp32_; + _vala_assert (g_strcmp0 (_tmp33_, "bar") == 0, "test2.test_property == \"bar\""); + _tmp34_ = test2; + _tmp35_ = test2_get_test_int_property (_tmp34_); + _tmp36_ = _tmp35_; + _vala_assert (_tmp36_ == 53, "test2.test_int_property == 53"); + _tmp37_ = test; + g_signal_connect_data (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, G_TYPE_OBJECT, GObject), "notify::test-property", (GCallback) __vala_lambda1__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0); + _tmp38_ = test2; + test2_set_test_property (_tmp38_, "baz"); + _tmp39_ = test2; + test2_set_test_int_property (_tmp39_, 765); + _tmp40_ = _data2_->main_loop2; + g_main_loop_run (_tmp40_); + _tmp41_ = test2; + _tmp42_ = test2_get_test_property (_tmp41_); + _tmp43_ = _tmp42_; + _vala_assert (g_strcmp0 (_tmp43_, "baz") == 0, "test2.test_property == \"baz\""); + _tmp44_ = test2; + _tmp45_ = test2_get_test_int_property (_tmp44_); + _tmp46_ = _tmp45_; + _vala_assert (_tmp46_ == 765, "test2.test_int_property == 765"); + _tmp47_ = test; + test_check_everything (_tmp47_, &_inner_error0_); + if (G_UNLIKELY (_inner_error0_ != NULL)) { + block2_data_unref (_data2_); + _data2_ = NULL; + _g_object_unref0 (test2); + _g_object_unref0 (test); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + block2_data_unref (_data2_); + _data2_ = NULL; + } + _g_object_unref0 (test2); + _g_object_unref0 (test); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/dbus/properties_server.c-expected b/tests/dbus/properties_server.c-expected new file mode 100644 index 000000000..e0f83baff --- /dev/null +++ b/tests/dbus/properties_server.c-expected @@ -0,0 +1,747 @@ +/* dbus_properties_server.c generated by valac, the Vala compiler + * generated from dbus_properties_server.vala, do not modify */ + +#include +#include +#include +#include +#include + +#if !defined(VALA_STRICT_C) +#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14) +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" +#elif defined(__clang__) && (__clang_major__ >= 16) +#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types" +#pragma clang diagnostic ignored "-Wincompatible-pointer-types" +#endif +#endif +#if !defined(VALA_EXTERN) +#if defined(_WIN32) || defined(__CYGWIN__) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +#define TYPE_TEST (test_get_type ()) +#define TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST, Test)) +#define TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEST, TestClass)) +#define IS_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST)) +#define IS_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEST)) +#define TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEST, TestClass)) + +typedef struct _Test Test; +typedef struct _TestClass TestClass; +typedef struct _TestPrivate TestPrivate; +enum { + TEST_0_PROPERTY, + TEST_TEST_PROPERTY_PROPERTY, + TEST_TEST_INT_PROPERTY_PROPERTY, + TEST_NUM_PROPERTIES +}; +static GParamSpec* test_properties[TEST_NUM_PROPERTIES]; +#define _g_free0(var) (var = (g_free (var), NULL)) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) +#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) +#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); +#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } +#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } +#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); + +struct _Test { + GObject parent_instance; + TestPrivate * priv; +}; + +struct _TestClass { + GObjectClass parent_class; +}; + +struct _TestPrivate { + gchar* _test_property; + gint _test_int_property; +}; + +static gint Test_private_offset; +static gpointer test_parent_class = NULL; +VALA_EXTERN GMainLoop* main_loop; +GMainLoop* main_loop = NULL; + +VALA_EXTERN GType test_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) +VALA_EXTERN guint test_register_object (void* object, + GDBusConnection* connection, + const gchar* path, + GError** error); +VALA_EXTERN void test_change_everything (Test* self, + GError** error); +VALA_EXTERN void test_set_test_property (Test* self, + const gchar* value); +VALA_EXTERN void test_set_test_int_property (Test* self, + gint value); +VALA_EXTERN void test_check_everything (Test* self, + GError** error); +VALA_EXTERN gchar* test_get_test_property (Test* self); +VALA_EXTERN gint test_get_test_int_property (Test* self); +VALA_EXTERN Test* test_new (void); +VALA_EXTERN Test* test_construct (GType object_type); +static void test_finalize (GObject * obj); +static GType test_get_type_once (void); +static void _vala_test_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec); +static void _vala_test_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec); +static void _dbus_test_change_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation); +static void _dbus_test_check_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation); +static void test_dbus_interface_method_call (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data); +static GVariant* test_dbus_interface_get_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GError** error, + gpointer user_data); +static GVariant* _dbus_test_get_test_property (Test* self); +static GVariant* _dbus_test_get_test_int_property (Test* self); +static gboolean test_dbus_interface_set_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GVariant* value, + GError** error, + gpointer user_data); +static void _dbus_test_set_test_property (Test* self, + GVariant* _value); +static void _dbus_test_set_test_int_property (Test* self, + GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); +static void _test_unregister_object (gpointer user_data); +VALA_EXTERN void client_exit (GPid pid, + gint status); +static void _vala_main (void); +static guint _variant_get1 (GVariant* value); +static void _client_exit_gchild_watch_func (GPid pid, + gint wait_status, + gpointer self); +static void _vala_array_destroy (gpointer array, + gssize array_length, + GDestroyNotify destroy_func); +static void _vala_array_free (gpointer array, + gssize array_length, + GDestroyNotify destroy_func); + +static const GDBusArgInfo * const _test_dbus_arg_info_change_everything_in[] = {NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_change_everything_out[] = {NULL}; +static const GDBusMethodInfo _test_dbus_method_info_change_everything = {-1, "ChangeEverything", (GDBusArgInfo **) (&_test_dbus_arg_info_change_everything_in), (GDBusArgInfo **) (&_test_dbus_arg_info_change_everything_out), NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_check_everything_in[] = {NULL}; +static const GDBusArgInfo * const _test_dbus_arg_info_check_everything_out[] = {NULL}; +static const GDBusMethodInfo _test_dbus_method_info_check_everything = {-1, "CheckEverything", (GDBusArgInfo **) (&_test_dbus_arg_info_check_everything_in), (GDBusArgInfo **) (&_test_dbus_arg_info_check_everything_out), NULL}; +static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_change_everything, &_test_dbus_method_info_check_everything, NULL}; +static const GDBusSignalInfo * const _test_dbus_signal_info[] = {NULL}; +static const GDBusPropertyInfo _test_dbus_property_info_test_property = {-1, "TestProperty", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL}; +static const GDBusPropertyInfo _test_dbus_property_info_test_int_property = {-1, "TestIntProperty", "i", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL}; +static const GDBusPropertyInfo * const _test_dbus_property_info[] = {&_test_dbus_property_info_test_property, &_test_dbus_property_info_test_int_property, NULL}; +static const GDBusInterfaceInfo _test_dbus_interface_info = {-1, "org.example.Test", (GDBusMethodInfo **) (&_test_dbus_method_info), (GDBusSignalInfo **) (&_test_dbus_signal_info), (GDBusPropertyInfo **) (&_test_dbus_property_info), NULL}; +static const GDBusInterfaceVTable _test_dbus_interface_vtable = {test_dbus_interface_method_call, test_dbus_interface_get_property, test_dbus_interface_set_property}; + +static inline gpointer +test_get_instance_private (Test* self) +{ + return G_STRUCT_MEMBER_P (self, Test_private_offset); +} + +void +test_change_everything (Test* self, + GError** error) +{ + g_return_if_fail (IS_TEST (self)); + test_set_test_property (self, "bar"); + test_set_test_int_property (self, 53); +} + +void +test_check_everything (Test* self, + GError** error) +{ + gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + gint _tmp3_; + g_return_if_fail (IS_TEST (self)); + _tmp0_ = test_get_test_property (self); + _tmp1_ = _tmp0_; + _tmp2_ = _tmp1_; + _vala_assert (g_strcmp0 (_tmp2_, "baz") == 0, "test_property == \"baz\""); + _g_free0 (_tmp2_); + _tmp3_ = self->priv->_test_int_property; + _vala_assert (_tmp3_ == 765, "test_int_property == 765"); +} + +Test* +test_construct (GType object_type) +{ + Test * self = NULL; + self = (Test*) g_object_new (object_type, NULL); + return self; +} + +Test* +test_new (void) +{ + return test_construct (TYPE_TEST); +} + +gchar* +test_get_test_property (Test* self) +{ + gchar* result; + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_val_if_fail (IS_TEST (self), NULL); + _tmp0_ = self->priv->_test_property; + _tmp1_ = g_strdup (_tmp0_); + result = _tmp1_; + return result; +} + +void +test_set_test_property (Test* self, + const gchar* value) +{ + gchar* old_value; + g_return_if_fail (IS_TEST (self)); + old_value = test_get_test_property (self); + if (g_strcmp0 (value, old_value) != 0) { + gchar* _tmp0_; + _tmp0_ = g_strdup (value); + _g_free0 (self->priv->_test_property); + self->priv->_test_property = _tmp0_; + g_object_notify_by_pspec ((GObject *) self, test_properties[TEST_TEST_PROPERTY_PROPERTY]); + } + _g_free0 (old_value); +} + +gint +test_get_test_int_property (Test* self) +{ + gint result; + g_return_val_if_fail (IS_TEST (self), 0); + result = self->priv->_test_int_property; + return result; +} + +void +test_set_test_int_property (Test* self, + gint value) +{ + gint old_value; + g_return_if_fail (IS_TEST (self)); + old_value = test_get_test_int_property (self); + if (old_value != value) { + self->priv->_test_int_property = value; + g_object_notify_by_pspec ((GObject *) self, test_properties[TEST_TEST_INT_PROPERTY_PROPERTY]); + } +} + +static void +test_class_init (TestClass * klass, + gpointer klass_data) +{ + test_parent_class = g_type_class_peek_parent (klass); + g_type_class_adjust_private_offset (klass, &Test_private_offset); + G_OBJECT_CLASS (klass)->get_property = _vala_test_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_test_set_property; + G_OBJECT_CLASS (klass)->finalize = test_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_TEST_PROPERTY_PROPERTY, test_properties[TEST_TEST_PROPERTY_PROPERTY] = g_param_spec_string ("test-property", "test-property", "test-property", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_TEST_INT_PROPERTY_PROPERTY, test_properties[TEST_TEST_INT_PROPERTY_PROPERTY] = g_param_spec_int ("test-int-property", "test-int-property", "test-int-property", G_MININT, G_MAXINT, 17, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +static void +test_instance_init (Test * self, + gpointer klass) +{ + gchar* _tmp0_; + self->priv = test_get_instance_private (self); + _tmp0_ = g_strdup ("foo"); + self->priv->_test_property = _tmp0_; + self->priv->_test_int_property = 17; +} + +static void +test_finalize (GObject * obj) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TEST, Test); + _g_free0 (self->priv->_test_property); + G_OBJECT_CLASS (test_parent_class)->finalize (obj); +} + +static GType +test_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (TestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Test), 0, (GInstanceInitFunc) test_instance_init, NULL }; + GType test_type_id; + test_type_id = g_type_register_static (G_TYPE_OBJECT, "Test", &g_define_type_info, 0); + g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) test_register_object); + Test_private_offset = g_type_add_instance_private (test_type_id, sizeof (TestPrivate)); + return test_type_id; +} + +GType +test_get_type (void) +{ + static volatile gsize test_type_id__once = 0; + if (g_once_init_enter (&test_type_id__once)) { + GType test_type_id; + test_type_id = test_get_type_once (); + g_once_init_leave (&test_type_id__once, test_type_id); + } + return test_type_id__once; +} + +static void +_vala_test_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_TEST_PROPERTY_PROPERTY: + g_value_take_string (value, test_get_test_property (self)); + break; + case TEST_TEST_INT_PROPERTY_PROPERTY: + g_value_set_int (value, test_get_test_int_property (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +_vala_test_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_TEST_PROPERTY_PROPERTY: + test_set_test_property (self, g_value_get_string (value)); + break; + case TEST_TEST_INT_PROPERTY_PROPERTY: + test_set_test_int_property (self, g_value_get_int (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +_dbus_test_change_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation) +{ + GError* error = NULL; + GVariantIter _arguments_iter; + GDBusMessage* _reply_message = NULL; + GVariant* _reply; + GVariantBuilder _reply_builder; + g_variant_iter_init (&_arguments_iter, _parameters_); + test_change_everything (self, &error); + if (error) { + g_dbus_method_invocation_take_error (invocation, error); + return; + } + _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation)); + g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE); + _reply = g_variant_builder_end (&_reply_builder); + g_dbus_message_set_body (_reply_message, _reply); + g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_object_unref (invocation); + g_object_unref (_reply_message); +} + +static void +_dbus_test_check_everything (Test* self, + GVariant* _parameters_, + GDBusMethodInvocation* invocation) +{ + GError* error = NULL; + GVariantIter _arguments_iter; + GDBusMessage* _reply_message = NULL; + GVariant* _reply; + GVariantBuilder _reply_builder; + g_variant_iter_init (&_arguments_iter, _parameters_); + test_check_everything (self, &error); + if (error) { + g_dbus_method_invocation_take_error (invocation, error); + return; + } + _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation)); + g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE); + _reply = g_variant_builder_end (&_reply_builder); + g_dbus_message_set_body (_reply_message, _reply); + g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_object_unref (invocation); + g_object_unref (_reply_message); +} + +static void +test_dbus_interface_method_call (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (method_name, "ChangeEverything") == 0) { + _dbus_test_change_everything (object, parameters, invocation); + } else if (strcmp (method_name, "CheckEverything") == 0) { + _dbus_test_check_everything (object, parameters, invocation); + } else { + g_object_unref (invocation); + } +} + +static GVariant* +_dbus_test_get_test_property (Test* self) +{ + gchar* result; + GVariant* _reply; + result = test_get_test_property (self); + _reply = g_variant_new_string (result); + _g_free0 (result); + return _reply; +} + +static GVariant* +_dbus_test_get_test_int_property (Test* self) +{ + gint result; + GVariant* _reply; + result = test_get_test_int_property (self); + _reply = g_variant_new_int32 (result); + return _reply; +} + +static GVariant* +test_dbus_interface_get_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GError** error, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "TestProperty") == 0) { + return _dbus_test_get_test_property (object); + } else if (strcmp (property_name, "TestIntProperty") == 0) { + return _dbus_test_get_test_int_property (object); + } + return NULL; +} + +static void +_dbus_test_set_test_property (Test* self, + GVariant* _value) +{ + gchar* value = NULL; + value = g_variant_dup_string (_value, NULL); + test_set_test_property (self, value); + _g_free0 (value); +} + +static void +_dbus_test_set_test_int_property (Test* self, + GVariant* _value) +{ + gint value = 0; + value = g_variant_get_int32 (_value); + test_set_test_int_property (self, value); +} + +static gboolean +test_dbus_interface_set_property (GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* property_name, + GVariant* value, + GError** error, + gpointer user_data) +{ + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "TestProperty") == 0) { + _dbus_test_set_test_property (object, value); + return TRUE; + } else if (strcmp (property_name, "TestIntProperty") == 0) { + _dbus_test_set_test_int_property (object, value); + return TRUE; + } + return FALSE; +} + +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +static void +_test_notify_test_int_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_int_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestIntProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + +guint +test_register_object (gpointer object, + GDBusConnection* connection, + const gchar* path, + GError** error) +{ + guint result; + gpointer *data; + data = g_new (gpointer, 3); + data[0] = g_object_ref (object); + data[1] = g_object_ref (connection); + data[2] = g_strdup (path); + result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_test_dbus_interface_info), &_test_dbus_interface_vtable, data, _test_unregister_object, error); + if (!result) { + return 0; + } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); + g_signal_connect (object, "notify::test-int-property", (GCallback) _test_notify_test_int_property, data); + return result; +} + +static void +_test_unregister_object (gpointer user_data) +{ + gpointer* data; + data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_int_property, data); + g_object_unref (data[0]); + g_object_unref (data[1]); + g_free (data[2]); + g_free (data); +} + +void +client_exit (GPid pid, + gint status) +{ + GMainLoop* _tmp0_; + _vala_assert (status == 0, "status == 0"); + _tmp0_ = main_loop; + g_main_loop_quit (_tmp0_); +} + +static guint +_variant_get1 (GVariant* value) +{ + return g_variant_get_uint32 (value); +} + +static void +_client_exit_gchild_watch_func (GPid pid, + gint wait_status, + gpointer self) +{ + client_exit (pid, wait_status); +} + +static void +_vala_main (void) +{ + GDBusConnection* conn = NULL; + GDBusConnection* _tmp0_; + GDBusConnection* _tmp1_; + Test* _tmp2_; + Test* _tmp3_; + GVariant* request_result = NULL; + GDBusConnection* _tmp4_; + GVariant* _tmp5_; + GVariant* _tmp6_; + GVariant* _tmp7_; + GVariant* _tmp8_; + GVariant* _tmp9_; + GVariant* _tmp10_; + GVariant* _tmp11_; + guint _tmp12_; + GPid client_pid = 0; + gchar* _tmp13_; + gchar** _tmp14_; + gchar** _tmp15_; + gint _tmp15__length1; + GPid _tmp16_ = 0; + GMainLoop* _tmp17_; + GMainLoop* _tmp18_; + GError* _inner_error0_ = NULL; + _tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error0_); + conn = _tmp0_; + if (G_UNLIKELY (_inner_error0_ != NULL)) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + _tmp1_ = conn; + _tmp2_ = test_new (); + _tmp3_ = _tmp2_; + test_register_object (_tmp3_, _tmp1_, "/org/example/test", &_inner_error0_); + _g_object_unref0 (_tmp3_); + if (G_UNLIKELY (_inner_error0_ != NULL)) { + _g_object_unref0 (conn); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + _tmp4_ = conn; + _tmp5_ = g_variant_new ("(su)", "org.example.Test", 0x4, NULL); + g_variant_ref_sink (_tmp5_); + _tmp6_ = _tmp5_; + _tmp7_ = g_dbus_connection_call_sync (_tmp4_, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName", _tmp6_, NULL, 0, -1, NULL, &_inner_error0_); + _tmp8_ = _tmp7_; + _g_variant_unref0 (_tmp6_); + request_result = _tmp8_; + if (G_UNLIKELY (_inner_error0_ != NULL)) { + _g_object_unref0 (conn); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + _tmp9_ = request_result; + _tmp10_ = g_variant_get_child_value (_tmp9_, (gsize) 0); + _tmp11_ = _tmp10_; + _tmp12_ = _variant_get1 (_tmp11_); + _vala_assert (_tmp12_ == ((guint) 1), "(uint) request_result.get_child_value (0) == 1"); + _g_variant_unref0 (_tmp11_); + _tmp13_ = g_strdup ("dbus_properties_client"); + _tmp14_ = g_new0 (gchar*, 1 + 1); + _tmp14_[0] = _tmp13_; + _tmp15_ = _tmp14_; + _tmp15__length1 = 1; + g_spawn_async (NULL, _tmp15_, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &_tmp16_, &_inner_error0_); + client_pid = _tmp16_; + _tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) g_free), NULL); + if (G_UNLIKELY (_inner_error0_ != NULL)) { + _g_variant_unref0 (request_result); + _g_object_unref0 (conn); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); + g_clear_error (&_inner_error0_); + return; + } + g_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, client_pid, _client_exit_gchild_watch_func, NULL, NULL); + _tmp17_ = g_main_loop_new (NULL, FALSE); + _g_main_loop_unref0 (main_loop); + main_loop = _tmp17_; + _tmp18_ = main_loop; + g_main_loop_run (_tmp18_); + _g_variant_unref0 (request_result); + _g_object_unref0 (conn); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + +static void +_vala_array_destroy (gpointer array, + gssize array_length, + GDestroyNotify destroy_func) +{ + if ((array != NULL) && (destroy_func != NULL)) { + gssize i; + for (i = 0; i < array_length; i = i + 1) { + if (((gpointer*) array)[i] != NULL) { + destroy_func (((gpointer*) array)[i]); + } + } + } +} + +static void +_vala_array_free (gpointer array, + gssize array_length, + GDestroyNotify destroy_func) +{ + _vala_array_destroy (array, array_length, destroy_func); + g_free (array); +} + diff --git a/tests/dbus/rawvariants_client.c-expected b/tests/dbus/rawvariants_client.c-expected index 63c9315f4..da7226471 100644 --- a/tests/dbus/rawvariants_client.c-expected +++ b/tests/dbus/rawvariants_client.c-expected @@ -41,6 +41,12 @@ enum { static guint test_signals[TEST_NUM_SIGNALS] = {0}; typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_TEST_PROPERTY_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_free0(var) (var = (g_free (var), NULL)) #define TYPE_TEST_RAW (test_raw_get_type ()) @@ -59,6 +65,12 @@ enum { static guint test_raw_signals[TEST_RAW_NUM_SIGNALS] = {0}; typedef GDBusProxy TestRawProxy; typedef GDBusProxyClass TestRawProxyClass; +enum { + TEST_RAW_PROXY_0_PROPERTY, + TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY, + TEST_RAW_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_raw_proxy_properties[TEST_RAW_PROXY_NUM_PROPERTIES]; #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) typedef struct _Block1Data Block1Data; #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) @@ -108,12 +120,24 @@ VALA_EXTERN gchar* test_get_test_property (Test* self); VALA_EXTERN void test_set_test_property (Test* self, const gchar* value); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); static void _dbus_handle_test_test_signal (Test* self, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static gint test_proxy_test_method (Test* self, gint j, gint k, @@ -154,6 +178,9 @@ static void _dbus_test_set_test_property (Test* self, static void _dbus_test_test_signal (GObject* _sender, gint i, gpointer* _data); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); VALA_EXTERN GType test_raw_proxy_get_type (void) G_GNUC_CONST ; VALA_EXTERN guint test_raw_register_object (void* object, @@ -170,12 +197,24 @@ VALA_EXTERN GVariant* test_raw_get_test_property (TestRaw* self); VALA_EXTERN void test_raw_set_test_property (TestRaw* self, GVariant* value); static GType test_raw_get_type_once (void); +static GParamSpec * _vala_test_raw_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_raw_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_raw_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_raw_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); static void _dbus_handle_test_raw_test_signal (TestRaw* self, GVariant* parameters); +static void test_raw_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static GVariant* test_raw_proxy_test_method (TestRaw* self, GVariant* j, GVariant* k, @@ -216,6 +255,9 @@ static void _dbus_test_raw_set_test_property (TestRaw* self, static void _dbus_test_raw_test_signal (GObject* _sender, GVariant* i, gpointer* _data); +static void _test_raw_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_raw_unregister_object (gpointer user_data); VALA_EXTERN void test_raw (TestRaw* test); static Block1Data* block1_data_ref (Block1Data* _data1_); @@ -315,6 +357,7 @@ static void test_default_init (TestIface * iface, gpointer iface_data) { + g_object_interface_install_property (iface, g_param_spec_string ("test-property", "test-property", "test-property", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); test_signals[TEST_TEST_SIGNAL_SIGNAL] = g_signal_new ("test-signal", TYPE_TEST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); } @@ -348,7 +391,59 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; + g_object_class_override_property (object_class, TEST_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + g_value_take_string (value, test_dbus_proxy_get_test_property (self)); + break; + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_property (self, g_value_get_string (value)); + break; + default: + return; + } } static void @@ -376,6 +471,31 @@ test_proxy_g_signal (GDBusProxy* proxy, } } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { @@ -614,6 +734,27 @@ _dbus_test_test_signal (GObject* _sender, g_dbus_connection_emit_signal (_connection, NULL, _path, "org.example.Test", "TestSignal", _arguments, NULL); } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -631,6 +772,7 @@ test_register_object (gpointer object, return 0; } g_signal_connect (object, "test-signal", (GCallback) _dbus_test_test_signal, data); + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -640,6 +782,7 @@ _test_unregister_object (gpointer user_data) gpointer* data; data = user_data; g_signal_handlers_disconnect_by_func (data[0], _dbus_test_test_signal, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); @@ -689,6 +832,7 @@ static void test_raw_default_init (TestRawIface * iface, gpointer iface_data) { + g_object_interface_install_property (iface, g_param_spec_variant ("test-property", "test-property", "test-property", G_VARIANT_TYPE_ANY, NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); test_raw_signals[TEST_RAW_TEST_SIGNAL_SIGNAL] = g_signal_new ("test-signal", TYPE_TEST_RAW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VARIANT, G_TYPE_NONE, 1, G_TYPE_VARIANT); } @@ -722,7 +866,59 @@ G_DEFINE_TYPE_EXTENDED (TestRawProxy, test_raw_proxy, G_TYPE_DBUS_PROXY, 0, G_IM static void test_raw_proxy_class_init (TestRawProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_raw_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_raw_proxy_g_signal; + proxy_class->g_properties_changed = test_raw_proxy_g_properties_changed; + object_class->get_property = test_raw_proxy_get_property; + object_class->set_property = test_raw_proxy_set_property; + g_object_class_override_property (object_class, TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_raw_proxy_properties[TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); +} + +static GParamSpec * +_vala_test_raw_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_raw_proxy_properties[TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_raw_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + TestRaw * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST_RAW, TestRaw); + switch (property_id) { + case TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY: + g_value_take_variant (value, test_raw_dbus_proxy_get_test_property (self)); + break; + default: + return; + } +} + +static void +test_raw_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + TestRaw * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST_RAW, TestRaw); + switch (property_id) { + case TEST_RAW_PROXY_TEST_PROPERTY_PROPERTY: + test_raw_dbus_proxy_set_test_property (self, g_value_get_variant (value)); + break; + default: + return; + } } static void @@ -748,6 +944,31 @@ test_raw_proxy_g_signal (GDBusProxy* proxy, } } +static void +test_raw_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_raw_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_raw_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_raw_proxy_init (TestRawProxy* self) { @@ -977,6 +1198,27 @@ _dbus_test_raw_test_signal (GObject* _sender, g_dbus_connection_emit_signal (_connection, NULL, _path, "org.example.Test", "TestSignal", _arguments, NULL); } +static void +_test_raw_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + TestRaw * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST_RAW, TestRaw); + variant = _dbus_test_raw_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_raw_register_object (gpointer object, GDBusConnection* connection, @@ -994,6 +1236,7 @@ test_raw_register_object (gpointer object, return 0; } g_signal_connect (object, "test-signal", (GCallback) _dbus_test_raw_test_signal, data); + g_signal_connect (object, "notify::test-property", (GCallback) _test_raw_notify_test_property, data); return result; } @@ -1003,6 +1246,7 @@ _test_raw_unregister_object (gpointer user_data) gpointer* data; data = user_data; g_signal_handlers_disconnect_by_func (data[0], _dbus_test_raw_test_signal, data); + g_signal_handlers_disconnect_by_func (data[0], _test_raw_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/rawvariants_server.c-expected b/tests/dbus/rawvariants_server.c-expected index 29f5dcc35..2844b22b4 100644 --- a/tests/dbus/rawvariants_server.c-expected +++ b/tests/dbus/rawvariants_server.c-expected @@ -166,6 +166,9 @@ static void _dbus_test_set_test_property (Test* self, static void _dbus_test_test_signal (GObject* _sender, gint i, gpointer* _data); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); VALA_EXTERN GType test_raw_get_type (void) G_GNUC_CONST ; G_DEFINE_AUTOPTR_CLEANUP_FUNC (TestRaw, g_object_unref) @@ -227,6 +230,9 @@ static void _dbus_test_raw_set_test_property (TestRaw* self, static void _dbus_test_raw_test_signal (GObject* _sender, GVariant* i, gpointer* _data); +static void _test_raw_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_raw_unregister_object (gpointer user_data); VALA_EXTERN void client_exit (GPid pid, gint status); @@ -557,6 +563,27 @@ _dbus_test_test_signal (GObject* _sender, g_dbus_connection_emit_signal (_connection, NULL, _path, "org.example.Test", "TestSignal", _arguments, NULL); } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -574,6 +601,7 @@ test_register_object (gpointer object, return 0; } g_signal_connect (object, "test-signal", (GCallback) _dbus_test_test_signal, data); + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -583,6 +611,7 @@ _test_unregister_object (gpointer user_data) gpointer* data; data = user_data; g_signal_handlers_disconnect_by_func (data[0], _dbus_test_test_signal, data); + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); @@ -909,6 +938,27 @@ _dbus_test_raw_test_signal (GObject* _sender, g_dbus_connection_emit_signal (_connection, NULL, _path, "org.example.Test", "TestSignal", _arguments, NULL); } +static void +_test_raw_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + TestRaw * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST_RAW, TestRaw); + variant = _dbus_test_raw_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_raw_register_object (gpointer object, GDBusConnection* connection, @@ -926,6 +976,7 @@ test_raw_register_object (gpointer object, return 0; } g_signal_connect (object, "test-signal", (GCallback) _dbus_test_raw_test_signal, data); + g_signal_connect (object, "notify::test-property", (GCallback) _test_raw_notify_test_property, data); return result; } @@ -935,6 +986,7 @@ _test_raw_unregister_object (gpointer user_data) gpointer* data; data = user_data; g_signal_handlers_disconnect_by_func (data[0], _dbus_test_raw_test_signal, data); + g_signal_handlers_disconnect_by_func (data[0], _test_raw_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/signals_client.c-expected b/tests/dbus/signals_client.c-expected index de9a7ccca..faa46138d 100644 --- a/tests/dbus/signals_client.c-expected +++ b/tests/dbus/signals_client.c-expected @@ -43,6 +43,11 @@ enum { static guint test_signals[TEST_NUM_SIGNALS] = {0}; typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); @@ -80,6 +85,15 @@ static void g_cclosure_user_marshal_VOID__BOXED_INT (GClosure * closure, gpointer invocation_hint, gpointer marshal_data); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, @@ -88,6 +102,9 @@ static void _dbus_handle_test_foo (Test* self, GVariant* parameters); static void _dbus_handle_test_bar (Test* self, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void test_proxy_do_foo (Test* self, gint i, GError** error); @@ -266,7 +283,48 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + default: + return; + } } static void @@ -334,6 +392,31 @@ test_proxy_g_signal (GDBusProxy* proxy, } } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { diff --git a/tests/dbus/structs_client.c-expected b/tests/dbus/structs_client.c-expected index 9be666981..07117808d 100644 --- a/tests/dbus/structs_client.c-expected +++ b/tests/dbus/structs_client.c-expected @@ -40,6 +40,12 @@ typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; +enum { + TEST_PROXY_0_PROPERTY, + TEST_PROXY_TEST_PROPERTY_PROPERTY, + TEST_PROXY_NUM_PROPERTIES +}; +static GParamSpec* test_proxy_properties[TEST_PROXY_NUM_PROPERTIES]; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } @@ -85,10 +91,22 @@ VALA_EXTERN void test_get_test_property (Test* self, VALA_EXTERN void test_set_test_property (Test* self, FooStruct * value); static GType test_get_type_once (void); +static GParamSpec * _vala_test_find_property_from_dbus_name (const gchar * dbus_property_name); +static void test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec); +static void test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); +static void test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties); static void test_proxy_test_struct (Test* self, FooStruct* f, FooStruct* g, @@ -128,6 +146,9 @@ static gboolean test_dbus_interface_set_property (GDBusConnection* connection, gpointer user_data); static void _dbus_test_set_test_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); static void _vala_main (void); @@ -257,6 +278,7 @@ static void test_default_init (TestIface * iface, gpointer iface_data) { + g_object_interface_install_property (iface, g_param_spec_boxed ("test-property", "test-property", "test-property", TYPE_FOO_STRUCT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); } static GType @@ -289,7 +311,64 @@ G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT static void test_proxy_class_init (TestProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; + GDBusProxyClass * proxy_class = G_DBUS_PROXY_CLASS (klass); + GObjectClass * object_class = G_OBJECT_CLASS (klass); + proxy_class->g_signal = test_proxy_g_signal; + proxy_class->g_properties_changed = test_proxy_g_properties_changed; + object_class->get_property = test_proxy_get_property; + object_class->set_property = test_proxy_set_property; + g_object_class_override_property (object_class, TEST_PROXY_TEST_PROPERTY_PROPERTY, "test-property"); + test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY] = g_object_class_find_property (object_class, "test-property"); +} + +static GParamSpec * +_vala_test_find_property_from_dbus_name (const gchar * dbus_property_name) +{ + if (g_strcmp0 (dbus_property_name, "TestProperty") == 0) { + return test_proxy_properties[TEST_PROXY_TEST_PROPERTY_PROPERTY]; + } + return NULL; +} + +static void +test_proxy_get_property (GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + Test * self; + GVariant * variant; + const gchar * dbus_property_name = NULL; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + { + FooStruct boxed; + test_dbus_proxy_get_test_property (self, &boxed); + g_value_set_boxed (value, &boxed); + foo_struct_destroy (&boxed); + } + break; + default: + return; + } +} + +static void +test_proxy_set_property (GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + Test * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TEST, Test); + switch (property_id) { + case TEST_PROXY_TEST_PROPERTY_PROPERTY: + test_dbus_proxy_set_test_property (self, g_value_get_boxed (value)); + break; + default: + return; + } } static void @@ -300,6 +379,31 @@ test_proxy_g_signal (GDBusProxy* proxy, { } +static void +test_proxy_g_properties_changed (GDBusProxy* proxy, + GVariant* changed_properties, + const gchar* const* invalidated_properties) +{ + GVariantIter * iter; + const gchar * key; + GParamSpec * pspec; + guint n; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { + pspec = _vala_test_find_property_from_dbus_name (key); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) { + pspec = _vala_test_find_property_from_dbus_name (invalidated_properties[n]); + if (pspec != NULL) { + g_object_notify_by_pspec ((GObject *) proxy, pspec); + } + } +} + static void test_proxy_init (TestProxy* self) { @@ -600,6 +704,27 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -616,6 +741,7 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -624,6 +750,7 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); diff --git a/tests/dbus/structs_server.c-expected b/tests/dbus/structs_server.c-expected index 090b314b0..09b624876 100644 --- a/tests/dbus/structs_server.c-expected +++ b/tests/dbus/structs_server.c-expected @@ -143,6 +143,9 @@ static gboolean test_dbus_interface_set_property (GDBusConnection* connection, gpointer user_data); static void _dbus_test_set_test_property (Test* self, GVariant* _value); +static void _test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data); static void _test_unregister_object (gpointer user_data); VALA_EXTERN void client_exit (GPid pid, gint status); @@ -589,6 +592,27 @@ test_dbus_interface_set_property (GDBusConnection* connection, return FALSE; } +static void +_test_notify_test_property (GObject * gobject, + GParamSpec * pspec, + gpointer user_data) +{ + gpointer* data = user_data; + GError* error = NULL; + GVariant* parameters = NULL; + GVariant* variant = NULL; + GVariantBuilder changed_builder; + GVariantBuilder invalidated_builder; + Test * self; + g_variant_builder_init (&changed_builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE_STRING_ARRAY); + self = G_TYPE_CHECK_INSTANCE_CAST (gobject, TYPE_TEST, Test); + variant = _dbus_test_get_test_property (self); + g_variant_builder_add (&changed_builder, "{sv}", "TestProperty", variant); + parameters = g_variant_new ("(sa{sv}as)", "org.example.Test", &changed_builder, &invalidated_builder); + g_dbus_connection_emit_signal ((GDBusConnection *) data[1], NULL, (const gchar *) data[2], "org.freedesktop.DBus.Properties", "PropertiesChanged", parameters, &error); +} + guint test_register_object (gpointer object, GDBusConnection* connection, @@ -605,6 +629,7 @@ test_register_object (gpointer object, if (!result) { return 0; } + g_signal_connect (object, "notify::test-property", (GCallback) _test_notify_test_property, data); return result; } @@ -613,6 +638,7 @@ _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; + g_signal_handlers_disconnect_by_func (data[0], _test_notify_test_property, data); g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]);