empathy r2809 - trunk/libempathy-gtk



Author: xclaesse
Date: Fri Apr 10 17:31:39 2009
New Revision: 2809
URL: http://svn.gnome.org/viewvc/empathy?rev=2809&view=rev

Log:
Fix support for /me and /say commands.

From: Xavier Claessens <xclaesse gmail com>

Modified:
   trunk/libempathy-gtk/empathy-chat.c

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Fri Apr 10 17:31:39 2009
@@ -349,6 +349,7 @@
 	   const gchar *msg)
 {
 	EmpathyChatPriv *priv;
+	EmpathyMessage  *message;
 
 	if (EMP_STR_EMPTY (msg)) {
 		return;
@@ -358,24 +359,25 @@
 
 	chat_sent_message_add (chat, msg);
 
-	/* If this is not a command, send the message */
-	if (msg[0] != '/') {
-		EmpathyMessage  *message;
-
-		message = empathy_message_new (msg);
-		empathy_tp_chat_send (priv->tp_chat, message);
-		g_object_unref (message);
+	if (g_str_has_prefix (msg, "/clear")) {
+		empathy_chat_view_clear (chat->view);
 		return;
 	}
 
-	/* Check for all supported commands */
-	if (g_str_has_prefix (msg, "/clear")) {
-		empathy_chat_view_clear (chat->view);
+	/* Blacklist messages begining by '/', except for "/me" and "/say"
+	 * because they are handled in EmpathyMessage */
+	if (msg[0] == '/' &&
+	    !g_str_has_prefix (msg, "/me") &&
+	    !g_str_has_prefix (msg, "/say")) {
+		empathy_chat_view_append_event (chat->view,
+			_("Unsupported command"));
 		return;
 	}
 
-	/* This is an unknown command, display a message to the user */
-	empathy_chat_view_append_event (chat->view, _("Unsupported command"));
+	/* We can send the message */
+	message = empathy_message_new (msg);
+	empathy_tp_chat_send (priv->tp_chat, message);
+	g_object_unref (message);
 }
 
 static void
@@ -567,28 +569,6 @@
 	}
 }
 
-static gboolean
-chat_get_is_command (const gchar *str)
-{
-	g_return_val_if_fail (str != NULL, FALSE);
-
-	if (str[0] != '/') {
-		return FALSE;
-	}
-
-	if (g_str_has_prefix (str, "/me")) {
-		return TRUE;
-	}
-	else if (g_str_has_prefix (str, "/nick")) {
-		return TRUE;
-	}
-	else if (g_str_has_prefix (str, "/topic")) {
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
 static void
 chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
 				   EmpathyChat    *chat)
@@ -648,8 +628,8 @@
 
 		str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
 
-		/* spell check string */
-		if (!chat_get_is_command (str)) {
+		/* spell check string if not a command */
+		if (str[0] != '/') {
 			correct = empathy_spell_check (str);
 		} else {
 			correct = TRUE;



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