Mercurial > pidgin.yaz
annotate src/protocols/irc/irc.c @ 4692:a81443d3516b
[gaim-migrate @ 5003]
Thanks, Ha-King
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 10 Mar 2003 07:21:18 +0000 |
parents | 283fb289c510 |
children | c15e0699acae |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim - IRC Protocol Plugin | |
3 * | |
4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> | |
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
2290
23c06449ae8e
[gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
6 * |
23c06449ae8e
[gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
7 * A large portion of this was copied more or less directly from X-Chat, |
23c06449ae8e
[gaim-migrate @ 2300]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
8 * the world's most rocking IRC client. http://www.xchat.org/ |
2086 | 9 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
25 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
26 #include <config.h> |
2086 | 27 |
3630 | 28 #ifndef _WIN32 |
29 #include <unistd.h> | |
30 #else | |
31 #include <winsock.h> | |
32 #endif | |
33 | |
3029 | 34 #include <fcntl.h> |
2086 | 35 #include <errno.h> |
36 #include <string.h> | |
37 #include <stdlib.h> | |
38 #include <stdio.h> | |
3867 | 39 #include <sys/time.h> |
2086 | 40 #include <time.h> |
41 #include <sys/stat.h> | |
42 #include <ctype.h> | |
4608 | 43 #include "gaim.h" |
2086 | 44 #include "multi.h" |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4359
diff
changeset
|
45 #include "core.h" |
2086 | 46 #include "prpl.h" |
47 #include "proxy.h" | |
48 | |
3630 | 49 #ifdef _WIN32 |
50 #include "win32dep.h" | |
51 #endif | |
52 | |
2086 | 53 #define IRC_BUF_LEN 4096 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
54 #define PDIWORDS 32 |
2086 | 55 |
56 #define USEROPT_SERV 0 | |
57 #define USEROPT_PORT 1 | |
3751 | 58 #define USEROPT_CHARSET 2 |
2086 | 59 |
4249 | 60 static struct prpl *my_protocol = NULL; |
61 | |
3630 | 62 /* for win32 compatability */ |
63 G_MODULE_IMPORT GSList *connections; | |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4359
diff
changeset
|
64 G_MODULE_IMPORT GSList *groups; |
3630 | 65 |
4422 | 66 #ifndef INET6_ADDRSTRLEN |
67 #define INET6_ADDRSTRLEN 46 | |
68 #endif | |
69 | |
3751 | 70 /* Datastructs */ |
3029 | 71 struct dcc_chat |
72 { | |
73 struct gaim_connection *gc; | |
4422 | 74 char ip_address[INET6_ADDRSTRLEN]; |
3029 | 75 int port; |
76 int fd; | |
77 int inpa; | |
78 char nick[80]; | |
79 }; | |
80 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
81 struct irc_xfer_data |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
82 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
83 char *ip; |
3708 | 84 int port; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
85 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
86 struct irc_data *idata; |
3616 | 87 }; |
88 | |
2086 | 89 struct irc_data { |
90 int fd; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
91 gboolean online; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
92 guint32 timer; |
2086 | 93 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
94 char *rxqueue; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
95 int rxlen; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
96 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
97 GString *str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
98 int bc; |
2086 | 99 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
100 char *chantypes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
101 char *chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
102 char *nickmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
103 gboolean six_modes; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
104 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
105 gboolean in_whois; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
106 gboolean in_list; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
107 GString *liststr; |
3616 | 108 GSList *file_transfers; |
2086 | 109 }; |
110 | |
3751 | 111 /* Prototypes */ |
112 static void irc_start_chat(struct gaim_connection *gc, char *who); | |
113 static void irc_ctcp_clientinfo(struct gaim_connection *gc, char *who); | |
114 static void irc_ctcp_userinfo(struct gaim_connection *gc, char *who); | |
115 static void irc_ctcp_version(struct gaim_connection *gc, char *who); | |
116 static void irc_ctcp_ping(struct gaim_connection *gc, char *who); | |
117 | |
118 static void irc_send_privmsg(struct gaim_connection *gc, char *who, char *what, gboolean fragment); | |
119 static void irc_send_notice(struct gaim_connection *gc, char *who, char *what); | |
120 | |
121 static char *irc_send_convert(struct gaim_connection *gc, char *string, int maxlen, int *done); | |
122 static char *irc_recv_convert(struct gaim_connection *gc, char *string); | |
123 static void irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex, | |
124 char *word[], char *word_eol[]); | |
125 static void irc_parse_join(struct gaim_connection *gc, char *nick, | |
126 char *word[], char *word_eol[]); | |
127 static gboolean irc_parse_part(struct gaim_connection *gc, char *nick, char *cmd, | |
128 char *word[], char *word_eol[]); | |
129 static void irc_parse_topic(struct gaim_connection *gc, char *nick, | |
130 char *word[], char *word_eol[]); | |
131 | |
132 static void dcc_chat_cancel(struct dcc_chat *); | |
133 | |
134 /* Global variables */ | |
135 GSList *dcc_chat_list = NULL; | |
136 | |
3029 | 137 struct dcc_chat * |
138 find_dcc_chat (struct gaim_connection *gc, char *nick) | |
139 { | |
140 GSList *tmp; | |
141 struct dcc_chat *data; | |
142 tmp = dcc_chat_list; | |
143 while (tmp != NULL) | |
144 { | |
145 data = (struct dcc_chat *) (tmp)->data; | |
146 if (data | |
147 && data->nick | |
148 && strcmp (nick, data->nick) == 0 | |
149 && gc == data->gc) | |
150 { | |
151 return data; | |
152 } | |
153 tmp = tmp->next; | |
154 } | |
155 return NULL; | |
156 } | |
157 | |
3751 | 158 static int |
159 irc_write(int fd, char *data, int len) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
160 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
161 debug_printf("IRC C: %s", data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
162 return write(fd, data, len); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
163 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
164 |
3751 | 165 static char * |
166 irc_send_convert(struct gaim_connection *gc, char *string, int maxlen, int *done) | |
167 { | |
168 char *converted = g_malloc(maxlen + 1); | |
169 gchar *inptr = string, *outptr = converted; | |
170 int inleft = strlen(string), outleft = maxlen; | |
171 GIConv conv; | |
172 | |
4491 | 173 conv = g_iconv_open(gc->account->proto_opt[USEROPT_CHARSET], "UTF-8"); |
3751 | 174 if (g_iconv(conv, &inptr, &inleft, &outptr, &outleft) == -1) { |
175 debug_printf("IRC charset conversion error\n"); | |
176 debug_printf("Sending as UTF-8 (this is a hack!)\n"); | |
177 g_free(converted); | |
178 *done = maxlen; | |
179 return(g_strndup(string, maxlen)); | |
180 } | |
181 | |
182 *done = strlen(string) - inleft; | |
183 *outptr = '\0'; | |
184 return(converted); | |
185 } | |
186 | |
187 static char * | |
188 irc_recv_convert(struct gaim_connection *gc, char *string) | |
189 { | |
190 char *utf8; | |
191 GError *err = NULL; | |
192 | |
193 utf8 = g_convert(string, strlen(string), "UTF-8", | |
4491 | 194 gc->account->proto_opt[USEROPT_CHARSET], NULL, NULL, &err); |
3751 | 195 if (err) { |
196 debug_printf("IRC recv conversion error: %s\n", err->message); | |
197 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); | |
198 } | |
199 | |
200 return (utf8); | |
201 } | |
202 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
203 static struct gaim_conversation * |
3751 | 204 irc_find_chat(struct gaim_connection *gc, char *name) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
205 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
206 GSList *bcs = gc->buddy_chats; |
2086 | 207 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
208 while (bcs) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
209 struct gaim_conversation *b = bcs->data; |
2331
1ea2792b6004
[gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2328
diff
changeset
|
210 if (!g_strcasecmp(b->name, name)) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
211 return b; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
212 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
213 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
214 return NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
215 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
216 |
3751 | 217 static void |
218 process_data_init(char *buf, char *cmd, char *word[], char *eol[], gboolean quotes) | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
219 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
220 int wordcount = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
221 gboolean space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
222 gboolean quote = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
223 int j = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
224 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
225 word[1] = cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
226 eol[1] = buf; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
227 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
228 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
229 switch (*cmd) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
230 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
231 buf[j] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
232 for (j = wordcount; j < PDIWORDS; j++) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
233 word[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
234 eol[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
235 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
236 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
237 case '"': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
238 if (!quotes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
239 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
240 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
241 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
242 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
243 quote = !quote; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
244 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
245 case ' ': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
246 if (quote) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
247 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
248 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
249 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
250 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
251 if (space) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
252 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
253 buf[j++] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
254 word[wordcount] = &buf[j]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
255 eol[wordcount++] = cmd + 1; |
2294
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
256 if (wordcount == PDIWORDS - 1) { |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
257 buf[j] = 0; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
258 return; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
259 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
260 space = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
261 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
262 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
263 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
264 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
265 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
266 cmd++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
267 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
268 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
269 |
3751 | 270 static void |
271 handle_005(struct gaim_connection *gc, char *word[], char *word_eol[]) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
272 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
273 int w = 4; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
274 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
275 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
276 while (w < PDIWORDS && *word[w]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
277 if (!strncmp(word[w], "MODES=", 5)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
278 if (atoi(word[w] + 6) >= 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
279 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
280 } else if (!strncmp(word[w], "CHANTYPES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
281 g_free(id->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
282 id->chantypes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
283 } else if (!strncmp(word[w], "CHANMODES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
284 g_free(id->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
285 id->chanmodes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
286 } else if (!strncmp(word[w], "PREFIX=", 7)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
287 char *pre = strchr(word[w] + 7, ')'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
288 if (pre) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
289 *pre = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
290 g_free(id->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
291 id->nickmodes = g_strdup(word[w] + 8); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
292 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
293 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
294 w++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
295 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
296 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
297 |
4221 | 298 static const char *irc_colors[] = { |
299 "#000000", "#ffffff", "#000066", "#006600", | |
300 "#ff0000", "#660000", "#660066", "#666600", | |
301 "#cccc00", "#33cc33", "#00acac", "#00ccac", | |
302 "#0000ff", "#cc00cc", "#666666", "#00ccac" | |
303 }; | |
304 | |
305 #define int_to_col(c) (irc_colors[(((c)<0 || (c)> 15)?0:c)]) | |
2086 | 306 |
3751 | 307 static GString * |
308 encode_html(char *msg) | |
3029 | 309 { |
310 GString *str = g_string_new(""); | |
311 char *cur = msg, *end = msg; | |
312 gboolean bold = FALSE, underline = FALSE, italics = FALSE; | |
313 | |
314 while ((end = strchr(cur, '<'))) { | |
315 *end = 0; | |
316 str = g_string_append(str, cur); | |
317 cur = ++end; | |
318 if (!g_strncasecmp(cur, "B>", 2)) { | |
3063 | 319 if (!bold) { |
320 bold = TRUE; | |
321 str = g_string_append_c(str, '\2'); | |
322 } | |
3029 | 323 cur = cur + 2; |
324 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */ | |
3063 | 325 if (!italics) { |
326 italics = TRUE; | |
327 str = g_string_append_c(str, '\2'); | |
328 } | |
3029 | 329 cur = cur + 2; |
330 } else if (!g_strncasecmp(cur, "U>", 2)) { | |
3063 | 331 if (!underline) { |
332 underline = TRUE; | |
333 str = g_string_append_c(str, '\37'); | |
334 } | |
3029 | 335 cur = cur + 2; |
3063 | 336 } else if (!g_strncasecmp(cur, "/B>", 3)) { |
337 if (bold) { | |
338 bold = FALSE; | |
339 str = g_string_append_c(str, '\2'); | |
340 } | |
3029 | 341 cur = cur + 3; |
3063 | 342 } else if (!g_strncasecmp(cur, "/I>", 3)) { |
343 if (italics) { | |
344 italics = FALSE; | |
345 str = g_string_append_c(str, '\2'); | |
346 } | |
3029 | 347 cur = cur + 3; |
3063 | 348 } else if (!g_strncasecmp(cur, "/U>", 3)) { |
349 if (underline) { | |
350 underline = FALSE; | |
351 str = g_string_append_c(str, '\37'); | |
352 } | |
3029 | 353 cur = cur + 3; |
3063 | 354 } else { |
355 str = g_string_append_c(str, '<'); | |
3029 | 356 } |
3063 | 357 |
3029 | 358 } |
359 str = g_string_append(str, cur); | |
360 return str; | |
361 } | |
362 | |
3751 | 363 static GString * |
364 decode_html(char *msg) | |
2086 | 365 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
366 GString /* oo la la */ *str = g_string_new(""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
367 char *cur = msg, *end = msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
368 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
369 int fore, back; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
370 while (*end) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
371 switch (*end) { |
3708 | 372 case 02: /* ^B */ |
373 *end = 0; | |
374 str = g_string_append(str, cur); | |
375 if (bold) | |
376 str = g_string_append(str, "</B>"); | |
377 else | |
378 str = g_string_append(str, "<B>"); | |
379 bold = !bold; | |
380 cur = end + 1; | |
381 break; | |
382 case 03: /* ^C */ | |
383 *end++ = 0; | |
384 str = g_string_append(str, cur); | |
385 fore = back = -1; | |
386 if (isdigit(*end)) { | |
387 fore = *end++ - '0'; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
388 if (isdigit(*end)) { |
3708 | 389 fore *= 10; |
390 fore += *end++ - '0'; | |
391 } | |
392 if (*end == ',' && isdigit(end[1])) { | |
393 end++; | |
394 back = *end++ - '0'; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
395 if (isdigit(*end)) { |
3708 | 396 back *= 10; |
397 back += *end++ - '0'; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
398 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
399 } |
3708 | 400 } |
401 if (fore == -1) { | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
402 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
403 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
404 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
405 str = g_string_append(str, "</FONT>"); |
3708 | 406 fg = bg = FALSE; |
407 } else { | |
408 fore %= 16; | |
409 if (fg) | |
410 str = g_string_append(str, "</FONT>"); | |
411 if (back != -1) { | |
412 if (bg) | |
413 str = g_string_append(str, "</FONT>"); | |
414 back %= 16; | |
415 str = g_string_append(str, "<FONT BACK="); | |
416 str = g_string_append(str, int_to_col(back)); | |
417 str = g_string_append_c(str, '>'); | |
418 bg = TRUE; | |
419 } | |
420 str = g_string_append(str, "<FONT COLOR="); | |
421 str = g_string_append(str, int_to_col(fore)); | |
422 str = g_string_append_c(str, '>'); | |
423 fg = TRUE; | |
424 } | |
425 cur = end--; | |
426 break; | |
427 case 017: /* ^O */ | |
428 if (!bold && !underline && !fg && !bg) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
429 break; |
3708 | 430 *end = 0; |
431 str = g_string_append(str, cur); | |
432 if (bold) | |
433 str = g_string_append(str, "</B>"); | |
434 if (underline) | |
435 str = g_string_append(str, "</U>"); | |
436 if (fg) | |
437 str = g_string_append(str, "</FONT>"); | |
438 if (bg) | |
439 str = g_string_append(str, "</FONT>"); | |
440 bold = underline = fg = bg = FALSE; | |
441 cur = end + 1; | |
442 break; | |
443 case 037: /* ^_ */ | |
444 *end = 0; | |
445 str = g_string_append(str, cur); | |
446 if (underline) | |
447 str = g_string_append(str, "</U>"); | |
448 else | |
449 str = g_string_append(str, "<U>"); | |
450 underline = !underline; | |
451 cur = end + 1; | |
452 break; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
453 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
454 end++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
455 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
456 if (*cur) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
457 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
458 return str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
459 } |
2086 | 460 |
3751 | 461 static void |
462 irc_got_im(struct gaim_connection *gc, char *who, char *what, int flags, time_t t) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
463 { |
3751 | 464 char *utf8 = irc_recv_convert(gc, what); |
465 GString *str = decode_html(utf8); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
466 serv_got_im(gc, who, str->str, flags, t, -1); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
467 g_string_free(str, TRUE); |
3751 | 468 g_free(utf8); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
469 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
470 |
3751 | 471 static void |
472 dcc_chat_cancel(struct dcc_chat *); | |
3029 | 473 |
474 void | |
475 dcc_chat_in (gpointer data, gint source, GaimInputCondition condition) | |
476 { | |
477 struct dcc_chat *chat = data; | |
478 gchar buffer[IRC_BUF_LEN]; | |
479 gchar buf[128]; | |
3793 | 480 int n = 0; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
481 struct gaim_conversation *convo; |
3029 | 482 debug_printf("THIS IS TOO MUCH EFFORT\n"); |
483 n = read (chat->fd, buffer, IRC_BUF_LEN); | |
3707 | 484 if (n > 0) { |
485 | |
486 buffer[n] = 0; | |
487 g_strstrip(buffer); | |
488 | |
489 /* Convert to HTML */ | |
490 if (strlen(buffer)) { | |
491 debug_printf ("DCC Message from: %s\n", chat->nick); | |
492 irc_got_im(chat->gc, chat->nick, buffer, 0, | |
493 time(NULL)); | |
494 } | |
495 } | |
3029 | 496 else { |
497 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), | |
498 chat->nick); | |
4491 | 499 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4456
diff
changeset
|
500 chat->nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
501 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
502 time(NULL)); |
3730 | 503 dcc_chat_cancel (chat); |
3029 | 504 } |
505 } | |
506 | |
3751 | 507 void |
508 irc_read_dcc_ack (gpointer data, gint source, GaimInputCondition condition) { | |
3708 | 509 /* Read ACK Here */ |
3633 | 510 |
3630 | 511 } |
512 | |
3751 | 513 void |
514 dcc_send_callback (gpointer data, gint source, GaimInputCondition condition) { | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
515 #if 0 |
3708 | 516 struct irc_file_transfer *ift = data; |
517 struct sockaddr_in addr; | |
518 int len = sizeof(addr); | |
3622 | 519 |
3708 | 520 addr.sin_family = AF_INET; |
521 addr.sin_port = htons(ift->port); | |
522 addr.sin_addr.s_addr = INADDR_ANY; | |
3622 | 523 |
3708 | 524 ift->fd = accept(ift->fd, (struct sockaddr *)&addr, &len); |
525 if (!ift->fd) { | |
526 /* FIXME: Handle this gracefully XXX */ | |
527 printf("Something bad happened here, bubba!\n"); | |
528 return; | |
529 } | |
3622 | 530 |
3633 | 531 /* ift->awatcher = gaim_input_add(ift->fd, GAIM_INPUT_READ, irc_read_dcc_ack, ift); */ |
3630 | 532 |
3708 | 533 if (transfer_out_do(ift->xfer, ift->fd, 0)) { |
534 gaim_input_remove(ift->watcher); | |
535 ift->watcher = 0; | |
536 } | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
537 #endif |
3616 | 538 } |
539 | |
3751 | 540 void |
541 dcc_chat_callback (gpointer data, gint source, GaimInputCondition condition) { | |
3029 | 542 struct dcc_chat *chat = data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
543 struct gaim_conversation *convo; |
3029 | 544 char buf[IRC_BUF_LEN]; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
545 |
4491 | 546 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, chat->nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
547 |
3029 | 548 chat->fd = source; |
549 g_snprintf (buf, sizeof buf, | |
4221 | 550 _("DCC Chat with %s established"), |
3029 | 551 chat->nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
552 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
3029 | 553 debug_printf ("Chat with %s established\n", chat->nick); |
554 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
555 gaim_input_remove(chat->inpa); | |
556 chat->inpa = gaim_input_add(source, GAIM_INPUT_READ, dcc_chat_in, chat); | |
557 } | |
558 | |
3751 | 559 static void |
560 irc_got_chat_in(struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t t) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
561 { |
3751 | 562 char *utf8 = irc_recv_convert(gc, msg); |
563 GString *str = decode_html(utf8); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
564 serv_got_chat_in(gc, id, who, whisper, str->str, t); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
565 g_string_free(str, TRUE); |
3751 | 566 g_free(utf8); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
567 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
568 |
3751 | 569 static void |
570 handle_list(struct gaim_connection *gc, char *list) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
571 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
572 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
573 GSList *gr; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
574 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
575 id->str = g_string_append_c(id->str, ' '); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
576 id->str = g_string_append(id->str, list); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
577 id->bc--; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
578 if (id->bc) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
579 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
580 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
581 g_strdown(id->str->str); |
4349 | 582 gr = groups; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
583 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
584 GSList *m = ((struct group *)gr->data)->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
585 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
586 struct buddy *b = m->data; |
4491 | 587 if(b->account->gc == gc) { |
4349 | 588 char *tmp = g_strdup(b->name); |
589 char *x, *l; | |
590 g_strdown(tmp); | |
591 x = strstr(id->str->str, tmp); | |
592 l = x + strlen(b->name); | |
593 if (x && (*l != ' ' && *l != 0)) | |
594 x = 0; | |
595 if (!b->present && x) | |
596 serv_got_update(gc, b->name, 1, 0, 0, 0, 0, 0); | |
597 else if (b->present && !x) | |
598 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0); | |
599 g_free(tmp); | |
600 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
601 m = m->next; |
2086 | 602 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
603 gr = gr->next; |
2086 | 604 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
605 g_string_free(id->str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
606 id->str = g_string_new(""); |
2086 | 607 } |
608 | |
3751 | 609 static gboolean |
610 irc_request_buddy_update(gpointer data) | |
2086 | 611 { |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
612 struct gaim_connection *gc = data; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
613 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
614 char buf[500]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
615 int n = g_snprintf(buf, sizeof(buf), "ISON"); |
4416
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
616 gboolean found = FALSE; |
2086 | 617 |
4349 | 618 GSList *gr = groups; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
619 if (!gr || id->bc) |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
620 return TRUE; |
2086 | 621 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
622 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
623 struct group *g = gr->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
624 GSList *m = g->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
625 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
626 struct buddy *b = m->data; |
4491 | 627 if(b->account->gc == gc) { |
4349 | 628 if (n + strlen(b->name) + 2 > sizeof(buf)) { |
629 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); | |
630 irc_write(id->fd, buf, n); | |
631 id->bc++; | |
632 n = g_snprintf(buf, sizeof(buf), "ISON"); | |
633 } | |
634 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name); | |
4416
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
635 |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
636 found = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
637 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
638 m = m->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
639 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
640 gr = gr->next; |
2086 | 641 } |
4416
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
642 |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
643 if (found) { |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
644 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
645 irc_write(id->fd, buf, strlen(buf)); |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
646 id->bc++; |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
647 } |
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
648 |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
649 return TRUE; |
2086 | 650 } |
651 | |
3751 | 652 static void |
653 handle_names(struct gaim_connection *gc, char *chan, char *names) | |
2086 | 654 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
655 struct gaim_conversation *c = irc_find_chat(gc, chan); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
656 struct gaim_chat *chat; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
657 char **buf, **tmp; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
658 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
659 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
660 if (*names == ':') names++; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
661 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
662 chat = GAIM_CHAT(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
663 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
664 buf = g_strsplit(names, " ", -1); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
665 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
666 for (tmp = buf; *tmp; tmp++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
667 gaim_chat_add_user(chat, *tmp, NULL); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
668 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
669 g_strfreev(buf); |
2086 | 670 } |
671 | |
3751 | 672 static void |
673 handle_notopic(struct gaim_connection *gc, char *text) | |
3707 | 674 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
675 struct gaim_conversation *c; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
676 |
3707 | 677 if ((c = irc_find_chat(gc, text))) { |
678 char buf[IRC_BUF_LEN]; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
679 |
3707 | 680 g_snprintf(buf, sizeof(buf), _("No topic is set")); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
681 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
682 gaim_chat_set_topic(GAIM_CHAT(c), NULL, buf); |
3707 | 683 } |
684 } | |
685 | |
3751 | 686 static void |
687 handle_topic(struct gaim_connection *gc, char *text) | |
2086 | 688 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
689 struct gaim_conversation *c; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
690 char *po = strchr(text, ' '); |
2086 | 691 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
692 if (!po) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
693 return; |
2086 | 694 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
695 *po = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
696 po += 2; |
2086 | 697 |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
698 if ((c = irc_find_chat(gc, text))) { |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
699 char buf[IRC_BUF_LEN]; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
700 gaim_chat_set_topic(GAIM_CHAT(c), NULL, po); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
701 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"), |
3708 | 702 text, po); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
703 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
704 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
705 } |
2086 | 706 } |
707 | |
3751 | 708 static gboolean |
709 mode_has_arg(struct gaim_connection *gc, char sign, char mode) | |
2086 | 710 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
711 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
712 char *cm = id->chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
713 int type = 0; |
2086 | 714 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
715 if (strchr(id->nickmodes, mode)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
716 return TRUE; |
2086 | 717 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
718 while (*cm) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
719 if (*cm == ',') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
720 type++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
721 else if (*cm == mode) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
722 switch (type) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
723 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
724 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
725 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
726 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
727 if (sign == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
728 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
729 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
730 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
731 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
732 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
733 cm++; |
2086 | 734 } |
735 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
736 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
737 } |
2086 | 738 |
3751 | 739 static void |
740 irc_chan_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *argstr, char *who) | |
3452 | 741 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
742 struct gaim_conversation *c = irc_find_chat(gc, room); |
3452 | 743 char buf[IRC_BUF_LEN]; |
744 char *nick = g_strndup(who, strchr(who, '!') - who); | |
745 | |
4221 | 746 g_snprintf(buf, sizeof(buf), _("-:- mode/%s [%c%c %s] by %s"), |
3707 | 747 room, sign, mode, strlen(argstr) ? argstr : "", |
748 nick); | |
3452 | 749 g_free(nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
750 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
751 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
3452 | 752 } |
753 | |
3751 | 754 static void |
755 irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
756 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
757 struct gaim_conversation *c = irc_find_chat(gc, room); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
758 GList *r; |
2086 | 759 |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
760 if (mode != 'o' && mode != 'v' && mode != 'h') |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
761 return; |
2086 | 762 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
763 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
764 return; |
2086 | 765 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
766 r = gaim_chat_get_users(GAIM_CHAT(c)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
767 while (r) { |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
768 gboolean op = FALSE, halfop = FALSE, voice = FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
769 char *who = r->data; |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
770 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
771 if (*who == '@') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
772 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
773 who++; |
2086 | 774 } |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
775 |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
776 if (*who == '%') { |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
777 halfop = TRUE; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
778 who++; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
779 } |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
780 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
781 if (*who == '+') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
782 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
783 who++; |
2086 | 784 } |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
785 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
786 if (!strcmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
787 char *tmp, buf[IRC_BUF_LEN]; |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
788 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
789 if (mode == 'o') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
790 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
791 op = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
792 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
793 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
794 } |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
795 |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
796 if (mode == 'h') { |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
797 if (sign == '-') |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
798 halfop = FALSE; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
799 else |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
800 halfop = TRUE; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
801 } |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
802 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
803 if (mode == 'v') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
804 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
805 voice = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
806 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
807 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
808 } |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
809 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
810 tmp = g_strdup(r->data); |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
811 g_snprintf(buf, sizeof(buf), "%s%s%s", |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
812 (op ? "@" : (halfop ? "%" : "")), |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
813 voice ? "+" : "", nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
814 gaim_chat_rename_user(GAIM_CHAT(c), tmp, buf); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
815 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
816 return; |
2086 | 817 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
818 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
819 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
820 } |
2086 | 821 |
3751 | 822 static void |
823 handle_mode(struct gaim_connection *gc, char *word[], char *word_eol[], gboolean n324) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
824 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
825 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
826 int offset = n324 ? 4 : 3; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
827 char *chan = word[offset]; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
828 struct gaim_conversation *c = irc_find_chat(gc, chan); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
829 char *modes = word[offset + 1]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
830 int len = strlen(word_eol[offset]) - 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
831 char sign = *modes++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
832 int arg = 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
833 char *argstr; |
3452 | 834 char *who = word[1]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
835 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
836 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
837 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
838 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
839 if (word_eol[offset][len] == ' ') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
840 word_eol[offset][len] = 0; |
2086 | 841 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
842 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
843 switch (*modes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
844 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
845 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
846 case '+': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
847 case '-': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
848 sign = *modes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
849 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
850 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
851 if (mode_has_arg(gc, sign, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
852 argstr = word[++arg + offset]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
853 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
854 argstr = ""; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
855 if (strchr(id->nickmodes, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
856 irc_user_mode(gc, chan, sign, *modes, argstr); |
3452 | 857 else if (strchr(who, '!')) |
858 irc_chan_mode(gc, chan, sign, *modes, argstr, who); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
859 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
860 modes++; |
2086 | 861 } |
862 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
863 |
3751 | 864 static void |
865 handle_version(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
3452 | 866 { |
867 struct irc_data *id = gc->proto_data; | |
868 GString *str; | |
869 | |
870 id->liststr = g_string_new(""); | |
871 | |
872 id->liststr = g_string_append(id->liststr, "<b>Version: </b>"); | |
873 id->liststr = g_string_append(id->liststr, word_eol[4]); | |
874 | |
875 str = decode_html(id->liststr->str); | |
876 g_show_info_text(gc, NULL, 2, str->str, NULL); | |
877 g_string_free(str, TRUE); | |
878 g_string_free(id->liststr, TRUE); | |
879 id->liststr = NULL; | |
880 } | |
881 | |
3751 | 882 static void |
883 handle_who(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
3452 | 884 { |
885 struct irc_data *id = gc->proto_data; | |
886 char buf[IRC_BUF_LEN]; | |
887 | |
888 if (!id->in_whois) { | |
889 id->in_whois = TRUE; | |
890 id->liststr = g_string_new(""); | |
891 } | |
892 | |
893 switch (num) { | |
894 case 352: | |
895 g_snprintf(buf, sizeof(buf), "<b>%s</b> (%s@%s): %s<br>", | |
896 word[8], word[5], word[6], word_eol[11]); | |
897 id->liststr = g_string_append(id->liststr, buf); | |
898 break; | |
899 } | |
900 } | |
901 | |
2648 | 902 /* Handle our whois stuff here. You know what, I have a sore throat. You know |
903 * what I think about that? I'm not too pleased with it. Perhaps I should take | |
904 * some medicine, or perhaps I should go to bed? Blah!! */ | |
905 | |
3751 | 906 static void |
907 handle_whois(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
2648 | 908 { |
909 struct irc_data *id = gc->proto_data; | |
910 char tmp[1024]; | |
911 | |
912 if (!id->in_whois) { | |
913 id->in_whois = TRUE; | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
914 id->liststr = g_string_new(""); |
2648 | 915 } else { |
916 /* I can't decide if we should have one break or two */ | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
917 id->liststr = g_string_append(id->liststr, "<BR>"); |
2648 | 918 id->in_whois = TRUE; |
919 } | |
920 | |
921 switch (num) { | |
3707 | 922 case 311: |
923 id->liststr = g_string_append(id->liststr, "<b>User: </b>"); | |
924 break; | |
925 case 312: | |
926 id->liststr = g_string_append(id->liststr, "<b>Server: </b>"); | |
927 break; | |
928 case 313: | |
929 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]); | |
930 id->liststr = g_string_append(id->liststr, tmp); | |
931 break; | |
932 case 314: | |
933 id->liststr = g_string_append(id->liststr, "<b>User: </b>"); | |
934 g_snprintf(tmp, sizeof(tmp), "<b>%s</b> (%s@%s) %s", | |
935 word[4], word[5], word[6], word_eol[8]); | |
936 id->liststr = g_string_append(id->liststr, tmp); | |
937 return; | |
938 case 317: | |
939 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>"); | |
940 break; | |
941 case 319: | |
942 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>"); | |
943 break; | |
4509
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
944 /* Numeric 320 is used by the freenode irc network for showing |
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
945 * that a user is identified to services (Jason Straw <misato@wopn.org>)*/ |
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
946 case 320: |
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
947 g_snprintf(tmp, sizeof(tmp), "%s is an Identified User", word[4]); |
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
948 id->liststr = g_string_append(id->liststr, tmp); |
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
949 return; |
3707 | 950 default: |
951 break; | |
2648 | 952 } |
3452 | 953 |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
954 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
955 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
3452 | 956 /* Nicer idle time output, by jonas@birme.se */ |
957 else if (isdigit(word_eol[5][0])) { | |
958 time_t idle = atol(word_eol[5]); | |
959 time_t signon = atol(strchr(word_eol[5], ' ')); | |
960 | |
961 g_snprintf(tmp, sizeof(tmp), | |
962 "%ld seconds [signon: %s]", (idle / 1000), ctime(&signon)); | |
963 id->liststr = g_string_append(id->liststr, tmp); | |
964 } | |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
965 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
966 id->liststr = g_string_append(id->liststr, word_eol[5]); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
967 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
968 |
3751 | 969 static void |
970 handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[]) | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
971 { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
972 struct irc_data *id = gc->proto_data; |
2648 | 973 |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
974 if (!id->in_list) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
975 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
976 id->liststr = g_string_new(""); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
977 } else { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
978 id->liststr = g_string_append(id->liststr, "<BR>"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
979 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
980 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
981 |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
982 id->liststr = g_string_append(id->liststr, word_eol[4]); |
2648 | 983 } |
984 | |
3751 | 985 static void |
986 irc_change_nick(void *a, char *b) { | |
3511 | 987 struct gaim_connection *gc = a; |
988 struct irc_data *id = gc->proto_data; | |
989 char buf[IRC_BUF_LEN]; | |
990 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", b); | |
991 irc_write(id->fd, buf, strlen(buf)); | |
992 } | |
993 | |
3751 | 994 static void |
995 process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[]) | |
2086 | 996 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
997 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
998 char *text = word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
999 int n = atoi(word[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1000 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1001 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname))) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1002 text += strlen(gc->displayname) + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1003 if (*text == ':') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1004 text++; |
2086 | 1005 |
3707 | 1006 /* RPL_ and ERR_ */ |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1007 switch (n) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1008 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1009 if (!strncmp(word[5], "u2.10", 5)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1010 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1011 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1012 id->six_modes = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1013 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1014 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1015 handle_005(gc, word, word_eol); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1016 break; |
3707 | 1017 case 301: /* RPL_AWAY */ |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1018 if (id->in_whois) { |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1019 id->liststr = g_string_append(id->liststr, "<BR><b>Away: </b>"); |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
1020 |
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
1021 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1022 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
1023 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1024 id->liststr = g_string_append(id->liststr, word_eol[5]); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1025 } else |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1026 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1027 break; |
3707 | 1028 case 303: /* RPL_ISON */ |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1029 handle_list(gc, &word_eol[4][1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1030 break; |
3707 | 1031 case 311: /* RPL_WHOISUSER */ |
1032 case 312: /* RPL_WHOISSERVER */ | |
1033 case 313: /* RPL_WHOISOPERATOR */ | |
1034 case 314: /* RPL_WHOWASUSER */ | |
1035 case 317: /* RPL_WHOISIDLE */ | |
1036 case 319: /* RPL_WHOISCHANNELS */ | |
4509
cf2f5a1f1e46
[gaim-migrate @ 4785]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1037 case 320: /* FreeNode Identified */ |
2648 | 1038 handle_whois(gc, word, word_eol, n); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1039 break; |
3707 | 1040 case 322: /* RPL_LIST */ |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1041 handle_roomlist(gc, word, word_eol); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1042 break; |
3707 | 1043 case 315: /* RPL_ENDOFWHO */ |
1044 case 318: /* RPL_ENDOFWHOIS */ | |
1045 case 323: /* RPL_LISTEND */ | |
1046 case 369: /* RPL_ENDOFWHOWAS */ | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1047 if ((id->in_whois || id->in_list) && id->liststr) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1048 GString *str = decode_html(id->liststr->str); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2782
diff
changeset
|
1049 g_show_info_text(gc, NULL, 2, str->str, NULL); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1050 g_string_free(str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1051 g_string_free(id->liststr, TRUE); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1052 id->liststr = NULL; |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
1053 id->in_whois = FALSE; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1054 id->in_list = FALSE; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1055 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1056 break; |
3707 | 1057 case 324: /* RPL_CHANNELMODEIS */ |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1058 handle_mode(gc, word, word_eol, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1059 break; |
3707 | 1060 case 331: /* RPL_NOTOPIC */ |
1061 handle_notopic(gc, text); | |
1062 break; | |
1063 case 332: /* RPL_TOPIC */ | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1064 handle_topic(gc, text); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1065 break; |
3707 | 1066 case 351: /* RPL_VERSION */ |
3452 | 1067 handle_version(gc, word, word_eol, n); |
1068 break; | |
3707 | 1069 case 352: /* RPL_WHOREPLY */ |
3708 | 1070 handle_who(gc, word, word_eol, n); |
1071 break; | |
3707 | 1072 case 353: /* RPL_NAMREPLY */ |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1073 handle_names(gc, word[5], word_eol[6]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1074 break; |
3707 | 1075 case 376: /* RPL_ENDOFMOTD */ |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1076 irc_request_buddy_update(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1077 break; |
3707 | 1078 case 382: /* RPL_REHASHING */ |
1079 do_error_dialog(_("Rehashing server"), _("IRC Operator"), GAIM_ERROR); | |
1080 break; | |
1081 case 401: /* ERR_NOSUCHNICK */ | |
1082 do_error_dialog(_("No such nick/channel"), _("IRC Error"), GAIM_ERROR); | |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
1083 break; |
3707 | 1084 case 402: /* ERR_NOSUCHSERVER */ |
1085 do_error_dialog(_("No such server"), _("IRC Error"), GAIM_ERROR); | |
1086 case 431: /* ERR_NONICKNAMEGIVEN */ | |
1087 do_error_dialog(_("No nickname given"), _("IRC Error"), GAIM_ERROR); | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1088 break; |
3707 | 1089 case 481: /* ERR_NOPRIVILEGES */ |
1090 do_error_dialog(_("You're not an IRC operator!"), _("IRC Error"), GAIM_ERROR); | |
1091 break; | |
3511 | 1092 case 433: |
1093 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL); | |
3605 | 1094 break; |
3452 | 1095 default: |
3707 | 1096 /* Other error messages */ |
3452 | 1097 if (n > 400 && n < 502) { |
1098 char errmsg[IRC_BUF_LEN]; | |
1099 char *errmsg1 = strrchr(text, ':'); | |
1100 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n); | |
1101 if (errmsg) | |
3536 | 1102 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR); |
3452 | 1103 } |
1104 break; | |
2086 | 1105 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1106 } |
2086 | 1107 |
3751 | 1108 static gboolean |
1109 is_channel(struct gaim_connection *gc, char *name) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1110 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1111 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1112 if (strchr(id->chantypes, *name)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1113 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1114 return FALSE; |
2086 | 1115 } |
1116 | |
3751 | 1117 static void |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1118 irc_rem_chat_bud(struct gaim_connection *gc, char *nick, struct gaim_conversation *b, char *reason) |
2086 | 1119 { |
1120 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1121 struct gaim_chat *chat; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1122 |
4067 | 1123 if (b) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1124 GList *r; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1125 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1126 chat = GAIM_CHAT(b); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1127 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1128 r = gaim_chat_get_users(chat); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1129 |
4067 | 1130 while (r) { |
1131 char *who = r->data; | |
1132 if (*who == '@') | |
1133 who++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1134 if (*who == '%') |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1135 who++; |
4067 | 1136 if (*who == '+') |
1137 who++; | |
1138 if (!g_strcasecmp(who, nick)) { | |
1139 char *tmp = g_strdup(r->data); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1140 gaim_chat_remove_user(chat, tmp, reason); |
4067 | 1141 g_free(tmp); |
1142 break; | |
1143 } | |
1144 r = r->next; | |
4065 | 1145 } |
4067 | 1146 } else { |
1147 GSList *bcs = gc->buddy_chats; | |
1148 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1149 struct gaim_conversation *bc = bcs->data; |
4067 | 1150 irc_rem_chat_bud(gc, nick, bc, reason); |
1151 bcs = bcs->next; | |
1152 } | |
2086 | 1153 } |
1154 } | |
1155 | |
3751 | 1156 static void |
1157 irc_change_name(struct gaim_connection *gc, char *old, char *new) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1158 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1159 GSList *bcs = gc->buddy_chats; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1160 char buf[IRC_BUF_LEN]; |
2086 | 1161 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1162 while (bcs) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1163 struct gaim_conversation *b = bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1164 struct gaim_chat *chat; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1165 GList *r; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1166 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1167 chat = GAIM_CHAT(b); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1168 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1169 r = gaim_chat_get_users(chat); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1170 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1171 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1172 char *who = r->data; |
2292
6625d0755c51
[gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2291
diff
changeset
|
1173 int n = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1174 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1175 buf[n++] = *who++; |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1176 if (*who == '%') |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1177 buf[n++] = *who++; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1178 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1179 buf[n++] = *who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1180 g_snprintf(buf + n, sizeof(buf) - n, "%s", new); |
2312
766603034af8
[gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2310
diff
changeset
|
1181 if (!strcmp(who, old)) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1182 char *tmp = g_strdup(r->data); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1183 gaim_chat_rename_user(chat, tmp, buf); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1184 r = gaim_chat_get_users(chat); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1185 g_free(tmp); |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2687
diff
changeset
|
1186 break; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1187 } else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1188 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1189 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1190 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1191 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1192 } |
2086 | 1193 |
3751 | 1194 static void |
1195 handle_privmsg(struct gaim_connection *gc, char *to, char *nick, char *msg) | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1196 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1197 if (is_channel(gc, to)) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1198 struct gaim_conversation *c = irc_find_chat(gc, to); |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1199 if (!c) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1200 return; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1201 irc_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1202 nick, 0, msg, time(NULL)); |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1203 } else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1204 char *tmp = g_malloc(strlen(nick) + 2); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1205 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1206 if (gaim_find_conversation(tmp)) |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1207 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1208 else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1209 *tmp = '+'; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1210 if (gaim_find_conversation(tmp)) |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1211 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1212 else |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1213 irc_got_im(gc, nick, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1214 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1215 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1216 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1217 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1218 |
3751 | 1219 static void |
1220 dcc_chat_init(struct dcc_chat *data) { | |
4249 | 1221 if (g_slist_find(connections, data->gc)) { |
4634 | 1222 proxy_connect(data->gc->account, data->ip_address, data->port, dcc_chat_callback, data); |
4249 | 1223 } else { |
1224 g_free(data); | |
1225 } | |
3029 | 1226 } |
1227 | |
3751 | 1228 static void |
1229 dcc_chat_cancel(struct dcc_chat *data){ | |
4249 | 1230 if (g_slist_find(connections, data->gc) && find_dcc_chat(data->gc, data->nick)) { |
3029 | 1231 dcc_chat_list = g_slist_remove(dcc_chat_list, data); |
1232 gaim_input_remove (data->inpa); | |
1233 close (data->fd); | |
1234 } | |
1235 g_free(data); | |
1236 } | |
1237 | |
3751 | 1238 static void |
1239 irc_convo_closed(struct gaim_connection *gc, char *who) | |
3029 | 1240 { |
1241 struct dcc_chat *dchat = find_dcc_chat(gc, who); | |
1242 if (!dchat) | |
1243 return; | |
1244 | |
3730 | 1245 dcc_chat_cancel(dchat); |
3029 | 1246 } |
1247 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1248 static void |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1249 irc_xfer_init(struct gaim_xfer *xfer) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1250 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1251 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1252 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1253 gaim_xfer_start(xfer, -1, data->ip, data->port); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1254 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1255 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1256 static void |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1257 irc_xfer_end(struct gaim_xfer *xfer) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1258 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1259 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1260 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1261 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers, |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1262 xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1263 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1264 g_free(data); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1265 xfer->data = NULL; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1266 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1267 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1268 static void |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1269 irc_xfer_cancel_send(struct gaim_xfer *xfer) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1270 { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1271 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data; |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1272 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1273 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers, |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1274 xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1275 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1276 g_free(data); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1277 xfer->data = NULL; |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1278 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1279 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1280 static void |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1281 irc_xfer_cancel_recv(struct gaim_xfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1282 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1283 struct irc_xfer_data *data = (struct irc_xfer_data *)xfer->data; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1284 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1285 data->idata->file_transfers = g_slist_remove(data->idata->file_transfers, |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1286 xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1287 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1288 g_free(data); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1289 xfer->data = NULL; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1290 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1291 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1292 static void |
4594 | 1293 irc_xfer_ack(struct gaim_xfer *xfer, const char *buffer, size_t size) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1294 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1295 guint32 pos; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1296 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1297 pos = htonl(gaim_xfer_get_bytes_sent(xfer)); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1298 |
4552
a2f2a717fdf2
[gaim-migrate @ 4832]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
1299 write(xfer->fd, (char *)&pos, 4); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1300 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1301 |
3751 | 1302 static void |
1303 handle_ctcp(struct gaim_connection *gc, char *to, char *nick, | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1304 char *msg, char *word[], char *word_eol[]) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1305 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1306 struct irc_data *id = gc->proto_data; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1307 char buf[IRC_BUF_LEN]; |
3735 | 1308 char out[IRC_BUF_LEN]; |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1309 |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1310 if (!g_strncasecmp(msg, "VERSION", 7)) { |
3735 | 1311 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' " |
1312 "Multi-protocol Messaging Client: " WEBSITE "\001"); | |
1313 irc_send_notice (gc, nick, buf); | |
1314 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick); | |
1315 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1316 } |
3707 | 1317 if (!g_strncasecmp(msg, "CLIENTINFO", 10)) { |
3735 | 1318 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001"); |
1319 irc_send_notice (gc, nick, buf); | |
1320 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick); | |
1321 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | |
3707 | 1322 } |
1323 if (!g_strncasecmp(msg, "USERINFO", 8)) { | |
4491 | 1324 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias); |
3735 | 1325 irc_send_notice (gc, nick, buf); |
1326 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick); | |
1327 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | |
3707 | 1328 } |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1329 if (!g_strncasecmp(msg, "ACTION", 6)) { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1330 char *po = strchr(msg + 6, 1); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1331 char *tmp; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1332 if (po) *po = 0; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1333 tmp = g_strconcat("/me", msg + 6, NULL); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1334 handle_privmsg(gc, to, nick, tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1335 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1336 } |
3735 | 1337 if (!g_strncasecmp(msg, "PING", 4)) { |
1338 g_snprintf(buf, sizeof(buf), "\001%s\001", msg); | |
1339 irc_send_notice (gc, nick, buf); | |
1340 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick); | |
1341 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | |
1342 } | |
3029 | 1343 if (!g_strncasecmp(msg, "DCC CHAT", 8)) { |
1344 char **chat_args = g_strsplit(msg, " ", 5); | |
1345 char ask[1024]; | |
3707 | 1346 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1); |
3029 | 1347 dccchat->gc = gc; |
1348 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]); | |
1349 dccchat->port=atoi(chat_args[4]); | |
1350 g_snprintf(dccchat->nick, sizeof(dccchat->nick), nick); | |
3730 | 1351 g_snprintf(ask, sizeof(ask), _("%s would like to establish a DCC chat"), nick); |
4249 | 1352 do_ask_dialog(ask, _("This requires a direct connection to be established between the two computers. Messages sent will not pass through the IRC server"), dccchat, _("Connect"), dcc_chat_init, _("Cancel"), dcc_chat_cancel, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
3029 | 1353 } |
3616 | 1354 |
1355 | |
1356 if (!g_strncasecmp(msg, "DCC SEND", 8)) { | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1357 struct gaim_xfer *xfer; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1358 char **send_args; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1359 char *ip, *filename; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1360 struct irc_xfer_data *xfer_data; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1361 size_t size; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1362 int port; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1363 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1364 send_args = g_strsplit(msg, " ", 6); |
3708 | 1365 send_args[5][strlen(send_args[5])-1] = 0; |
3616 | 1366 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1367 /* Give these better names. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1368 ip = send_args[3]; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1369 filename = send_args[2]; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1370 size = atoi(send_args[5]); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1371 port = atoi(send_args[4]); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1372 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1373 /* Setup the IRC-specific transfer data. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1374 xfer_data = g_malloc0(sizeof(struct irc_xfer_data)); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1375 xfer_data->ip = ip; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1376 xfer_data->port = port; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1377 xfer_data->idata = id; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1378 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1379 /* Build the file transfer handle. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1380 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, nick); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1381 xfer->data = xfer_data; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1382 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1383 /* Set the info about the incoming file. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1384 gaim_xfer_set_filename(xfer, filename); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1385 gaim_xfer_set_size(xfer, size); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1386 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1387 g_free(filename); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1388 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1389 /* Setup our I/O op functions. */ |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1390 gaim_xfer_set_init_fnc(xfer, irc_xfer_init); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1391 gaim_xfer_set_end_fnc(xfer, irc_xfer_end); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1392 gaim_xfer_set_cancel_send_fnc(xfer, irc_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1393 gaim_xfer_set_cancel_recv_fnc(xfer, irc_xfer_cancel_recv); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4634
diff
changeset
|
1394 gaim_xfer_set_ack_fnc(xfer, irc_xfer_ack); |
3616 | 1395 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1396 /* Keep track of this transfer for later. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1397 id->file_transfers = g_slist_append(id->file_transfers, xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1398 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1399 /* Now perform the request! */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1400 gaim_xfer_request(xfer); |
3616 | 1401 } |
3735 | 1402 |
1403 /*write_to_conv(c, out, WFLAG_SYSTEM, NULL, time(NULL), -1);*/ | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1404 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1405 |
3751 | 1406 static gboolean |
1407 irc_parse(struct gaim_connection *gc, char *buf) | |
2086 | 1408 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1409 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1410 gchar outbuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1411 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1412 char pdibuf[522]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1413 char *ex, ip[128], nick[128]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1414 char *cmd; |
2086 | 1415 |
1416 /* Check for errors */ | |
3452 | 1417 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1418 if (*buf != ':') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1419 if (!strncmp(buf, "NOTICE ", 7)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1420 buf += 7; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1421 if (!strncmp(buf, "PING ", 5)) { |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1422 int r = FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1423 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1424 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1425 hide_login_progress(gc, _("Unable to write")); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1426 signoff(gc); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1427 r = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1428 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1429 return r; |
2086 | 1430 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1431 /* XXX doesn't handle ERROR */ |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1432 return FALSE; |
2086 | 1433 } |
1434 | |
2782
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1435 if (!idata->online) { |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1436 /* Now lets sign ourselves on */ |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1437 account_online(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1438 serv_finish_login(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1439 |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1440 /* we don't call this now because otherwise some IRC servers might not like us */ |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1441 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1442 idata->online = TRUE; |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1443 } |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1444 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1445 buf++; |
2086 | 1446 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1447 process_data_init(pdibuf, buf, word, word_eol, FALSE); |
2086 | 1448 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1449 if (atoi(word[2])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1450 if (*word_eol[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1451 process_numeric(gc, word, word_eol); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1452 return FALSE; |
2086 | 1453 } |
1454 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1455 cmd = word[2]; |
2086 | 1456 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1457 ex = strchr(pdibuf, '!'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1458 if (!ex) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1459 strncpy(ip, pdibuf, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1460 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1461 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1462 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1463 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1464 strncpy(ip, ex + 1, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1465 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1466 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1467 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1468 if ((ex - pdibuf) < sizeof (nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1469 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */ |
2086 | 1470 } |
1471 | |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1472 if (!strcmp(cmd, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1473 char *chan = g_strdup(word[4]); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1474 serv_got_chat_invite(gc, chan + 1, nick, NULL, g_list_append(NULL, chan)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1475 } else if (!strcmp(cmd, "JOIN")) { |
3751 | 1476 irc_parse_join(gc, nick, word, word_eol); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1477 } else if (!strcmp(cmd, "KICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1478 if (!strcmp(gc->displayname, word[4])) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1479 struct gaim_conversation *c = irc_find_chat(gc, word[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1480 if (!c) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1481 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1482 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
4491 | 1483 gaim_conversation_set_account(c, NULL); |
3707 | 1484 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s: %s"), |
1485 word[3], *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]); | |
1486 do_error_dialog(outbuf, _("IRC Error"), GAIM_ERROR); | |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1487 } else { |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1488 char *reason = *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]; |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1489 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1490 struct gaim_conversation *c = irc_find_chat(gc, word[3]); |
4065 | 1491 irc_rem_chat_bud(gc, word[4], c, msg); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1492 g_free(msg); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1493 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1494 } else if (!strcmp(cmd, "KILL")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1495 } else if (!strcmp(cmd, "MODE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1496 handle_mode(gc, word, word_eol, FALSE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1497 } else if (!strcmp(cmd, "NICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1498 char *new = *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1499 if (!strcmp(gc->displayname, nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1500 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1501 irc_change_name(gc, nick, new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1502 } else if (!strcmp(cmd, "NOTICE")) { |
3751 | 1503 irc_parse_notice(gc, nick, ex, word, word_eol); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1504 } else if (!strcmp(cmd, "PART")) { |
3751 | 1505 if (!irc_parse_part(gc, nick, cmd, word, word_eol)) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1506 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1507 } else if (!strcmp(cmd, "PRIVMSG")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1508 char *to, *msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1509 if (!*word[3]) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1510 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1511 to = word[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1512 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1513 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */ |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1514 if (!g_strncasecmp(msg + 1, "DCC ", 4)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1515 process_data_init(pdibuf, buf, word, word_eol, TRUE); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1516 handle_ctcp(gc, to, nick, msg + 1, word, word_eol); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1517 } else { |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1518 handle_privmsg(gc, to, nick, msg); |
2086 | 1519 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1520 } else if (!strcmp(cmd, "PONG")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1521 } else if (!strcmp(cmd, "QUIT")) { |
4065 | 1522 irc_rem_chat_bud(gc, nick, irc_find_chat(gc, word[3]), *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1523 } else if (!strcmp(cmd, "TOPIC")) { |
3751 | 1524 irc_parse_topic(gc, nick, word, word_eol); |
3707 | 1525 } else if (!strcmp(cmd, "WALLOPS")) { /* Don't know if a dialog box is the right way? */ |
1526 char *msg = strrchr(word_eol[0], ':'); | |
1527 if (msg) | |
1528 do_error_dialog(msg+1, _("IRC Operator"), GAIM_ERROR); | |
2086 | 1529 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1530 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1531 return FALSE; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1532 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1533 |
3751 | 1534 /* CTCP by jonas@birme.se */ |
1535 static void | |
1536 irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex, | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1537 char *word[], char *word_eol[]) |
3751 | 1538 { |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1539 char buf[IRC_BUF_LEN]; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1540 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1541 if (!g_strcasecmp(word[4], ":\001CLIENTINFO")) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1542 char *p = g_strrstr(word_eol[5], "\001"); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1543 *p = 0; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1544 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1545 do_error_dialog(buf, _("CTCP ClientInfo"), GAIM_INFO); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1546 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1547 } else if (!g_strcasecmp(word[4], ":\001USERINFO")) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1548 char *p = g_strrstr(word_eol[5], "\001"); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1549 *p = 0; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1550 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1551 do_error_dialog(buf, _("CTCP UserInfo"), GAIM_INFO); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1552 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1553 } else if (!g_strcasecmp(word[4], ":\001VERSION")) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1554 char *p = g_strrstr(word_eol[5], "\001"); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1555 *p = 0; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1556 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1557 do_error_dialog(buf, _("CTCP Version"), GAIM_INFO); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1558 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1559 } else if (!g_strcasecmp(word[4], ":\001PING")) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1560 char *p = g_strrstr(word_eol[5], "\001"); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1561 struct timeval ping_time; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1562 struct timeval now; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1563 gchar **vector; |
3751 | 1564 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1565 if (p) |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1566 *p = 0; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1567 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1568 vector = g_strsplit(word_eol[5], " ", 2); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1569 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1570 if (gettimeofday(&now, NULL) == 0 && vector != NULL) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1571 if (now.tv_usec - atol(vector[1]) < 0) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1572 ping_time.tv_sec = now.tv_sec - atol(vector[0]) - 1; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1573 ping_time.tv_usec = now.tv_usec - atol(vector[1]) + 1000000; |
3751 | 1574 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1575 } else { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1576 ping_time.tv_sec = now.tv_sec - atol(vector[0]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1577 ping_time.tv_usec = now.tv_usec - atol(vector[1]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1578 } |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1579 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1580 g_snprintf(buf, sizeof(buf), |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1581 "CTCP Ping reply from %s: %lu.%.03lu seconds", |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1582 nick, ping_time.tv_sec, (ping_time.tv_usec/1000)); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1583 |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1584 do_error_dialog(buf, _("CTCP Ping"), GAIM_INFO); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1585 g_strfreev(vector); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1586 } |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1587 } else { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1588 if (*word_eol[4] == ':') word_eol[4]++; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1589 if (ex) |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1590 irc_got_im(gc, nick, word_eol[4], 0, time(NULL)); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1591 } |
3751 | 1592 } |
1593 | |
1594 static void | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1595 irc_parse_join(struct gaim_connection *gc, char *nick, |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1596 char *word[], char *word_eol[]) |
3751 | 1597 { |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1598 char *chan = *word[3] == ':' ? word[3] + 1 : word[3]; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1599 static int id = 1; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1600 struct gaim_conversation *c; |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1601 char *hostmask, *p; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1602 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1603 if (!g_strcasecmp(gc->displayname, nick)) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1604 serv_got_joined_chat(gc, id++, chan); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1605 } else { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1606 c = irc_find_chat(gc, chan); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1607 if (c) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1608 hostmask = g_strdup(word[1]); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1609 p = strchr(hostmask, '!'); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1610 if (p) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1611 char *pend = strchr(p, ' '); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1612 if (pend) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1613 *pend = 0; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1614 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1615 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1616 gaim_chat_add_user(GAIM_CHAT(c), nick, p + 1); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1617 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1618 g_free(hostmask); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1619 } |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1620 } |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1621 } |
3751 | 1622 } |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1623 |
3751 | 1624 static void |
1625 irc_parse_topic(struct gaim_connection *gc, char *nick, | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1626 char *word[], char *word_eol[]) |
3751 | 1627 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1628 struct gaim_conversation *c = irc_find_chat(gc, word[3]); |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1629 char *topic = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1630 char buf[IRC_BUF_LEN]; |
3751 | 1631 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1632 if (c) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1633 gaim_chat_set_topic(GAIM_CHAT(c), nick, topic); |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1634 g_snprintf(buf, sizeof(buf), |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1635 _("<B>%s has changed the topic to: %s</B>"), nick, topic); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1636 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1637 gaim_conversation_write(c, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1638 } |
3751 | 1639 } |
1640 | |
1641 static gboolean | |
1642 irc_parse_part(struct gaim_connection *gc, char *nick, char *cmd, | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1643 char *word[], char *word_eol[]) |
3751 | 1644 { |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1645 char *chan = cmd + 5; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1646 struct gaim_conversation *c; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1647 struct gaim_chat *chat; |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1648 char *reason = word_eol[4]; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1649 GList *r; |
3751 | 1650 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1651 if (*chan == ':') |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1652 chan++; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1653 if (*reason == ':') |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1654 reason++; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1655 if (!(c = irc_find_chat(gc, chan))) |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1656 return FALSE; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1657 if (!strcmp(nick, gc->displayname)) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1658 serv_got_chat_left(gc, gaim_chat_get_id(GAIM_CHAT(c))); |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1659 return FALSE; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1660 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1661 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1662 chat = GAIM_CHAT(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1663 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1664 r = gaim_chat_get_users(GAIM_CHAT(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1665 |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1666 while (r) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1667 char *who = r->data; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1668 if (*who == '@') |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1669 who++; |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1670 if (*who == '%') |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
1671 who++; |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1672 if (*who == '+') |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1673 who++; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1674 if (!g_strcasecmp(who, nick)) { |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1675 char *tmp = g_strdup(r->data); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1676 gaim_chat_remove_user(chat, tmp, reason); |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1677 g_free(tmp); |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1678 break; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1679 } |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1680 r = r->next; |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1681 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1682 return TRUE; |
3751 | 1683 } |
1684 | |
1685 static void | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1686 irc_callback(gpointer data, gint source, GaimInputCondition condition) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1687 { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1688 struct gaim_connection *gc = data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1689 struct irc_data *idata = gc->proto_data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1690 int i = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1691 gchar buf[1024]; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1692 gboolean off; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1693 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1694 i = read(idata->fd, buf, 1024); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1695 if (i <= 0) { |
3074 | 1696 hide_login_progress_error(gc, "Read error"); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1697 signoff(gc); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1698 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1699 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1700 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1701 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1702 memcpy(idata->rxqueue + idata->rxlen, buf, i); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1703 idata->rxlen += i; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1704 idata->rxqueue[idata->rxlen] = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1705 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1706 while (1) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1707 char *d, *e; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1708 int len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1709 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1710 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL)) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1711 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1712 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1713 len = e - idata->rxqueue + 1; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1714 d = g_strndup(idata->rxqueue, len); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1715 g_strchomp(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1716 debug_printf("IRC S: %s\n", d); |
3707 | 1717 |
3708 | 1718 /* REMOVE ME BEFORE SUBMIT! */ |
3751 | 1719 /*fprintf(stderr, "IRC S: %s\n", d);*/ |
3708 | 1720 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1721 idata->rxlen -= len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1722 if (idata->rxlen) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1723 char *tmp = g_strdup(e + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1724 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1725 idata->rxqueue = tmp; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1726 } else { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1727 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1728 idata->rxqueue = NULL; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1729 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1730 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1731 off = irc_parse(gc, d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1732 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1733 g_free(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1734 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1735 if (off) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1736 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1737 } |
2086 | 1738 } |
1739 | |
3751 | 1740 static void |
1741 irc_login_callback(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 1742 { |
1743 struct gaim_connection *gc = data; | |
1744 struct irc_data *idata; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1745 char hostname[256]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1746 char buf[IRC_BUF_LEN]; |
3751 | 1747 char *test; |
1748 GError *err = NULL; | |
1749 | |
2086 | 1750 if (!g_slist_find(connections, gc)) { |
1751 close(source); | |
1752 return; | |
1753 } | |
1754 | |
1755 idata = gc->proto_data; | |
1756 | |
4456 | 1757 if (source < 0) { |
2086 | 1758 hide_login_progress(gc, "Write error"); |
1759 signoff(gc); | |
1760 return; | |
1761 } | |
4452 | 1762 idata->fd = source; |
3751 | 1763 |
1764 /* Try a quick conversion to see if the specified encoding is OK */ | |
4491 | 1765 test = g_convert("test", strlen("test"), gc->account->proto_opt[USEROPT_CHARSET], |
3751 | 1766 "UTF-8", NULL, NULL, &err); |
1767 if (err) { | |
1768 debug_printf("Couldn't initialize %s for IRC charset conversion, using ISO-8859-1\n", | |
4491 | 1769 gc->account->proto_opt[USEROPT_CHARSET]); |
1770 strcpy(gc->account->proto_opt[USEROPT_CHARSET], "ISO-8859-1"); | |
3751 | 1771 } |
1772 | |
4223 | 1773 g_free(test); |
1774 | |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1775 gethostname(hostname, sizeof(hostname) - 1); |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1776 hostname[sizeof(hostname) - 1] = 0; |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1777 if (!*hostname) |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1778 g_snprintf(hostname, sizeof(hostname), "localhost"); |
3789 | 1779 |
4491 | 1780 if (*gc->account->password) { |
1781 g_snprintf(buf, sizeof(buf), "PASS %s\r\n", gc->account->password); | |
3789 | 1782 |
1783 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { | |
1784 hide_login_progress(gc, "Write error"); | |
1785 signoff(gc); | |
1786 return; | |
1787 } | |
1788 } | |
1789 | |
3562 | 1790 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n", |
3452 | 1791 g_get_user_name(), hostname, |
4491 | 1792 gc->account->proto_opt[USEROPT_SERV], |
1793 gc->account->alias && strlen(gc->account->alias) ? gc->account->alias : "gaim"); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1794 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1795 hide_login_progress(gc, "Write error"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1796 signoff(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1797 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1798 } |
2086 | 1799 |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1800 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", gc->username); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1801 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
2086 | 1802 hide_login_progress(gc, "Write error"); |
1803 signoff(gc); | |
1804 return; | |
1805 } | |
1806 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1807 gc->inpa = gaim_input_add(idata->fd, GAIM_INPUT_READ, irc_callback, gc); |
2086 | 1808 } |
1809 | |
3751 | 1810 static void |
4491 | 1811 irc_login(struct gaim_account *account) |
2086 | 1812 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1813 char buf[IRC_BUF_LEN]; |
4422 | 1814 int rc; |
2086 | 1815 |
4491 | 1816 struct gaim_connection *gc = new_gaim_conn(account); |
2086 | 1817 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1818 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1819 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1820 |
2086 | 1821 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1822 set_login_progress(gc, 2, buf); | |
1823 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1824 idata->chantypes = g_strdup("#&!+"); |
3452 | 1825 idata->chanmodes = g_strdup("beI,k,lnt"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1826 idata->nickmodes = g_strdup("ohv"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1827 idata->str = g_string_new(""); |
4422 | 1828 idata->fd = -1; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1829 |
4634 | 1830 rc = proxy_connect(account, account->proto_opt[USEROPT_SERV], |
4491 | 1831 account->proto_opt[USEROPT_PORT][0] ? |
1832 atoi(account->proto_opt[USEROPT_PORT]) : 6667, | |
1833 irc_login_callback, gc); | |
1834 if (!account->gc || (rc != 0)) { | |
2086 | 1835 hide_login_progress(gc, "Unable to create socket"); |
1836 signoff(gc); | |
1837 return; | |
1838 } | |
1839 } | |
1840 | |
3751 | 1841 static void |
1842 irc_close(struct gaim_connection *gc) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1843 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1844 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
3618 | 1845 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1846 gchar buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1847 |
3452 | 1848 if (idata->str->len > 0) { |
1849 g_snprintf(buf, sizeof(buf), "QUIT :%s\r\n", idata->str->str); | |
1850 } else { | |
1851 g_snprintf(buf, sizeof(buf), | |
1852 "QUIT :Download Gaim [%s]\r\n", WEBSITE); | |
1853 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1854 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1855 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1856 if (idata->rxqueue) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1857 g_free(idata->rxqueue); |
3618 | 1858 |
3619 | 1859 idata->rxqueue = NULL; |
1860 idata->rxlen = 0; | |
1861 | |
3618 | 1862 /* Kill any existing transfers */ |
1863 while (idata->file_transfers) { | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1864 struct gaim_xfer *xfer; |
3618 | 1865 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1866 xfer = (struct gaim_xfer *)idata->file_transfers->data; |
3618 | 1867 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1868 gaim_xfer_end(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
1869 gaim_xfer_destroy(xfer); |
3618 | 1870 |
3708 | 1871 idata->file_transfers = idata->file_transfers->next; |
3618 | 1872 } |
3619 | 1873 idata->file_transfers = NULL; |
3618 | 1874 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1875 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1876 g_free(idata->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1877 g_free(idata->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1878 g_free(idata->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1879 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1880 g_string_free(idata->str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1881 if (idata->liststr) |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1882 g_string_free(idata->liststr, TRUE); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1883 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1884 if (idata->timer) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1885 g_source_remove(idata->timer); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1886 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1887 if (gc->inpa) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1888 gaim_input_remove(gc->inpa); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1889 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1890 close(idata->fd); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1891 g_free(gc->proto_data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1892 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1893 |
3751 | 1894 static void |
1895 set_mode_3(struct gaim_connection *gc, char *who, int sign, int mode, | |
3708 | 1896 int start, int end, char *word[]) |
2086 | 1897 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1898 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1899 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1900 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1901 int i = start; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1902 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1903 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1904 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1905 switch (left) { |
3708 | 1906 case 0: |
1907 return; | |
1908 case 1: | |
1909 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", | |
1910 who, sign, mode, word[i]); | |
1911 i += 1; | |
1912 break; | |
1913 case 2: | |
1914 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", | |
1915 who, sign, mode, mode, word[i], word[i + 1]); | |
1916 i += 2; | |
1917 break; | |
1918 default: | |
1919 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", | |
1920 who, sign, mode, mode, mode, | |
1921 word[i], word[i + 1], word[i + 2]); | |
1922 i += 2; | |
1923 break; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1924 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1925 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1926 if (left < 3) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1927 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1928 } |
2086 | 1929 } |
1930 | |
3751 | 1931 static void |
1932 set_mode_6(struct gaim_connection *gc, char *who, int sign, int mode, | |
3708 | 1933 int start, int end, char *word[]) |
2086 | 1934 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1935 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1936 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1937 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1938 int i = start; |
2086 | 1939 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1940 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1941 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1942 switch (left) { |
3708 | 1943 case 0: |
1944 return; | |
1945 case 1: | |
1946 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", | |
1947 who, sign, mode, word[i]); | |
1948 i += 1; | |
1949 break; | |
1950 case 2: | |
1951 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", | |
1952 who, sign, mode, mode, word[i], word[i + 1]); | |
1953 i += 2; | |
1954 break; | |
1955 case 3: | |
1956 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", | |
1957 who, sign, mode, mode, mode, | |
1958 word[i], word[i + 1], word[i + 2]); | |
1959 i += 3; | |
1960 break; | |
1961 case 4: | |
1962 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c %s %s %s %s\r\n", | |
1963 who, sign, mode, mode, mode, mode, | |
1964 word[i], word[i + 1], word[i + 2], word[i + 3]); | |
1965 i += 4; | |
1966 break; | |
1967 case 5: | |
1968 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c %s %s %s %s %s\r\n", | |
1969 who, sign, mode, mode, mode, mode, mode, | |
1970 word[i], word[i + 1], word[i + 2], | |
1971 word[i + 3], word[i + 4]); | |
1972 i += 5; | |
1973 break; | |
1974 default: | |
1975 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c%c %s %s %s %s %s %s\r\n", | |
1976 who, sign, mode, mode, mode, mode, mode, mode, | |
1977 word[i], word[i + 1], word[i + 2], | |
1978 word[i + 3], word[i + 4], word[i + 5]); | |
1979 i += 6; | |
1980 break; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1981 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1982 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1983 if (left < 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1984 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1985 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1986 } |
2086 | 1987 |
3751 | 1988 static void |
1989 set_mode(struct gaim_connection *gc, char *who, int sign, int mode, char *word[]) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1990 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1991 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1992 int i = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1993 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1994 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1995 if (!*word[i]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1996 if (i == 2) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1997 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1998 if (id->six_modes) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1999 set_mode_6(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2000 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2001 set_mode_3(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2002 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2003 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2004 i++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2005 } |
2086 | 2006 } |
2007 | |
3751 | 2008 static void |
2009 set_chan_mode(struct gaim_connection *gc, char *chan, char *mode_str) | |
3452 | 2010 { |
2011 struct irc_data *id = gc->proto_data; | |
2012 char buf[IRC_BUF_LEN]; | |
2013 | |
2014 if ((mode_str[0] == '-') || (mode_str[0] == '+')) { | |
2015 g_snprintf(buf, sizeof(buf), "MODE %s %s\r\n", chan, mode_str); | |
2016 irc_write(id->fd, buf, strlen(buf)); | |
2017 } | |
2018 } | |
2019 | |
3751 | 2020 static int |
2021 handle_command(struct gaim_connection *gc, char *who, char *what) | |
2086 | 2022 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2023 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2024 char pdibuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2025 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
3029 | 2026 char *tmp = g_strdup(what); |
2027 GString *str = encode_html(tmp); | |
3751 | 2028 char *intl; |
2029 int len; | |
3029 | 2030 struct dcc_chat *dccchat = find_dcc_chat(gc, who); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2031 struct irc_data *id = gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2032 |
3029 | 2033 g_free(tmp); |
3030 | 2034 what = str->str; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2035 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2036 if (*what != '/') { |
3029 | 2037 if (dccchat) { |
3751 | 2038 intl = irc_send_convert(gc, what, sizeof(buf), &len); |
2039 g_snprintf(buf, sizeof(buf), "%s\r\n", intl); | |
2040 g_free(intl); | |
3029 | 2041 irc_write(dccchat->fd, buf, strlen(buf)); |
2042 g_string_free(str, TRUE); | |
2043 return 1; | |
2044 } | |
3751 | 2045 irc_send_privmsg (gc, who, what, TRUE); |
3029 | 2046 g_string_free(str, TRUE); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2047 return 1; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2048 } |
3029 | 2049 |
3033 | 2050 process_data_init(pdibuf, what + 1, word, word_eol, TRUE); |
2051 g_string_free(str, FALSE); | |
3029 | 2052 if (!g_strcasecmp(pdibuf, "ME")) { |
2053 if (dccchat) { | |
3751 | 2054 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len); |
2055 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", intl); | |
2056 g_free(intl); | |
3029 | 2057 irc_write(dccchat->fd, buf, strlen(buf)); |
3033 | 2058 g_free(what); |
3029 | 2059 return 1; |
2060 } | |
3735 | 2061 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001", word_eol[2]); |
3751 | 2062 irc_send_privmsg (gc, who, buf, FALSE); |
3033 | 2063 g_free(what); |
2304
15fb364935ec
[gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2064 return 1; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2065 } else if (!g_strcasecmp(pdibuf, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2066 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2067 g_snprintf(buf, sizeof(buf), "INVITE %s\r\n", word_eol[2]); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2068 irc_write(id->fd, buf, strlen(buf)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2069 } else if (!g_strcasecmp(pdibuf, "TOPIC")) { |
3033 | 2070 if (!*word_eol[2]) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2071 struct gaim_conversation *c; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2072 struct gaim_chat *chat; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2073 |
3501 | 2074 c = irc_find_chat(gc, who); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2075 chat = GAIM_CHAT(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2076 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2077 g_snprintf(buf, sizeof(buf), _("Topic for %s is %s"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2078 who, (gaim_chat_get_topic(chat) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2079 ? gaim_chat_get_topic(chat) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2080 : "(no topic set)")); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2081 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2082 gaim_conversation_write(c, NULL, buf, -1, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2083 WFLAG_SYSTEM | WFLAG_NOLOG, time(NULL)); |
3501 | 2084 } else { |
3751 | 2085 /* This could be too long */ |
2086 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len); | |
2087 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, intl); | |
2088 g_free(intl); | |
3501 | 2089 irc_write(id->fd, buf, strlen(buf)); |
3033 | 2090 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2091 } else if (!g_strcasecmp(pdibuf, "NICK")) { |
3033 | 2092 if (!*word_eol[2]) { |
2093 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2094 return -EINVAL; |
3033 | 2095 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2096 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2097 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2098 } else if (!g_strcasecmp(pdibuf, "OP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2099 set_mode(gc, who, '+', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2100 } else if (!g_strcasecmp(pdibuf, "DEOP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2101 set_mode(gc, who, '-', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2102 } else if (!g_strcasecmp(pdibuf, "VOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2103 set_mode(gc, who, '+', 'v', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2104 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2105 set_mode(gc, who, '-', 'v', word); |
3452 | 2106 } else if (!g_strcasecmp(pdibuf, "MODE")) { |
2107 char *chan = who; | |
2108 set_chan_mode(gc, chan, word_eol[2]); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2109 } else if (!g_strcasecmp(pdibuf, "QUOTE")) { |
3033 | 2110 if (!*word_eol[2]) { |
2111 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2112 return -EINVAL; |
3033 | 2113 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2114 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2115 irc_write(id->fd, buf, strlen(buf)); |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2116 } else if (!g_strcasecmp(pdibuf, "SAY")) { |
3033 | 2117 if (!*word_eol[2]) { |
2118 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2119 return -EINVAL; |
3033 | 2120 } |
3751 | 2121 irc_send_privmsg (gc, who, word_eol[2], TRUE); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2122 return 1; |
2302
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
2123 } else if (!g_strcasecmp(pdibuf, "MSG")) { |
3033 | 2124 if (!*word[2]) { |
2125 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2126 return -EINVAL; |
3033 | 2127 } |
2128 if (!*word_eol[3]) { | |
2129 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2130 return -EINVAL; |
3033 | 2131 } |
3751 | 2132 irc_send_privmsg (gc, word[2], word_eol[3], TRUE); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2133 } else if (!g_strcasecmp(pdibuf, "KICK")) { |
3033 | 2134 if (!*word[2]) { |
2135 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2136 return -EINVAL; |
3033 | 2137 } |
3751 | 2138 if (*word_eol[3]) { |
2139 intl = irc_send_convert(gc, word_eol[3], sizeof(buf), &len); | |
2140 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], intl); | |
2141 g_free(intl); | |
2142 } else | |
2298
57da45349e50
[gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2295
diff
changeset
|
2143 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2144 irc_write(id->fd, buf, strlen(buf)); |
2801 | 2145 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) { |
3033 | 2146 if (!*word[2]) { |
2147 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2148 return -EINVAL; |
3033 | 2149 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2150 if (*word[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2151 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2152 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2153 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2154 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2155 } else if (!g_strcasecmp(pdibuf, "PART")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2156 char *chan = *word[2] ? word[2] : who; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2157 char *reason = word_eol[3]; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2158 struct gaim_conversation *c; |
3033 | 2159 if (!is_channel(gc, chan)) { |
2160 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2161 return -EINVAL; |
3033 | 2162 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2163 c = irc_find_chat(gc, chan); |
3751 | 2164 if (*reason) { |
2165 intl = irc_send_convert(gc, reason, sizeof(buf), &len); | |
2166 g_snprintf(buf, sizeof(buf), "PART %s :%s\r\n", chan, intl); | |
2167 g_free(intl); | |
2168 } else | |
2169 g_snprintf(buf, sizeof(buf), "PART %s\r\n", chan); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2170 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2171 if (c) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2172 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
4491 | 2173 gaim_conversation_set_account(c, NULL); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2174 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); |
3707 | 2175 do_error_dialog(buf, _("IRC Part"), GAIM_INFO); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2176 } |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2177 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2178 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2179 irc_write(id->fd, buf, strlen(buf)); |
3707 | 2180 } else if (!g_strcasecmp(pdibuf, "WHOWAS")) { |
2181 g_snprintf(buf, sizeof(buf), "WHOWAS %s\r\n", word_eol[2]); | |
2182 irc_write(id->fd, buf, strlen(buf)); | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2183 } else if (!g_strcasecmp(pdibuf, "LIST")) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2184 g_snprintf(buf, sizeof(buf), "LIST\r\n"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2185 irc_write(id->fd, buf, strlen(buf)); |
3452 | 2186 } else if (!g_strcasecmp(pdibuf, "QUIT")) { |
2187 char *reason = word_eol[2]; | |
2188 id->str = g_string_insert(id->str, 0, reason); | |
2189 do_quit(); | |
2190 } else if (!g_strcasecmp(pdibuf, "VERSION")) { | |
2191 g_snprintf(buf, sizeof(buf), "VERSION\r\n"); | |
2192 irc_write(id->fd, buf, strlen(buf)); | |
2193 } else if (!g_strcasecmp(pdibuf, "W")) { | |
2194 g_snprintf(buf, sizeof(buf), "WHO *\r\n"); | |
2195 irc_write(id->fd, buf, strlen(buf)); | |
3707 | 2196 } else if (!g_strcasecmp(pdibuf, "REHASH")) { |
2197 g_snprintf(buf, sizeof(buf), "REHASH\r\n"); | |
2198 irc_write(id->fd, buf, strlen(buf)); | |
2199 } else if (!g_strcasecmp(pdibuf, "RESTART")) { | |
2200 g_snprintf(buf, sizeof(buf), "RESTART\r\n"); | |
2201 irc_write(id->fd, buf, strlen(buf)); | |
2202 } else if (!g_strcasecmp(pdibuf, "CTCP")) { | |
2203 if (!g_strcasecmp(word[2], "CLIENTINFO")) { | |
2204 if (word[3]) | |
2205 irc_ctcp_clientinfo(gc, word[3]); | |
2206 } else if (!g_strcasecmp(word[2], "USERINFO")) { | |
2207 if (word[3]) | |
2208 irc_ctcp_userinfo(gc, word[3]); | |
2209 } else if (!g_strcasecmp(word[2], "VERSION")) { | |
2210 if (word[3]) | |
2211 irc_ctcp_version(gc, word[3]); | |
3735 | 2212 |
2213 } else if (!g_strcasecmp(word[2], "PING")) { | |
2214 if (word[3]) | |
2215 irc_ctcp_ping(gc, word[3]); | |
3707 | 2216 } |
2217 } else if (!g_strcasecmp(pdibuf, "DCC")) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2218 struct gaim_conversation *c = NULL; |
3707 | 2219 if (!g_strcasecmp(word[2], "CHAT")) { |
2220 if (word[3]) | |
2221 irc_start_chat(gc, word[3]); | |
2222 | |
2223 if (is_channel(gc, who)) { | |
2224 c = irc_find_chat(gc, who); | |
2225 } else { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2226 c = gaim_find_conversation(who); |
3707 | 2227 } |
2228 if (c) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2229 gaim_conversation_write(c, NULL, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2230 _("<I>Requesting DCC CHAT</I>"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2231 -1, WFLAG_SYSTEM, time(NULL)); |
3707 | 2232 } |
2233 } | |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2234 } else if (!g_strcasecmp(pdibuf, "HELP")) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2235 struct gaim_conversation *c = NULL; |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2236 if (is_channel(gc, who)) { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2237 c = irc_find_chat(gc, who); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2238 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2239 c = gaim_find_conversation(who); |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
2240 } |
3033 | 2241 if (!c) { |
2242 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2243 return -EINVAL; |
3033 | 2244 } |
3707 | 2245 if (!g_strcasecmp(word[2], "OPER")) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2246 gaim_conversation_write(c, NULL, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2247 _("<B>Operator commands:<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2248 "REHASH RESTART</B>"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2249 -1, WFLAG_NOLOG, time(NULL)); |
3707 | 2250 } else if (!g_strcasecmp(word[2], "CTCP")) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2251 gaim_conversation_write(c, NULL, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2252 _("<B>CTCP commands:<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2253 "CLIENTINFO <nick><BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2254 "USERINFO <nick><BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2255 "VERSION <nick><BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2256 "PING <nick></B><BR>"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2257 -1, WFLAG_NOLOG, time(NULL)); |
3707 | 2258 } else if (!g_strcasecmp(word[2], "DCC")) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2259 gaim_conversation_write(c, NULL, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2260 _("<B>DCC commands:<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2261 "CHAT <nick></B>"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2262 -1, WFLAG_NOLOG, time(NULL)); |
3707 | 2263 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2264 gaim_conversation_write(c, NULL, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2265 _("<B>Currently supported commands:<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2266 "WHOIS INVITE NICK LIST<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2267 "JOIN PART TOPIC KICK<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2268 "OP DEOP VOICE DEVOICE<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2269 "ME MSG QUOTE SAY QUIT<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2270 "MODE VERSION W WHOWAS<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2271 "Type /HELP OPER for operator commands<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2272 "Type /HELP CTCP for CTCP commands<BR>" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2273 "Type /HELP DCC for DCC commands"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2274 -1, WFLAG_NOLOG, time(NULL)); |
3707 | 2275 } |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2276 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2277 struct gaim_conversation *c = NULL; |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2278 if (is_channel(gc, who)) { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2279 c = irc_find_chat(gc, who); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2280 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2281 c = gaim_find_conversation(who); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2282 } |
3033 | 2283 if (!c) { |
2284 g_free(what); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
2285 return -EINVAL; |
3033 | 2286 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2287 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2288 gaim_conversation_write(c, NULL, _("<B>Unknown command</B>"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2289 -1, WFLAG_NOLOG, time(NULL)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2290 } |
3033 | 2291 g_free(what); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2292 return 0; |
2086 | 2293 } |
2294 | |
3751 | 2295 static int |
2296 send_msg(struct gaim_connection *gc, char *who, char *what) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2297 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2298 char *cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2299 if (cr) { |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2300 int ret = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2301 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2302 if (cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2303 *cr = 0; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2304 ret = handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2305 if (!cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2306 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2307 what = cr + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2308 if (!*what) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2309 break; |
2295
24dc9ce95127
[gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2294
diff
changeset
|
2310 *cr = '\n'; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2311 cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2312 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2313 return ret; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2314 } else |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2315 return handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2316 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2317 |
3751 | 2318 static void |
2319 irc_chat_invite(struct gaim_connection *gc, int idn, const char *message, const char *name) { | |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2320 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2321 struct irc_data *id = gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2322 struct gaim_conversation *c = gaim_find_chat(gc, idn); |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2323 g_snprintf(buf, sizeof(buf), "INVITE %s %s\r\n", name, c->name); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2324 irc_write(id->fd, buf, strlen(buf)); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2325 } |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2326 |
3751 | 2327 static int |
2328 irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2329 { |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2330 if (*who == '@' || *who == '%' || *who == '+') |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2331 return send_msg(gc, who + 1, what); |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2332 return send_msg(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2333 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2334 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2335 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */ |
3751 | 2336 static void |
2337 irc_add_buddy(struct gaim_connection *gc, const char *who) {} | |
2338 static void | |
2339 irc_remove_buddy(struct gaim_connection *gc, char *who, char *group) {} | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2340 |
3751 | 2341 static GList * |
2342 irc_chat_info(struct gaim_connection *gc) | |
2086 | 2343 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2344 GList *m = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2345 struct proto_chat_entry *pce; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2346 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2347 pce = g_new0(struct proto_chat_entry, 1); |
2466
f8eb5f120603
[gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2459
diff
changeset
|
2348 pce->label = _("Channel:"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2349 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2350 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2351 pce = g_new0(struct proto_chat_entry, 1); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2352 pce->label = _("Password:"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2353 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2354 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2355 return m; |
2086 | 2356 } |
2357 | |
3751 | 2358 static void |
2359 irc_join_chat(struct gaim_connection *gc, GList *data) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2360 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2361 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2362 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2363 char *name, *pass; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2364 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2365 if (!data) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2366 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2367 name = data->data; |
2299
b5b7dece5249
[gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2298
diff
changeset
|
2368 if (data->next) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2369 pass = data->next->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2370 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", name, pass); |
2299
b5b7dece5249
[gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2298
diff
changeset
|
2371 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2372 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2373 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2374 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2375 |
3751 | 2376 static void |
2377 irc_chat_leave(struct gaim_connection *gc, int id) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2378 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2379 struct irc_data *idata = gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2380 struct gaim_conversation *c = gaim_find_chat(gc, id); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2381 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2382 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2383 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2384 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2385 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2386 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2387 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2388 |
3751 | 2389 static int |
2390 irc_chat_send(struct gaim_connection *gc, int id, char *what) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2391 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2392 struct gaim_conversation *c = gaim_find_chat(gc, id); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2393 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2394 return -EINVAL; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
2395 if (send_msg(gc, c->name, what) > 0) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2396 serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2397 gc->displayname, 0, what, time(NULL)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2398 return 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2399 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2400 |
3751 | 2401 static GList * |
2402 irc_away_states(struct gaim_connection *gc) | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2403 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2404 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2405 } |
2086 | 2406 |
3751 | 2407 static void |
2408 irc_set_away(struct gaim_connection *gc, char *state, char *msg) | |
2086 | 2409 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2410 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2411 char buf[IRC_BUF_LEN]; |
2086 | 2412 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4067
diff
changeset
|
2413 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4067
diff
changeset
|
2414 g_free(gc->away); |
2394
579f8d4347ad
[gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
2415 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4067
diff
changeset
|
2416 } |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
2417 |
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
2418 if (msg) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2419 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4067
diff
changeset
|
2420 gc->away = g_strdup(msg); |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
2421 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2422 g_snprintf(buf, sizeof(buf), "AWAY\r\n"); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4067
diff
changeset
|
2423 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2424 irc_write(idata->fd, buf, strlen(buf)); |
2086 | 2425 } |
2426 | |
4687 | 2427 static const char * |
2428 irc_list_icon(struct gaim_account *a, struct buddy *b) | |
2086 | 2429 { |
4687 | 2430 return "irc"; |
2086 | 2431 } |
2432 | |
3751 | 2433 static int |
2434 getlocalip(char *ip) /* Thanks, libfaim */ | |
3029 | 2435 { |
2436 struct hostent *hptr; | |
2437 char localhost[129]; | |
2438 long unsigned add; | |
2439 | |
2440 /* XXX if available, use getaddrinfo() */ | |
2441 /* XXX allow client to specify which IP to use for multihomed boxes */ | |
2442 | |
2443 if (gethostname(localhost, 128) < 0) | |
2444 return -1; | |
2445 | |
2446 if (!(hptr = gethostbyname(localhost))) | |
2447 return -1; | |
2448 | |
2449 memcpy(&add, hptr->h_addr_list[0], 4); | |
2450 add = htonl(add); | |
2451 g_snprintf(ip, 11, "%lu", add); | |
2452 | |
2453 return 0; | |
2454 } | |
2455 | |
3751 | 2456 static void |
2457 dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition) | |
3029 | 2458 { |
2459 struct dcc_chat *chat = data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2460 struct gaim_conversation *convo; |
3029 | 2461 char buf[128]; |
2462 struct sockaddr_in addr; | |
2463 int addrlen = sizeof (addr); | |
2464 addr.sin_family = AF_INET; | |
2465 addr.sin_port = htons (chat->port); | |
2466 addr.sin_addr.s_addr = INADDR_ANY; | |
2467 chat->fd = accept (chat->fd, (struct sockaddr *) (&addr), &addrlen); | |
3707 | 2468 if (!chat->fd) { |
3730 | 2469 dcc_chat_cancel (chat); |
4491 | 2470 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4456
diff
changeset
|
2471 chat->nick); |
3707 | 2472 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), |
2473 chat->nick); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2474 gaim_conversation_write(convo, NULL, buf, -1, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2475 WFLAG_SYSTEM, time(NULL)); |
3707 | 2476 return; |
2477 } | |
3029 | 2478 chat->inpa = |
2479 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat); | |
4491 | 2480 convo = gaim_conversation_new(GAIM_CONV_IM, chat->gc->account, chat->nick); |
4221 | 2481 g_snprintf (buf, sizeof buf, _("DCC Chat with %s established"), |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2482 chat->nick); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
2483 gaim_conversation_write(convo, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
3029 | 2484 debug_printf ("Chat with %s established\n", chat->nick); |
2485 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
2486 } | |
3665
7cb6cf20ed7d
[gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3633
diff
changeset
|
2487 #if 0 |
3751 | 2488 static void |
2489 irc_ask_send_file(struct gaim_connection *gc, char *destsn) { | |
3708 | 2490 struct irc_data *id = (struct irc_data *)gc->proto_data; |
2491 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1); | |
2492 char *localip = (char *)malloc(12); | |
3622 | 2493 |
3708 | 2494 if (getlocalip(localip) == -1) { |
2495 free(localip); | |
2496 return; | |
2497 } | |
3616 | 2498 |
3708 | 2499 ift->type = IFT_SENDFILE_OUT; |
2500 ift->sn = g_strdup(destsn); | |
2501 ift->gc = gc; | |
2502 snprintf(ift->ip, sizeof(ift->ip), "%s", localip); | |
2503 id->file_transfers = g_slist_append(id->file_transfers, ift); | |
3622 | 2504 |
3708 | 2505 ift->xfer = transfer_out_add(gc, ift->sn); |
3616 | 2506 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2507 |
3751 | 2508 static struct |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2509 irc_file_transfer *find_ift_by_xfer(struct gaim_connection *gc, |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2510 struct file_transfer *xfer) { |
3616 | 2511 |
3708 | 2512 GSList *g = ((struct irc_data *)gc->proto_data)->file_transfers; |
2513 struct irc_file_transfer *f = NULL; | |
3616 | 2514 |
3708 | 2515 while (g) { |
2516 f = (struct irc_file_transfer *)g->data; | |
2517 if (f->xfer == xfer) | |
2518 break; | |
2519 g = g->next; | |
2520 f = NULL; | |
2521 } | |
3616 | 2522 |
3708 | 2523 return f; |
3616 | 2524 } |
2525 | |
3751 | 2526 static void |
2527 irc_file_transfer_data_chunk(struct gaim_connection *gc, struct file_transfer *xfer, const char *data, int len) { | |
3616 | 2528 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); |
2529 guint32 pos; | |
2530 | |
2531 ift->cur += len; | |
2532 pos = htonl(ift->cur); | |
2533 write(ift->fd, (char *)&pos, 4); | |
2534 | |
3623 | 2535 // FIXME: You should check to verify that they received the data when |
2536 // you are sending a file ... | |
3616 | 2537 } |
2538 | |
3751 | 2539 static void |
2540 irc_file_transfer_cancel (struct gaim_connection *gc, struct file_transfer *xfer) { | |
3616 | 2541 struct irc_data *id = (struct irc_data *)gc->proto_data; |
2542 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2543 | |
2544 printf("Our shit got canceled, yo!\n"); | |
2545 | |
2546 /* Remove the FT from our list of transfers */ | |
2547 id->file_transfers = g_slist_remove(id->file_transfers, ift); | |
2548 | |
2549 gaim_input_remove(ift->watcher); | |
2550 | |
2551 /* Close our FT because we're done */ | |
2552 close(ift->fd); | |
2553 | |
2554 g_free(ift->sn); | |
2555 g_free(ift->name); | |
2556 | |
2557 g_free(ift); | |
2558 } | |
2559 | |
3751 | 2560 static void |
2561 irc_file_transfer_done(struct gaim_connection *gc, struct file_transfer *xfer) { | |
3616 | 2562 struct irc_data *id = (struct irc_data *)gc->proto_data; |
2563 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2564 | |
2565 | |
2566 printf("Our shit be done, yo.\n"); | |
2567 | |
2568 /* Remove the FT from our list of transfers */ | |
2569 id->file_transfers = g_slist_remove(id->file_transfers, ift); | |
2570 | |
2571 gaim_input_remove(ift->watcher); | |
2572 | |
2573 /* Close our FT because we're done */ | |
2574 close(ift->fd); | |
2575 | |
2576 g_free(ift->sn); | |
2577 g_free(ift->name); | |
2578 | |
2579 g_free(ift); | |
2580 } | |
2581 | |
3751 | 2582 static void |
2583 irc_file_transfer_out (struct gaim_connection *gc, struct file_transfer *xfer, const char *name, int totfiles, int totsize) { | |
3622 | 2584 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); |
2585 struct sockaddr_in addr; | |
2586 char buf[IRC_BUF_LEN]; | |
2587 int len; | |
2588 | |
2589 | |
2590 ift->fd = socket (AF_INET, SOCK_STREAM, 0); | |
2591 addr.sin_family = AF_INET; | |
2592 addr.sin_port = 0; | |
2593 addr.sin_addr.s_addr = INADDR_ANY; | |
2594 bind (ift->fd, (struct sockaddr *) &addr, sizeof(addr)); | |
2595 listen(ift->fd, 1); | |
2596 | |
2597 len = sizeof(addr); | |
2598 getsockname (ift->fd, (struct sockaddr *) &addr, &len); | |
2599 | |
2600 ift->port = ntohs(addr.sin_port); | |
2601 | |
2602 ift->watcher = gaim_input_add (ift->fd, GAIM_INPUT_READ, dcc_send_callback, ift); | |
3633 | 2603 printf("watcher is %d\n", ift->watcher); |
3622 | 2604 |
2605 snprintf(buf, sizeof(buf), "\001DCC SEND %s %s %d %d\001\n", name, ift->ip, ift->port, totsize); | |
2606 printf("Trying: %s\n", buf); | |
2607 irc_send_im (gc, ift->sn, buf, -1, 0); | |
2608 } | |
2609 | |
3751 | 2610 static void |
2611 irc_file_transfer_in(struct gaim_connection *gc, | |
3708 | 2612 struct file_transfer *xfer, int offset) { |
3616 | 2613 |
2614 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2615 | |
2616 ift->xfer = xfer; | |
4634 | 2617 proxy_connect(gc->account, ift->ip, ift->port, dcc_recv_callback, ift); |
3616 | 2618 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2619 #endif |
3616 | 2620 |
3751 | 2621 static void |
2622 irc_ctcp_clientinfo(struct gaim_connection *gc, char *who) | |
2623 { | |
2624 char buf[IRC_BUF_LEN]; | |
2625 | |
2626 snprintf (buf, sizeof buf, "\001CLIENTINFO\001"); | |
2627 irc_send_privmsg(gc, who, buf, FALSE); | |
2628 } | |
2629 | |
2630 static void | |
2631 irc_ctcp_userinfo(struct gaim_connection *gc, char *who) | |
3707 | 2632 { |
3735 | 2633 char buf[IRC_BUF_LEN]; |
2634 | |
3751 | 2635 snprintf (buf, sizeof buf, "\001USERINFO\001"); |
2636 irc_send_privmsg(gc, who, buf, FALSE); | |
3707 | 2637 } |
2638 | |
3751 | 2639 static void |
2640 irc_ctcp_version(struct gaim_connection *gc, char *who) | |
3707 | 2641 { |
3735 | 2642 char buf[IRC_BUF_LEN]; |
2643 | |
3751 | 2644 snprintf (buf, sizeof buf, "\001VERSION\001"); |
2645 irc_send_privmsg(gc, who, buf, FALSE); | |
3707 | 2646 } |
2647 | |
3751 | 2648 static void |
2649 irc_ctcp_ping(struct gaim_connection *gc, char *who) | |
3707 | 2650 { |
3735 | 2651 char buf[IRC_BUF_LEN]; |
2652 | |
3867 | 2653 g_snprintf (buf, sizeof(buf), "\001PING %ld\001", time(NULL)); |
3751 | 2654 irc_send_privmsg(gc, who, buf, FALSE); |
3735 | 2655 } |
2656 | |
3751 | 2657 static void |
2658 irc_send_notice(struct gaim_connection *gc, char *who, char *what) | |
3735 | 2659 { |
3751 | 2660 char buf[IRC_BUF_LEN], *intl; |
3735 | 2661 struct irc_data *id = gc->proto_data; |
3751 | 2662 int len; |
2663 | |
2664 intl = irc_send_convert(gc, what, 501, &len); | |
2665 g_snprintf(buf, sizeof(buf), "NOTICE %s :%s\r\n", who, intl); | |
2666 g_free(intl); | |
3735 | 2667 irc_write(id->fd, buf, strlen(buf)); |
2668 } | |
2669 | |
3751 | 2670 /* Don't call this guy with fragment = 1 for anything but straight |
2671 * up privmsgs. (no CTCP/whatever) It's still dangerous for CTCPs | |
2672 * (it might not include the trailing \001), but I think this behavior | |
2673 * is generally better than not fragmenting at all on lots of our | |
2674 * packets. */ | |
2675 /* From RFC2812: | |
2676 * IRC messages are always lines of characters terminated with a CR-LF | |
2677 * (Carriage Return - Line Feed) pair, and these messages SHALL NOT | |
2678 * exceed 512 characters in length, counting all characters including | |
2679 * the trailing CR-LF. Thus, there are 510 characters maximum allowed | |
2680 * for the command and its parameters. */ | |
2681 /* So apparently that includes all the inter-server crap, which is up | |
2682 * to NINETY-THREE chars on dancer, which seems to be a pretty liberal | |
2683 * ircd. My rough calculation for now is ":<nick>!~<user>@<host> ", | |
2684 * where <host> is a max of an (uncalculated) 63 chars. Thanks to | |
2685 * trelane and #freenode for giving a hand here. */ | |
2686 static void | |
2687 irc_send_privmsg(struct gaim_connection *gc, char *who, char *what, gboolean fragment) | |
3735 | 2688 { |
3751 | 2689 char buf[IRC_BUF_LEN], *intl; |
3735 | 2690 struct irc_data *id = gc->proto_data; |
3751 | 2691 /* 512 - 12 (for PRIVMSG" "" :""\r\n") - namelen - nicklen - 68 */ |
4491 | 2692 int nicklen = (gc->account->alias && strlen(gc->account->alias)) ? strlen(gc->account->alias) : 4; |
3751 | 2693 int max = 444 - strlen(who) - strlen(g_get_user_name()) - nicklen; |
2694 | |
2695 int len; | |
2696 | |
2697 do { | |
2698 /* the \001 on CTCPs may cause a problem here for some | |
2699 * charsets, but probably not ones people use for IRC. */ | |
2700 intl = irc_send_convert(gc, what, max, &len); | |
2701 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, intl); | |
2702 g_free(intl); | |
2703 irc_write(id->fd, buf, strlen(buf)); | |
2704 what += len; | |
2705 } while (fragment && strlen(what)); | |
3707 | 2706 } |
2707 | |
3751 | 2708 static void |
2709 irc_start_chat(struct gaim_connection *gc, char *who) { | |
3029 | 2710 struct dcc_chat *chat; |
2711 int len; | |
2712 struct sockaddr_in addr; | |
3735 | 2713 char buf[IRC_BUF_LEN]; |
3029 | 2714 |
2715 /* Create a socket */ | |
2716 chat = g_new0 (struct dcc_chat, 1); | |
2717 chat->fd = socket (AF_INET, SOCK_STREAM, 0); | |
2718 chat->gc = gc; | |
2719 g_snprintf (chat->nick, sizeof (chat->nick), "%s", who); | |
2720 if (chat->fd < 0) { | |
3730 | 2721 dcc_chat_cancel (chat); |
3708 | 2722 return; |
3029 | 2723 } |
2724 addr.sin_family = AF_INET; | |
2725 addr.sin_port = 0; | |
2726 addr.sin_addr.s_addr = INADDR_ANY; | |
2727 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr)); | |
2728 listen (chat->fd, 1); | |
2729 len = sizeof (addr); | |
2730 getsockname (chat->fd, (struct sockaddr *) &addr, &len); | |
2731 chat->port = ntohs (addr.sin_port); | |
2732 getlocalip(chat->ip_address); | |
2733 chat->inpa = | |
2734 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, | |
3708 | 2735 chat); |
3630 | 2736 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", |
3708 | 2737 chat->ip_address, chat->port); |
3033 | 2738 irc_send_im (gc, who, buf, -1, 0); |
3029 | 2739 } |
2740 | |
3751 | 2741 static void |
2742 irc_get_info(struct gaim_connection *gc, char *who) | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2743 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2744 struct irc_data *idata = gc->proto_data; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2745 char buf[IRC_BUF_LEN]; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2746 |
2633
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2747 if (*who == '@') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2748 who++; |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2749 if (*who == '%') |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2750 who++; |
2633
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2751 if (*who == '+') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2752 who++; |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2753 |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2754 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2755 irc_write(idata->fd, buf, strlen(buf)); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2756 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2757 |
3751 | 2758 static GList * |
2759 irc_buddy_menu(struct gaim_connection *gc, char *who) | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2760 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2761 GList *m = NULL; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2762 struct proto_buddy_menu *pbm; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2763 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2764 pbm = g_new0(struct proto_buddy_menu, 1); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2765 pbm->label = _("Get Info"); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2766 pbm->callback = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2767 pbm->gc = gc; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2768 m = g_list_append(m, pbm); |
3616 | 2769 |
3029 | 2770 pbm = g_new0(struct proto_buddy_menu, 1); |
2771 pbm->label = _("DCC Chat"); | |
2772 pbm->callback = irc_start_chat; | |
2773 pbm->gc = gc; | |
2774 m = g_list_append(m, pbm); | |
3708 | 2775 /* |
2776 pbm = g_new0(struct proto_buddy_menu, 1); | |
2777 pbm->label = _("DCC Send"); | |
2778 pbm->callback = irc_ask_send_file; | |
2779 pbm->gc = gc; | |
2780 m = g_list_append(m, pbm); | |
2781 */ | |
3707 | 2782 |
2783 pbm = g_new0(struct proto_buddy_menu, 1); | |
2784 pbm->label = _("CTCP ClientInfo"); | |
2785 pbm->callback = irc_ctcp_clientinfo; | |
2786 pbm->gc = gc; | |
2787 m = g_list_append(m, pbm); | |
2788 | |
2789 pbm = g_new0(struct proto_buddy_menu, 1); | |
2790 pbm->label = _("CTCP UserInfo"); | |
2791 pbm->callback = irc_ctcp_userinfo; | |
2792 pbm->gc = gc; | |
2793 m = g_list_append(m, pbm); | |
2794 | |
2795 pbm = g_new0(struct proto_buddy_menu, 1); | |
2796 pbm->label = _("CTCP Version"); | |
2797 pbm->callback = irc_ctcp_version; | |
2798 pbm->gc = gc; | |
2799 m = g_list_append(m, pbm); | |
2800 | |
3735 | 2801 pbm = g_new0(struct proto_buddy_menu, 1); |
2802 pbm->label = _("CTCP Ping"); | |
2803 pbm->callback = irc_ctcp_ping; | |
2804 pbm->gc = gc; | |
2805 m = g_list_append(m, pbm); | |
2806 | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2807 return m; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2808 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2809 |
3751 | 2810 G_MODULE_EXPORT void |
2811 irc_init(struct prpl *ret) | |
2086 | 2812 { |
3572 | 2813 struct proto_user_opt *puo; |
2086 | 2814 ret->protocol = PROTO_IRC; |
3789 | 2815 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL; |
3572 | 2816 ret->name = g_strdup("IRC"); |
2086 | 2817 ret->list_icon = irc_list_icon; |
2818 ret->login = irc_login; | |
2819 ret->close = irc_close; | |
2820 ret->send_im = irc_send_im; | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
2821 ret->add_buddy = irc_add_buddy; |
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
2822 ret->remove_buddy = irc_remove_buddy; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
2823 ret->chat_info = irc_chat_info; |
2086 | 2824 ret->join_chat = irc_join_chat; |
2825 ret->chat_leave = irc_chat_leave; | |
2826 ret->chat_send = irc_chat_send; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2827 ret->away_states = irc_away_states; |
2086 | 2828 ret->set_away = irc_set_away; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2829 ret->get_info = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2830 ret->buddy_menu = irc_buddy_menu; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2831 ret->chat_invite = irc_chat_invite; |
3029 | 2832 ret->convo_closed = irc_convo_closed; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2833 #if 0 |
3622 | 2834 ret->file_transfer_out = irc_file_transfer_out; |
3616 | 2835 ret->file_transfer_in = irc_file_transfer_in; |
2836 ret->file_transfer_data_chunk = irc_file_transfer_data_chunk; | |
2837 ret->file_transfer_done = irc_file_transfer_done; | |
2838 ret->file_transfer_cancel =irc_file_transfer_cancel; | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
2839 #endif |
3572 | 2840 |
2841 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 2842 puo->label = g_strdup(_("Server:")); |
3914
9ced82507a79
[gaim-migrate @ 4073]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
2843 puo->def = g_strdup("irc.freenode.net"); |
3572 | 2844 puo->pos = USEROPT_SERV; |
2845 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2846 | |
2847 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 2848 puo->label = g_strdup(_("Port:")); |
3572 | 2849 puo->def = g_strdup("6667"); |
2850 puo->pos = USEROPT_PORT; | |
2851 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2852 | |
3751 | 2853 puo = g_new0(struct proto_user_opt, 1); |
4115 | 2854 puo->label = g_strdup(_("Encoding:")); |
3751 | 2855 puo->def = g_strdup("ISO-8859-1"); |
2856 puo->pos = USEROPT_CHARSET; | |
2857 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2858 | |
3616 | 2859 my_protocol = ret; |
2086 | 2860 } |
2861 | |
2862 #ifndef STATIC | |
3751 | 2863 G_MODULE_EXPORT void |
2864 gaim_prpl_init(struct prpl* prpl) | |
2086 | 2865 { |
3572 | 2866 irc_init(prpl); |
2867 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 2868 } |
2869 | |
2870 #endif |