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