g_hash_table_unref (proxy->priv->properties);
if (proxy->priv->expected_interface != NULL)
- g_dbus_interface_info_unref (proxy->priv->expected_interface);
+ {
+ g_dbus_interface_info_cache_release (proxy->priv->expected_interface);
+ g_dbus_interface_info_unref (proxy->priv->expected_interface);
+ }
G_OBJECT_CLASS (g_dbus_proxy_parent_class)->finalize (object);
}
value = g_hash_table_lookup (proxy->priv->properties, property_name);
if (value == NULL)
{
- const GDBusPropertyInfo *info;
- info = lookup_property_info_or_warn (proxy, property_name);
+ lookup_property_info_or_warn (proxy, property_name);
/* no difference */
goto out;
}
* g_dbus_proxy_set_cached_property:
* @proxy: A #GDBusProxy
* @property_name: Property name.
- * @value: Value for the property or %NULL to remove it from the cache.
+ * @value: (allow-none): Value for the property or %NULL to remove it from the cache.
*
* If @value is not %NULL, sets the cached value for the property with
* name @property_name to the value in @value.
if (proxy->priv->name_owner != NULL && g_strcmp0 (sender_name, proxy->priv->name_owner) != 0)
goto out;
+ if (proxy->priv->expected_interface != NULL)
+ {
+ const GDBusSignalInfo *info;
+ GVariantType *expected_type;
+ info = g_dbus_interface_info_lookup_signal (proxy->priv->expected_interface, signal_name);
+ if (info == NULL)
+ goto out;
+ expected_type = _g_dbus_compute_complete_signature (info->args);
+ if (!g_variant_type_equal (expected_type, g_variant_get_type (parameters)))
+ {
+ g_variant_type_free (expected_type);
+ goto out;
+ }
+ g_variant_type_free (expected_type);
+ }
+
g_signal_emit (proxy,
signals[SIGNAL_SIGNAL],
0,
/* ---------------------------------------------------------------------------------------------------- */
static void
+insert_property_checked (GDBusProxy *proxy,
+ gchar *property_name,
+ GVariant *value)
+{
+ if (proxy->priv->expected_interface != NULL)
+ {
+ const GDBusPropertyInfo *info;
+
+ info = g_dbus_interface_info_lookup_property (proxy->priv->expected_interface, property_name);
+ /* Ignore unknown properties */
+ if (info == NULL)
+ goto invalid;
+
+ /* Ignore properties with the wrong type */
+ if (g_strcmp0 (info->signature, g_variant_get_type_string (value)) != 0)
+ goto invalid;
+ }
+
+ g_hash_table_insert (proxy->priv->properties,
+ property_name, /* adopts string */
+ value); /* adopts value */
+
+ return;
+
+ invalid:
+ g_variant_unref (value);
+ g_free (property_name);
+}
+
+static void
on_properties_changed (GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
gpointer user_data)
{
GDBusProxy *proxy = G_DBUS_PROXY (user_data);
- GError *error;
const gchar *interface_name_for_signal;
GVariant *changed_properties;
gchar **invalidated_properties;
GVariant *value;
guint n;
- error = NULL;
changed_properties = NULL;
invalidated_properties = NULL;
g_variant_iter_init (&iter, changed_properties);
while (g_variant_iter_next (&iter, "{sv}", &key, &value))
{
- g_hash_table_insert (proxy->priv->properties,
- key, /* adopts string */
- value); /* adopts value */
+ insert_property_checked (proxy,
+ key, /* adopts string */
+ value); /* adopts value */
}
for (n = 0; invalidated_properties[n] != NULL; n++)
g_variant_get (result, "(a{sv})", &iter);
while (g_variant_iter_next (iter, "{sv}", &key, &value))
{
- g_hash_table_insert (proxy->priv->properties,
- key, /* adopts string */
- value); /* adopts value */
+ insert_property_checked (proxy,
+ key, /* adopts string */
+ value); /* adopts value */
}
g_variant_iter_free (iter);
* g_dbus_proxy_new:
* @connection: A #GDBusConnection.
* @flags: Flags used when constructing the proxy.
- * @info: A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
- * @name: A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @info: (allow-none): A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
* @object_path: An object path.
* @interface_name: A D-Bus interface name.
* @cancellable: A #GCancellable or %NULL.
* g_dbus_proxy_new_for_bus:
* @bus_type: A #GBusType.
* @flags: Flags used when constructing the proxy.
- * @info: A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
+ * @info: (allow-none): A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
* @name: A bus name (well-known or unique).
* @object_path: An object path.
* @interface_name: A D-Bus interface name.
* g_dbus_proxy_new_for_bus_sync:
* @bus_type: A #GBusType.
* @flags: Flags used when constructing the proxy.
- * @info: A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
+ * @info: (allow-none): A #GDBusInterfaceInfo specifying the minimal interface
+ * that @proxy conforms to or %NULL.
* @name: A bus name (well-known or unique).
* @object_path: An object path.
* @interface_name: A D-Bus interface name.
/**
* g_dbus_proxy_set_interface_info:
* @proxy: A #GDBusProxy
- * @info: Minimum interface this proxy conforms to or %NULL to unset.
+ * @info: (allow-none): Minimum interface this proxy conforms to or %NULL to unset.
*
* Ensure that interactions with @proxy conform to the given
* interface. For example, when completing a method call, if the type
{
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
if (proxy->priv->expected_interface != NULL)
- g_dbus_interface_info_unref (proxy->priv->expected_interface);
+ {
+ g_dbus_interface_info_cache_release (proxy->priv->expected_interface);
+ g_dbus_interface_info_unref (proxy->priv->expected_interface);
+ }
proxy->priv->expected_interface = info != NULL ? g_dbus_interface_info_ref (info) : NULL;
+ if (proxy->priv->expected_interface != NULL)
+ g_dbus_interface_info_cache_build (proxy->priv->expected_interface);
}
/* ---------------------------------------------------------------------------------------------------- */
* g_dbus_proxy_call:
* @proxy: A #GDBusProxy.
* @method_name: Name of method to invoke.
- * @parameters: A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+ * @parameters: (allow-none): A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
* @flags: Flags from the #GDBusCallFlags enumeration.
* @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
* "infinite") or -1 to use the proxy default timeout.
* g_dbus_proxy_call_sync:
* @proxy: A #GDBusProxy.
* @method_name: Name of method to invoke.
- * @parameters: A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+ * @parameters: (allow-none): A #GVariant tuple with parameters for the signal
+ * or %NULL if not passing parameters.
* @flags: Flags from the #GDBusCallFlags enumeration.
* @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
* "infinite") or -1 to use the proxy default timeout.