]> git.0d.be Git - empathy.git/commitdiff
Add sms-channel property to empathy-chat
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 7 Apr 2011 01:41:54 +0000 (11:41 +1000)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 5 May 2011 06:31:26 +0000 (16:31 +1000)
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.h

index c146941b3b9157f7bc3a23d5929363f194f085fe..32627271c971db98a995dedd466423563df98408 100644 (file)
@@ -146,6 +146,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 {
@@ -170,6 +171,7 @@ enum {
        PROP_SUBJECT,
        PROP_REMOTE_CONTACT,
        PROP_SHOW_CONTACTS,
+       PROP_SMS_CHANNEL,
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -209,6 +211,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;
@@ -249,8 +254,14 @@ account_reconnected (EmpathyChat *chat,
        * https://bugs.freedesktop.org/show_bug.cgi?id=13422 */
        switch (priv->handle_type) {
                case TP_HANDLE_TYPE_CONTACT:
-                       empathy_chat_with_contact_id (
-                               account, priv->id, TP_USER_ACTION_TIME_NOT_USER_ACTION);
+                       if (priv->sms_channel)
+                               empathy_sms_contact_id (
+                                       account, priv->id,
+                                       TP_USER_ACTION_TIME_NOT_USER_ACTION);
+                       else
+                               empathy_chat_with_contact_id (
+                                       account, priv->id,
+                                       TP_USER_ACTION_TIME_NOT_USER_ACTION);
                        break;
                case TP_HANDLE_TYPE_ROOM:
                        empathy_join_muc (account, priv->id,
@@ -2963,6 +2974,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),
@@ -3459,6 +3478,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)
@@ -3508,6 +3536,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);
@@ -3528,6 +3559,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) {
@@ -3812,3 +3844,13 @@ empathy_chat_is_composing (EmpathyChat *chat)
 {
   return chat->priv->compositors != NULL;
 }
+
+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;
+}
index 77122f7c873dc7343047a854aea4ecb0c0037d8d..8665bf34dfe93c059812990d0086307da56a26c4 100644 (file)
@@ -94,6 +94,8 @@ guint              empathy_chat_get_nb_unread_messages (EmpathyChat   *chat);
 void               empathy_chat_messages_read        (EmpathyChat *self);
 
 gboolean           empathy_chat_is_composing (EmpathyChat *chat);
+
+gboolean           empathy_chat_is_sms_channel       (EmpathyChat *self);
 G_END_DECLS
 
 #endif /* __EMPATHY_CHAT_H__ */