core: handle shadow properties on the MmPropertiesChanged interface
Need to emit the D-Bus API property name, not the GObject property name for a few things on the Location interface.
This commit is contained in:
@@ -4062,27 +4062,33 @@ mm_generic_gsm_init (MMGenericGsm *self)
|
|||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_GSM_NETWORK_ALLOWED_MODE,
|
MM_MODEM_GSM_NETWORK_ALLOWED_MODE,
|
||||||
|
NULL,
|
||||||
MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
|
MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
|
||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY,
|
MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY,
|
||||||
|
NULL,
|
||||||
MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
|
MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
|
||||||
|
|
||||||
#if LOCATION_API
|
#if LOCATION_API
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_LOCATION_CAPABILITIES,
|
MM_MODEM_LOCATION_CAPABILITIES,
|
||||||
|
"Capabilities",
|
||||||
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_LOCATION_ENABLED,
|
MM_MODEM_LOCATION_ENABLED,
|
||||||
|
"Enabled",
|
||||||
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_LOCATION_SIGNALS_LOCATION,
|
MM_MODEM_LOCATION_SIGNALS_LOCATION,
|
||||||
|
NULL,
|
||||||
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_LOCATION_LOCATION,
|
MM_MODEM_LOCATION_LOCATION,
|
||||||
|
NULL,
|
||||||
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
MM_MODEM_LOCATION_DBUS_INTERFACE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -562,15 +562,19 @@ mm_modem_base_init (MMModemBase *self)
|
|||||||
|
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_ENABLED,
|
MM_MODEM_ENABLED,
|
||||||
|
NULL,
|
||||||
MM_MODEM_DBUS_INTERFACE);
|
MM_MODEM_DBUS_INTERFACE);
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_EQUIPMENT_IDENTIFIER,
|
MM_MODEM_EQUIPMENT_IDENTIFIER,
|
||||||
|
NULL,
|
||||||
MM_MODEM_DBUS_INTERFACE);
|
MM_MODEM_DBUS_INTERFACE);
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_UNLOCK_REQUIRED,
|
MM_MODEM_UNLOCK_REQUIRED,
|
||||||
|
NULL,
|
||||||
MM_MODEM_DBUS_INTERFACE);
|
MM_MODEM_DBUS_INTERFACE);
|
||||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||||
MM_MODEM_UNLOCK_RETRIES,
|
MM_MODEM_UNLOCK_RETRIES,
|
||||||
|
NULL,
|
||||||
MM_MODEM_DBUS_INTERFACE);
|
MM_MODEM_DBUS_INTERFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* GNU General Public License for more details:
|
* GNU General Public License for more details:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 - 2008 Novell, Inc.
|
* Copyright (C) 2007 - 2008 Novell, Inc.
|
||||||
* Copyright (C) 2008 - 2009 Red Hat, Inc.
|
* Copyright (C) 2008 - 2010 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -26,11 +26,16 @@
|
|||||||
#define PC_SIGNAL_NAME "mm-properties-changed"
|
#define PC_SIGNAL_NAME "mm-properties-changed"
|
||||||
#define MM_DBUS_PROPERTY_CHANGED "MM_DBUS_PROPERTY_CHANGED"
|
#define MM_DBUS_PROPERTY_CHANGED "MM_DBUS_PROPERTY_CHANGED"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *real_property;
|
||||||
|
char *interface;
|
||||||
|
} ChangeInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Whitelist of GObject property names for which changes will be emitted
|
/* Whitelist of GObject property names for which changes will be emitted
|
||||||
* over the bus.
|
* over the bus.
|
||||||
*
|
*
|
||||||
* Mapping of {property-name -> dbus-interface}
|
* Mapping of {property-name -> ChangeInfo}
|
||||||
*/
|
*/
|
||||||
GHashTable *registered;
|
GHashTable *registered;
|
||||||
|
|
||||||
@@ -55,6 +60,17 @@ destroy_value (gpointer data)
|
|||||||
g_slice_free (GValue, val);
|
g_slice_free (GValue, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
change_info_free (gpointer data)
|
||||||
|
{
|
||||||
|
ChangeInfo *info = data;
|
||||||
|
|
||||||
|
g_free (info->real_property);
|
||||||
|
g_free (info->interface);
|
||||||
|
memset (info, 0, sizeof (ChangeInfo));
|
||||||
|
g_free (info);
|
||||||
|
}
|
||||||
|
|
||||||
static PropertiesChangedInfo *
|
static PropertiesChangedInfo *
|
||||||
properties_changed_info_new (void)
|
properties_changed_info_new (void)
|
||||||
{
|
{
|
||||||
@@ -62,7 +78,7 @@ properties_changed_info_new (void)
|
|||||||
|
|
||||||
info = g_slice_new0 (PropertiesChangedInfo);
|
info = g_slice_new0 (PropertiesChangedInfo);
|
||||||
|
|
||||||
info->registered = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
info->registered = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, change_info_free);
|
||||||
info->hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
info->hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
(GDestroyNotify) g_free,
|
(GDestroyNotify) g_free,
|
||||||
(GDestroyNotify) g_hash_table_destroy);
|
(GDestroyNotify) g_hash_table_destroy);
|
||||||
@@ -204,23 +220,23 @@ notify (GObject *object, GParamSpec *pspec)
|
|||||||
{
|
{
|
||||||
GHashTable *interfaces;
|
GHashTable *interfaces;
|
||||||
PropertiesChangedInfo *info;
|
PropertiesChangedInfo *info;
|
||||||
const char *interface;
|
ChangeInfo *ch_info;
|
||||||
GValue *value;
|
GValue *value;
|
||||||
|
|
||||||
info = get_properties_changed_info (object);
|
info = get_properties_changed_info (object);
|
||||||
|
|
||||||
interface = g_hash_table_lookup (info->registered, pspec->name);
|
ch_info = g_hash_table_lookup (info->registered, pspec->name);
|
||||||
if (!interface)
|
if (!ch_info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check if there are other changed properties for this interface already,
|
/* Check if there are other changed properties for this interface already,
|
||||||
* otherwise create a new hash table for all changed properties for this
|
* otherwise create a new hash table for all changed properties for this
|
||||||
* D-Bus interface.
|
* D-Bus interface.
|
||||||
*/
|
*/
|
||||||
interfaces = g_hash_table_lookup (info->hash, interface);
|
interfaces = g_hash_table_lookup (info->hash, ch_info->interface);
|
||||||
if (!interfaces) {
|
if (!interfaces) {
|
||||||
interfaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_value);
|
interfaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_value);
|
||||||
g_hash_table_insert (info->hash, g_strdup (interface), interfaces);
|
g_hash_table_insert (info->hash, g_strdup (ch_info->interface), interfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now put the changed property value into the hash table of changed values
|
/* Now put the changed property value into the hash table of changed values
|
||||||
@@ -229,7 +245,9 @@ notify (GObject *object, GParamSpec *pspec)
|
|||||||
value = g_slice_new0 (GValue);
|
value = g_slice_new0 (GValue);
|
||||||
g_value_init (value, pspec->value_type);
|
g_value_init (value, pspec->value_type);
|
||||||
g_object_get_property (object, pspec->name, value);
|
g_object_get_property (object, pspec->name, value);
|
||||||
g_hash_table_insert (interfaces, uscore_to_wincaps (pspec->name), value);
|
|
||||||
|
/* Use real property name, which takes shadow properties into accound */
|
||||||
|
g_hash_table_insert (interfaces, uscore_to_wincaps (ch_info->real_property), value);
|
||||||
|
|
||||||
if (!info->idle_id)
|
if (!info->idle_id)
|
||||||
info->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, properties_changed, object, idle_id_reset);
|
info->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, properties_changed, object, idle_id_reset);
|
||||||
@@ -237,11 +255,12 @@ notify (GObject *object, GParamSpec *pspec)
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_properties_changed_signal_register_property (GObject *object,
|
mm_properties_changed_signal_register_property (GObject *object,
|
||||||
const char *property,
|
const char *gobject_property,
|
||||||
|
const char *real_property,
|
||||||
const char *interface)
|
const char *interface)
|
||||||
{
|
{
|
||||||
PropertiesChangedInfo *info;
|
PropertiesChangedInfo *info;
|
||||||
const char *tmp;
|
ChangeInfo *ch_info;
|
||||||
|
|
||||||
/* All exported properties need to be registered explicitly for now since
|
/* All exported properties need to be registered explicitly for now since
|
||||||
* dbus-glib doesn't expose any method to find out the properties registered
|
* dbus-glib doesn't expose any method to find out the properties registered
|
||||||
@@ -249,12 +268,16 @@ mm_properties_changed_signal_register_property (GObject *object,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
info = get_properties_changed_info (object);
|
info = get_properties_changed_info (object);
|
||||||
tmp = g_hash_table_lookup (info->registered, property);
|
ch_info = g_hash_table_lookup (info->registered, gobject_property);
|
||||||
if (tmp) {
|
if (ch_info) {
|
||||||
g_warning ("%s: property '%s' already registerd on interface '%s'",
|
g_warning ("%s: property '%s' already registerd on interface '%s'",
|
||||||
__func__, property, tmp);
|
__func__, gobject_property, ch_info->interface);
|
||||||
} else
|
} else {
|
||||||
g_hash_table_insert (info->registered, g_strdup (property), g_strdup (interface));
|
ch_info = g_malloc0 (sizeof (ChangeInfo));
|
||||||
|
ch_info->real_property = g_strdup (real_property ? real_property : gobject_property);
|
||||||
|
ch_info->interface = g_strdup (interface);
|
||||||
|
g_hash_table_insert (info->registered, g_strdup (gobject_property), ch_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* GNU General Public License for more details:
|
* GNU General Public License for more details:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 - 2008 Novell, Inc.
|
* Copyright (C) 2007 - 2008 Novell, Inc.
|
||||||
* Copyright (C) 2008 - 2009 Red Hat, Inc.
|
* Copyright (C) 2008 - 2010 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MM_PROPERTIES_CHANGED_SIGNAL_H_
|
#ifndef _MM_PROPERTIES_CHANGED_SIGNAL_H_
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
guint mm_properties_changed_signal_new (GObjectClass *object_class);
|
guint mm_properties_changed_signal_new (GObjectClass *object_class);
|
||||||
|
|
||||||
void mm_properties_changed_signal_register_property (GObject *object,
|
void mm_properties_changed_signal_register_property (GObject *object,
|
||||||
const char *property,
|
const char *gobject_property,
|
||||||
|
const char *real_property,
|
||||||
const char *interface);
|
const char *interface);
|
||||||
|
|
||||||
#endif /* _MM_PROPERTIES_CHANGED_SIGNAL_H_ */
|
#endif /* _MM_PROPERTIES_CHANGED_SIGNAL_H_ */
|
||||||
|
Reference in New Issue
Block a user