[empathy: 2/12] Add support for /join command



commit d283411b3f1ba3685b329a7a41d59ae153bd15ba
Author: Xavier Claessens <xclaesse gmail com>
Date:   Sat Oct 10 09:48:23 2009 +0200

    Add support for /join command
    
    https://bugzilla.gnome.org/show_bug.cgi?id=573407

 libempathy-gtk/empathy-chat.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 6c712a5..a8bddde 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -377,11 +377,26 @@ chat_sent_message_get_last (EmpathyChat *chat)
 }
 
 static void
+chat_join_command_cb (EmpathyDispatchOperation *dispatch,
+		      const GError             *error,
+		      gpointer                  user_data)
+{
+	EmpathyChat *chat = user_data;
+
+	if (error != NULL) {
+		DEBUG ("Error: %s", error->message);
+		empathy_chat_view_append_event (chat->view,
+			_("Failed to join chatroom"));
+	}
+}
+
+static void
 chat_send (EmpathyChat  *chat,
 	   const gchar *msg)
 {
 	EmpathyChatPriv *priv;
 	EmpathyMessage  *message;
+	gchar           *join = NULL;
 
 	if (EMP_STR_EMPTY (msg)) {
 		return;
@@ -394,7 +409,7 @@ chat_send (EmpathyChat  *chat,
 	if (strcmp (msg, "/clear") == 0) {
 		empathy_chat_view_clear (chat->view);
 		return;
-	} else if (g_str_has_prefix (msg, "/topic")) {
+	} else if (g_str_has_prefix (msg, "/topic ")) {
 		EmpathyTpChatProperty *property;
 		GValue value = {0, };
 		gchar *topic;
@@ -412,13 +427,26 @@ chat_send (EmpathyChat  *chat,
 			return;
 		}
 
-		topic = g_strstrip (g_strdup (msg + strlen ("/topic")));
+		topic = g_strstrip (g_strdup (msg + strlen ("/topic ")));
 		g_value_init (&value, G_TYPE_STRING);
 		g_value_take_string (&value, topic);
 		empathy_tp_chat_set_property (priv->tp_chat, "subject", &value);
 		g_value_unset (&value);
 
 		return;
+	} else if (g_str_has_prefix (msg, "/join ")) {
+		join = g_strstrip (g_strdup (msg + strlen ("/join ")));
+	} else if (g_str_has_prefix (msg, "/j ")) {
+		join = g_strstrip (g_strdup (msg + strlen ("/j ")));
+	}
+	if (join != NULL) {
+		TpConnection *connection;
+
+		connection = empathy_tp_chat_get_connection (priv->tp_chat);
+		empathy_dispatcher_join_muc (connection, join,
+					     chat_join_command_cb, chat);
+		g_free (join);
+		return;
 	}
 
 	message = empathy_message_new_from_entry (msg);



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