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.
This commit is contained in:
@@ -15,4 +15,5 @@ EXTRA_DIST = \
|
|||||||
mm-modem-simple.xml \
|
mm-modem-simple.xml \
|
||||||
mm-serial-error.xml \
|
mm-serial-error.xml \
|
||||||
mm-modem-location.xml \
|
mm-modem-location.xml \
|
||||||
mm-modem-gsm-ussd.xml
|
mm-modem-gsm-ussd.xml \
|
||||||
|
mm-properties-changed.xml
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
<xi:include href="mm-modem-gsm-sms.xml"/>
|
<xi:include href="mm-modem-gsm-sms.xml"/>
|
||||||
<xi:include href="mm-modem-gsm-hso.xml"/>
|
<xi:include href="mm-modem-gsm-hso.xml"/>
|
||||||
<xi:include href="mm-modem-gsm-ussd.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-serial-error.xml"/>
|
||||||
<xi:include href="mm-modem-error.xml"/>
|
<xi:include href="mm-modem-error.xml"/>
|
||||||
|
@@ -2,24 +2,6 @@
|
|||||||
|
|
||||||
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
|
<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">
|
<interface name="org.freedesktop.ModemManager.Modem">
|
||||||
<method name="Enable">
|
<method name="Enable">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
|
45
introspection/mm-properties-changed.xml
Normal file
45
introspection/mm-properties-changed.xml
Normal file
@@ -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>
|
@@ -6,4 +6,5 @@ VOID:UINT,UINT
|
|||||||
VOID:UINT,UINT,UINT
|
VOID:UINT,UINT,UINT
|
||||||
VOID:STRING,BOXED
|
VOID:STRING,BOXED
|
||||||
VOID:POINTER,UINT
|
VOID:POINTER,UINT
|
||||||
|
VOID:STRING,BOXED,BOXED
|
||||||
|
|
||||||
|
@@ -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
|
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=$@ $<
|
$(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 = \
|
BUILT_SOURCES = \
|
||||||
mm-manager-glue.h \
|
mm-manager-glue.h \
|
||||||
mm-modem-glue.h \
|
mm-modem-glue.h \
|
||||||
@@ -152,7 +155,8 @@ BUILT_SOURCES = \
|
|||||||
mm-modem-gsm-card-glue.h \
|
mm-modem-gsm-card-glue.h \
|
||||||
mm-modem-gsm-network-glue.h \
|
mm-modem-gsm-network-glue.h \
|
||||||
mm-modem-gsm-sms-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
|
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=$@ $<
|
$(AM_V_GEN) dbus-binding-tool --prefix=mm_modem_location --mode=glib-server --output=$@ $<
|
||||||
|
@@ -31,11 +31,13 @@
|
|||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
|
|
||||||
static void modem_init (MMModem *modem_class);
|
static void modem_init (MMModem *modem_class);
|
||||||
|
static void pc_init (MMPropertiesChanged *pc_class);
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED (MMModemBase, mm_modem_base,
|
G_DEFINE_TYPE_EXTENDED (MMModemBase, mm_modem_base,
|
||||||
G_TYPE_OBJECT,
|
G_TYPE_OBJECT,
|
||||||
G_TYPE_FLAG_VALUE_ABSTRACT,
|
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))
|
#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;
|
modem_class->auth_finish = modem_auth_finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pc_init (MMPropertiesChanged *pc_class)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_enabled (MMModemState state)
|
is_enabled (MMModemState state)
|
||||||
{
|
{
|
||||||
@@ -846,6 +853,6 @@ mm_modem_base_class_init (MMModemBaseClass *klass)
|
|||||||
MM_MODEM_PROP_HW_PID,
|
MM_MODEM_PROP_HW_PID,
|
||||||
MM_MODEM_HW_PID);
|
MM_MODEM_HW_PID);
|
||||||
|
|
||||||
mm_properties_changed_signal_new (object_class);
|
mm_properties_changed_signal_enable (object_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,12 +20,17 @@
|
|||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include "mm-marshal.h"
|
#include "mm-marshal.h"
|
||||||
#include "mm-properties-changed-signal.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"
|
#define MM_DBUS_PROPERTY_CHANGED "MM_DBUS_PROPERTY_CHANGED"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *real_property;
|
char *real_property;
|
||||||
char *interface;
|
char *interface;
|
||||||
@@ -47,7 +52,6 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
|
|
||||||
gulong signal_id;
|
|
||||||
guint idle_id;
|
guint idle_id;
|
||||||
} PropertiesChangedInfo;
|
} PropertiesChangedInfo;
|
||||||
|
|
||||||
@@ -140,6 +144,7 @@ properties_changed (gpointer data)
|
|||||||
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
||||||
const char *interface = (const char *) key;
|
const char *interface = (const char *) key;
|
||||||
GHashTable *props = (GHashTable *) value;
|
GHashTable *props = (GHashTable *) value;
|
||||||
|
GPtrArray *ignore = g_ptr_array_new ();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
@@ -153,7 +158,9 @@ properties_changed (gpointer data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Send the PropertiesChanged signal */
|
/* 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);
|
g_hash_table_remove_all (info->hash);
|
||||||
|
|
||||||
@@ -207,8 +214,6 @@ get_properties_changed_info (GObject *object)
|
|||||||
if (!info) {
|
if (!info) {
|
||||||
info = properties_changed_info_new ();
|
info = properties_changed_info_new ();
|
||||||
g_object_set_data_full (object, MM_DBUS_PROPERTY_CHANGED, info, properties_changed_info_destroy);
|
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);
|
g_assert (info);
|
||||||
@@ -280,20 +285,67 @@ mm_properties_changed_signal_register_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
void
|
||||||
mm_properties_changed_signal_new (GObjectClass *object_class)
|
mm_properties_changed_signal_enable (GObjectClass *object_class)
|
||||||
{
|
{
|
||||||
guint id;
|
|
||||||
|
|
||||||
object_class->notify = notify;
|
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);
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_properties_changed_init (gpointer g_iface)
|
||||||
|
{
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@@ -19,7 +19,18 @@
|
|||||||
|
|
||||||
#include <glib-object.h>
|
#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,
|
void mm_properties_changed_signal_register_property (GObject *object,
|
||||||
const char *gobject_property,
|
const char *gobject_property,
|
||||||
|
Reference in New Issue
Block a user