aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-06 15:13:33 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-08 08:55:12 +0800
commitcc7f77f31bd42f816dad43e811fb17264b4a756e (patch)
tree809df44f495ec2e0e3365e4164a726873cf5f43e
parent065e5efff3e181b8de28d3b0e04e7378d53f2e44 (diff)
downloadgsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar.gz
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar.bz2
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar.lz
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar.xz
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.tar.zst
gsoc2013-empathy-cc7f77f31bd42f816dad43e811fb17264b4a756e.zip
Add sms-channel property to empathy-tp-chat
-rw-r--r--libempathy/empathy-tp-chat.c77
-rw-r--r--libempathy/empathy-tp-chat.h1
2 files changed, 78 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index e8542a021..7f1a0dd43 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -60,6 +60,8 @@ typedef struct {
gboolean got_password_flags;
gboolean ready;
gboolean can_upgrade_to_muc;
+ gboolean got_sms_channel;
+ gboolean sms_channel;
} EmpathyTpChatPriv;
static void tp_chat_iface_init (EmpathyContactListIface *iface);
@@ -71,6 +73,7 @@ enum {
PROP_REMOTE_CONTACT,
PROP_PASSWORD_NEEDED,
PROP_READY,
+ PROP_SMS_CHANNEL,
};
enum {
@@ -854,6 +857,9 @@ check_almost_ready (EmpathyTpChat *chat)
if (!priv->got_password_flags)
return;
+ if (!priv->got_sms_channel)
+ return;
+
/* We need either the members (room) or the remote contact (private chat).
* If the chat is protected by a password we can't get these information so
* consider the chat as ready so it can be presented to the user. */
@@ -1255,6 +1261,41 @@ got_password_flags_cb (TpChannel *proxy,
check_almost_ready (EMPATHY_TP_CHAT (self));
}
+static void
+sms_channel_changed_cb (TpChannel *channel,
+ gboolean sms_channel,
+ gpointer user_data,
+ GObject *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ priv->sms_channel = sms_channel;
+
+ g_object_notify (G_OBJECT (chat), "sms-channel");
+}
+
+static void
+get_sms_channel_cb (TpProxy *channel,
+ const GValue *value,
+ const GError *in_error,
+ gpointer user_data,
+ GObject *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ if (in_error != NULL) {
+ DEBUG ("Failed to get SMSChannel: %s", in_error->message);
+ return;
+ }
+
+ g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
+
+ priv->sms_channel = g_value_get_boolean (value);
+ priv->got_sms_channel = TRUE;
+
+ check_almost_ready (EMPATHY_TP_CHAT (chat));
+}
+
static GObject *
tp_chat_constructor (GType type,
guint n_props,
@@ -1363,6 +1404,19 @@ tp_chat_constructor (GType type,
priv->got_password_flags = TRUE;
}
+ /* Check if the chat is for SMS */
+ if (tp_proxy_has_interface_by_id (priv->channel,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_SMS)) {
+ tp_cli_channel_interface_sms_connect_to_sms_channel_changed (
+ priv->channel,
+ sms_channel_changed_cb, chat, NULL, G_OBJECT (chat),
+ NULL);
+
+ tp_cli_dbus_properties_call_get (priv->channel, -1,
+ TP_IFACE_CHANNEL_INTERFACE_SMS, "SMSChannel",
+ get_sms_channel_cb, chat, NULL, G_OBJECT (chat));
+ }
+
return chat;
}
@@ -1391,6 +1445,9 @@ tp_chat_get_property (GObject *object,
case PROP_PASSWORD_NEEDED:
g_value_set_boolean (value, empathy_tp_chat_password_needed (self));
break;
+ case PROP_SMS_CHANNEL:
+ g_value_set_boolean (value, priv->sms_channel);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -1472,6 +1529,14 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
FALSE,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_SMS_CHANNEL,
+ g_param_spec_boolean ("sms-channel",
+ "SMS Channel",
+ "TRUE if channel is for sending SMSes",
+ FALSE,
+ G_PARAM_READABLE));
+
/* Signals */
signals[MESSAGE_RECEIVED] =
g_signal_new ("message-received",
@@ -1972,3 +2037,15 @@ empathy_tp_chat_get_channel_path (EmpathyTpChat *self)
return tp_proxy_get_object_path (priv->channel);
}
+
+gboolean
+empathy_tp_chat_is_sms_channel (EmpathyTpChat *self)
+{
+ EmpathyTpChatPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CHAT (self), FALSE);
+
+ priv = GET_PRIV (self);
+
+ return priv->sms_channel;
+}
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index fe3de4ea7..a71c81c7e 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -107,6 +107,7 @@ gboolean empathy_tp_chat_is_invited (EmpathyTpChat *chat,
TpHandle *inviter);
const char * empathy_tp_chat_get_channel_path (EmpathyTpChat *chat);
+gboolean empathy_tp_chat_is_sms_channel (EmpathyTpChat *chat);
G_END_DECLS