diff src/gtkconv.c @ 9597:d6f398e80b32

[gaim-migrate @ 10440] denyri added a void *data argument to most of the command related functions. This makes it easier for language binding and such. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 26 Jul 2004 03:27:03 +0000
parents 7b3212aa698c
children 00e678a71a7f
line wrap: on
line diff
--- a/src/gtkconv.c	Sun Jul 25 22:47:11 2004 +0000
+++ b/src/gtkconv.c	Mon Jul 26 03:27:03 2004 +0000
@@ -288,7 +288,7 @@
 
 static GaimCmdRet
 me_command_cb(GaimConversation *conv,
-              const char *cmd, char **args, char **error)
+              const char *cmd, char **args, char **error, void *data)
 {
 	char *tmp;
 
@@ -305,7 +305,7 @@
 
 static GaimCmdRet
 debug_command_cb(GaimConversation *conv,
-                 const char *cmd, char **args, char **error)
+                 const char *cmd, char **args, char **error, void *data)
 {
 	char *tmp, *markup;
 	GaimCmdStatus status;
@@ -328,51 +328,38 @@
 
 static GaimCmdRet
 help_command_cb(GaimConversation *conv,
-                 const char *cmd, char **args, char **error)
+                 const char *cmd, char **args, char **error, void *data)
 {
+	GList *l, *text;
 	GString *s;
-	GList *cmds, *l;
-
-	s = g_string_new(_("Use \"/help &lt;command&gt;\" for help on a specific command.\n"
-	                   "The following commands are available in this context:\n"));
-
-	cmds = gaim_cmd_list(conv);
-	for (l = cmds; l; l = l->next)
-		if (l->next)
-			g_string_append_printf(s, "%s, ", (char *)l->data);
-		else
-			g_string_append_printf(s, "%s.", (char *)l->data);
-
-	gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL));
-	g_string_free(s, TRUE);
-	g_list_free(cmds);
-
-	return GAIM_CMD_STATUS_OK;
-}
-
-static GaimCmdRet
-help_arg_command_cb(GaimConversation *conv,
-                 const char *cmd, char **args, char **error)
-{
-	GList *help, *l;
-	GString *s;
-
-	s = g_string_new("");
-	help = gaim_cmd_help(conv, args[0]);
-
-	if (help) {
-		for (l = help; l; l = l->next)
+
+	if (args[0] != NULL) {
+		s = g_string_new("");
+		text = gaim_cmd_help(conv, args[0]);
+
+		if (text) {
+			for (l = text; l; l = l->next)
+				if (l->next)
+					g_string_append_printf(s, "/%s\n", (char *)l->data);
+				else
+					g_string_append_printf(s, "/%s", (char *)l->data);
+		} else {
+			g_string_append(s, _("No such command (in this context)."));
+		}
+	} else {
+		s = g_string_new(_("Use \"/help &lt;command&gt;\" for help on a specific command.\n"
+											 "The following commands are available in this context:\n"));
+
+		text = gaim_cmd_list(conv);
+		for (l = text; l; l = l->next)
 			if (l->next)
-				g_string_append_printf(s, "/%s\n", (char *)l->data);
+				g_string_append_printf(s, "%s, ", (char *)l->data);
 			else
-				g_string_append_printf(s, "/%s", (char *)l->data);
-	} else {
-		g_string_append(s, _("No such command (in this context)."));
+				g_string_append_printf(s, "%s.", (char *)l->data);
 	}
 
 	gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL));
 	g_string_free(s, TRUE);
-	g_list_free(help);
 
 	return GAIM_CMD_STATUS_OK;
 }
@@ -6318,18 +6305,14 @@
 	 **********************************************************************/
 	gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT,
 	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
-	                  me_command_cb, _("me &lt;action&gt;:  Send an IRC style action to a buddy or chat."));
+	                  me_command_cb, _("me &lt;action&gt;:  Send an IRC style action to a buddy or chat."), NULL);
 	gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT,
 	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
-	                  debug_command_cb, _("debug &lt;option&gt;:  Send various debug information to the current conversation."));
-
-	gaim_cmd_register("help", "", GAIM_CMD_P_DEFAULT,
-	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
-	                  help_command_cb, _("help:  List available commands."));
+	                  debug_command_cb, _("debug &lt;option&gt;:  Send various debug information to the current conversation."), NULL);
 
 	gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT,
-	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
-	                  help_arg_command_cb, _("help &lt;command&gt;:  Help on a specific command."));
+	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
+	                  help_command_cb, _("help &lt;command&gt;:  Help on a specific command."), NULL);
 }
 
 void