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