Mon, 12 Jun 2017 17:48:37 -0300
Merge release-2.x.y into default
| 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 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
54 | if (args[0] && !purple_strequal(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)) { |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
111 | pmsg = purple_message_new_outgoing( |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
112 | purple_conversation_get_name(convo), msg, 0); |
|
36079
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 { |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
117 | pmsg = purple_message_new_outgoing(NULL, msg, 0); |
|
36080
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 |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
192 | purple_conversation_write_message(convo, purple_message_new_outgoing( |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
193 | purple_connection_get_display_name(gc), action, 0)); |
| 6333 | 194 | g_free(action); |
| 195 | } | |
| 196 | ||
| 197 | return 1; | |
| 198 | } | |
| 199 | ||
| 13943 | 200 | int irc_cmd_ctcp_version(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 201 | { | |
| 202 | char *buf; | |
| 203 | ||
| 204 | if (!args || !args[0]) | |
| 205 | return 0; | |
| 206 | ||
| 207 | buf = irc_format(irc, "vn:", "PRIVMSG", args[0], "\001VERSION\001"); | |
| 208 | irc_send(irc, buf); | |
| 209 | g_free(buf); | |
| 210 | ||
| 211 | return 0; | |
| 212 | } | |
| 213 | ||
| 6333 | 214 | int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 215 | { | |
| 216 | char *buf; | |
| 217 | ||
| 218 | if (!args || !args[0] || !(args[1] || target)) | |
| 219 | return 0; | |
| 220 | ||
| 221 | buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target); | |
| 222 | irc_send(irc, buf); | |
| 223 | g_free(buf); | |
| 224 | ||
| 225 | return 0; | |
| 226 | } | |
| 227 | ||
| 228 | int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 229 | { | |
| 230 | char *buf; | |
| 231 | ||
| 232 | if (!args || !args[0]) | |
| 233 | return 0; | |
| 234 | ||
| 235 | if (args[1]) | |
| 236 | buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]); | |
| 237 | else | |
| 238 | buf = irc_format(irc, "vc", "JOIN", args[0]); | |
| 239 | irc_send(irc, buf); | |
| 240 | g_free(buf); | |
| 241 | ||
| 242 | return 0; | |
| 243 | } | |
| 244 | ||
| 245 | int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 246 | { | |
| 247 | char *buf; | |
| 248 | ||
| 249 | if (!args || !args[0]) | |
| 250 | return 0; | |
| 251 | ||
|
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
|
252 | if (!purple_conversations_find_chat_with_account(target, irc->account)) |
| 6350 | 253 | return 0; |
| 6333 | 254 | |
| 255 | if (args[1]) | |
| 256 | buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | |
| 257 | else | |
| 258 | buf = irc_format(irc, "vcn", "KICK", target, args[0]); | |
| 259 | irc_send(irc, buf); | |
| 260 | g_free(buf); | |
| 261 | ||
| 262 | return 0; | |
| 263 | } | |
| 264 | ||
| 8114 | 265 | int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 266 | { | |
| 15884 | 267 | purple_roomlist_show_with_account(irc->account); |
| 8114 | 268 | |
| 269 | return 0; | |
| 270 | } | |
| 271 | ||
| 6333 | 272 | int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 273 | { | |
| 15884 | 274 | PurpleConnection *gc; |
| 6333 | 275 | char *buf; |
| 276 | ||
| 277 | if (!args) | |
| 278 | return 0; | |
| 279 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
280 | if (purple_strequal(cmd, "mode")) { |
| 10208 | 281 | if (!args[0] && irc_ischannel(target)) |
| 6333 | 282 | buf = irc_format(irc, "vc", "MODE", target); |
| 283 | 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
|
284 | buf = irc_format(irc, "vcn", "MODE", target, args[0]); |
| 6333 | 285 | 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
|
286 | buf = irc_format(irc, "vn", "MODE", args[0]); |
| 6333 | 287 | else |
| 6350 | 288 | return 0; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
289 | } else if (purple_strequal(cmd, "umode")) { |
| 6333 | 290 | if (!args[0]) |
| 6350 | 291 | return 0; |
| 15884 | 292 | 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
|
293 | buf = irc_format(irc, "vnc", "MODE", purple_connection_get_display_name(gc), args[0]); |
| 6365 | 294 | } else { |
| 295 | return 0; | |
| 6333 | 296 | } |
| 6365 | 297 | |
| 6333 | 298 | irc_send(irc, buf); |
| 299 | g_free(buf); | |
| 300 | ||
| 301 | return 0; | |
| 302 | } | |
| 303 | ||
| 304 | int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 305 | { | |
| 306 | char *buf; | |
| 307 | ||
| 10208 | 308 | if (!args || (!args[0] && !irc_ischannel(target))) |
| 6333 | 309 | return 0; |
| 310 | ||
| 311 | buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target); | |
| 312 | irc_send(irc, buf); | |
| 313 | g_free(buf); | |
| 314 | ||
| 315 | return 0; | |
| 316 | } | |
| 317 | ||
| 318 | int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 319 | { | |
| 320 | char *buf; | |
| 321 | ||
| 322 | if (!args || !args[0]) | |
| 323 | return 0; | |
| 324 | ||
| 325 | 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
|
326 | 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
|
327 | 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
|
328 | irc->nickused = FALSE; |
| 6333 | 329 | irc_send(irc, buf); |
| 330 | g_free(buf); | |
| 331 | ||
| 332 | return 0; | |
| 333 | } | |
| 334 | ||
| 335 | int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 336 | { | |
| 337 | char **nicks, **ops, *sign, *mode; | |
| 338 | int i = 0, used = 0; | |
| 339 | ||
| 340 | if (!args || !args[0] || !*args[0]) | |
| 341 | return 0; | |
| 342 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
343 | if (purple_strequal(cmd, "op")) { |
| 6333 | 344 | sign = "+"; |
| 345 | mode = "o"; | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
346 | } else if (purple_strequal(cmd, "deop")) { |
| 6333 | 347 | sign = "-"; |
| 348 | mode = "o"; | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
349 | } else if (purple_strequal(cmd, "voice")) { |
| 6333 | 350 | sign = "+"; |
| 351 | mode = "v"; | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
352 | } else if (purple_strequal(cmd, "devoice")) { |
| 6333 | 353 | sign = "-"; |
| 354 | mode = "v"; | |
| 355 | } else { | |
| 15884 | 356 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); |
| 6333 | 357 | return 0; |
| 358 | } | |
| 359 | ||
| 360 | nicks = g_strsplit(args[0], " ", -1); | |
| 361 | ||
| 362 | for (i = 0; nicks[i]; i++) | |
| 363 | /* nothing */; | |
| 364 | ops = g_new0(char *, i * 2 + 1); | |
| 365 | ||
| 366 | for (i = 0; nicks[i]; i++) { | |
| 22521 | 367 | if (*nicks[i]) { |
| 368 | ops[used++] = mode; | |
| 369 | ops[used++] = nicks[i]; | |
|
21694
ac3973a88b24
Plug a tiny little leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
370 | } |
| 6333 | 371 | } |
| 372 | ||
| 373 | irc_do_mode(irc, target, sign, ops); | |
| 374 | g_free(ops); | |
| 22521 | 375 | g_strfreev(nicks); |
| 6333 | 376 | |
| 6350 | 377 | return 0; |
| 6333 | 378 | } |
| 379 | ||
| 380 | int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 381 | { | |
| 382 | char *buf; | |
| 383 | ||
| 384 | if (!args) | |
| 385 | return 0; | |
| 386 | ||
| 387 | if (args[1]) | |
| 388 | buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]); | |
| 389 | else | |
| 390 | buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target); | |
| 391 | irc_send(irc, buf); | |
| 392 | g_free(buf); | |
| 393 | ||
| 394 | return 0; | |
| 395 | } | |
| 396 | ||
| 397 | int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 398 | { | |
| 399 | char *stamp; | |
| 400 | char *buf; | |
| 401 | ||
| 402 | if (args && args[0]) { | |
| 10208 | 403 | if (irc_ischannel(args[0])) |
| 6333 | 404 | return 0; |
| 405 | stamp = g_strdup_printf("\001PING %lu\001", time(NULL)); | |
| 406 | buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp); | |
| 407 | g_free(stamp); | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
408 | } else if (target) { |
| 6350 | 409 | stamp = g_strdup_printf("%s %lu", target, time(NULL)); |
| 6333 | 410 | buf = irc_format(irc, "v:", "PING", stamp); |
| 411 | g_free(stamp); | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
412 | } else { |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
413 | stamp = g_strdup_printf("%lu", time(NULL)); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
414 | buf = irc_format(irc, "vv", "PING", stamp); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
415 | g_free(stamp); |
| 6333 | 416 | } |
| 417 | irc_send(irc, buf); | |
| 418 | g_free(buf); | |
| 419 | ||
| 420 | return 0; | |
| 421 | } | |
| 422 | ||
| 423 | int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 424 | { | |
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
425 | int max_privmsg_arg_len; |
| 6333 | 426 | const char *cur, *end; |
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
427 | gchar *salvaged; |
| 6333 | 428 | char *msg, *buf; |
| 429 | ||
| 430 | if (!args || !args[0] || !args[1]) | |
| 431 | return 0; | |
| 432 | ||
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
433 | max_privmsg_arg_len = IRC_MAX_MSG_SIZE - strlen(args[0]) - 64; |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
434 | salvaged = purple_utf8_salvage(args[1]); |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
435 | cur = salvaged; |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
436 | end = salvaged; |
| 6333 | 437 | while (*end && *cur) { |
| 438 | end = strchr(cur, '\n'); | |
| 439 | if (!end) | |
| 440 | end = cur + strlen(cur); | |
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
441 | if (end - cur > max_privmsg_arg_len) { |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
442 | /* this call is used to find the last valid character position in the first |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
443 | * max_privmsg_arg_len bytes of the utf-8 message |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
444 | */ |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
445 | g_utf8_validate(cur, max_privmsg_arg_len, &end); |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
446 | } |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
447 | |
| 6333 | 448 | 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
|
449 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
450 | if(purple_strequal(cmd, "notice")) |
| 22167 | 451 | buf = irc_format(irc, "vt:", "NOTICE", args[0], msg); |
| 452 | 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
|
453 | 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
|
454 | |
| 6333 | 455 | irc_send(irc, buf); |
| 456 | g_free(msg); | |
| 457 | g_free(buf); | |
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
458 | cur = end; |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
459 | if(*cur == '\n') { |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
460 | cur++; |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
461 | } |
| 6333 | 462 | } |
| 463 | ||
|
37954
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
464 | g_free(salvaged); |
|
b76dd48063d6
Fix issue #4753 with IRC message truncation
Senya <senya@riseup.net>
parents:
35925
diff
changeset
|
465 | |
| 6333 | 466 | return 0; |
| 467 | } | |
| 468 | ||
| 469 | int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 470 | { | |
| 471 | char *buf; | |
| 472 | ||
| 9440 | 473 | if (!irc->quitting) { |
| 11763 | 474 | /* |
| 15884 | 475 | * Use purple_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT) |
| 11763 | 476 | * and uncomment the appropriate account preference in irc.c if we |
| 477 | * decide we want custom quit messages. | |
| 478 | */ | |
| 479 | buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT); | |
| 9440 | 480 | irc_send(irc, buf); |
| 481 | g_free(buf); | |
| 482 | ||
| 483 | irc->quitting = TRUE; | |
|
13839
e27a7f02055c
[gaim-migrate @ 16286]
Mark Doliner <markdoliner@pidgin.im>
parents:
12669
diff
changeset
|
484 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
485 | if (!purple_account_is_disconnecting(irc->account)) |
| 15884 | 486 | purple_account_set_status(irc->account, "offline", TRUE, NULL); |
| 9440 | 487 | } |
| 6333 | 488 | |
| 489 | return 0; | |
| 490 | } | |
| 491 | ||
| 492 | int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 493 | { | |
| 494 | char *buf; | |
| 495 | ||
| 496 | if (!args || !args[0]) | |
| 497 | return 0; | |
| 498 | ||
|
30469
7f787c107093
Fixes non-ASCII arguments to /mode, /umode, etc. Thanks to Max
Max Ulidtko <ulidtko@gmail.com>
parents:
27185
diff
changeset
|
499 | buf = irc_format(irc, "n", args[0]); |
| 6333 | 500 | irc_send(irc, buf); |
| 501 | g_free(buf); | |
| 502 | ||
| 503 | return 0; | |
| 504 | } | |
| 505 | ||
| 506 | int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 507 | { | |
|
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
|
508 | PurpleIMConversation *im; |
| 15884 | 509 | PurpleConnection *gc; |
| 6333 | 510 | |
| 511 | if (!args || !args[0]) | |
| 512 | return 0; | |
| 513 | ||
|
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
|
514 | 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
|
515 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 6333 | 516 | |
| 517 | if (args[1]) { | |
| 15884 | 518 | gc = purple_account_get_connection(irc->account); |
| 6333 | 519 | 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
|
520 | purple_conversation_write_message(PURPLE_CONVERSATION(im), |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
521 | purple_message_new_outgoing( |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
522 | purple_connection_get_display_name(gc), args[1], 0)); |
| 6333 | 523 | } |
| 524 | ||
| 525 | return 0; | |
| 526 | } | |
| 527 | ||
| 528 | int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 529 | { | |
| 530 | char *buf; | |
| 531 | ||
| 532 | if (!args || !args[0]) | |
| 533 | return 0; | |
| 534 | ||
| 10208 | 535 | if (!irc_ischannel(target)) /* not a channel, punt */ |
| 6333 | 536 | return 0; |
| 537 | ||
| 538 | if (args[1]) | |
| 539 | buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]); | |
| 540 | else | |
| 541 | buf = irc_format(irc, "vcn", "REMOVE", target, args[0]); | |
| 542 | irc_send(irc, buf); | |
| 543 | g_free(buf); | |
| 544 | ||
| 545 | return 0; | |
| 546 | } | |
| 547 | ||
| 12013 | 548 | int irc_cmd_service(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 549 | { | |
| 550 | char *capital_cmd, *buf; | |
| 551 | ||
| 552 | if (!args || !args[0]) | |
| 553 | return 0; | |
| 554 | ||
| 555 | /* cmd will be one of nickserv, chanserv, memoserv or operserv */ | |
| 556 | capital_cmd = g_ascii_strup(cmd, -1); | |
| 557 | buf = irc_format(irc, "v:", capital_cmd, args[0]); | |
| 558 | irc_send(irc, buf); | |
| 559 | g_free(capital_cmd); | |
| 560 | g_free(buf); | |
| 561 | ||
| 562 | return 0; | |
| 563 | } | |
| 564 | ||
| 10564 | 565 | int irc_cmd_time(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 566 | { | |
| 567 | char *buf; | |
| 568 | ||
| 569 | buf = irc_format(irc, "v", "TIME"); | |
| 570 | irc_send(irc, buf); | |
| 571 | g_free(buf); | |
| 572 | ||
| 573 | return 0; | |
| 574 | } | |
| 575 | ||
| 6333 | 576 | int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 577 | { | |
| 578 | char *buf; | |
| 579 | 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
|
580 | PurpleChatConversation *chat; |
| 6333 | 581 | |
| 582 | if (!args) | |
| 583 | return 0; | |
| 584 | ||
|
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
|
585 | 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
|
586 | if (!chat) |
| 6350 | 587 | return 0; |
| 6333 | 588 | |
| 589 | 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
|
590 | topic = purple_chat_conversation_get_topic (chat); |
| 6333 | 591 | |
| 8504 | 592 | if (topic) { |
| 9762 | 593 | char *tmp, *tmp2; |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10609
diff
changeset
|
594 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 595 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 596 | buf = g_strdup_printf(_("current topic is: %s"), tmp2); |
| 8504 | 597 | g_free(tmp); |
| 9762 | 598 | g_free(tmp2); |
| 8504 | 599 | } else |
| 6333 | 600 | buf = g_strdup(_("No topic is set")); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
601 | purple_conversation_write_system_message( |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
602 | PURPLE_CONVERSATION(chat), buf, PURPLE_MESSAGE_NO_LOG); |
| 6333 | 603 | g_free(buf); |
| 604 | ||
| 605 | return 0; | |
| 606 | } | |
| 607 | ||
| 608 | buf = irc_format(irc, "vt:", "TOPIC", target, args[0]); | |
| 609 | irc_send(irc, buf); | |
| 610 | g_free(buf); | |
| 611 | ||
| 612 | return 0; | |
| 613 | } | |
| 614 | ||
| 615 | int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 616 | { | |
| 617 | char *buf; | |
| 618 | ||
| 619 | if (!args || !args[0]) | |
| 6350 | 620 | return 0; |
| 6333 | 621 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
622 | if (purple_strequal(cmd, "wallops")) |
| 6333 | 623 | buf = irc_format(irc, "v:", "WALLOPS", args[0]); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
37954
diff
changeset
|
624 | else if (purple_strequal(cmd, "operwall")) |
| 6333 | 625 | buf = irc_format(irc, "v:", "OPERWALL", args[0]); |
| 6365 | 626 | else |
| 627 | return 0; | |
| 6333 | 628 | |
| 629 | irc_send(irc, buf); | |
| 630 | g_free(buf); | |
| 631 | ||
| 632 | return 0; | |
| 633 | } | |
| 634 | ||
| 635 | int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 636 | { | |
| 637 | char *buf; | |
| 638 | ||
| 639 | if (!args || !args[0]) | |
| 640 | return 0; | |
| 641 | ||
|
10609
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
642 | if (args[1]) { |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
643 | buf = irc_format(irc, "vvn", "WHOIS", args[0], args[1]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
644 | irc->whois.nick = g_strdup(args[1]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
645 | } else { |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
646 | buf = irc_format(irc, "vn", "WHOIS", args[0]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
647 | irc->whois.nick = g_strdup(args[0]); |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
648 | } |
|
170a5af61448
[gaim-migrate @ 12055]
Richard Laager <rlaager@pidgin.im>
parents:
10564
diff
changeset
|
649 | |
| 6333 | 650 | irc_send(irc, buf); |
| 651 | g_free(buf); | |
| 652 | ||
| 653 | return 0; | |
| 654 | } | |
| 655 | ||
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
656 | 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
|
657 | { |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
658 | char *buf; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
659 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
660 | if (!args || !args[0]) |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
661 | return 0; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
662 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
663 | buf = irc_format(irc, "vn", "WHOWAS", args[0]); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30469
diff
changeset
|
664 | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
665 | irc->whois.nick = g_strdup(args[0]); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
666 | irc_send(irc, buf); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
667 | g_free(buf); |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
668 | |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
669 | return 0; |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
670 | } |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
15884
diff
changeset
|
671 | |
| 6333 | 672 | static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops) |
| 673 | { | |
| 674 | char *buf, mode[5]; | |
| 675 | int i = 0; | |
| 676 | ||
| 677 | if (!sign) | |
| 678 | return; | |
| 679 | ||
| 680 | while (ops[i]) { | |
| 681 | if (ops[i + 2] && ops[i + 4]) { | |
| 682 | g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign, | |
| 683 | ops[i], ops[i + 2], ops[i + 4]); | |
| 684 | buf = irc_format(irc, "vcvnnn", "MODE", target, mode, | |
| 685 | ops[i + 1], ops[i + 3], ops[i + 5]); | |
| 686 | i += 6; | |
| 687 | } else if (ops[i + 2]) { | |
| 688 | g_snprintf(mode, sizeof(mode), "%s%s%s", | |
| 689 | sign, ops[i], ops[i + 2]); | |
| 690 | buf = irc_format(irc, "vcvnn", "MODE", target, mode, | |
| 691 | ops[i + 1], ops[i + 3]); | |
| 692 | i += 4; | |
| 693 | } else { | |
| 694 | g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]); | |
| 695 | buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]); | |
| 696 | i += 2; | |
| 697 | } | |
| 698 | irc_send(irc, buf); | |
| 699 | g_free(buf); | |
| 700 | } | |
| 6350 | 701 | |
| 702 | return; | |
| 6333 | 703 | } |