[empathy: 1/2] Use tp-glib SMS high level API (#651242)



commit eaf1ecca8c31263cef90bfbb4839e7114719eed8
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri May 27 15:13:34 2011 +0200

    Use tp-glib SMS high level API (#651242)

 libempathy-gtk/empathy-chat.c |    5 ++-
 libempathy/empathy-tp-chat.c  |   76 -----------------------------------------
 libempathy/empathy-tp-chat.h  |    2 -
 src/empathy-chat-manager.c    |    2 +-
 4 files changed, 4 insertions(+), 81 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index f026bbc..533b1e7 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -3642,7 +3642,8 @@ chat_sms_channel_changed_cb (EmpathyChat *self)
 {
 	EmpathyChatPriv *priv = GET_PRIV (self);
 
-	priv->sms_channel = empathy_tp_chat_is_sms_channel (priv->tp_chat);
+	priv->sms_channel = tp_text_channel_is_sms_channel (
+		(TpTextChannel *) priv->tp_chat);
 	g_object_notify (G_OBJECT (self), "sms-channel");
 }
 
@@ -3703,7 +3704,7 @@ 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_signal_connect_swapped (tp_chat, "notify::is-sms-channel",
 				  G_CALLBACK (chat_sms_channel_changed_cb),
 				  chat);
 	g_signal_connect_swapped (tp_chat, "notify::n-messages-sending",
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 02bdc80..5d4ce26 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -54,8 +54,6 @@ struct _EmpathyTpChatPrivate {
 	 * (channel doesn't implement the Password interface) */
 	gboolean               got_password_flags;
 	gboolean               can_upgrade_to_muc;
-	gboolean               got_sms_channel;
-	gboolean               sms_channel;
 
 	GHashTable            *messages_being_sent;
 
@@ -70,7 +68,6 @@ enum {
 	PROP_ACCOUNT,
 	PROP_REMOTE_CONTACT,
 	PROP_PASSWORD_NEEDED,
-	PROP_SMS_CHANNEL,
 	PROP_N_MESSAGES_SENDING,
 };
 
@@ -872,9 +869,6 @@ check_almost_ready (EmpathyTpChat *self)
 	if (!self->priv->got_password_flags)
 		return;
 
-	if (!self->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. */
@@ -1265,41 +1259,6 @@ got_password_flags_cb (TpChannel *proxy,
 }
 
 static void
-sms_channel_changed_cb (TpChannel *channel,
-			gboolean   sms_channel,
-			gpointer   user_data,
-			GObject   *chat)
-{
-	EmpathyTpChat *self = (EmpathyTpChat *) chat;
-
-	self->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)
-{
-	EmpathyTpChat *self = (EmpathyTpChat *) chat;
-
-	if (in_error != NULL) {
-		DEBUG ("Failed to get SMSChannel: %s", in_error->message);
-		return;
-	}
-
-	g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
-
-	self->priv->sms_channel = g_value_get_boolean (value);
-	self->priv->got_sms_channel = TRUE;
-
-	check_almost_ready (EMPATHY_TP_CHAT (chat));
-}
-
-static void
 tp_chat_get_property (GObject    *object,
 		      guint       param_id,
 		      GValue     *value,
@@ -1317,9 +1276,6 @@ 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, self->priv->sms_channel);
-		break;
 	case PROP_N_MESSAGES_SENDING:
 		g_value_set_uint (value,
 			g_hash_table_size (self->priv->messages_being_sent));
@@ -1414,14 +1370,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
 							       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));
-
-	g_object_class_install_property (object_class,
 					 PROP_N_MESSAGES_SENDING,
 					 g_param_spec_uint ("n-messages-sending",
 						 	    "Num Messages Sending",
@@ -1805,15 +1753,6 @@ empathy_tp_chat_get_self_contact (EmpathyTpChat *self)
 	return self->priv->user;
 }
 
-
-gboolean
-empathy_tp_chat_is_sms_channel (EmpathyTpChat *self)
-{
-	g_return_val_if_fail (EMPATHY_IS_TP_CHAT (self), FALSE);
-
-	return self->priv->sms_channel;
-}
-
 GQuark
 empathy_tp_chat_get_feature_ready (void)
 {
@@ -1926,21 +1865,6 @@ conn_prepared_cb (GObject *source,
 		/* No Password interface, so no need to fetch the password flags */
 		self->priv->got_password_flags = TRUE;
 	}
-
-	/* Check if the chat is for SMS */
-	if (tp_proxy_has_interface_by_id (channel,
-					  TP_IFACE_QUARK_CHANNEL_INTERFACE_SMS)) {
-		tp_cli_channel_interface_sms_connect_to_sms_channel_changed (
-			channel,
-			sms_channel_changed_cb, self, NULL, G_OBJECT (self), NULL);
-
-		tp_cli_dbus_properties_call_get (channel, -1,
-			TP_IFACE_CHANNEL_INTERFACE_SMS, "SMSChannel",
-			get_sms_channel_cb, self, NULL, G_OBJECT (self));
-	} else {
-		/* if there's no SMS support, then we're not waiting for it */
-		self->priv->got_sms_channel = TRUE;
-	}
 }
 
 static void
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index de55c1a..20ba02a 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -121,8 +121,6 @@ TpChannelChatState
 
 EmpathyContact * empathy_tp_chat_get_self_contact   (EmpathyTpChat      *self);
 
-gboolean       empathy_tp_chat_is_sms_channel       (EmpathyTpChat      *chat);
-
 G_END_DECLS
 
 #endif /* __EMPATHY_TP_CHAT_H__ */
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index 4ed26af..e6ffaa0 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -148,7 +148,7 @@ process_tp_chat (EmpathyChatManager *self,
   if (!tp_str_empty (id))
     {
       chat = empathy_chat_window_find_chat (account, id,
-          empathy_tp_chat_is_sms_channel (tp_chat));
+          tp_text_channel_is_sms_channel ((TpTextChannel *) tp_chat));
     }
 
   if (chat != NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]