Mercurial > pidgin
changeset 13966:80cbf6c2d562
[gaim-migrate @ 16522]
Enable the commands (prefixed with /) in conversations.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 19 Jul 2006 23:52:01 +0000 |
parents | df0dba522147 |
children | 99b9b58b19dd |
files | console/Makefile console/gntconv.c console/gntgaim.c console/gntui.c |
diffstat | 4 files changed, 51 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/console/Makefile Wed Jul 19 20:14:58 2006 +0000 +++ b/console/Makefile Wed Jul 19 23:52:01 2006 +0000 @@ -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 = \
--- a/console/gntconv.c Wed Jul 19 20:14:58 2006 +0000 +++ b/console/gntconv.c Wed Jul 19 23:52:01 2006 +0000 @@ -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 {
--- a/console/gntgaim.c Wed Jul 19 20:14:58 2006 +0000 +++ b/console/gntgaim.c Wed Jul 19 23:52:01 2006 +0000 @@ -299,8 +299,9 @@ /* Initialize and run the UI */ init_gnt_ui(); - +#ifdef STANDALONE gaim_core_quit(); +#endif return 0; }
--- a/console/gntui.c Wed Jul 19 20:14:58 2006 +0000 +++ b/console/gntui.c Wed Jul 19 23:52:01 2006 +0000 @@ -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 }