diff options
author | Dan Williams <dcbw@redhat.com> | 2010-12-17 16:27:55 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-12-17 16:27:55 -0600 |
commit | d2ce75b57a27a9feaddb25558e62ae7162ef7f9f (patch) | |
tree | 4a7363b88fdc2c03d05cf9e834086d7f9384f49f | |
parent | 592d71ff76318b6389f6866d5394a844c7e35513 (diff) |
core: separate PropertiesChanged signal XML
Which requires that we turn it into a GInterface that MMModemBase
can implement, because dbus-glib does not allow attaching more
than one introspection glue structure to an object at a time.
Also implement the standard D-Bus properties changed signal.
-rw-r--r-- | introspection/Makefile.am | 3 | ||||
-rw-r--r-- | introspection/all.xml | 1 | ||||
-rw-r--r-- | introspection/mm-modem.xml | 18 | ||||
-rw-r--r-- | introspection/mm-properties-changed.xml | 45 | ||||
-rw-r--r-- | marshallers/mm-marshal.list | 1 | ||||
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/mm-modem-base.c | 11 | ||||
-rw-r--r-- | src/mm-properties-changed-signal.c | 86 | ||||
-rw-r--r-- | src/mm-properties-changed-signal.h | 13 |
9 files changed, 144 insertions, 40 deletions
diff --git a/introspection/Makefile.am b/introspection/Makefile.am index 941c9244..5c2a5ebb 100644 --- a/introspection/Makefile.am +++ b/introspection/Makefile.am @@ -15,4 +15,5 @@ EXTRA_DIST = \ mm-modem-simple.xml \ mm-serial-error.xml \ mm-modem-location.xml \ - mm-modem-gsm-ussd.xml + mm-modem-gsm-ussd.xml \ + mm-properties-changed.xml diff --git a/introspection/all.xml b/introspection/all.xml index 6489cf8a..dd30b574 100644 --- a/introspection/all.xml +++ b/introspection/all.xml @@ -35,6 +35,7 @@ <xi:include href="mm-modem-gsm-sms.xml"/> <xi:include href="mm-modem-gsm-hso.xml"/> <xi:include href="mm-modem-gsm-ussd.xml"/> + <xi:include href="mm-properties-changed.xml"/> <xi:include href="mm-serial-error.xml"/> <xi:include href="mm-modem-error.xml"/> diff --git a/introspection/mm-modem.xml b/introspection/mm-modem.xml index 9391bad5..e0cf4bd5 100644 --- a/introspection/mm-modem.xml +++ b/introspection/mm-modem.xml @@ -2,24 +2,6 @@ <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <interface name="org.freedesktop.DBus.Properties"> - <signal name="MmPropertiesChanged"> - <tp:docstring> - One or more properties' values changed. - </tp:docstring> - <arg name="interface" type="s"> - <tp:docstring> - The D-Bus interface of the changed properties. - </tp:docstring> - </arg> - <arg name="properties" type="a{sv}"> - <tp:docstring> - The changed property names and their new values. - </tp:docstring> - </arg> - </signal> - </interface> - <interface name="org.freedesktop.ModemManager.Modem"> <method name="Enable"> <tp:docstring> diff --git a/introspection/mm-properties-changed.xml b/introspection/mm-properties-changed.xml new file mode 100644 index 00000000..b2d09236 --- /dev/null +++ b/introspection/mm-properties-changed.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.DBus.Properties"> + <signal name="MmPropertiesChanged"> + <tp:docstring> + One or more properties' values changed. + </tp:docstring> + <arg name="interface" type="s"> + <tp:docstring> + The D-Bus interface of the changed properties. + </tp:docstring> + </arg> + <arg name="properties" type="a{sv}"> + <tp:docstring> + The changed property names and their new values. + </tp:docstring> + </arg> + </signal> + + <signal name="PropertiesChanged"> + <tp:docstring> + One or more properties value changed; this signal implements the + D-Bus specification's PropertiesChanged signal. + </tp:docstring> + <arg name="interface" type="s"> + <tp:docstring> + The D-Bus interface of the changed properties. + </tp:docstring> + </arg> + <arg name="changed_properties" type="a{sv}"> + <tp:docstring> + The changed property names and their new values. + </tp:docstring> + </arg> + <arg name="invalidated_properties" type="as"> + <tp:docstring> + Properties which are now invalid, but for which the new value is not + emitted in this signal. Clients interested in these properties should + issue a Get request for them to retrieve the new value. + </tp:docstring> + </arg> + </signal> + </interface> +</node> diff --git a/marshallers/mm-marshal.list b/marshallers/mm-marshal.list index c209bbbf..81fcadb6 100644 --- a/marshallers/mm-marshal.list +++ b/marshallers/mm-marshal.list @@ -6,4 +6,5 @@ VOID:UINT,UINT VOID:UINT,UINT,UINT VOID:STRING,BOXED VOID:POINTER,UINT +VOID:STRING,BOXED,BOXED diff --git a/src/Makefile.am b/src/Makefile.am index de15beea..924ca261 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -144,6 +144,9 @@ mm-modem-gsm-sms-glue.h: $(top_srcdir)/introspection/mm-modem-gsm-sms.xml mm-modem-gsm-ussd-glue.h: $(top_srcdir)/introspection/mm-modem-gsm-ussd.xml $(AM_V_GEN) dbus-binding-tool --prefix=mm_modem_gsm_ussd --mode=glib-server --output=$@ $< +mm-properties-changed-glue.h: $(top_srcdir)/introspection/mm-properties-changed.xml + $(AM_V_GEN) dbus-binding-tool --prefix=mm_properties_changed --mode=glib-server --output=$@ $< + BUILT_SOURCES = \ mm-manager-glue.h \ mm-modem-glue.h \ @@ -152,7 +155,8 @@ BUILT_SOURCES = \ mm-modem-gsm-card-glue.h \ mm-modem-gsm-network-glue.h \ mm-modem-gsm-sms-glue.h \ - mm-modem-gsm-ussd-glue.h + mm-modem-gsm-ussd-glue.h \ + mm-properties-changed-glue.h mm-modem-location-glue.h: $(top_srcdir)/introspection/mm-modem-location.xml $(AM_V_GEN) dbus-binding-tool --prefix=mm_modem_location --mode=glib-server --output=$@ $< diff --git a/src/mm-modem-base.c b/src/mm-modem-base.c index adb19467..50088fb5 100644 --- a/src/mm-modem-base.c +++ b/src/mm-modem-base.c @@ -31,11 +31,13 @@ #include "mm-modem-helpers.h" static void modem_init (MMModem *modem_class); +static void pc_init (MMPropertiesChanged *pc_class); G_DEFINE_TYPE_EXTENDED (MMModemBase, mm_modem_base, G_TYPE_OBJECT, G_TYPE_FLAG_VALUE_ABSTRACT, - G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM, modem_init)) + G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM, modem_init) + G_IMPLEMENT_INTERFACE (MM_TYPE_PROPERTIES_CHANGED, pc_init)) #define MM_MODEM_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_BASE, MMModemBasePrivate)) @@ -633,6 +635,11 @@ modem_init (MMModem *modem_class) modem_class->auth_finish = modem_auth_finish; } +static void +pc_init (MMPropertiesChanged *pc_class) +{ +} + static gboolean is_enabled (MMModemState state) { @@ -846,6 +853,6 @@ mm_modem_base_class_init (MMModemBaseClass *klass) MM_MODEM_PROP_HW_PID, MM_MODEM_HW_PID); - mm_properties_changed_signal_new (object_class); + mm_properties_changed_signal_enable (object_class); } diff --git a/src/mm-properties-changed-signal.c b/src/mm-properties-changed-signal.c index b45d0692..633ff771 100644 --- a/src/mm-properties-changed-signal.c +++ b/src/mm-properties-changed-signal.c @@ -20,12 +20,17 @@ #include <dbus/dbus-glib.h> #include "mm-marshal.h" #include "mm-properties-changed-signal.h" +#include "mm-properties-changed-glue.h" -#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) +#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) +#define DBUS_TYPE_G_ARRAY_OF_STRING (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING)) -#define PC_SIGNAL_NAME "mm-properties-changed" +#define MM_PC_SIGNAL_NAME "mm-properties-changed" +#define DBUS_PC_SIGNAL_NAME "properties-changed" #define MM_DBUS_PROPERTY_CHANGED "MM_DBUS_PROPERTY_CHANGED" +/*****************************************************************************/ + typedef struct { char *real_property; char *interface; @@ -47,7 +52,6 @@ typedef struct { */ GHashTable *hash; - gulong signal_id; guint idle_id; } PropertiesChangedInfo; @@ -140,6 +144,7 @@ properties_changed (gpointer data) while (g_hash_table_iter_next (&iter, &key, &value)) { const char *interface = (const char *) key; GHashTable *props = (GHashTable *) value; + GPtrArray *ignore = g_ptr_array_new (); #ifdef DEBUG { @@ -153,7 +158,9 @@ properties_changed (gpointer data) #endif /* Send the PropertiesChanged signal */ - g_signal_emit (object, info->signal_id, 0, interface, props); + g_signal_emit_by_name (object, MM_PC_SIGNAL_NAME, interface, props); + g_signal_emit_by_name (object, DBUS_PC_SIGNAL_NAME, interface, props, ignore); + g_ptr_array_free (ignore, TRUE); } g_hash_table_remove_all (info->hash); @@ -207,8 +214,6 @@ get_properties_changed_info (GObject *object) if (!info) { info = properties_changed_info_new (); g_object_set_data_full (object, MM_DBUS_PROPERTY_CHANGED, info, properties_changed_info_destroy); - info->signal_id = g_signal_lookup (PC_SIGNAL_NAME, G_OBJECT_TYPE (object)); - g_assert (info->signal_id); } g_assert (info); @@ -280,20 +285,67 @@ mm_properties_changed_signal_register_property (GObject *object, } } -guint -mm_properties_changed_signal_new (GObjectClass *object_class) +void +mm_properties_changed_signal_enable (GObjectClass *object_class) { - guint id; - object_class->notify = notify; +} - id = g_signal_new (PC_SIGNAL_NAME, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - mm_marshal_VOID__STRING_BOXED, - G_TYPE_NONE, 2, G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT); +/*****************************************************************************/ + +static void +mm_properties_changed_init (gpointer g_iface) +{ + static gboolean initialized = FALSE; - return id; + if (initialized) + return; + + g_signal_new (MM_PC_SIGNAL_NAME, + G_TYPE_FROM_INTERFACE (g_iface), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + mm_marshal_VOID__STRING_BOXED, + G_TYPE_NONE, 2, G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT); + + g_signal_new (DBUS_PC_SIGNAL_NAME, + G_TYPE_FROM_INTERFACE (g_iface), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + mm_marshal_VOID__STRING_BOXED_BOXED, + G_TYPE_NONE, 3, + G_TYPE_STRING, + DBUS_TYPE_G_MAP_OF_VARIANT, + DBUS_TYPE_G_ARRAY_OF_STRING); + + initialized = TRUE; } +GType +mm_properties_changed_get_type (void) +{ + static GType pc_type = 0; + + if (!G_UNLIKELY (pc_type)) { + const GTypeInfo pc_info = { + sizeof (MMPropertiesChanged), /* class_size */ + mm_properties_changed_init, /* base_init */ + NULL, /* base_finalize */ + NULL, + NULL, /* class_finalize */ + NULL, /* class_data */ + 0, + 0, /* n_preallocs */ + NULL + }; + + pc_type = g_type_register_static (G_TYPE_INTERFACE, + "MMPropertiesChanged", + &pc_info, 0); + + g_type_interface_add_prerequisite (pc_type, G_TYPE_OBJECT); + dbus_g_object_type_install_info (pc_type, &dbus_glib_mm_properties_changed_object_info); + } + + return pc_type; +} diff --git a/src/mm-properties-changed-signal.h b/src/mm-properties-changed-signal.h index 87f46a9f..a6d0f3ee 100644 --- a/src/mm-properties-changed-signal.h +++ b/src/mm-properties-changed-signal.h @@ -19,7 +19,18 @@ #include <glib-object.h> -guint mm_properties_changed_signal_new (GObjectClass *object_class); +#define MM_TYPE_PROPERTIES_CHANGED (mm_properties_changed_get_type ()) +#define MM_PROPERTIES_CHANGED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PROPERTIES_CHANGED, MMPropertiesChanged)) +#define MM_IS_PROPERTIES_CHANGED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PROPERTIES_CHANGED)) +#define MM_PROPERTIES_CHANGED_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_PROPERTIES_CHANGED, MMPropertiesChanged)) + +typedef struct { + GTypeInterface g_iface; +} MMPropertiesChanged; + +GType mm_properties_changed_get_type (void); + +void mm_properties_changed_signal_enable (GObjectClass *object_class); void mm_properties_changed_signal_register_property (GObject *object, const char *gobject_property, |