X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusproxy.c;h=67af1fb83e24f41a686f4af6893acef0e4400ffb;hb=0729260141bb585943ad1c6efa8ab7ee9058b0aa;hp=06957f6b82c3a0a12155f7e70d471f4dedca565d;hpb=c95ff4de046d583fe2e8189522214069b708d32f;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index 06957f6..67af1fb 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -166,7 +166,10 @@ g_dbus_proxy_finalize (GObject *object) 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); } @@ -640,8 +643,7 @@ g_dbus_proxy_get_cached_property (GDBusProxy *proxy, 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; } @@ -656,7 +658,7 @@ g_dbus_proxy_get_cached_property (GDBusProxy *proxy, * 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. @@ -752,6 +754,22 @@ on_signal_received (GDBusConnection *connection, 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, @@ -765,6 +783,36 @@ on_signal_received (GDBusConnection *connection, /* ---------------------------------------------------------------------------------------------------- */ 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, @@ -774,7 +822,6 @@ on_properties_changed (GDBusConnection *connection, gpointer user_data) { GDBusProxy *proxy = G_DBUS_PROXY (user_data); - GError *error; const gchar *interface_name_for_signal; GVariant *changed_properties; gchar **invalidated_properties; @@ -783,7 +830,6 @@ on_properties_changed (GDBusConnection *connection, GVariant *value; guint n; - error = NULL; changed_properties = NULL; invalidated_properties = NULL; @@ -812,9 +858,9 @@ on_properties_changed (GDBusConnection *connection, 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++) @@ -854,9 +900,9 @@ process_get_all_reply (GDBusProxy *proxy, 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); @@ -1613,8 +1659,8 @@ initable_iface_init (GInitableIface *initable_iface) * 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. @@ -1783,7 +1829,7 @@ g_dbus_proxy_new_sync (GDBusConnection *connection, * 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. @@ -1848,7 +1894,8 @@ g_dbus_proxy_new_for_bus_finish (GAsyncResult *res, * 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. @@ -2075,7 +2122,7 @@ g_dbus_proxy_get_interface_info (GDBusProxy *proxy) /** * 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 @@ -2093,8 +2140,13 @@ g_dbus_proxy_set_interface_info (GDBusProxy *proxy, { 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); } /* ---------------------------------------------------------------------------------------------------- */ @@ -2208,7 +2260,7 @@ get_destination_for_call (GDBusProxy *proxy) * 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. @@ -2376,7 +2428,8 @@ g_dbus_proxy_call_finish (GDBusProxy *proxy, * 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.