From: <sa...@us...> - 2006-07-19 23:52:07
|
Revision: 16522 Author: sadrul Date: 2006-07-19 16:52:01 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16522&view=rev Log Message: ----------- Enable the commands (prefixed with /) in conversations. Modified Paths: -------------- trunk/console/Makefile trunk/console/gntconv.c trunk/console/gntgaim.c trunk/console/gntui.c Modified: trunk/console/Makefile =================================================================== --- trunk/console/Makefile 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/Makefile 2006-07-19 23:52:01 UTC (rev 16522) @@ -1,6 +1,6 @@ VERSION=gntgaim-0.0.0dev CC=gcc -CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" +CFLAGS=`pkg-config --cflags gaim gobject-2.0 gnt` -g -Wall -DVERSION=\"$(VERSION)\" -DSTANDALONE LDFLAGS=`pkg-config --libs gaim gobject-2.0 libxml-2.0 gnt` -pg GG_SOURCES = \ Modified: trunk/console/gntconv.c =================================================================== --- trunk/console/gntconv.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntconv.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -1,4 +1,6 @@ #include <string.h> + +#include <cmds.h> #include <util.h> #include "gntgaim.h" @@ -49,12 +51,53 @@ const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); if (*text == '/') { - /* XXX: Need to check for /-commands here */ + GaimConversation *conv = ggconv->conv; + GaimCmdStatus status; + const char *cmdline = text + 1; + char *error = NULL, *escape; + + escape = g_markup_escape_text(cmdline, -1); + status = gaim_cmd_do_command(conv, cmdline, escape, &error); + g_free(escape); + + switch (status) + { + case GAIM_CMD_STATUS_OK: + break; + case GAIM_CMD_STATUS_NOT_FOUND: + gaim_conversation_write(conv, "", _("No such command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_ARGS: + gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " + "to that command."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_FAILED: + gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_TYPE: + if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) + gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + else + gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + case GAIM_CMD_STATUS_WRONG_PRPL: + gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), + GAIM_MESSAGE_NO_LOG, time(NULL)); + break; + } + g_free(error); +#if 0 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), _("Commands are not supported yet. Message was NOT sent."), GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); +#endif } else { Modified: trunk/console/gntgaim.c =================================================================== --- trunk/console/gntgaim.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntgaim.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -299,8 +299,9 @@ /* Initialize and run the UI */ init_gnt_ui(); - +#ifdef STANDALONE gaim_core_quit(); +#endif return 0; } Modified: trunk/console/gntui.c =================================================================== --- trunk/console/gntui.c 2006-07-19 20:14:58 UTC (rev 16521) +++ trunk/console/gntui.c 2006-07-19 23:52:01 UTC (rev 16522) @@ -8,8 +8,9 @@ void init_gnt_ui() { +#ifdef STANDALONE gnt_init(); - +#endif /* Accounts */ gg_accounts_init(); gaim_accounts_set_ui_ops(gg_accounts_get_ui_ops()); @@ -30,6 +31,7 @@ gg_notify_init(); gaim_notify_set_ui_ops(gg_notify_get_ui_ops()); +#ifdef STANDALONE gnt_main(); gaim_accounts_set_ui_ops(NULL); @@ -48,5 +50,6 @@ gg_notify_uninit(); gnt_quit(); +#endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |