Mercurial > pidgin.yaz
comparison console/gntconv.c @ 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 | 25be562aaca8 |
children | df8183b7fa2c |
comparison
equal
deleted
inserted
replaced
13965:df0dba522147 | 13966:80cbf6c2d562 |
---|---|
1 #include <string.h> | 1 #include <string.h> |
2 | |
3 #include <cmds.h> | |
2 #include <util.h> | 4 #include <util.h> |
3 | 5 |
4 #include "gntgaim.h" | 6 #include "gntgaim.h" |
5 #include "gntblist.h" | 7 #include "gntblist.h" |
6 #include "gntconv.h" | 8 #include "gntconv.h" |
47 if (key[0] == '\r' && key[1] == 0) | 49 if (key[0] == '\r' && key[1] == 0) |
48 { | 50 { |
49 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); | 51 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); |
50 if (*text == '/') | 52 if (*text == '/') |
51 { | 53 { |
52 /* XXX: Need to check for /-commands here */ | 54 GaimConversation *conv = ggconv->conv; |
55 GaimCmdStatus status; | |
56 const char *cmdline = text + 1; | |
57 char *error = NULL, *escape; | |
58 | |
59 escape = g_markup_escape_text(cmdline, -1); | |
60 status = gaim_cmd_do_command(conv, cmdline, escape, &error); | |
61 g_free(escape); | |
62 | |
63 switch (status) | |
64 { | |
65 case GAIM_CMD_STATUS_OK: | |
66 break; | |
67 case GAIM_CMD_STATUS_NOT_FOUND: | |
68 gaim_conversation_write(conv, "", _("No such command."), | |
69 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
70 break; | |
71 case GAIM_CMD_STATUS_WRONG_ARGS: | |
72 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
73 "to that command."), | |
74 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
75 break; | |
76 case GAIM_CMD_STATUS_FAILED: | |
77 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
78 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
79 break; | |
80 case GAIM_CMD_STATUS_WRONG_TYPE: | |
81 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
82 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), | |
83 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
84 else | |
85 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), | |
86 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
87 break; | |
88 case GAIM_CMD_STATUS_WRONG_PRPL: | |
89 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
90 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
91 break; | |
92 } | |
93 g_free(error); | |
94 #if 0 | |
53 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | 95 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
54 _("Commands are not supported yet. Message was NOT sent."), | 96 _("Commands are not supported yet. Message was NOT sent."), |
55 GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); | 97 GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); |
56 gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); | 98 gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); |
57 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | 99 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); |
100 #endif | |
58 } | 101 } |
59 else | 102 else |
60 { | 103 { |
61 switch (gaim_conversation_get_type(ggconv->conv)) | 104 switch (gaim_conversation_get_type(ggconv->conv)) |
62 { | 105 { |