annotate src/protocols/irc/cmds.c @ 13912:3d1cee0d360d

[gaim-migrate @ 16411] Fix the IRC crash-on-quit bug that I introduced two weeks ago. My bad. account->disconnecting seems weird to me... it seems like we should get rid of it and add a GAIM_DISCONNECTING state to GaimConnectionState, instead committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 03 Jul 2006 05:37:41 +0000
parents 5d5e249c488e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /**
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * @file cmds.c
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * gaim
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 *
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu>
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 *
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 *
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 *
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #include "conversation.h"
8504
534b479692d0 [gaim-migrate @ 9240]
Mark Doliner <mark@kingant.net>
parents: 8352
diff changeset
26 #include "debug.h"
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #include "notify.h"
8624
da687392cbcb [gaim-migrate @ 9375]
Nathan Walp <nwalp@pidgin.im>
parents: 8504
diff changeset
28 #include "util.h"
8504
534b479692d0 [gaim-migrate @ 9240]
Mark Doliner <mark@kingant.net>
parents: 8352
diff changeset
29
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "irc.h"
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
37 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 if (!convo)
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
41 return 1;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 buf = g_strdup_printf(_("Unknown command: %s"), cmd);
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
44 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_IM)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
45 gaim_conv_im_write(GAIM_CONV_IM(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 else
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
47 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 return 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 {
12669
879f90dbd21f [gaim-migrate @ 15012]
Richard Laager <rlaager@wiktel.com>
parents: 12013
diff changeset
55 char *buf, *message;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 if (args[0] && strcmp(cmd, "back")) {
12669
879f90dbd21f [gaim-migrate @ 15012]
Richard Laager <rlaager@wiktel.com>
parents: 12013
diff changeset
58 message = gaim_markup_strip_html(args[0]);
879f90dbd21f [gaim-migrate @ 15012]
Richard Laager <rlaager@wiktel.com>
parents: 12013
diff changeset
59 gaim_util_chrreplace(message, '\n', ' ');
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 buf = irc_format(irc, "v:", "AWAY", message);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 g_free(message);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 buf = irc_format(irc, "v", "AWAY");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
66 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 GaimConnection *gc = gaim_account_get_connection(irc->account);
10933
f43113333717 [gaim-migrate @ 12716]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10732
diff changeset
74 char *action, *escaped, *dst, **newargs;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 const char *src;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 GaimConversation *convo;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 if (!args || !args[0] || !gc)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80
6376
05b488eda686 [gaim-migrate @ 6881]
Nathan Walp <nwalp@pidgin.im>
parents: 6371
diff changeset
81 action = g_malloc(strlen(args[0]) + 10);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83 sprintf(action, "\001ACTION ");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 src = args[0];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 dst = action + 8;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 while (*src) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88 if (*src == '\n') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 if (*(src + 1) == '\0') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90 break;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 *dst++ = ' ';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93 src++;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 continue;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 *dst++ = *src++;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 *dst++ = '\001';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 *dst = '\0';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 newargs = g_new0(char *, 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 newargs[0] = g_strdup(target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 newargs[1] = action;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 g_free(newargs[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 g_free(newargs[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 g_free(newargs);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
110 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
111 if (convo) {
10933
f43113333717 [gaim-migrate @ 12716]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10732
diff changeset
112 escaped = g_markup_escape_text(args[0], -1);
f43113333717 [gaim-migrate @ 12716]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10732
diff changeset
113 action = g_strdup_printf("/me %s", escaped);
f43113333717 [gaim-migrate @ 12716]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10732
diff changeset
114 g_free(escaped);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 if (action[strlen(action) - 1] == '\n')
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 action[strlen(action) - 1] = '\0';
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
117 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
118 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)),
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
119 gaim_connection_get_display_name(gc),
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
120 0, action, time(NULL));
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
121 else
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
122 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc),
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 8624
diff changeset
123 action, 0, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 g_free(action);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 return 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129
13881
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
130 int irc_cmd_ctcp_version(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
131 {
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
132 char *buf;
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
133
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
134
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
135 if (!args || !args[0])
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
136 return 0;
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
137
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
138 buf = irc_format(irc, "vn:", "PRIVMSG", args[0], "\001VERSION\001");
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
139 irc_send(irc, buf);
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
140 g_free(buf);
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
141
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
142 return 0;
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
143 }
5d5e249c488e [gaim-migrate @ 16361]
Ethan Blanton <elb@pidgin.im>
parents: 13876
diff changeset
144
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149 if (!args || !args[0] || !(args[1] || target))
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
152 buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 if (args[1])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 buf = irc_format(irc, "vc", "JOIN", args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 GaimConversation *convo;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
184 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account);
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10208
diff changeset
185 if (!convo)
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
186 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 if (args[1])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 buf = irc_format(irc, "vcn", "KICK", target, args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
198 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
199 {
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8114
diff changeset
200 gaim_roomlist_show_with_account(irc->account);
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
201
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
202 return 0;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
203 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
204
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
205 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 GaimConnection *gc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 if (!args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 if (!strcmp(cmd, "mode")) {
10208
cbdce0acbbe6 [gaim-migrate @ 11330]
Ethan Blanton <elb@pidgin.im>
parents: 9762
diff changeset
214 if (!args[0] && irc_ischannel(target))
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
215 buf = irc_format(irc, "vc", "MODE", target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
216 else if (args[0] && (*args[0] == '+' || *args[0] == '-'))
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 buf = irc_format(irc, "vcv", "MODE", target, args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
218 else if (args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 buf = irc_format(irc, "vv", "MODE", args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220 else
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
221 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222 } else if (!strcmp(cmd, "umode")) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
223 if (!args[0])
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
224 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
225 gc = gaim_account_get_connection(irc->account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
226 buf = irc_format(irc, "vnv", "MODE", gaim_connection_get_display_name(gc), args[0]);
6365
72bbe310ac77 [gaim-migrate @ 6870]
Nathan Walp <nwalp@pidgin.im>
parents: 6350
diff changeset
227 } else {
72bbe310ac77 [gaim-migrate @ 6870]
Nathan Walp <nwalp@pidgin.im>
parents: 6350
diff changeset
228 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 }
6365
72bbe310ac77 [gaim-migrate @ 6870]
Nathan Walp <nwalp@pidgin.im>
parents: 6350
diff changeset
230
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
233
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
235 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
237 int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
238 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240
10208
cbdce0acbbe6 [gaim-migrate @ 11330]
Ethan Blanton <elb@pidgin.im>
parents: 9762
diff changeset
241 if (!args || (!args[0] && !irc_ischannel(target)))
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244 buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 irc->nameconv = g_strdup(target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 buf = irc_format(irc, "v:", "NICK", args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
265 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
266
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269 char **nicks, **ops, *sign, *mode;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 int i = 0, used = 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 if (!args || !args[0] || !*args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 if (!strcmp(cmd, "op")) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276 sign = "+";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277 mode = "o";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 } else if (!strcmp(cmd, "deop")) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279 sign = "-";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280 mode = "o";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 } else if (!strcmp(cmd, "voice")) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
282 sign = "+";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283 mode = "v";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 } else if (!strcmp(cmd, "devoice")) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
285 sign = "-";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 mode = "v";
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
287 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 gaim_debug(GAIM_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 nicks = g_strsplit(args[0], " ", -1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294 for (i = 0; nicks[i]; i++)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295 /* nothing */;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
296 ops = g_new0(char *, i * 2 + 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
298 for (i = 0; nicks[i]; i++) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
299 if (!*nicks[i])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
300 continue;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301 ops[used++] = mode;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
302 ops[used++] = nicks[i];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305 irc_do_mode(irc, target, sign, ops);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306 g_free(ops);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
307
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
308 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
309 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
310
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
314
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
315 if (!args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
316 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
317
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
318 if (args[1])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
319 buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
320 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
321 buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
322 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
323 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
324
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
325 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
326 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
327
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
328 int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
329 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
330 char *stamp;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
331 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
332
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
333 if (args && args[0]) {
10208
cbdce0acbbe6 [gaim-migrate @ 11330]
Ethan Blanton <elb@pidgin.im>
parents: 9762
diff changeset
334 if (irc_ischannel(args[0]))
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
335 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
336 stamp = g_strdup_printf("\001PING %lu\001", time(NULL));
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
337 buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
338 g_free(stamp);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 } else {
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
340 stamp = g_strdup_printf("%s %lu", target, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
341 buf = irc_format(irc, "v:", "PING", stamp);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
342 g_free(stamp);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
343 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
344 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
345 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
346
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
347 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
348 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
349
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
350 int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
351 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
352 const char *cur, *end;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
353 char *msg, *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
354
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
355 if (!args || !args[0] || !args[1])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
356 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
357
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
358 cur = args[1];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
359 end = args[1];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
360 while (*end && *cur) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
361 end = strchr(cur, '\n');
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
362 if (!end)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
363 end = cur + strlen(cur);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
364 msg = g_strndup(cur, end - cur);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
365 buf = irc_format(irc, "vt:", "PRIVMSG", args[0], msg);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
366 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
367 g_free(msg);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
368 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
369 cur = end + 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
370 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
371
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
372 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
373 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
374
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
375 int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
376 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
377 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
378
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
379 if (!irc->quitting) {
11763
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
380 /*
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
381 * Use gaim_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT)
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
382 * and uncomment the appropriate account preference in irc.c if we
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
383 * decide we want custom quit messages.
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
384 */
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11338
diff changeset
385 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT);
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
386 irc_send(irc, buf);
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
387 g_free(buf);
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
388
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
389 irc->quitting = TRUE;
13837
1a095ac881ce [gaim-migrate @ 16286]
Mark Doliner <mark@kingant.net>
parents: 12669
diff changeset
390
13912
3d1cee0d360d [gaim-migrate @ 16411]
Mark Doliner <mark@kingant.net>
parents: 13881
diff changeset
391 if (!irc->account->disconnecting)
3d1cee0d360d [gaim-migrate @ 16411]
Mark Doliner <mark@kingant.net>
parents: 13881
diff changeset
392 gaim_account_set_status(irc->account, "offline", TRUE, NULL);
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9248
diff changeset
393 }
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
394
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
395 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
396 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
397
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
398 int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
399 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
400 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
401
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
402 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
403 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
404
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
405 buf = irc_format(irc, "v", args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
406 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
407 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
408
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
409 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
410 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
411
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
412 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
413 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
414 GaimConversation *convo;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
415 GaimConnection *gc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
416
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
417 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
418 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
419
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
420 convo = gaim_conversation_new(GAIM_CONV_TYPE_IM, irc->account, args[0]);
13876
1a862fb5e713 [gaim-migrate @ 16351]
Ethan Blanton <elb@pidgin.im>
parents: 13837
diff changeset
421 gaim_conversation_present(convo);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
422
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
423 if (args[1]) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
424 gc = gaim_account_get_connection(irc->account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
425 irc_cmd_privmsg(irc, cmd, target, args);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
426 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc),
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6621
diff changeset
427 args[1], GAIM_MESSAGE_SEND, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
428 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
429
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
430 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
431 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
432
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
433 int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
434 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
435 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
436
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
437 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
438 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
439
10208
cbdce0acbbe6 [gaim-migrate @ 11330]
Ethan Blanton <elb@pidgin.im>
parents: 9762
diff changeset
440 if (!irc_ischannel(target)) /* not a channel, punt */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
441 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
442
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
443 if (args[1])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
444 buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
445 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
446 buf = irc_format(irc, "vcn", "REMOVE", target, args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
447 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
448 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
449
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
450 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
451 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
452
12013
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
453 int irc_cmd_service(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
454 {
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
455 char *capital_cmd, *buf;
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
456
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
457 if (!args || !args[0])
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
458 return 0;
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
459
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
460 /* cmd will be one of nickserv, chanserv, memoserv or operserv */
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
461 capital_cmd = g_ascii_strup(cmd, -1);
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
462 buf = irc_format(irc, "v:", capital_cmd, args[0]);
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
463 irc_send(irc, buf);
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
464 g_free(capital_cmd);
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
465 g_free(buf);
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
466
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
467 return 0;
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
468 }
39734dd473e0 [gaim-migrate @ 14306]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
469
10564
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
470 int irc_cmd_time(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
471 {
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
472 char *buf;
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
473
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
474 buf = irc_format(irc, "v", "TIME");
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
475 irc_send(irc, buf);
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
476 g_free(buf);
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
477
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
478 return 0;
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
479 }
cdeb727d1de3 [gaim-migrate @ 11946]
Ethan Blanton <elb@pidgin.im>
parents: 10246
diff changeset
480
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
481 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
482 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
483 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
484 const char *topic;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
485 GaimConversation *convo;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
486
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
487 if (!args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
488 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
489
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11073
diff changeset
490 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account);
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10208
diff changeset
491 if (!convo)
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
492 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
493
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
494 if (!args[0]) {
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
495 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(convo));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
496
8504
534b479692d0 [gaim-migrate @ 9240]
Mark Doliner <mark@kingant.net>
parents: 8352
diff changeset
497 if (topic) {
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9440
diff changeset
498 char *tmp, *tmp2;
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10609
diff changeset
499 tmp = g_markup_escape_text(topic, -1);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9440
diff changeset
500 tmp2 = gaim_markup_linkify(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9440
diff changeset
501 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
8504
534b479692d0 [gaim-migrate @ 9240]
Mark Doliner <mark@kingant.net>
parents: 8352
diff changeset
502 g_free(tmp);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9440
diff changeset
503 g_free(tmp2);
8504
534b479692d0 [gaim-migrate @ 9240]
Mark Doliner <mark@kingant.net>
parents: 8352
diff changeset
504 } else
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
505 buf = g_strdup(_("No topic is set"));
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
506 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), target, buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
507 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
508
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
509 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
510 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
511
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
512 buf = irc_format(irc, "vt:", "TOPIC", target, args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
513 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
514 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
515
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
516 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
517 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
518
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
519 int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
520 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
521 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
522
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
523 if (!args || !args[0])
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
524 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
525
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
526 if (!strcmp(cmd, "wallops"))
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
527 buf = irc_format(irc, "v:", "WALLOPS", args[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
528 else if (!strcmp(cmd, "operwall"))
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
529 buf = irc_format(irc, "v:", "OPERWALL", args[0]);
6365
72bbe310ac77 [gaim-migrate @ 6870]
Nathan Walp <nwalp@pidgin.im>
parents: 6350
diff changeset
530 else
72bbe310ac77 [gaim-migrate @ 6870]
Nathan Walp <nwalp@pidgin.im>
parents: 6350
diff changeset
531 return 0;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
532
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
533 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
534 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
535
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
536 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
537 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
538
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
539 int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
540 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
541 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
542
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
543 if (!args || !args[0])
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
544 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
545
10609
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
546 if (args[1]) {
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
547 buf = irc_format(irc, "vvn", "WHOIS", args[0], args[1]);
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
548 irc->whois.nick = g_strdup(args[1]);
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
549 } else {
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
550 buf = irc_format(irc, "vn", "WHOIS", args[0]);
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
551 irc->whois.nick = g_strdup(args[0]);
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
552 }
6239870efd8e [gaim-migrate @ 12055]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
553
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
554 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
555 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
556
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
557 return 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
558 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
559
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
560 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
561 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
562 char *buf, mode[5];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
563 int i = 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
564
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
565 if (!sign)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
566 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
567
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
568 while (ops[i]) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
569 if (ops[i + 2] && ops[i + 4]) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
570 g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
571 ops[i], ops[i + 2], ops[i + 4]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
572 buf = irc_format(irc, "vcvnnn", "MODE", target, mode,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
573 ops[i + 1], ops[i + 3], ops[i + 5]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
574 i += 6;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
575 } else if (ops[i + 2]) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
576 g_snprintf(mode, sizeof(mode), "%s%s%s",
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
577 sign, ops[i], ops[i + 2]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
578 buf = irc_format(irc, "vcvnn", "MODE", target, mode,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
579 ops[i + 1], ops[i + 3]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
580 i += 4;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
581 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
582 g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
583 buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
584 i += 2;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
585 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
586 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
587 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
588 }
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
589
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
590 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
591 }