summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-20 10:31:48 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-30 09:45:32 +0200
commit088ab9f68b221949c3142612f32b53e4c9870aa2 (patch)
treed34504b4e99631c8d8d577839467378e27724bd2
parent6a34a59d39e7c18c343b19f212b576d7ef2dd8bb (diff)
downloadtelepathy-glib-088ab9f68b221949c3142612f32b53e4c9870aa2.tar.gz
ExampleEcho2Channel: implement SMS interface
-rw-r--r--examples/cm/echo-message-parts/chan.c121
-rw-r--r--examples/cm/echo-message-parts/chan.h5
2 files changed, 118 insertions, 8 deletions
diff --git a/examples/cm/echo-message-parts/chan.c b/examples/cm/echo-message-parts/chan.c
index 4f6339074..610c0e42d 100644
--- a/examples/cm/echo-message-parts/chan.c
+++ b/examples/cm/echo-message-parts/chan.c
@@ -18,16 +18,18 @@
#include <telepathy-glib/svc-channel.h>
static void destroyable_iface_init (gpointer iface, gpointer data);
+static void sms_iface_init (gpointer iface, gpointer data);
G_DEFINE_TYPE_WITH_CODE (ExampleEcho2Channel,
example_echo_2_channel,
TP_TYPE_BASE_CHANNEL,
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_TEXT,
- tp_message_mixin_text_iface_init);
+ tp_message_mixin_text_iface_init)
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_MESSAGES,
- tp_message_mixin_messages_iface_init);
+ tp_message_mixin_messages_iface_init)
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE,
destroyable_iface_init)
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_SMS, sms_iface_init)
)
/* type definition stuff */
@@ -35,18 +37,33 @@ G_DEFINE_TYPE_WITH_CODE (ExampleEcho2Channel,
static const char * example_echo_2_channel_interfaces[] = {
TP_IFACE_CHANNEL_INTERFACE_MESSAGES,
TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE,
+ TP_IFACE_CHANNEL_INTERFACE_SMS,
NULL };
+enum
+{
+ PROP_SMS = 1,
+ PROP_SMS_FLASH,
+ N_PROPS
+};
+
+struct _ExampleEcho2ChannelPrivate
+{
+ gboolean sms;
+};
+
static void
example_echo_2_channel_init (ExampleEcho2Channel *self)
{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EXAMPLE_TYPE_ECHO_2_CHANNEL, ExampleEcho2ChannelPrivate);
}
static void
send_message (GObject *object,
- TpMessage *message,
- TpMessageSendingFlags flags)
+ TpMessage *message,
+ TpMessageSendingFlags flags)
{
ExampleEcho2Channel *self = EXAMPLE_ECHO_2_CHANNEL (object);
TpBaseChannel *base = TP_BASE_CHANNEL (self);
@@ -150,8 +167,8 @@ finally:
static GObject *
constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
+ guint n_props,
+ GObjectConstructParam *props)
{
GObject *object =
G_OBJECT_CLASS (example_echo_2_channel_parent_class)->constructor (type,
@@ -229,16 +246,68 @@ example_echo_2_channel_fill_immutable_properties (TpBaseChannel *chan,
TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "DeliveryReportingSupport",
TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "SupportedContentTypes",
TP_IFACE_CHANNEL_INTERFACE_MESSAGES, "MessageTypes",
+ TP_IFACE_CHANNEL_INTERFACE_SMS, "Flash",
NULL);
}
static void
+set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ExampleEcho2Channel *self = (ExampleEcho2Channel *) object;
+
+ switch (property_id)
+ {
+ case PROP_SMS:
+ self->priv->sms = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ExampleEcho2Channel *self = (ExampleEcho2Channel *) object;
+
+ switch (property_id)
+ {
+ case PROP_SMS:
+ g_value_set_boolean (value, self->priv->sms);
+ break;
+ case PROP_SMS_FLASH:
+ g_value_set_boolean (value, TRUE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
example_echo_2_channel_class_init (ExampleEcho2ChannelClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
TpBaseChannelClass *base_class = (TpBaseChannelClass *) klass;
+ GParamSpec *param_spec;
+ static TpDBusPropertiesMixinPropImpl sms_props[] = {
+ { "SMSChannel", "sms", NULL },
+ { "Flash", "sms-flash", NULL },
+ { NULL }
+ };
+
+ g_type_class_add_private (klass, sizeof (ExampleEcho2ChannelPrivate));
object_class->constructor = constructor;
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
object_class->finalize = finalize;
base_class->channel_type = TP_IFACE_CHANNEL_TYPE_TEXT;
@@ -248,12 +317,29 @@ example_echo_2_channel_class_init (ExampleEcho2ChannelClass *klass)
base_class->fill_immutable_properties =
example_echo_2_channel_fill_immutable_properties;
+ param_spec = g_param_spec_boolean ("sms", "SMS",
+ "SMS.SMSChannel",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SMS, param_spec);
+
+ param_spec = g_param_spec_boolean ("sms-flash", "SMS Flash",
+ "SMS.Flash",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SMS_FLASH, param_spec);
+
+ tp_dbus_properties_mixin_implement_interface (object_class,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_SMS,
+ tp_dbus_properties_mixin_getter_gobject_properties, NULL,
+ sms_props);
+
tp_message_mixin_init_dbus_properties (object_class);
}
static void
destroyable_destroy (TpSvcChannelInterfaceDestroyable *iface,
- DBusGMethodInvocation *context)
+ DBusGMethodInvocation *context)
{
TpBaseChannel *self = TP_BASE_CHANNEL (iface);
@@ -265,7 +351,7 @@ destroyable_destroy (TpSvcChannelInterfaceDestroyable *iface,
static void
destroyable_iface_init (gpointer iface,
- gpointer data)
+ gpointer data)
{
TpSvcChannelInterfaceDestroyableClass *klass = iface;
@@ -274,3 +360,22 @@ destroyable_iface_init (gpointer iface,
IMPLEMENT (destroy);
#undef IMPLEMENT
}
+
+
+void
+example_echo_2_channel_set_sms (ExampleEcho2Channel *self,
+ gboolean sms)
+{
+ if (self->priv->sms == sms)
+ return;
+
+ self->priv->sms = sms;
+
+ tp_svc_channel_interface_sms_emit_sms_channel_changed (self, sms);
+}
+
+static void
+sms_iface_init (gpointer iface,
+ gpointer data)
+{
+}
diff --git a/examples/cm/echo-message-parts/chan.h b/examples/cm/echo-message-parts/chan.h
index dd82bed80..06ae70c12 100644
--- a/examples/cm/echo-message-parts/chan.h
+++ b/examples/cm/echo-message-parts/chan.h
@@ -20,6 +20,7 @@ G_BEGIN_DECLS
typedef struct _ExampleEcho2Channel ExampleEcho2Channel;
typedef struct _ExampleEcho2ChannelClass ExampleEcho2ChannelClass;
+typedef struct _ExampleEcho2ChannelPrivate ExampleEcho2ChannelPrivate;
GType example_echo_2_channel_get_type (void);
@@ -46,8 +47,12 @@ struct _ExampleEcho2ChannelClass {
struct _ExampleEcho2Channel {
TpBaseChannel parent;
TpMessageMixin text;
+ ExampleEcho2ChannelPrivate *priv;
};
+void example_echo_2_channel_set_sms (ExampleEcho2Channel *self,
+ gboolean sms);
+
G_END_DECLS
#endif