From 97f0e63fecc9e5639417f9cdbb216278a48d2aa3 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Thu, 7 Apr 2011 11:41:54 +1000 Subject: Add sms-channel property to empathy-chat --- libempathy-gtk/empathy-chat.c | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk/empathy-chat.c') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index e6eca0906..32c79eb04 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -144,6 +144,7 @@ struct _EmpathyChatPriv { * notified again about the already notified pending messages when the * messages in tab will be properly shown */ gboolean retrieving_backlogs; + gboolean sms_channel; }; typedef struct { @@ -168,6 +169,7 @@ enum { PROP_SUBJECT, PROP_REMOTE_CONTACT, PROP_SHOW_CONTACTS, + PROP_SMS_CHANNEL, }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -205,6 +207,9 @@ chat_get_property (GObject *object, case PROP_SHOW_CONTACTS: g_value_set_boolean (value, priv->show_contacts); 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; @@ -245,8 +250,14 @@ account_reconnected (EmpathyChat *chat, * https://bugs.freedesktop.org/show_bug.cgi?id=13422 */ switch (priv->handle_type) { case TP_HANDLE_TYPE_CONTACT: - empathy_dispatcher_chat_with_contact_id ( - account, priv->id, TP_USER_ACTION_TIME_NOT_USER_ACTION); + if (priv->sms_channel) + empathy_dispatcher_sms_contact_id ( + account, priv->id, + TP_USER_ACTION_TIME_NOT_USER_ACTION); + else + empathy_dispatcher_chat_with_contact_id ( + account, priv->id, + TP_USER_ACTION_TIME_NOT_USER_ACTION); break; case TP_HANDLE_TYPE_ROOM: empathy_dispatcher_join_muc (account, priv->id, @@ -2762,6 +2773,14 @@ empathy_chat_class_init (EmpathyChatClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_SMS_CHANNEL, + g_param_spec_boolean ("sms-channel", + "SMS Channel", + "TRUE if this channel is for sending SMSes", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + signals[COMPOSING] = g_signal_new ("composing", G_OBJECT_CLASS_TYPE (object_class), @@ -3029,6 +3048,15 @@ chat_password_needed_changed_cb (EmpathyChat *self) } } +static void +chat_sms_channel_changed_cb (EmpathyChat *self) +{ + EmpathyChatPriv *priv = GET_PRIV (self); + + priv->sms_channel = empathy_tp_chat_is_sms_channel (priv->tp_chat); + g_object_notify (G_OBJECT (self), "sms-channel"); +} + void empathy_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat) @@ -3080,6 +3108,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, g_signal_connect_swapped (tp_chat, "notify::password-needed", G_CALLBACK (chat_password_needed_changed_cb), chat); + g_signal_connect_swapped (tp_chat, "notify::sms-channel", + G_CALLBACK (chat_sms_channel_changed_cb), + chat); /* Get initial value of properties */ properties = empathy_tp_chat_get_properties (priv->tp_chat); @@ -3100,6 +3131,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, } } + chat_sms_channel_changed_cb (chat); chat_remote_contact_changed_cb (chat); if (chat->input_text_view) { @@ -3356,3 +3388,13 @@ empathy_chat_messages_read (EmpathyChat *self) } priv->unread_messages = 0; } + +gboolean +empathy_chat_is_sms_channel (EmpathyChat *self) +{ + EmpathyChatPriv *priv = GET_PRIV (self); + + g_return_val_if_fail (EMPATHY_IS_CHAT (self), 0); + + return priv->sms_channel; +} -- cgit v1.2.3