Thu, 22 May 2014 22:09:55 +0200
Fix message flags
| 6333 | 1 | /** |
| 2 | * @file cmds.c | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 6333 | 5 | * |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
7 | * |
| 6333 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16474
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6333 | 21 | */ |
| 22 | ||
| 23 | #include "internal.h" | |
| 24 | ||
| 25 | #include "conversation.h" | |
| 8504 | 26 | #include "debug.h" |
| 6333 | 27 | #include "notify.h" |
| 8624 | 28 | #include "util.h" |
| 8504 | 29 | |
| 6333 | 30 | #include "irc.h" |
| 31 | ||
| 32 | ||
| 33 | static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); | |
| 34 | ||
| 35 | int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 36 | { | |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
37 | PurpleConversation *convo = purple_conversations_find_with_account(target, irc->account); |
| 6333 | 38 | char *buf; |
| 39 | ||
| 40 | if (!convo) | |
| 6350 | 41 | return 1; |
| 6333 | 42 | |
| 43 | buf = g_strdup_printf(_("Unknown command: %s"), cmd); | |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36082
diff
changeset
|
44 | purple_conversation_write_system_message(convo, buf, PURPLE_MESSAGE_NO_LOG); |
| 6333 | 45 | g_free(buf); |
| 46 | ||
| 47 | return 1; | |
| 48 | } | |
| 49 | ||
| 50 | int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 51 | { | |
|
12669
c15115dcfc23
[gaim-migrate @ 15012]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12013
diff
changeset
|
52 | char *buf, *message; |
| 6333 | 53 | |
| 54 | if (args[0] && strcmp(cmd, "back")) { | |
| 15884 | 55 | message = purple_markup_strip_html(args[0]); |
| 56 | purple_util_chrreplace(message, '\n', ' '); | |
| 6333 | 57 | buf = irc_format(irc, "v:", "AWAY", message); |
| 58 | g_free(message); | |
| 59 | } else { | |
| 60 | buf = irc_format(irc, "v", "AWAY"); | |
| 61 | } | |
| 62 | irc_send(irc, buf); | |
| 63 | g_free(buf); | |
| 64 | ||
| 65 | return 0; | |
| 66 | } | |
| 67 | ||
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
68 | int irc_cmd_ctcp(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
69 | { |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
70 | /* we have defined args as args[0] is target and args[1] is ctcp command */ |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23896
diff
changeset
|
71 | char *buf; |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
72 | GString *string; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30469
diff
changeset
|
73 | |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
74 | /* check if we have args */ |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
75 | if (!args || !args[0] || !args[1]) |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
76 | return 0; |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
77 | |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
78 | /* TODO:strip newlines or send each line as separate ctcp or something |
|
23896
f75e9380c5c8
Correct some IRC comments for /ctcp
Ethan Blanton <elb@pidgin.im>
parents:
23895
diff
changeset
|
79 | * actually, this shouldn't be done here but somewhere else since irc should support escaping newlines */ |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
80 | |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
81 | string = g_string_new(args[1]); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
82 | g_string_prepend_c (string,'\001'); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
83 | g_string_append_c (string,'\001'); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
84 | buf = irc_format(irc, "vn:", "PRIVMSG", args[0], string->str); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
85 | g_string_free(string,TRUE); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
86 | |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
87 | irc_send(irc, buf); |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
88 | g_free(buf); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30469
diff
changeset
|
89 | |
|
23895
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
90 | return 1; |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
91 | } |
|
4d883627111f
/ctcp command for IRC
Vladislav Guberinic <neosisani@gmail.com>
parents:
23118
diff
changeset
|
92 | |
| 6333 | 93 | int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 94 | { | |
| 15884 | 95 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10933
ba1a5024f03a
[gaim-migrate @ 12716]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10732
diff
changeset
|
96 | char *action, *escaped, *dst, **newargs; |
| 6333 | 97 | const char *src; |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
98 | char *msg; |
| 15884 | 99 | PurpleConversation *convo; |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
100 | PurpleMessage *pmsg; |
| 6333 | 101 | |
| 102 | if (!args || !args[0] || !gc) | |
| 103 | return 0; | |
| 104 | ||
| 35972 | 105 | convo = purple_conversations_find_with_account(target, irc->account); |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
106 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
107 | msg = g_strdup_printf("/me %s", args[0]); |
| 6333 | 108 | |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
109 | /* XXX: we'd prefer to keep this in conversation.c */ |
| 35972 | 110 | if (PURPLE_IS_IM_CONVERSATION(convo)) { |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
111 | pmsg = purple_message_new(purple_conversation_get_name(convo), |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
112 | msg, PURPLE_MESSAGE_SEND); |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
113 | |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
114 | purple_signal_emit(purple_conversations_get_handle(), |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
115 | "sending-im-msg", irc->account, pmsg); |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
116 | } else { |
|
36080
637a1a87c4d3
Switch sending-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
117 | pmsg = purple_message_new(NULL, msg, PURPLE_MESSAGE_SEND); |
|
637a1a87c4d3
Switch sending-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
118 | |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
119 | purple_signal_emit(purple_conversations_get_handle(), |
|
36080
637a1a87c4d3
Switch sending-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
120 | "sending-chat-msg", irc->account, pmsg, |
| 35972 | 121 | purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(convo))); |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
122 | } |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
123 | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
124 | g_free(msg); |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
125 | if (purple_message_is_empty(pmsg)) |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
126 | return 0; |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35972
diff
changeset
|
127 | msg = g_strdup(purple_message_get_contents(pmsg)); /* XXX: is it really necessary? */ |
| 6333 | 128 | |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
129 | if (strncmp(msg, "/me ", 4) != 0) { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
130 | newargs = g_new0(char *, 2); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
131 | newargs[0] = g_strdup(target); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
132 | newargs[1] = msg; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
133 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
134 | irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
135 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
136 | g_free(newargs[0]); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
137 | g_free(newargs); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
138 | } else { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
139 | action = g_malloc(strlen(&msg[4]) + 10); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
140 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
141 | sprintf(action, "\001ACTION "); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
142 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
143 | src = &msg[4]; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
144 | dst = action + 8; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
145 | while (*src) { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
146 | if (*src == '\n') { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
147 | if (*(src + 1) == '\0') { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
148 | break; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
149 | } else { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
150 | *dst++ = ' '; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
151 | src++; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
152 | continue; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
153 | } |
| 6333 | 154 | } |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
155 | *dst++ = *src++; |
| 6333 | 156 | } |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
157 | *dst++ = '\001'; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
158 | *dst = '\0'; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
159 | |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
160 | newargs = g_new0(char *, 2); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
161 | newargs[0] = g_strdup(target); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
162 | newargs[1] = action; |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
163 | irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
164 | g_free(newargs[0]); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
165 | g_free(newargs); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
166 | g_free(action); |
| 6333 | 167 | } |
| 168 | ||
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
169 | /* XXX: we'd prefer to keep this in conversation.c */ |
| 35972 | 170 | if (PURPLE_IS_IM_CONVERSATION(convo)) { |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
171 | purple_signal_emit(purple_conversations_get_handle(), |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36080
diff
changeset
|
172 | "sent-im-msg", irc->account, pmsg); |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
173 | } else { |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
174 | purple_signal_emit(purple_conversations_get_handle(), |
|
36082
247d94c903c3
Switch sent-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36081
diff
changeset
|
175 | "sent-chat-msg", irc->account, pmsg, |
| 35972 | 176 | purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(convo))); |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
177 | } |
| 6333 | 178 | |
|
35925
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
179 | g_free(msg); |
|
3edc70bf4e09
Emit sending/sent signals when doing /me irc command. Fixes #15750
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
180 | |
| 9130 | 181 | if (convo) { |
|
10933
ba1a5024f03a
[gaim-migrate @ 12716]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10732
diff
changeset
|
182 | escaped = g_markup_escape_text(args[0], -1); |
|
ba1a5024f03a
[gaim-migrate @ 12716]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10732
diff
changeset
|
183 | action = g_strdup_printf("/me %s", escaped); |
|
ba1a5024f03a
[gaim-migrate @ 12716]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10732
diff
changeset
|
184 | g_free(escaped); |
| 6333 | 185 | if (action[strlen(action) - 1] == '\n') |
| 186 | action[strlen(action) - 1] = '\0'; | |
|
34629
3c3bed0fd13c
Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
187 | if (PURPLE_IS_CHAT_CONVERSATION(convo)) |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
188 | purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(convo)), |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23896
diff
changeset
|
189 | purple_connection_get_display_name(gc), |
|
27185
47b88eabc980
Fix outgoing IRC /mes to be printed to the conversation window as sent
Florian Quèze <florian@instantbird.org>
parents:
24763
diff
changeset
|
190 | PURPLE_MESSAGE_SEND, action, time(NULL)); |
| 9130 | 191 | else |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
192 | purple_conversation_write_message(convo, purple_message_new( |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
193 | purple_connection_get_display_name(gc), action, |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
194 | PURPLE_MESSAGE_SEND)); |
| 6333 | 195 | g_free(action); |
| 196 | } | |
| 197 | ||
| 198 | return 1; | |
| 199 | } | |
| 200 | ||
| 13943 | 201 | int irc_cmd_ctcp_version(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 202 | { | |
| 203 | char *buf; | |
| 204 | ||
| 205 | if (!args || !args[0]) | |
| 206 | return 0; | |
| 207 | ||
| 208 | buf = irc_format(irc, "vn:", "PRIVMSG", args[0], "\001VERSION\001"); | |
| 209 | irc_send(irc, buf); | |
| 210 | g_free(buf); | |
| 211 | ||
| 212 | return 0; | |
| 213 | } | |
| 214 | ||
| 6333 | 215 | int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 216 | { | |
| 217 | char *buf; | |
| 218 | ||
| 219 | if (!args || !args[0] || !(args[1] || target)) | |
| 220 | return 0; | |
| 221 | ||
| 222 | buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target); | |
| 223 | irc_send(irc, buf); | |
| 224 | g_free(buf); | |
| 225 | ||
| 226 | return 0; | |
| 227 | } | |
| 228 | ||
| 229 | int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 230 | { | |
| 231 | char *buf; | |
| 232 | ||
| 233 | if (!args || !args[0]) | |
| 234 | return 0; | |
| 235 | ||
| 236 | if (args[1]) | |
| 237 | buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]); | |
| 238 | else | |
| 239 | buf = irc_format(irc, "vc", "JOIN", args[0]); | |
| 240 | irc_send(irc, buf); | |
| 241 | g_free(buf); | |
| 242 | ||
| 243 | return 0; | |
| 244 | } | |
| 245 | ||
| 246 | int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 247 | { | |
| 248 | char *buf; | |
| 249 | ||
| 250 | if (!args || !args[0]) | |
| 251 | return 0; | |
| 252 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
253 | if (!purple_conversations_find_chat_with_account(target, irc->account)) |
| 6350 | 254 | return 0; |
| 6333 | 255 | |
| 256 | if (args[1]) | |
| 257 | buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | |
| 258 | else | |
| 259 | buf = irc_format(irc, "vcn", "KICK", target, args[0]); | |
| 260 | irc_send(irc, buf); | |
| 261 | g_free(buf); | |
| 262 | ||
| 263 | return 0; | |
| 264 | } | |
| 265 | ||
| 8114 | 266 | int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 267 | { | |
| 15884 | 268 | purple_roomlist_show_with_account(irc->account); |
| 8114 | 269 | |
| 270 | return 0; | |
| 271 | } | |
| 272 | ||
| 6333 | 273 | int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 274 | { | |
| 15884 | 275 | PurpleConnection *gc; |
| 6333 | 276 | char *buf; |
| 277 | ||
| 278 | if (!args) | |
| 279 | return 0; | |
| 280 | ||
| 281 | if (!strcmp(cmd, "mode")) { | |
| 10208 | 282 | if (!args[0] && irc_ischannel(target)) |
| 6333 | 283 | buf = irc_format(irc, "vc", "MODE", target); |
| 284 | else if (args[0] && (*args[0] == '+' || *args[0] == '-')) | |
|
30469
7f787c107093
Fixes non-ASCII arguments to /mode, /umode, etc. Thanks to Max
Max Ulidtko <ulidtko@gmail.com>
parents:
27185
diff
changeset
|
285 | buf = irc_format(irc, "vcn", "MODE", target, args[0]); |
| 6333 | 286 | else if (args[0]) |
|
30469
7f787c107093
Fixes non-ASCII arguments to /mode, /umode, etc. Thanks to Max
Max Ulidtko <ulidtko@gmail.com>
parents:
27185
diff
changeset
|
287 | buf = irc_format(irc, "vn", "MODE", args[0]); |
| 6333 | 288 | else |
| 6350 | 289 | return 0; |
| 6333 | 290 | } else if (!strcmp(cmd, "umode")) { |
| 291 | if (!args[0]) | |
| 6350 | 292 | return 0; |
| 15884 | 293 | gc = purple_account_get_connection(irc->account); |
|
30469
7f787c107093
Fixes non-ASCII arguments to /mode, /umode, etc. Thanks to Max
Max Ulidtko <ulidtko@gmail.com>
parents:
27185
diff
changeset
|
294 | buf = irc_format(irc, "vnc", "MODE", purple_connection_get_display_name(gc), args[0]); |
| 6365 | 295 | } else { |
| 296 | return 0; | |
| 6333 | 297 | } |
| 6365 | 298 | |
| 6333 | 299 | irc_send(irc, buf); |
| 300 | g_free(buf); | |
| 301 | ||
| 302 | return 0; | |
| 303 | } | |
| 304 | ||
| 305 | int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 306 | { | |
| 307 | char *buf; | |
| 308 | ||
| 10208 | 309 | if (!args || (!args[0] && !irc_ischannel(target))) |
| 6333 | 310 | return 0; |
| 311 | ||
| 312 | buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target); | |
| 313 | irc_send(irc, buf); | |
| 314 | g_free(buf); | |
| 315 | ||
| 316 | return 0; | |
| 317 | } | |
| 318 | ||
| 319 | int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 320 | { | |
| 321 | char *buf; | |
| 322 | ||
| 323 | if (!args || !args[0]) | |
| 324 | return 0; | |
| 325 | ||
| 326 | buf = irc_format(irc, "v:", "NICK", args[0]); | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22521
diff
changeset
|
327 | g_free(irc->reqnick); |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22521
diff
changeset
|
328 | irc->reqnick = g_strdup(args[0]); |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22521
diff
changeset
|
329 | irc->nickused = FALSE; |
| 6333 | 330 | irc_send(irc, buf); |
| 331 | g_free(buf); | |
| 332 | ||
| 333 | return 0; | |
| 334 | } | |
| 335 | ||
| 336 | int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 337 | { | |
| 338 | char **nicks, **ops, *sign, *mode; | |
| 339 | int i = 0, used = 0; | |
| 340 | ||
| 341 | if (!args || !args[0] || !*args[0]) | |
| 342 | return 0; | |
| 343 | ||
| 344 | if (!strcmp(cmd, "op")) { | |
| 345 | sign = "+"; | |
| 346 | mode = "o"; | |
| 347 | } else if (!strcmp(cmd, "deop")) { | |
| 348 | sign = "-"; | |
| 349 | mode = "o"; | |
| 350 | } else if (!strcmp(cmd, "voice")) { | |
| 351 | sign = "+"; | |
| 352 | mode = "v"; | |
| 353 | } else if (!strcmp(cmd, "devoice")) { | |
| 354 | sign = "-"; | |
| 355 | mode = "v"; | |
| 356 | } else { | |
| 15884 | 357 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); |
| 6333 | 358 | return 0; |
| 359 | } | |
| 360 | ||
| 361 | nicks = g_strsplit(args[0], " ", -1); | |
| 362 | ||
| 363 | for (i = 0; nicks[i]; i++) | |
| 364 | /* nothing */; | |
| 365 | ops = g_new0(char *, i * 2 + 1); | |
| 366 | ||
| 367 | for (i = 0; nicks[i]; i++) { | |
| 22521 | 368 | if (*nicks[i]) { |
| 369 | ops[used++] = mode; | |
| 370 | ops[used++] = nicks[i]; | |
|
21694
ac3973a88b24
Plug a tiny little leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
371 | } |
| 6333 | 372 | } |
| 373 | ||
| 374 | irc_do_mode(irc, target, sign, ops); | |
| 375 | g_free(ops); | |
| 22521 | 376 | g_strfreev(nicks); |
| 6333 | 377 | |
| 6350 | 378 | return 0; |
| 6333 | 379 | } |
| 380 | ||
| 381 | int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 382 | { | |
| 383 | char *buf; | |
| 384 | ||
| 385 | if (!args) | |
| 386 | return 0; | |
| 387 | ||
| 388 | if (args[1]) | |
| 389 | buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]); | |
| 390 | else | |
| 391 | buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target); | |
| 392 | irc_send(irc, buf); | |
| 393 | g_free(buf); | |
| 394 | ||
| 395 | return 0; | |
| 396 | } | |
| 397 | ||
| 398 | int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 399 | { | |
| 400 | char *stamp; | |
| 401 | char *buf; | |
| 402 | ||
| 403 | if (args && args[0]) { | |
| 10208 | 404 | if (irc_ischannel(args[0])) |
| 6333 | 405 | return 0; |
| 406 | stamp = g_strdup_printf("\001PING %lu\001", time(NULL)); | |
| 407 | buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp); | |
| 408 | g_free(stamp); | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
409 | } else if (target) { |
| 6350 | 410 | stamp = g_strdup_printf("%s %lu", target, time(NULL)); |
| 6333 | 411 | buf = irc_format(irc, "v:", "PING", stamp); |
| 412 | g_free(stamp); | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
413 | } else { |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
414 | stamp = g_strdup_printf("%lu", time(NULL)); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
415 | buf = irc_format(irc, "vv", "PING", stamp); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
416 | g_free(stamp); |
| 6333 | 417 | } |
| 418 | irc_send(irc, buf); | |
| 419 | g_free(buf); | |
| 420 | ||
| 421 | return 0; | |
| 422 | } | |
| 423 | ||
| 424 | int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 425 | { | |
| 426 | const char *cur, *end; | |
| 427 | char *msg, *buf; | |
| 428 | ||
| 429 | if (!args || !args[0] || !args[1]) | |
| 430 | return 0; | |
| 431 | ||
| 432 | cur = args[1]; | |
| 433 | end = args[1]; | |
| 434 | while (*end && *cur) { | |
| 435 | end = strchr(cur, '\n'); | |
| 436 | if (!end) | |
| 437 | end = cur + strlen(cur); | |
| 438 | msg = g_strndup(cur, end - cur); | |
|
22092
52c00ca73f6f
Added /notice support for IRC. If I didn't do this properly, feel free
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21694
diff
changeset
|
439 | |
| 22167 | 440 | if(!strcmp(cmd, "notice")) |
| 441 | buf = irc_format(irc, "vt:", "NOTICE", args[0], msg); | |
| 442 | else | |
|
22092
52c00ca73f6f
Added /notice support for IRC. If I didn't do this properly, feel free
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21694
diff
changeset
|
443 | buf = irc_format(irc, "vt:", "PRIVMSG", args[0], msg); |
|
52c00ca73f6f
Added /notice support for IRC. If I didn't do this properly, feel free
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
21694
diff
changeset
|
444 | |
| 6333 | 445 | irc_send(irc, buf); |
| 446 | g_free(msg); | |
| 447 | g_free(buf); | |
| 448 | cur = end + 1; | |
| 449 | } | |
| 450 | ||
| 451 | return 0; | |
| 452 | } | |
| 453 | ||
| 454 | int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 455 | { | |
| 456 | char *buf; | |
| 457 | ||
| 9440 | 458 | if (!irc->quitting) { |
| 11763 | 459 | /* |
| 15884 | 460 | * Use purple_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT) |
| 11763 | 461 | * and uncomment the appropriate account preference in irc.c if we |
| 462 | * decide we want custom quit messages. | |
| 463 | */ | |
| 464 | buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT); | |
| 9440 | 465 | irc_send(irc, buf); |
| 466 | g_free(buf); | |
| 467 | ||
| 468 | irc->quitting = TRUE; | |
|
13839
e27a7f02055c
[gaim-migrate @ 16286]
Mark Doliner <markdoliner@pidgin.im>
parents:
12669
diff
changeset
|
469 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
470 | if (!purple_account_is_disconnecting(irc->account)) |
| 15884 | 471 | purple_account_set_status(irc->account, "offline", TRUE, NULL); |
| 9440 | 472 | } |
| 6333 | 473 | |
| 474 | return 0; | |
| 475 | } | |
| 476 | ||
| 477 | int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 478 | { | |
| 479 | char *buf; | |
| 480 | ||
| 481 | if (!args || !args[0]) | |
| 482 | return 0; | |
| 483 | ||
|
30469
7f787c107093
Fixes non-ASCII arguments to /mode, /umode, etc. Thanks to Max
Max Ulidtko <ulidtko@gmail.com>
parents:
27185
diff
changeset
|
484 | buf = irc_format(irc, "n", args[0]); |
| 6333 | 485 | irc_send(irc, buf); |
| 486 | g_free(buf); | |
| 487 | ||
| 488 | return 0; | |
| 489 | } | |
| 490 | ||
| 491 | int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 492 | { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
493 | PurpleIMConversation *im; |
| 15884 | 494 | PurpleConnection *gc; |
| 6333 | 495 | |
| 496 | if (!args || !args[0]) | |
| 497 | return 0; | |
| 498 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
499 | im = purple_im_conversation_new(irc->account, args[0]); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
500 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 6333 | 501 | |
| 502 | if (args[1]) { | |
| 15884 | 503 | gc = purple_account_get_connection(irc->account); |
| 6333 | 504 | irc_cmd_privmsg(irc, cmd, target, args); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
505 | purple_conversation_write_message(PURPLE_CONVERSATION(im), |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
506 | purple_message_new(purple_connection_get_display_name(gc), |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
507 | args[1], PURPLE_MESSAGE_SEND)); |
| 6333 | 508 | } |
| 509 | ||
| 510 | return 0; | |
| 511 | } | |
| 512 | ||
| 513 | int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 514 | { | |
| 515 | char *buf; | |
| 516 | ||
| 517 | if (!args || !args[0]) | |
| 518 | return 0; | |
| 519 | ||
| 10208 | 520 | if (!irc_ischannel(target)) /* not a channel, punt */ |
| 6333 | 521 | return 0; |
| 522 | ||
| 523 | if (args[1]) | |
| 524 | buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]); | |
| 525 | else | |
| 526 | buf = irc_format(irc, "vcn", "REMOVE", target, args[0]); | |
| 527 | irc_send(irc, buf); | |
| 528 | g_free(buf); | |
| 529 | ||
| 530 | return 0; | |
| 531 | } | |
| 532 | ||
| 12013 | 533 | int irc_cmd_service(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 534 | { | |
| 535 | char *capital_cmd, *buf; | |
| 536 | ||
| 537 | if (!args || !args[0]) | |
| 538 | return 0; | |
| 539 | ||
| 540 | /* cmd will be one of nickserv, chanserv, memoserv or operserv */ | |
| 541 | capital_cmd = g_ascii_strup(cmd, -1); | |
| 542 | buf = irc_format(irc, "v:", capital_cmd, args[0]); | |
| 543 | irc_send(irc, buf); | |
| 544 | g_free(capital_cmd); | |
| 545 | g_free(buf); | |
| 546 | ||
| 547 | return 0; | |
| 548 | } | |
| 549 | ||
| 10564 | 550 | int irc_cmd_time(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 551 | { | |
| 552 | char *buf; | |
| 553 | ||
| 554 | buf = irc_format(irc, "v", "TIME"); | |
| 555 | irc_send(irc, buf); | |
| 556 | g_free(buf); | |
| 557 | ||
| 558 | return 0; | |
| 559 | } | |
| 560 | ||
| 6333 | 561 | int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 562 | { | |
| 563 | char *buf; | |
| 564 | const char *topic; | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
565 | PurpleChatConversation *chat; |
| 6333 | 566 | |
| 567 | if (!args) | |
| 568 | return 0; | |
| 569 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
570 | chat = purple_conversations_find_chat_with_account(target, irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
571 | if (!chat) |
| 6350 | 572 | return 0; |
| 6333 | 573 | |
| 574 | if (!args[0]) { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
575 | topic = purple_chat_conversation_get_topic (chat); |
| 6333 | 576 | |
| 8504 | 577 | if (topic) { |
| 9762 | 578 | char *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10609
diff
changeset
|
579 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 580 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 581 | buf = g_strdup_printf(_("current topic is: %s"), tmp2); |
| 8504 | 582 | g_free(tmp); |
| 9762 | 583 | g_free(tmp2); |
| 8504 | 584 | } else |
| 6333 | 585 | buf = g_strdup(_("No topic is set")); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
586 | purple_conversation_write_system_message( |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
587 | PURPLE_CONVERSATION(chat), buf, PURPLE_MESSAGE_NO_LOG); |
| 6333 | 588 | g_free(buf); |
| 589 | ||
| 590 | return 0; | |
| 591 | } | |
| 592 | ||
| 593 | buf = irc_format(irc, "vt:", "TOPIC", target, args[0]); | |
| 594 | irc_send(irc, buf); | |
| 595 | g_free(buf); | |
| 596 | ||
| 597 | return 0; | |
| 598 | } | |
| 599 | ||
| 600 | int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 601 | { | |
| 602 | char *buf; | |
| 603 | ||
| 604 | if (!args || !args[0]) | |
| 6350 | 605 | return 0; |
| 6333 | 606 | |
| 607 | if (!strcmp(cmd, "wallops")) | |
| 608 | buf = irc_format(irc, "v:", "WALLOPS", args[0]); | |
| 609 | else if (!strcmp(cmd, "operwall")) | |
| 610 | buf = irc_format(irc, "v:", "OPERWALL", args[0]); | |
| 6365 | 611 | else |
| 612 | return 0; | |
| 6333 | 613 | |
| 614 | irc_send(irc, buf); | |
| 615 | g_free(buf); | |
| 616 | ||
| 617 | return 0; | |
| 618 | } | |
| 619 | ||
| 620 | int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 621 | { | |
| 622 | char *buf; | |
| 623 | ||
| 624 | if (!args || !args[0]) | |
| 625 | return 0; | |
| 626 | ||
|
10609
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
627 | if (args[1]) { |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
628 | buf = irc_format(irc, "vvn", "WHOIS", args[0], args[1]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
629 | irc->whois.nick = g_strdup(args[1]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
630 | } else { |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
631 | buf = irc_format(irc, "vn", "WHOIS", args[0]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
632 | irc->whois.nick = g_strdup(args[0]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
633 | } |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
634 | |
| 6333 | 635 | irc_send(irc, buf); |
| 636 | g_free(buf); | |
| 637 | ||
| 638 | return 0; | |
| 639 | } | |
| 640 | ||
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
641 | int irc_cmd_whowas(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
642 | { |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
643 | char *buf; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
644 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
645 | if (!args || !args[0]) |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
646 | return 0; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
647 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
648 | buf = irc_format(irc, "vn", "WHOWAS", args[0]); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30469
diff
changeset
|
649 | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
650 | irc->whois.nick = g_strdup(args[0]); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
651 | irc_send(irc, buf); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
652 | g_free(buf); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
653 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
654 | return 0; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
655 | } |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
656 | |
| 6333 | 657 | static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops) |
| 658 | { | |
| 659 | char *buf, mode[5]; | |
| 660 | int i = 0; | |
| 661 | ||
| 662 | if (!sign) | |
| 663 | return; | |
| 664 | ||
| 665 | while (ops[i]) { | |
| 666 | if (ops[i + 2] && ops[i + 4]) { | |
| 667 | g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign, | |
| 668 | ops[i], ops[i + 2], ops[i + 4]); | |
| 669 | buf = irc_format(irc, "vcvnnn", "MODE", target, mode, | |
| 670 | ops[i + 1], ops[i + 3], ops[i + 5]); | |
| 671 | i += 6; | |
| 672 | } else if (ops[i + 2]) { | |
| 673 | g_snprintf(mode, sizeof(mode), "%s%s%s", | |
| 674 | sign, ops[i], ops[i + 2]); | |
| 675 | buf = irc_format(irc, "vcvnn", "MODE", target, mode, | |
| 676 | ops[i + 1], ops[i + 3]); | |
| 677 | i += 4; | |
| 678 | } else { | |
| 679 | g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]); | |
| 680 | buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]); | |
| 681 | i += 2; | |
| 682 | } | |
| 683 | irc_send(irc, buf); | |
| 684 | g_free(buf); | |
| 685 | } | |
| 6350 | 686 | |
| 687 | return; | |
| 6333 | 688 | } |