Mercurial > pidgin
annotate src/protocols/irc/irc.c @ 3665:7cb6cf20ed7d
[gaim-migrate @ 3794]
fixed warnings
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sun, 13 Oct 2002 16:35:14 +0000 |
parents | c084394b86de |
children | c1254110070a |
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> | |
39 #include <time.h> | |
40 #include <sys/stat.h> | |
41 #include <ctype.h> | |
42 #include "multi.h" | |
43 #include "prpl.h" | |
44 #include "gaim.h" | |
45 #include "proxy.h" | |
46 | |
3630 | 47 #ifdef _WIN32 |
48 #include "win32dep.h" | |
49 #endif | |
50 | |
3580 | 51 #include "pixmaps/protocols/irc/irc_icon.xpm" |
2086 | 52 |
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 | |
58 | |
3630 | 59 /* for win32 compatability */ |
60 G_MODULE_IMPORT GSList *connections; | |
61 | |
62 | |
3029 | 63 struct dcc_chat |
64 { | |
65 struct gaim_connection *gc; | |
66 char ip_address[12]; | |
67 int port; | |
68 int fd; | |
69 int inpa; | |
70 char nick[80]; | |
71 }; | |
72 | |
3616 | 73 struct irc_file_transfer { |
74 enum { IFT_SENDFILE_IN, IFT_SENDFILE_OUT } type; | |
75 struct file_transfer *xfer; | |
76 char *sn; | |
77 char *name; | |
78 int len; | |
79 int watcher; | |
3630 | 80 int awatcher; |
3616 | 81 char ip[12]; |
82 int port; | |
83 int fd; | |
84 int cur; | |
85 struct gaim_connection *gc; | |
86 }; | |
87 | |
3029 | 88 GSList *dcc_chat_list = NULL; |
89 | |
2086 | 90 struct irc_data { |
91 int fd; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
92 gboolean online; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
93 guint32 timer; |
2086 | 94 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
95 char *rxqueue; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
96 int rxlen; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
97 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
98 GString *str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
99 int bc; |
2086 | 100 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
101 char *chantypes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
102 char *chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
103 char *nickmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
104 gboolean six_modes; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
105 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
106 gboolean in_whois; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
107 gboolean in_list; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
108 GString *liststr; |
3616 | 109 GSList *file_transfers; |
2086 | 110 }; |
111 | |
3029 | 112 struct dcc_chat * |
113 find_dcc_chat (struct gaim_connection *gc, char *nick) | |
114 { | |
115 GSList *tmp; | |
116 struct dcc_chat *data; | |
117 tmp = dcc_chat_list; | |
118 while (tmp != NULL) | |
119 { | |
120 data = (struct dcc_chat *) (tmp)->data; | |
121 if (data | |
122 && data->nick | |
123 && strcmp (nick, data->nick) == 0 | |
124 && gc == data->gc) | |
125 { | |
126 return data; | |
127 } | |
128 tmp = tmp->next; | |
129 } | |
130 return NULL; | |
131 } | |
132 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
133 static int irc_write(int fd, char *data, int len) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
134 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
135 debug_printf("IRC C: %s", data); |
3630 | 136 #ifndef _WIN32 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
137 return write(fd, data, len); |
3630 | 138 #else |
139 return send(fd, data, len, 0); | |
140 #endif | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
141 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
142 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
143 static struct conversation *irc_find_chat(struct gaim_connection *gc, char *name) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
144 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
145 GSList *bcs = gc->buddy_chats; |
2086 | 146 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
147 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
148 struct conversation *b = bcs->data; |
2331
1ea2792b6004
[gaim-migrate @ 2343]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2328
diff
changeset
|
149 if (!g_strcasecmp(b->name, name)) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
150 return b; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
151 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
152 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
153 return NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
154 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
155 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
156 static struct conversation *irc_find_chat_by_id(struct gaim_connection *gc, int id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
157 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
158 GSList *bcs = gc->buddy_chats; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
159 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
160 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
161 struct conversation *b = bcs->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
162 if (b->id == id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
163 return b; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
164 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
165 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
166 return NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
167 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
168 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
169 static void 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
|
170 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
171 int wordcount = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
172 gboolean space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
173 gboolean quote = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
174 int j = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
175 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
176 word[1] = cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
177 eol[1] = buf; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
178 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
179 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
180 switch (*cmd) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
181 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
182 buf[j] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
183 for (j = wordcount; j < PDIWORDS; j++) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
184 word[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
185 eol[j] = "\000\000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
186 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
187 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
188 case '"': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
189 if (!quotes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
190 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
191 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
192 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
193 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
194 quote = !quote; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
195 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
196 case ' ': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
197 if (quote) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
198 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
199 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
200 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
201 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
202 if (space) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
203 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
204 buf[j++] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
205 word[wordcount] = &buf[j]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
206 eol[wordcount++] = cmd + 1; |
2294
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
207 if (wordcount == PDIWORDS - 1) { |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
208 buf[j] = 0; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
209 return; |
b6c6603a8915
[gaim-migrate @ 2304]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2293
diff
changeset
|
210 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
211 space = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
212 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
213 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
214 space = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
215 buf[j++] = *cmd; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
216 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
217 cmd++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
218 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
219 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
220 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
221 static void handle_005(struct gaim_connection *gc, char *word[], char *word_eol[]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
222 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
223 int w = 4; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
224 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
225 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
226 while (w < PDIWORDS && *word[w]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
227 if (!strncmp(word[w], "MODES=", 5)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
228 if (atoi(word[w] + 6) >= 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
229 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
230 } else if (!strncmp(word[w], "CHANTYPES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
231 g_free(id->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
232 id->chantypes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
233 } else if (!strncmp(word[w], "CHANMODES=", 10)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
234 g_free(id->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
235 id->chanmodes = g_strdup(word[w] + 10); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
236 } else if (!strncmp(word[w], "PREFIX=", 7)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
237 char *pre = strchr(word[w] + 7, ')'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
238 if (pre) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
239 *pre = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
240 g_free(id->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
241 id->nickmodes = g_strdup(word[w] + 8); |
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 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
244 w++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
245 } |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
246 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
247 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
248 static char *int_to_col(int c) |
2086 | 249 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
250 switch(c) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
251 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
252 return "#ffffff"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
253 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
254 return "#000066"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
255 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
256 return "#006600"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
257 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
258 return "#ff0000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
259 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
260 return "#660000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
261 case 6: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
262 return "#660066"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
263 case 7: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
264 return "#666600"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
265 case 8: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
266 return "#cccc00"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
267 case 9: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
268 return "#33cc33"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
269 case 10: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
270 return "#00acac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
271 case 11: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
272 return "#00ccac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
273 case 12: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
274 return "#0000ff"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
275 case 13: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
276 return "#cc00cc"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
277 case 14: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
278 return "#666666"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
279 case 15: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
280 return "#00ccac"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
281 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
282 return "#000000"; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
283 } |
2086 | 284 } |
285 | |
3029 | 286 static GString *encode_html(char *msg) |
287 { | |
288 GString *str = g_string_new(""); | |
289 char *cur = msg, *end = msg; | |
290 gboolean bold = FALSE, underline = FALSE, italics = FALSE; | |
291 | |
292 while ((end = strchr(cur, '<'))) { | |
293 *end = 0; | |
294 str = g_string_append(str, cur); | |
295 cur = ++end; | |
296 if (!g_strncasecmp(cur, "B>", 2)) { | |
3063 | 297 if (!bold) { |
298 bold = TRUE; | |
299 str = g_string_append_c(str, '\2'); | |
300 } | |
3029 | 301 cur = cur + 2; |
302 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */ | |
3063 | 303 if (!italics) { |
304 italics = TRUE; | |
305 str = g_string_append_c(str, '\2'); | |
306 } | |
3029 | 307 cur = cur + 2; |
308 } else if (!g_strncasecmp(cur, "U>", 2)) { | |
3063 | 309 if (!underline) { |
310 underline = TRUE; | |
311 str = g_string_append_c(str, '\37'); | |
312 } | |
3029 | 313 cur = cur + 2; |
3063 | 314 } else if (!g_strncasecmp(cur, "/B>", 3)) { |
315 if (bold) { | |
316 bold = FALSE; | |
317 str = g_string_append_c(str, '\2'); | |
318 } | |
3029 | 319 cur = cur + 3; |
3063 | 320 } else if (!g_strncasecmp(cur, "/I>", 3)) { |
321 if (italics) { | |
322 italics = FALSE; | |
323 str = g_string_append_c(str, '\2'); | |
324 } | |
3029 | 325 cur = cur + 3; |
3063 | 326 } else if (!g_strncasecmp(cur, "/U>", 3)) { |
327 if (underline) { | |
328 underline = FALSE; | |
329 str = g_string_append_c(str, '\37'); | |
330 } | |
3029 | 331 cur = cur + 3; |
3063 | 332 } else { |
333 str = g_string_append_c(str, '<'); | |
3029 | 334 } |
3063 | 335 |
3029 | 336 } |
337 str = g_string_append(str, cur); | |
338 return str; | |
339 } | |
340 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
341 static GString *decode_html(char *msg) |
2086 | 342 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
343 GString /* oo la la */ *str = g_string_new(""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
344 char *cur = msg, *end = msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
345 gboolean bold = FALSE, underline = FALSE, fg = FALSE, bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
346 int fore, back; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
347 while (*end) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
348 switch (*end) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
349 case 02: /* ^B */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
350 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
351 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
352 if (bold) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
353 str = g_string_append(str, "</B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
354 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
355 str = g_string_append(str, "<B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
356 bold = !bold; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
357 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
358 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
359 case 03: /* ^C */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
360 *end++ = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
361 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
362 fore = back = -1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
363 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
364 fore = *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
365 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
366 fore *= 10; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
367 fore += *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
368 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
369 if (*end == ',' && isdigit(end[1])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
370 end++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
371 back = *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
372 if (isdigit(*end)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
373 back *= 10; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
374 back += *end++ - '0'; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
375 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
376 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
377 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
378 if (fore == -1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
379 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
380 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
381 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
382 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
383 fg = bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
384 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
385 fore %= 16; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
386 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
387 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
388 if (back != -1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
389 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
390 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
391 back %= 16; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
392 str = g_string_append(str, "<FONT BACK="); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
393 str = g_string_append(str, int_to_col(back)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
394 str = g_string_append_c(str, '>'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
395 bg = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
396 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
397 str = g_string_append(str, "<FONT COLOR="); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
398 str = g_string_append(str, int_to_col(fore)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
399 str = g_string_append_c(str, '>'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
400 fg = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
401 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
402 cur = end--; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
403 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
404 case 017: /* ^O */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
405 if (!bold && !underline && !fg && !bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
406 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
407 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
408 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
409 if (bold) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
410 str = g_string_append(str, "</B>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
411 if (underline) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
412 str = g_string_append(str, "</U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
413 if (fg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
414 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
415 if (bg) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
416 str = g_string_append(str, "</FONT>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
417 bold = underline = fg = bg = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
418 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
419 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
420 case 037: /* ^_ */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
421 *end = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
422 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
423 if (underline) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
424 str = g_string_append(str, "</U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
425 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
426 str = g_string_append(str, "<U>"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
427 underline = !underline; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
428 cur = end + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
429 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
430 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
431 end++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
432 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
433 if (*cur) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
434 str = g_string_append(str, cur); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
435 return str; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
436 } |
2086 | 437 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
438 static void irc_got_im(struct gaim_connection *gc, char *who, char *what, int flags, time_t t) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
439 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
440 GString *str = decode_html(what); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
441 serv_got_im(gc, who, str->str, flags, t, -1); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
442 g_string_free(str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
443 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
444 |
3029 | 445 static void dcc_chat_cancel(void *, struct dcc_chat *); |
446 | |
447 void | |
448 dcc_chat_in (gpointer data, gint source, GaimInputCondition condition) | |
449 { | |
450 struct dcc_chat *chat = data; | |
451 gchar buffer[IRC_BUF_LEN]; | |
452 gchar buf[128]; | |
453 int n = 0, l; | |
454 struct conversation *convo; | |
455 debug_printf("THIS IS TOO MUCH EFFORT\n"); | |
3630 | 456 #ifndef _WIN32 |
3029 | 457 n = read (chat->fd, buffer, IRC_BUF_LEN); |
3630 | 458 #else |
459 n = recv (chat->fd, buffer, IRC_BUF_LEN, 0); | |
460 #endif | |
3029 | 461 if (n > 0) |
462 { | |
463 | |
464 /* Strip the terminating \n */ | |
465 l = 0; | |
466 while (buffer[l] && buffer[l] != '\n' && l <= n) | |
467 l++; | |
468 buffer[l] = '\000'; | |
469 | |
470 /* Convert to HTML */ | |
471 debug_printf ("DCC Message from: %s\n", chat->nick); | |
472 irc_got_im(chat->gc, chat->nick, buffer, 0, time(NULL)); | |
473 } | |
474 | |
475 else { | |
476 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), | |
477 chat->nick); | |
478 convo = new_conversation (chat->nick); | |
479 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
480 time ((time_t) NULL), -1); | |
481 dcc_chat_cancel (NULL,chat); | |
482 } | |
483 } | |
484 | |
3616 | 485 static void irc_file_transfer_do(struct gaim_connection *gc, struct irc_file_transfer *ift) { |
486 /* Ok, we better be receiving some crap here boyeee */ | |
487 if (transfer_in_do(ift->xfer, ift->fd, ift->name, ift->len)) { | |
488 gaim_input_remove(ift->watcher); | |
489 ift->watcher = 0; | |
490 } | |
491 } | |
492 | |
493 | |
3630 | 494 void irc_read_dcc_ack (gpointer data, gint source, GaimInputCondition condition) { |
3633 | 495 /* Read ACK Here */ |
496 | |
3630 | 497 } |
498 | |
3622 | 499 void dcc_send_callback (gpointer data, gint source, GaimInputCondition condition) { |
500 struct irc_file_transfer *ift = data; | |
501 struct sockaddr_in addr; | |
502 int len = sizeof(addr); | |
503 | |
504 addr.sin_family = AF_INET; | |
505 addr.sin_port = htons(ift->port); | |
506 addr.sin_addr.s_addr = INADDR_ANY; | |
507 | |
508 ift->fd = accept(ift->fd, (struct sockaddr *)&addr, &len); | |
509 if (!ift->fd) { | |
510 /* FIXME: Handle this gracefully XXX */ | |
3633 | 511 printf("Something bad happened here, bubba!\n"); |
3622 | 512 return; |
513 } | |
514 | |
3633 | 515 /* ift->awatcher = gaim_input_add(ift->fd, GAIM_INPUT_READ, irc_read_dcc_ack, ift); */ |
3630 | 516 |
3622 | 517 if (transfer_out_do(ift->xfer, ift->fd, 0)) { |
518 gaim_input_remove(ift->watcher); | |
519 ift->watcher = 0; | |
520 } | |
521 } | |
522 | |
3616 | 523 void dcc_recv_callback (gpointer data, gint source, GaimInputCondition condition) { |
524 struct irc_file_transfer *ift = data; | |
525 | |
526 ift->fd = source; | |
527 irc_file_transfer_do(ift->gc, ift); | |
528 } | |
529 | |
3029 | 530 void dcc_chat_callback (gpointer data, gint source, GaimInputCondition condition) { |
531 struct dcc_chat *chat = data; | |
532 struct conversation *convo = new_conversation (chat->nick); | |
533 char buf[IRC_BUF_LEN]; | |
534 chat->fd = source; | |
535 g_snprintf (buf, sizeof buf, | |
536 "DCC Chat with %s established", | |
537 chat->nick); | |
538 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
539 time ((time_t) NULL), -1); | |
540 debug_printf ("Chat with %s established\n", chat->nick); | |
541 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
542 gaim_input_remove(chat->inpa); | |
543 chat->inpa = gaim_input_add(source, GAIM_INPUT_READ, dcc_chat_in, chat); | |
544 } | |
545 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
546 static void irc_got_chat_in(struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t t) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
547 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
548 GString *str = decode_html(msg); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
549 serv_got_chat_in(gc, id, who, whisper, str->str, t); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
550 g_string_free(str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
551 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
552 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
553 static void handle_list(struct gaim_connection *gc, char *list) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
554 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
555 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
556 GSList *gr; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
557 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
558 id->str = g_string_append_c(id->str, ' '); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
559 id->str = g_string_append(id->str, list); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
560 id->bc--; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
561 if (id->bc) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
562 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
563 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
564 g_strdown(id->str->str); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
565 gr = gc->groups; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
566 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
567 GSList *m = ((struct group *)gr->data)->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
568 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
569 struct buddy *b = m->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
570 char *tmp = g_strdup(b->name); |
3028 | 571 char *x, *l; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
572 g_strdown(tmp); |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
573 x = strstr(id->str->str, tmp); |
3028 | 574 l = x + strlen(b->name); |
575 if (x && (*l != ' ' && *l != 0)) | |
576 x = 0; | |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
577 if (!b->present && x) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
578 serv_got_update(gc, b->name, 1, 0, 0, 0, 0, 0); |
2310
b2db2a76dcec
[gaim-migrate @ 2320]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
579 else if (b->present && !x) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
580 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
581 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
582 m = m->next; |
2086 | 583 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
584 gr = gr->next; |
2086 | 585 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
586 g_string_free(id->str, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
587 id->str = g_string_new(""); |
2086 | 588 } |
589 | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
590 static gboolean irc_request_buddy_update(gpointer data) |
2086 | 591 { |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
592 struct gaim_connection *gc = data; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
593 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
594 char buf[500]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
595 int n = g_snprintf(buf, sizeof(buf), "ISON"); |
2086 | 596 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
597 GSList *gr = gc->groups; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
598 if (!gr || id->bc) |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
599 return TRUE; |
2086 | 600 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
601 while (gr) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
602 struct group *g = gr->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
603 GSList *m = g->members; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
604 while (m) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
605 struct buddy *b = m->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
606 if (n + strlen(b->name) + 2 > sizeof(buf)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
607 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
608 irc_write(id->fd, buf, n); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
609 id->bc++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
610 n = g_snprintf(buf, sizeof(buf), "ISON"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
611 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
612 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", b->name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
613 m = m->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
614 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
615 gr = gr->next; |
2086 | 616 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
617 g_snprintf(buf + n, sizeof(buf) - n, "\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
618 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
619 id->bc++; |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
620 return TRUE; |
2086 | 621 } |
622 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
623 static void handle_names(struct gaim_connection *gc, char *chan, char *names) |
2086 | 624 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
625 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
626 char **buf, **tmp; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
627 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
628 if (*names == ':') names++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
629 buf = g_strsplit(names, " ", -1); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
630 for (tmp = buf; *tmp; tmp++) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
631 add_chat_buddy(c, *tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
632 g_strfreev(buf); |
2086 | 633 } |
634 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
635 static void handle_topic(struct gaim_connection *gc, char *text) |
2086 | 636 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
637 struct conversation *c; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
638 char *po = strchr(text, ' '); |
2086 | 639 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
640 if (!po) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
641 return; |
2086 | 642 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
643 *po = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
644 po += 2; |
2086 | 645 |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
646 if ((c = irc_find_chat(gc, text))) { |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
647 char buf[IRC_BUF_LEN]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
648 chat_set_topic(c, NULL, po); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
649 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"), |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
650 text, po); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
651 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
652 } |
2086 | 653 } |
654 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
655 static gboolean mode_has_arg(struct gaim_connection *gc, char sign, char mode) |
2086 | 656 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
657 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
658 char *cm = id->chanmodes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
659 int type = 0; |
2086 | 660 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
661 if (strchr(id->nickmodes, mode)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
662 return TRUE; |
2086 | 663 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
664 while (*cm) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
665 if (*cm == ',') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
666 type++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
667 else if (*cm == mode) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
668 switch (type) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
669 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
670 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
671 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
672 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
673 if (sign == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
674 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
675 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
676 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
677 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
678 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
679 cm++; |
2086 | 680 } |
681 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
682 return FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
683 } |
2086 | 684 |
3452 | 685 static void irc_chan_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *argstr, char *who) |
686 { | |
687 struct conversation *c = irc_find_chat(gc, room); | |
688 char buf[IRC_BUF_LEN]; | |
689 char *nick = g_strndup(who, strchr(who, '!') - who); | |
690 | |
691 g_snprintf(buf, sizeof(buf), "%s sets mode %c%c %s on %s", | |
692 nick, sign, mode, strlen(argstr) ? argstr : "", | |
693 room); | |
694 g_free(nick); | |
695 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL), -1); | |
696 } | |
697 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
698 static void irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
699 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
700 struct conversation *c = irc_find_chat(gc, room); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
701 GList *r; |
2086 | 702 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
703 if (mode != 'o' && mode != 'v') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
704 return; |
2086 | 705 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
706 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
707 return; |
2086 | 708 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
709 r = c->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
710 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
711 gboolean op = FALSE, voice = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
712 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
713 if (*who == '@') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
714 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
715 who++; |
2086 | 716 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
717 if (*who == '+') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
718 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
719 who++; |
2086 | 720 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
721 if (!strcmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
722 char *tmp, buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
723 if (mode == 'o') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
724 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
725 op = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
726 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
727 op = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
728 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
729 if (mode == 'v') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
730 if (sign == '-') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
731 voice = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
732 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
733 voice = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
734 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
735 tmp = g_strdup(r->data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
736 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
737 voice ? "+" : "", nick); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
738 rename_chat_buddy(c, tmp, buf); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
739 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
740 return; |
2086 | 741 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
742 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
743 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
744 } |
2086 | 745 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
746 static void handle_mode(struct gaim_connection *gc, char *word[], char *word_eol[], gboolean n324) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
747 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
748 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
749 int offset = n324 ? 4 : 3; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
750 char *chan = word[offset]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
751 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
752 char *modes = word[offset + 1]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
753 int len = strlen(word_eol[offset]) - 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
754 char sign = *modes++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
755 int arg = 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
756 char *argstr; |
3452 | 757 char *who = word[1]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
758 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
759 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
760 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
761 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
762 if (word_eol[offset][len] == ' ') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
763 word_eol[offset][len] = 0; |
2086 | 764 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
765 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
766 switch (*modes) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
767 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
768 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
769 case '+': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
770 case '-': |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
771 sign = *modes; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
772 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
773 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
774 if (mode_has_arg(gc, sign, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
775 argstr = word[++arg + offset]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
776 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
777 argstr = ""; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
778 if (strchr(id->nickmodes, *modes)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
779 irc_user_mode(gc, chan, sign, *modes, argstr); |
3452 | 780 else if (strchr(who, '!')) |
781 irc_chan_mode(gc, chan, sign, *modes, argstr, who); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
782 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
783 modes++; |
2086 | 784 } |
785 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
786 |
3452 | 787 static void handle_version(struct gaim_connection *gc, char *word[], char *word_eol[], int num) |
788 { | |
789 struct irc_data *id = gc->proto_data; | |
790 GString *str; | |
791 | |
792 id->liststr = g_string_new(""); | |
793 | |
794 id->liststr = g_string_append(id->liststr, "<b>Version: </b>"); | |
795 id->liststr = g_string_append(id->liststr, word_eol[4]); | |
796 | |
797 str = decode_html(id->liststr->str); | |
798 g_show_info_text(gc, NULL, 2, str->str, NULL); | |
799 g_string_free(str, TRUE); | |
800 g_string_free(id->liststr, TRUE); | |
801 id->liststr = NULL; | |
802 } | |
803 | |
804 static void handle_who(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
805 { | |
806 struct irc_data *id = gc->proto_data; | |
807 char buf[IRC_BUF_LEN]; | |
808 | |
809 if (!id->in_whois) { | |
810 id->in_whois = TRUE; | |
811 id->liststr = g_string_new(""); | |
812 } | |
813 | |
814 switch (num) { | |
815 case 352: | |
816 g_snprintf(buf, sizeof(buf), "<b>%s</b> (%s@%s): %s<br>", | |
817 word[8], word[5], word[6], word_eol[11]); | |
818 id->liststr = g_string_append(id->liststr, buf); | |
819 break; | |
820 } | |
821 } | |
822 | |
2648 | 823 /* Handle our whois stuff here. You know what, I have a sore throat. You know |
824 * what I think about that? I'm not too pleased with it. Perhaps I should take | |
825 * some medicine, or perhaps I should go to bed? Blah!! */ | |
826 | |
827 static void handle_whois(struct gaim_connection *gc, char *word[], char *word_eol[], int num) | |
828 { | |
829 struct irc_data *id = gc->proto_data; | |
830 char tmp[1024]; | |
831 | |
832 if (!id->in_whois) { | |
833 id->in_whois = TRUE; | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
834 id->liststr = g_string_new(""); |
2648 | 835 } else { |
836 /* 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
|
837 id->liststr = g_string_append(id->liststr, "<BR>"); |
2648 | 838 id->in_whois = TRUE; |
839 } | |
840 | |
841 switch (num) { | |
842 case 311: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
843 id->liststr = g_string_append(id->liststr, "<b>User: </b>"); |
2648 | 844 break; |
845 case 312: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
846 id->liststr = g_string_append(id->liststr, "<b>Server: </b>"); |
2648 | 847 break; |
848 case 313: | |
849 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]); | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
850 id->liststr = g_string_append(id->liststr, tmp); |
2648 | 851 break; |
852 | |
853 case 317: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
854 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>"); |
2648 | 855 break; |
856 case 319: | |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
857 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>"); |
2648 | 858 break; |
859 default: | |
860 break; | |
861 } | |
3452 | 862 |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
863 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
864 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
3452 | 865 /* Nicer idle time output, by jonas@birme.se */ |
866 else if (isdigit(word_eol[5][0])) { | |
867 time_t idle = atol(word_eol[5]); | |
868 time_t signon = atol(strchr(word_eol[5], ' ')); | |
869 | |
870 g_snprintf(tmp, sizeof(tmp), | |
871 "%ld seconds [signon: %s]", (idle / 1000), ctime(&signon)); | |
872 id->liststr = g_string_append(id->liststr, tmp); | |
873 } | |
2651
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
874 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
875 id->liststr = g_string_append(id->liststr, word_eol[5]); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
876 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
877 |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
878 static void handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[]) |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
879 { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
880 struct irc_data *id = gc->proto_data; |
2648 | 881 |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
882 if (!id->in_list) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
883 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
884 id->liststr = g_string_new(""); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
885 } else { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
886 id->liststr = g_string_append(id->liststr, "<BR>"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
887 id->in_list = TRUE; |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
888 } |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
889 |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
890 id->liststr = g_string_append(id->liststr, word_eol[4]); |
2648 | 891 } |
892 | |
3511 | 893 static void irc_change_nick(void *a, char *b) { |
894 struct gaim_connection *gc = a; | |
895 struct irc_data *id = gc->proto_data; | |
896 char buf[IRC_BUF_LEN]; | |
897 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", b); | |
898 irc_write(id->fd, buf, strlen(buf)); | |
899 } | |
900 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
901 static void process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[]) |
2086 | 902 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
903 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
904 char *text = word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
905 int n = atoi(word[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
906 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
907 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname))) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
908 text += strlen(gc->displayname) + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
909 if (*text == ':') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
910 text++; |
2086 | 911 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
912 switch (n) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
913 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
914 if (!strncmp(word[5], "u2.10", 5)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
915 id->six_modes = TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
916 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
917 id->six_modes = FALSE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
918 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
919 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
920 handle_005(gc, word, word_eol); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
921 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
922 case 301: |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
923 if (id->in_whois) { |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
924 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
|
925 |
f84dcbcfba4b
[gaim-migrate @ 2664]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2650
diff
changeset
|
926 if (word_eol[5][0] == ':') |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
927 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
|
928 else |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
929 id->liststr = g_string_append(id->liststr, word_eol[5]); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
930 } else |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
931 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
|
932 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
933 case 303: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
934 handle_list(gc, &word_eol[4][1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
935 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
936 case 311: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
937 case 312: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
938 case 313: |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
939 case 317: |
3452 | 940 case 319: |
2648 | 941 handle_whois(gc, word, word_eol, n); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
942 break; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
943 case 322: |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
944 handle_roomlist(gc, word, word_eol); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
945 break; |
3452 | 946 /* End of replies */ |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
947 case 323: |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
948 case 318: |
3452 | 949 case 315: |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
950 if ((id->in_whois || id->in_list) && id->liststr) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
951 GString *str = decode_html(id->liststr->str); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2782
diff
changeset
|
952 g_show_info_text(gc, NULL, 2, str->str, NULL); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
953 g_string_free(str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
954 g_string_free(id->liststr, TRUE); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
955 id->liststr = NULL; |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
956 id->in_whois = FALSE; |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
957 id->in_list = FALSE; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
958 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
959 break; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
960 case 324: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
961 handle_mode(gc, word, word_eol, TRUE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
962 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
963 case 332: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
964 handle_topic(gc, text); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
965 break; |
3452 | 966 case 351: |
967 handle_version(gc, word, word_eol, n); | |
968 break; | |
969 case 352: | |
970 handle_who(gc, word, word_eol, n); | |
971 break; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
972 case 353: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
973 handle_names(gc, word[5], word_eol[6]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
974 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
975 case 376: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
976 irc_request_buddy_update(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
977 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
978 case 401: |
3427 | 979 do_error_dialog(_("There is no such nick or channel on this IRC channel."), NULL, GAIM_ERROR); |
2652
65a602693286
[gaim-migrate @ 2665]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2651
diff
changeset
|
980 break; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
981 case 402: |
3427 | 982 do_error_dialog(_("There is no such IRC Server"), NULL, GAIM_ERROR); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
983 case 431: |
3427 | 984 do_error_dialog(_("No IRC nickname given"), NULL, GAIM_ERROR); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
985 break; |
3511 | 986 case 433: |
987 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL); | |
3605 | 988 break; |
3452 | 989 default: |
990 if (n > 400 && n < 502) { | |
991 char errmsg[IRC_BUF_LEN]; | |
992 char *errmsg1 = strrchr(text, ':'); | |
993 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n); | |
994 if (errmsg) | |
3536 | 995 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR); |
3452 | 996 } |
997 break; | |
2086 | 998 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
999 } |
2086 | 1000 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1001 static gboolean is_channel(struct gaim_connection *gc, char *name) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1002 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1003 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1004 if (strchr(id->chantypes, *name)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1005 return TRUE; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1006 return FALSE; |
2086 | 1007 } |
1008 | |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1009 static void irc_rem_chat_bud(struct gaim_connection *gc, char *nick, char *reason) |
2086 | 1010 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1011 GSList *bcs = gc->buddy_chats; |
2086 | 1012 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1013 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1014 struct conversation *b = bcs->data; |
2086 | 1015 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1016 GList *r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1017 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1018 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1019 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1020 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1021 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1022 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1023 if (!g_strcasecmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1024 char *tmp = g_strdup(r->data); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1025 remove_chat_buddy(b, tmp, reason); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1026 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1027 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1028 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1029 r = r->next; |
2086 | 1030 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1031 bcs = bcs->next; |
2086 | 1032 } |
1033 } | |
1034 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1035 static void irc_change_name(struct gaim_connection *gc, char *old, char *new) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1036 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1037 GSList *bcs = gc->buddy_chats; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1038 char buf[IRC_BUF_LEN]; |
2086 | 1039 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1040 while (bcs) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1041 struct conversation *b = bcs->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1042 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1043 GList *r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1044 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1045 char *who = r->data; |
2292
6625d0755c51
[gaim-migrate @ 2302]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2291
diff
changeset
|
1046 int n = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1047 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1048 buf[n++] = *who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1049 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1050 buf[n++] = *who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1051 g_snprintf(buf + n, sizeof(buf) - n, "%s", new); |
2312
766603034af8
[gaim-migrate @ 2322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2310
diff
changeset
|
1052 if (!strcmp(who, old)) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1053 char *tmp = g_strdup(r->data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1054 rename_chat_buddy(b, tmp, buf); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1055 r = b->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1056 g_free(tmp); |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2687
diff
changeset
|
1057 break; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1058 } else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1059 r = r->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1060 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1061 bcs = bcs->next; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1062 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1063 } |
2086 | 1064 |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1065 static void handle_privmsg(struct gaim_connection *gc, char *to, char *nick, char *msg) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1066 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1067 if (is_channel(gc, to)) { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1068 struct conversation *c = irc_find_chat(gc, to); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1069 if (!c) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1070 return; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1071 irc_got_chat_in(gc, c->id, nick, 0, msg, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1072 } else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1073 char *tmp = g_malloc(strlen(nick) + 2); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1074 g_snprintf(tmp, strlen(nick) + 2, "@%s", nick); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1075 if (find_conversation(tmp)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1076 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1077 else { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1078 *tmp = '+'; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1079 if (find_conversation(tmp)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1080 irc_got_im(gc, tmp, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1081 else |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1082 irc_got_im(gc, nick, msg, 0, time(NULL)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1083 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1084 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1085 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1086 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1087 |
3029 | 1088 static void dcc_chat_init(gpointer obj, struct dcc_chat *data) { |
1089 struct dcc_chat * chat = g_new0(struct dcc_chat, 1); | |
1090 | |
1091 memcpy(chat, data, sizeof(struct dcc_chat)); /* we have to make a new one | |
1092 * because the old one get's freed by | |
1093 * dcc_chat_cancel. */ | |
3616 | 1094 |
1095 printf("ONE MORE TIME: %s:%d\n", chat->ip_address, chat->port); | |
3029 | 1096 proxy_connect(chat->ip_address, chat->port, dcc_chat_callback, chat); |
1097 } | |
1098 | |
1099 static void dcc_chat_cancel(gpointer obj, struct dcc_chat *data){ | |
1100 if (find_dcc_chat(data->gc, data->nick)) { | |
1101 dcc_chat_list = g_slist_remove(dcc_chat_list, data); | |
1102 gaim_input_remove (data->inpa); | |
1103 close (data->fd); | |
1104 } | |
1105 g_free(data); | |
1106 } | |
1107 | |
1108 static void irc_convo_closed(struct gaim_connection *gc, char *who) | |
1109 { | |
1110 struct dcc_chat *dchat = find_dcc_chat(gc, who); | |
1111 if (!dchat) | |
1112 return; | |
1113 | |
1114 dcc_chat_cancel(NULL, dchat); | |
1115 } | |
1116 | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1117 static void handle_ctcp(struct gaim_connection *gc, char *to, char *nick, |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1118 char *msg, char *word[], char *word_eol[]) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1119 { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1120 struct irc_data *id = gc->proto_data; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1121 char buf[IRC_BUF_LEN]; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1122 |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1123 if (!g_strncasecmp(msg, "VERSION", 7)) { |
3245 | 1124 g_snprintf(buf, sizeof(buf), "NOTICE %s :\001VERSION Gaim " VERSION ": The Penguin Pimpin' " |
1125 "Multi-protocol Messaging Client: " WEBSITE "\001\r\n", nick); | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1126 irc_write(id->fd, buf, strlen(buf)); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1127 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1128 if (!g_strncasecmp(msg, "ACTION", 6)) { |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1129 char *po = strchr(msg + 6, 1); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1130 char *tmp; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1131 if (po) *po = 0; |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1132 tmp = g_strconcat("/me", msg + 6, NULL); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1133 handle_privmsg(gc, to, nick, tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1134 g_free(tmp); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1135 } |
3029 | 1136 if (!g_strncasecmp(msg, "DCC CHAT", 8)) { |
1137 char **chat_args = g_strsplit(msg, " ", 5); | |
1138 char ask[1024]; | |
1139 struct dcc_chat * dccchat = g_new0(struct dcc_chat, 1); | |
1140 dccchat->gc = gc; | |
1141 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]); | |
3616 | 1142 printf("DCC CHAT DEBUG CRAP: %s\n", dccchat->ip_address); |
3029 | 1143 dccchat->port=atoi(chat_args[4]); |
1144 g_snprintf(dccchat->nick, sizeof(dccchat->nick), nick); | |
1145 g_snprintf(ask, sizeof(ask), _("%s has requested a DCC chat. " | |
1146 "Would you like to establish the direct connection?"), nick); | |
1147 do_ask_dialog(ask, dccchat, dcc_chat_init, dcc_chat_cancel); | |
1148 } | |
3616 | 1149 |
1150 | |
1151 if (!g_strncasecmp(msg, "DCC SEND", 8)) { | |
1152 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1); | |
1153 char **send_args = g_strsplit(msg, " ", 6); | |
1154 send_args[5][strlen(send_args[5])-1] = 0; | |
1155 | |
1156 ift->type = IFT_SENDFILE_IN; | |
1157 ift->sn = g_strdup(nick); | |
1158 ift->gc = gc; | |
1159 g_snprintf(ift->ip, sizeof(ift->ip), send_args[3]); | |
1160 ift->port = atoi(send_args[4]); | |
1161 ift->len = atoi(send_args[5]); | |
1162 ift->name = g_strdup(send_args[2]); | |
1163 ift->cur = 0; | |
1164 | |
1165 id->file_transfers = g_slist_append(id->file_transfers, ift); | |
1166 | |
1167 ift->xfer = transfer_in_add(gc, nick, ift->name, ift->len, 1, NULL); | |
1168 } | |
1169 | |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1170 /* XXX should probably write_to_conv or something here */ |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1171 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1172 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1173 static gboolean irc_parse(struct gaim_connection *gc, char *buf) |
2086 | 1174 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1175 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1176 gchar outbuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1177 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1178 char pdibuf[522]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1179 char *ex, ip[128], nick[128]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1180 char *cmd; |
2086 | 1181 |
1182 /* Check for errors */ | |
3452 | 1183 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1184 if (*buf != ':') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1185 if (!strncmp(buf, "NOTICE ", 7)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1186 buf += 7; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1187 if (!strncmp(buf, "PING ", 5)) { |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1188 int r = FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1189 g_snprintf(outbuf, sizeof(outbuf), "PONG %s\r\n", buf + 5); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1190 if (irc_write(idata->fd, outbuf, strlen(outbuf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1191 hide_login_progress(gc, _("Unable to write")); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1192 signoff(gc); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1193 r = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1194 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1195 return r; |
2086 | 1196 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1197 /* XXX doesn't handle ERROR */ |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1198 return FALSE; |
2086 | 1199 } |
1200 | |
2782
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1201 if (!idata->online) { |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1202 /* Now lets sign ourselves on */ |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1203 account_online(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1204 serv_finish_login(gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1205 |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1206 if (bud_list_cache_exists(gc)) |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1207 do_import(gc, NULL); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1208 |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1209 /* 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
|
1210 idata->timer = g_timeout_add(20000, irc_request_buddy_update, gc); |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1211 idata->online = TRUE; |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1212 } |
428bd24c18c6
[gaim-migrate @ 2795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
1213 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1214 buf++; |
2086 | 1215 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1216 process_data_init(pdibuf, buf, word, word_eol, FALSE); |
2086 | 1217 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1218 if (atoi(word[2])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1219 if (*word_eol[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1220 process_numeric(gc, word, word_eol); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1221 return FALSE; |
2086 | 1222 } |
1223 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1224 cmd = word[2]; |
2086 | 1225 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1226 ex = strchr(pdibuf, '!'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1227 if (!ex) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1228 strncpy(ip, pdibuf, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1229 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1230 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1231 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1232 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1233 strncpy(ip, ex + 1, sizeof(ip)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1234 ip[sizeof(ip)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1235 strncpy(nick, pdibuf, sizeof(nick)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1236 nick[sizeof(nick)-1] = 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1237 if ((ex - pdibuf) < sizeof (nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1238 nick[ex - pdibuf] = 0; /* cut the buffer at the '!' */ |
2086 | 1239 } |
1240 | |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1241 if (!strcmp(cmd, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1242 char *chan = g_strdup(word[4]); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1243 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
|
1244 } else if (!strcmp(cmd, "JOIN")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1245 char *chan = *word[3] == ':' ? word[3] + 1 : word[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1246 if (!g_strcasecmp(gc->displayname, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1247 static int id = 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1248 serv_got_joined_chat(gc, id++, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1249 } else { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1250 struct conversation *c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1251 if (c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1252 add_chat_buddy(c, nick); |
2086 | 1253 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1254 } else if (!strcmp(cmd, "KICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1255 if (!strcmp(gc->displayname, word[4])) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1256 struct conversation *c = irc_find_chat(gc, word[3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1257 if (!c) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1258 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1259 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1260 c->gc = NULL; |
3599 | 1261 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s by %s:"), |
1262 word[3], nick); | |
3427 | 1263 do_error_dialog(outbuf, *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5], GAIM_INFO); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1264 } else { |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1265 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
|
1266 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1267 irc_rem_chat_bud(gc, word[4], msg); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1268 g_free(msg); |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1269 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1270 } else if (!strcmp(cmd, "KILL")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1271 } else if (!strcmp(cmd, "MODE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1272 handle_mode(gc, word, word_eol, FALSE); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1273 } else if (!strcmp(cmd, "NICK")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1274 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
|
1275 if (!strcmp(gc->displayname, nick)) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1276 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1277 irc_change_name(gc, nick, new); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1278 } else if (!strcmp(cmd, "NOTICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1279 if (*word_eol[4] == ':') word_eol[4]++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1280 if (ex) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1281 irc_got_im(gc, nick, word_eol[4], 0, time(NULL)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1282 } else if (!strcmp(cmd, "PART")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1283 char *chan = cmd + 5; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1284 struct conversation *c; |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1285 char *reason = word_eol[4]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1286 GList *r; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1287 if (*chan == ':') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1288 chan++; |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1289 if (*reason == ':') |
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1290 reason++; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1291 if (!(c = irc_find_chat(gc, chan))) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1292 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1293 if (!strcmp(nick, gc->displayname)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1294 serv_got_chat_left(gc, c->id); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1295 return FALSE; |
2086 | 1296 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1297 r = c->in_room; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1298 while (r) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1299 char *who = r->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1300 if (*who == '@') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1301 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1302 if (*who == '+') |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1303 who++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1304 if (!g_strcasecmp(who, nick)) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1305 char *tmp = g_strdup(r->data); |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1306 remove_chat_buddy(c, tmp, reason); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1307 g_free(tmp); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1308 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1309 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1310 r = r->next; |
2086 | 1311 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1312 } else if (!strcmp(cmd, "PRIVMSG")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1313 char *to, *msg; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1314 if (!*word[3]) |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1315 return FALSE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1316 to = word[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1317 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1318 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */ |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1319 if (!g_strncasecmp(msg + 1, "DCC ", 4)) |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1320 process_data_init(pdibuf, buf, word, word_eol, TRUE); |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1321 handle_ctcp(gc, to, nick, msg + 1, word, word_eol); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1322 } else { |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
1323 handle_privmsg(gc, to, nick, msg); |
2086 | 1324 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1325 } else if (!strcmp(cmd, "PONG")) { /* */ |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1326 } else if (!strcmp(cmd, "QUIT")) { |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2801
diff
changeset
|
1327 irc_rem_chat_bud(gc, nick, *word_eol[3] == ':' ? word_eol[3] + 1 : word_eol[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1328 } else if (!strcmp(cmd, "TOPIC")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1329 struct conversation *c = irc_find_chat(gc, word[3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1330 char *topic = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1331 if (c) { |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1332 char buf[IRC_BUF_LEN]; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1333 chat_set_topic(c, nick, topic); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1334 g_snprintf(buf, sizeof(buf), _("<B>%s has changed the topic to: %s</B>"), |
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1335 nick, topic); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1336 write_to_conv(c, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2328
14c8df9cc75f
[gaim-migrate @ 2338]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2312
diff
changeset
|
1337 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1338 } else if (!strcmp(cmd, "WALLOPS")) { /* */ |
2086 | 1339 } |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1340 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1341 return FALSE; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1342 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1343 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1344 static void irc_callback(gpointer data, gint source, GaimInputCondition condition) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1345 { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1346 struct gaim_connection *gc = data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1347 struct irc_data *idata = gc->proto_data; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1348 int i = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1349 gchar buf[1024]; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1350 gboolean off; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1351 |
3630 | 1352 #ifndef _WIN32 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1353 i = read(idata->fd, buf, 1024); |
3630 | 1354 #else |
1355 i = recv(idata->fd, buf, 1024, 0); | |
1356 #endif | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1357 if (i <= 0) { |
3074 | 1358 hide_login_progress_error(gc, "Read error"); |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1359 signoff(gc); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1360 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1361 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1362 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1363 idata->rxqueue = g_realloc(idata->rxqueue, i + idata->rxlen + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1364 memcpy(idata->rxqueue + idata->rxlen, buf, i); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1365 idata->rxlen += i; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1366 idata->rxqueue[idata->rxlen] = 0; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1367 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1368 while (1) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1369 char *d, *e; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1370 int len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1371 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1372 if (!idata->rxqueue || ((e = strchr(idata->rxqueue, '\n')) == NULL)) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1373 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1374 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1375 len = e - idata->rxqueue + 1; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1376 d = g_strndup(idata->rxqueue, len); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1377 g_strchomp(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1378 debug_printf("IRC S: %s\n", d); |
3452 | 1379 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1380 idata->rxlen -= len; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1381 if (idata->rxlen) { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1382 char *tmp = g_strdup(e + 1); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1383 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1384 idata->rxqueue = tmp; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1385 } else { |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1386 g_free(idata->rxqueue); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1387 idata->rxqueue = NULL; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1388 } |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1389 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1390 off = irc_parse(gc, d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1391 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1392 g_free(d); |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1393 |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1394 if (off) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1395 return; |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1396 } |
2086 | 1397 } |
1398 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1399 static void irc_login_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 1400 { |
1401 struct gaim_connection *gc = data; | |
1402 struct irc_data *idata; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1403 char hostname[256]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1404 char buf[IRC_BUF_LEN]; |
2086 | 1405 |
1406 if (!g_slist_find(connections, gc)) { | |
3630 | 1407 #ifndef _WIN32 |
2086 | 1408 close(source); |
3630 | 1409 #else |
1410 closesocket(source); | |
1411 #endif | |
2086 | 1412 return; |
1413 } | |
1414 | |
1415 idata = gc->proto_data; | |
1416 | |
1417 if (source == -1) { | |
1418 hide_login_progress(gc, "Write error"); | |
1419 signoff(gc); | |
1420 return; | |
1421 } | |
1422 | |
1423 if (idata->fd != source) | |
1424 idata->fd = source; | |
1425 | |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1426 gethostname(hostname, sizeof(hostname) - 1); |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1427 hostname[sizeof(hostname) - 1] = 0; |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1428 if (!*hostname) |
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1429 g_snprintf(hostname, sizeof(hostname), "localhost"); |
3562 | 1430 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n", |
3452 | 1431 g_get_user_name(), hostname, |
1432 gc->user->proto_opt[USEROPT_SERV], | |
3575 | 1433 gc->user->alias && strlen(gc->user->alias) ? gc->user->alias : "gaim"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1434 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1435 hide_login_progress(gc, "Write error"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1436 signoff(gc); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1437 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1438 } |
2086 | 1439 |
2574
3526c5581f92
[gaim-migrate @ 2587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2536
diff
changeset
|
1440 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
|
1441 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { |
2086 | 1442 hide_login_progress(gc, "Write error"); |
1443 signoff(gc); | |
1444 return; | |
1445 } | |
1446 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1447 gc->inpa = gaim_input_add(idata->fd, GAIM_INPUT_READ, irc_callback, gc); |
2086 | 1448 } |
1449 | |
1450 static void irc_login(struct aim_user *user) | |
1451 { | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1452 char buf[IRC_BUF_LEN]; |
2086 | 1453 |
1454 struct gaim_connection *gc = new_gaim_conn(user); | |
1455 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); | |
1456 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1457 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1458 |
2086 | 1459 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1460 set_login_progress(gc, 2, buf); | |
1461 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1462 idata->chantypes = g_strdup("#&!+"); |
3452 | 1463 idata->chanmodes = g_strdup("beI,k,lnt"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1464 idata->nickmodes = g_strdup("ohv"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1465 idata->str = g_string_new(""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1466 |
2086 | 1467 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV], |
1468 user->proto_opt[USEROPT_PORT][0] ? atoi(user-> | |
1469 proto_opt[USEROPT_PORT]) : | |
1470 6667, irc_login_callback, gc); | |
1471 if (!user->gc || (idata->fd < 0)) { | |
1472 hide_login_progress(gc, "Unable to create socket"); | |
1473 signoff(gc); | |
1474 return; | |
1475 } | |
1476 } | |
1477 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1478 static void irc_close(struct gaim_connection *gc) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1479 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1480 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
3618 | 1481 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1482 gchar buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1483 |
3452 | 1484 if (idata->str->len > 0) { |
1485 g_snprintf(buf, sizeof(buf), "QUIT :%s\r\n", idata->str->str); | |
1486 } else { | |
1487 g_snprintf(buf, sizeof(buf), | |
1488 "QUIT :Download Gaim [%s]\r\n", WEBSITE); | |
1489 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1490 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1491 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1492 if (idata->rxqueue) |
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1493 g_free(idata->rxqueue); |
3618 | 1494 |
3619 | 1495 idata->rxqueue = NULL; |
1496 idata->rxlen = 0; | |
1497 | |
3618 | 1498 /* Kill any existing transfers */ |
1499 while (idata->file_transfers) { | |
1500 struct irc_file_transfer *ift = (struct irc_file_transfer *)idata->file_transfers->data; | |
1501 | |
1502 g_free(ift->sn); | |
1503 g_free(ift->name); | |
1504 gaim_input_remove(ift->watcher); | |
1505 | |
1506 close(ift->fd); | |
1507 | |
1508 idata->file_transfers = idata->file_transfers->next; | |
1509 } | |
3619 | 1510 idata->file_transfers = NULL; |
3618 | 1511 |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1512 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1513 g_free(idata->chantypes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1514 g_free(idata->chanmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1515 g_free(idata->nickmodes); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1516 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1517 g_string_free(idata->str, TRUE); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1518 if (idata->liststr) |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1519 g_string_free(idata->liststr, TRUE); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1520 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1521 if (idata->timer) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1522 g_source_remove(idata->timer); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1523 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1524 if (gc->inpa) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1525 gaim_input_remove(gc->inpa); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1526 |
3630 | 1527 #ifndef _WIN32 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1528 close(idata->fd); |
3630 | 1529 #else |
1530 closesocket(idata->fd); | |
1531 #endif | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1532 g_free(gc->proto_data); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1533 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1534 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1535 static void set_mode_3(struct gaim_connection *gc, char *who, int sign, int mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1536 int start, int end, char *word[]) |
2086 | 1537 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1538 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1539 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1540 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1541 int i = start; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1542 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1543 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1544 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1545 switch (left) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1546 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1547 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1548 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1549 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1550 who, sign, mode, word[i]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1551 i += 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1552 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1553 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1554 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1555 who, sign, mode, mode, word[i], word[i + 1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1556 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1557 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1558 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1559 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1560 who, sign, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1561 word[i], word[i + 1], word[i + 2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1562 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1563 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1564 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1565 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1566 if (left < 3) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1567 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1568 } |
2086 | 1569 } |
1570 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1571 static void set_mode_6(struct gaim_connection *gc, char *who, int sign, int mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1572 int start, int end, char *word[]) |
2086 | 1573 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1574 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1575 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1576 int left; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1577 int i = start; |
2086 | 1578 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1579 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1580 left = end - i; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1581 switch (left) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1582 case 0: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1583 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1584 case 1: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1585 g_snprintf(buf, sizeof(buf), "MODE %s %c%c %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1586 who, sign, mode, word[i]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1587 i += 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1588 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1589 case 2: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1590 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1591 who, sign, mode, mode, word[i], word[i + 1]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1592 i += 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1593 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1594 case 3: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1595 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1596 who, sign, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1597 word[i], word[i + 1], word[i + 2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1598 i += 3; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1599 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1600 case 4: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1601 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1602 who, sign, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1603 word[i], word[i + 1], word[i + 2], word[i + 3]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1604 i += 4; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1605 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1606 case 5: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1607 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c %s %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1608 who, sign, mode, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1609 word[i], word[i + 1], word[i + 2], |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1610 word[i + 3], word[i + 4]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1611 i += 5; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1612 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1613 default: |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1614 g_snprintf(buf, sizeof(buf), "MODE %s %c%c%c%c%c%c%c %s %s %s %s %s %s\r\n", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1615 who, sign, mode, mode, mode, mode, mode, mode, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1616 word[i], word[i + 1], word[i + 2], |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1617 word[i + 3], word[i + 4], word[i + 5]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1618 i += 6; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1619 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1620 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1621 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1622 if (left < 6) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1623 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1624 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1625 } |
2086 | 1626 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1627 static void set_mode(struct gaim_connection *gc, char *who, int sign, int mode, char *word[]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1628 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1629 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1630 int i = 2; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1631 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1632 while (1) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1633 if (!*word[i]) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1634 if (i == 2) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1635 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1636 if (id->six_modes) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1637 set_mode_6(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1638 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1639 set_mode_3(gc, who, sign, mode, 2, i, word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1640 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1641 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1642 i++; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1643 } |
2086 | 1644 } |
1645 | |
3452 | 1646 static void set_chan_mode(struct gaim_connection *gc, char *chan, char *mode_str) |
1647 { | |
1648 struct irc_data *id = gc->proto_data; | |
1649 char buf[IRC_BUF_LEN]; | |
1650 | |
1651 if ((mode_str[0] == '-') || (mode_str[0] == '+')) { | |
1652 g_snprintf(buf, sizeof(buf), "MODE %s %s\r\n", chan, mode_str); | |
1653 irc_write(id->fd, buf, strlen(buf)); | |
1654 } | |
1655 } | |
1656 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1657 static int handle_command(struct gaim_connection *gc, char *who, char *what) |
2086 | 1658 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1659 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1660 char pdibuf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1661 char *word[PDIWORDS], *word_eol[PDIWORDS]; |
3029 | 1662 char *tmp = g_strdup(what); |
1663 GString *str = encode_html(tmp); | |
1664 struct dcc_chat *dccchat = find_dcc_chat(gc, who); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1665 struct irc_data *id = gc->proto_data; |
3029 | 1666 g_free(tmp); |
3030 | 1667 what = str->str; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1668 if (*what != '/') { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1669 unsigned int max = 440 - strlen(who); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1670 char t; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1671 while (strlen(what) > max) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1672 t = what[max]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1673 what[max] = 0; |
3029 | 1674 if (dccchat) { |
3030 | 1675 g_snprintf(buf, sizeof(buf), "%s\r\n", what); |
3029 | 1676 irc_write(dccchat->fd, buf, strlen(buf)); |
1677 g_string_free(str, TRUE); | |
1678 return 1; | |
1679 } | |
3030 | 1680 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1681 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1682 what[max] = t; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1683 what = what + max; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1684 } |
3029 | 1685 if (dccchat) { |
3030 | 1686 g_snprintf(buf, sizeof(buf), "%s\r\n", what); |
3029 | 1687 irc_write(dccchat->fd, buf, strlen(buf)); |
1688 g_string_free(str, TRUE); | |
1689 return 1; | |
1690 } | |
3030 | 1691 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1692 irc_write(id->fd, buf, strlen(buf)); |
3029 | 1693 g_string_free(str, TRUE); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1694 return 1; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1695 } |
3029 | 1696 |
3033 | 1697 process_data_init(pdibuf, what + 1, word, word_eol, TRUE); |
1698 g_string_free(str, FALSE); | |
3029 | 1699 if (!g_strcasecmp(pdibuf, "ME")) { |
1700 if (dccchat) { | |
1701 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", word_eol[2]); | |
1702 irc_write(dccchat->fd, buf, strlen(buf)); | |
3033 | 1703 g_free(what); |
3029 | 1704 return 1; |
1705 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1706 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :\001ACTION %s\001\r\n", who, word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1707 irc_write(id->fd, buf, strlen(buf)); |
3033 | 1708 g_free(what); |
2304
15fb364935ec
[gaim-migrate @ 2314]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1709 return 1; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1710 } else if (!g_strcasecmp(pdibuf, "INVITE")) { |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1711 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1712 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
|
1713 irc_write(id->fd, buf, strlen(buf)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1714 } else if (!g_strcasecmp(pdibuf, "TOPIC")) { |
3033 | 1715 if (!*word_eol[2]) { |
3501 | 1716 struct conversation *c; |
1717 c = irc_find_chat(gc, who); | |
1718 g_snprintf(buf, sizeof(buf), _("Topic for %s is %s"), who, c->topic ? c->topic : "(no topic set)"); | |
1719 write_to_conv(c, buf, WFLAG_SYSTEM | WFLAG_NOLOG, NULL, time(NULL), -1); | |
1720 } else { | |
1721 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, word_eol[2]); | |
1722 irc_write(id->fd, buf, strlen(buf)); | |
3033 | 1723 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1724 } else if (!g_strcasecmp(pdibuf, "NICK")) { |
3033 | 1725 if (!*word_eol[2]) { |
1726 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1727 return -EINVAL; |
3033 | 1728 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1729 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
|
1730 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1731 } else if (!g_strcasecmp(pdibuf, "OP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1732 set_mode(gc, who, '+', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1733 } else if (!g_strcasecmp(pdibuf, "DEOP")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1734 set_mode(gc, who, '-', 'o', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1735 } else if (!g_strcasecmp(pdibuf, "VOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1736 set_mode(gc, who, '+', 'v', word); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1737 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1738 set_mode(gc, who, '-', 'v', word); |
3452 | 1739 } else if (!g_strcasecmp(pdibuf, "MODE")) { |
1740 char *chan = who; | |
1741 set_chan_mode(gc, chan, word_eol[2]); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1742 } else if (!g_strcasecmp(pdibuf, "QUOTE")) { |
3033 | 1743 if (!*word_eol[2]) { |
1744 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1745 return -EINVAL; |
3033 | 1746 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1747 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1748 irc_write(id->fd, buf, strlen(buf)); |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1749 } else if (!g_strcasecmp(pdibuf, "SAY")) { |
3033 | 1750 if (!*word_eol[2]) { |
1751 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1752 return -EINVAL; |
3033 | 1753 } |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1754 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", who, word_eol[2]); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1755 irc_write(id->fd, buf, strlen(buf)); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1756 return 1; |
2302
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1757 } else if (!g_strcasecmp(pdibuf, "MSG")) { |
3033 | 1758 if (!*word[2]) { |
1759 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1760 return -EINVAL; |
3033 | 1761 } |
1762 if (!*word_eol[3]) { | |
1763 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1764 return -EINVAL; |
3033 | 1765 } |
2302
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1766 g_snprintf(buf, sizeof(buf), "PRIVMSG %s :%s\r\n", word[2], word_eol[3]); |
722a912562a0
[gaim-migrate @ 2312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2301
diff
changeset
|
1767 irc_write(id->fd, buf, strlen(buf)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1768 } else if (!g_strcasecmp(pdibuf, "KICK")) { |
3033 | 1769 if (!*word[2]) { |
1770 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1771 return -EINVAL; |
3033 | 1772 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1773 if (*word_eol[3]) |
2298
57da45349e50
[gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2295
diff
changeset
|
1774 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], word_eol[3]); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1775 else |
2298
57da45349e50
[gaim-migrate @ 2308]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2295
diff
changeset
|
1776 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
|
1777 irc_write(id->fd, buf, strlen(buf)); |
2801 | 1778 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) { |
3033 | 1779 if (!*word[2]) { |
1780 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1781 return -EINVAL; |
3033 | 1782 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1783 if (*word[3]) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1784 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
|
1785 else |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1786 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1787 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1788 } else if (!g_strcasecmp(pdibuf, "PART")) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1789 char *chan = *word[2] ? word[2] : who; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1790 char *reason = word_eol[3]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1791 struct conversation *c; |
3033 | 1792 if (!is_channel(gc, chan)) { |
1793 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1794 return -EINVAL; |
3033 | 1795 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1796 c = irc_find_chat(gc, chan); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1797 g_snprintf(buf, sizeof(buf), "PART %s%s%s\r\n", chan, |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1798 *reason ? " :" : "", |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1799 *reason ? reason : ""); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1800 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1801 if (c) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1802 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1803 c->gc = NULL; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1804 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); |
3427 | 1805 do_error_dialog(buf, NULL, GAIM_INFO); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1806 } |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1807 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
1808 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
|
1809 irc_write(id->fd, buf, strlen(buf)); |
2829
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1810 } else if (!g_strcasecmp(pdibuf, "LIST")) { |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1811 g_snprintf(buf, sizeof(buf), "LIST\r\n"); |
e3f98544eae0
[gaim-migrate @ 2842]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1812 irc_write(id->fd, buf, strlen(buf)); |
3452 | 1813 } else if (!g_strcasecmp(pdibuf, "QUIT")) { |
1814 char *reason = word_eol[2]; | |
1815 id->str = g_string_insert(id->str, 0, reason); | |
1816 do_quit(); | |
1817 } else if (!g_strcasecmp(pdibuf, "VERSION")) { | |
1818 g_snprintf(buf, sizeof(buf), "VERSION\r\n"); | |
1819 irc_write(id->fd, buf, strlen(buf)); | |
1820 } else if (!g_strcasecmp(pdibuf, "W")) { | |
1821 g_snprintf(buf, sizeof(buf), "WHO *\r\n"); | |
1822 irc_write(id->fd, buf, strlen(buf)); | |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1823 } else if (!g_strcasecmp(pdibuf, "HELP")) { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1824 struct conversation *c = NULL; |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1825 if (is_channel(gc, who)) { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1826 c = irc_find_chat(gc, who); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1827 } else { |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1828 c = find_conversation(who); |
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1829 } |
3033 | 1830 if (!c) { |
1831 g_free(what); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1832 return -EINVAL; |
3033 | 1833 } |
2301
171d11fb37b9
[gaim-migrate @ 2311]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2299
diff
changeset
|
1834 write_to_conv(c, "<B>Currently supported commands:<BR>" |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1835 "WHOIS INVITE NICK LIST<BR>" |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1836 "JOIN PART TOPIC KICK<BR>" |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1837 "OP DEOP VOICE DEVOICE<BR>" |
3452 | 1838 "ME MSG QUOTE SAY QUIT<BR>" |
1839 "MODE VERSION W</B>", | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1840 WFLAG_NOLOG, NULL, time(NULL), -1); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1841 } else { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1842 struct conversation *c = NULL; |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1843 if (is_channel(gc, who)) { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1844 c = irc_find_chat(gc, who); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1845 } else { |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1846 c = find_conversation(who); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1847 } |
3033 | 1848 if (!c) { |
1849 g_free(what); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2304
diff
changeset
|
1850 return -EINVAL; |
3033 | 1851 } |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2847
diff
changeset
|
1852 write_to_conv(c, "<B>Unknown command</B>", WFLAG_NOLOG, NULL, time(NULL), -1); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1853 } |
3033 | 1854 g_free(what); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1855 return 0; |
2086 | 1856 } |
1857 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1858 static int send_msg(struct gaim_connection *gc, char *who, char *what) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1859 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1860 char *cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1861 if (cr) { |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1862 int ret = 0; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1863 while (TRUE) { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1864 if (cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1865 *cr = 0; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1866 ret = handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1867 if (!cr) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1868 break; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1869 what = cr + 1; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1870 if (!*what) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1871 break; |
2295
24dc9ce95127
[gaim-migrate @ 2305]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2294
diff
changeset
|
1872 *cr = '\n'; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1873 cr = strchr(what, '\n'); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1874 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1875 return ret; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1876 } else |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1877 return handle_command(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1878 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1879 |
3466 | 1880 static void 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
|
1881 char buf[IRC_BUF_LEN]; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1882 struct irc_data *id = gc->proto_data; |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1883 struct conversation *c = irc_find_chat_by_id(gc, idn); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1884 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
|
1885 irc_write(id->fd, buf, strlen(buf)); |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1886 } |
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
1887 |
3033 | 1888 static int 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
|
1889 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1890 if (*who == '@' || *who == '+') |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1891 return send_msg(gc, who + 1, what); |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1892 return send_msg(gc, who, what); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1893 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1894 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1895 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */ |
3466 | 1896 static void irc_add_buddy(struct gaim_connection *gc, const char *who) {} |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
1897 static void 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
|
1898 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1899 static GList *irc_chat_info(struct gaim_connection *gc) |
2086 | 1900 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1901 GList *m = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1902 struct proto_chat_entry *pce; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1903 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1904 pce = g_new0(struct proto_chat_entry, 1); |
2466
f8eb5f120603
[gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2459
diff
changeset
|
1905 pce->label = _("Channel:"); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1906 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1907 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1908 pce = g_new0(struct proto_chat_entry, 1); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1909 pce->label = _("Password:"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1910 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1911 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1912 return m; |
2086 | 1913 } |
1914 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1915 static void irc_join_chat(struct gaim_connection *gc, GList *data) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1916 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1917 struct irc_data *id = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1918 char buf[IRC_BUF_LEN]; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1919 char *name, *pass; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1920 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1921 if (!data) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1922 return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1923 name = data->data; |
2299
b5b7dece5249
[gaim-migrate @ 2309]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2298
diff
changeset
|
1924 if (data->next) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1925 pass = data->next->data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1926 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
|
1927 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1928 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1929 irc_write(id->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1930 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1931 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1932 static void irc_chat_leave(struct gaim_connection *gc, int id) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1933 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1934 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1935 struct conversation *c = irc_find_chat_by_id(gc, id); |
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 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1938 if (!c) return; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1939 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1940 g_snprintf(buf, sizeof(buf), "PART %s\r\n", c->name); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1941 irc_write(idata->fd, buf, strlen(buf)); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1942 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1943 |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1944 static int irc_chat_send(struct gaim_connection *gc, int id, char *what) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1945 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1946 struct conversation *c = irc_find_chat_by_id(gc, id); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1947 if (!c) |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1948 return -EINVAL; |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1949 if (send_msg(gc, c->name, what) > 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2302
diff
changeset
|
1950 serv_got_chat_in(gc, c->id, gc->displayname, 0, what, time(NULL)); |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1951 return 0; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1952 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1953 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2466
diff
changeset
|
1954 static GList *irc_away_states(struct gaim_connection *gc) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1955 { |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1956 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1957 } |
2086 | 1958 |
1959 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) | |
1960 { | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1961 struct irc_data *idata = gc->proto_data; |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1962 char buf[IRC_BUF_LEN]; |
2086 | 1963 |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1964 if (gc->away) |
2394
579f8d4347ad
[gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1965 gc->away = NULL; |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1966 |
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1967 if (msg) { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1968 g_snprintf(buf, sizeof(buf), "AWAY :%s\r\n", msg); |
2394
579f8d4347ad
[gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1969 gc->away = ""; |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
1970 } else |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1971 g_snprintf(buf, sizeof(buf), "AWAY\r\n"); |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1972 irc_write(idata->fd, buf, strlen(buf)); |
2086 | 1973 } |
1974 | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1975 static char **irc_list_icon(int uc) |
2086 | 1976 { |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1977 return irc_icon_xpm; |
2086 | 1978 } |
1979 | |
3029 | 1980 static int getlocalip(char *ip) /* Thanks, libfaim */ |
1981 { | |
1982 struct hostent *hptr; | |
1983 char localhost[129]; | |
1984 long unsigned add; | |
1985 | |
1986 /* XXX if available, use getaddrinfo() */ | |
1987 /* XXX allow client to specify which IP to use for multihomed boxes */ | |
1988 | |
1989 if (gethostname(localhost, 128) < 0) | |
1990 return -1; | |
1991 | |
1992 if (!(hptr = gethostbyname(localhost))) | |
1993 return -1; | |
1994 | |
1995 memcpy(&add, hptr->h_addr_list[0], 4); | |
1996 add = htonl(add); | |
1997 g_snprintf(ip, 11, "%lu", add); | |
1998 | |
1999 return 0; | |
2000 } | |
2001 | |
2002 static void dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition) | |
2003 { | |
2004 struct dcc_chat *chat = data; | |
2005 struct conversation *convo; | |
2006 char buf[128]; | |
2007 struct sockaddr_in addr; | |
2008 int addrlen = sizeof (addr); | |
2009 addr.sin_family = AF_INET; | |
2010 addr.sin_port = htons (chat->port); | |
2011 addr.sin_addr.s_addr = INADDR_ANY; | |
2012 chat->fd = accept (chat->fd, (struct sockaddr *) (&addr), &addrlen); | |
2013 if (!chat->fd) | |
2014 { | |
2015 dcc_chat_cancel (NULL,chat); | |
2016 convo = new_conversation (chat->nick); | |
2017 g_snprintf (buf, sizeof buf, _("DCC Chat with %s closed"), | |
2018 chat->nick); | |
2019 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, | |
2020 time ((time_t) NULL), -1); | |
2021 return; | |
2022 } | |
2023 chat->inpa = | |
2024 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_in, chat); | |
2025 convo = new_conversation (chat->nick); | |
2026 g_snprintf (buf, sizeof buf, "DCC Chat with %s established", | |
2027 chat->nick); | |
2028 write_to_conv (convo, buf, WFLAG_SYSTEM, NULL, time ((time_t) NULL), -1); | |
2029 debug_printf ("Chat with %s established\n", chat->nick); | |
2030 dcc_chat_list = g_slist_append (dcc_chat_list, chat); | |
2031 } | |
3665
7cb6cf20ed7d
[gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3633
diff
changeset
|
2032 #if 0 |
3616 | 2033 static void irc_ask_send_file(struct gaim_connection *gc, char *destsn) { |
2034 struct irc_data *id = (struct irc_data *)gc->proto_data; | |
2035 struct irc_file_transfer *ift = g_new0(struct irc_file_transfer, 1); | |
3622 | 2036 char *localip = (char *)malloc(12); |
2037 | |
2038 if (getlocalip(localip) == -1) { | |
2039 free(localip); | |
2040 return; | |
2041 } | |
3616 | 2042 |
2043 ift->type = IFT_SENDFILE_OUT; | |
2044 ift->sn = g_strdup(destsn); | |
2045 ift->gc = gc; | |
3622 | 2046 snprintf(ift->ip, sizeof(ift->ip), "%s", localip); |
3616 | 2047 id->file_transfers = g_slist_append(id->file_transfers, ift); |
3622 | 2048 |
3616 | 2049 ift->xfer = transfer_out_add(gc, ift->sn); |
2050 } | |
3665
7cb6cf20ed7d
[gaim-migrate @ 3794]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3633
diff
changeset
|
2051 #endif |
3616 | 2052 static struct irc_file_transfer *find_ift_by_xfer(struct gaim_connection *gc, |
2053 struct file_transfer *xfer) { | |
2054 | |
2055 GSList *g = ((struct irc_data *)gc->proto_data)->file_transfers; | |
2056 struct irc_file_transfer *f = NULL; | |
2057 | |
2058 while (g) { | |
2059 f = (struct irc_file_transfer *)g->data; | |
2060 if (f->xfer == xfer) | |
2061 break; | |
2062 g = g->next; | |
2063 f = NULL; | |
2064 } | |
2065 | |
2066 return f; | |
2067 } | |
2068 | |
2069 static void irc_file_transfer_data_chunk(struct gaim_connection *gc, struct file_transfer *xfer, const char *data, int len) { | |
2070 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2071 guint32 pos; | |
2072 | |
2073 ift->cur += len; | |
2074 pos = htonl(ift->cur); | |
2075 write(ift->fd, (char *)&pos, 4); | |
2076 | |
3623 | 2077 // FIXME: You should check to verify that they received the data when |
2078 // you are sending a file ... | |
3616 | 2079 } |
2080 | |
2081 static void irc_file_transfer_cancel (struct gaim_connection *gc, struct file_transfer *xfer) { | |
2082 struct irc_data *id = (struct irc_data *)gc->proto_data; | |
2083 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2084 | |
2085 printf("Our shit got canceled, yo!\n"); | |
2086 | |
2087 /* Remove the FT from our list of transfers */ | |
2088 id->file_transfers = g_slist_remove(id->file_transfers, ift); | |
2089 | |
2090 gaim_input_remove(ift->watcher); | |
2091 | |
2092 /* Close our FT because we're done */ | |
2093 close(ift->fd); | |
2094 | |
2095 g_free(ift->sn); | |
2096 g_free(ift->name); | |
2097 | |
2098 g_free(ift); | |
2099 } | |
2100 | |
2101 static void irc_file_transfer_done(struct gaim_connection *gc, struct file_transfer *xfer) { | |
2102 struct irc_data *id = (struct irc_data *)gc->proto_data; | |
2103 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2104 | |
2105 | |
2106 printf("Our shit be done, yo.\n"); | |
2107 | |
2108 /* Remove the FT from our list of transfers */ | |
2109 id->file_transfers = g_slist_remove(id->file_transfers, ift); | |
2110 | |
2111 gaim_input_remove(ift->watcher); | |
2112 | |
2113 /* Close our FT because we're done */ | |
2114 close(ift->fd); | |
2115 | |
2116 g_free(ift->sn); | |
2117 g_free(ift->name); | |
2118 | |
2119 g_free(ift); | |
2120 } | |
2121 | |
3622 | 2122 static void irc_file_transfer_out (struct gaim_connection *gc, struct file_transfer *xfer, const char *name, int totfiles, int totsize) { |
2123 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2124 struct sockaddr_in addr; | |
2125 char buf[IRC_BUF_LEN]; | |
2126 int len; | |
2127 | |
2128 | |
2129 ift->fd = socket (AF_INET, SOCK_STREAM, 0); | |
2130 addr.sin_family = AF_INET; | |
2131 addr.sin_port = 0; | |
2132 addr.sin_addr.s_addr = INADDR_ANY; | |
2133 bind (ift->fd, (struct sockaddr *) &addr, sizeof(addr)); | |
2134 listen(ift->fd, 1); | |
2135 | |
2136 len = sizeof(addr); | |
2137 getsockname (ift->fd, (struct sockaddr *) &addr, &len); | |
2138 | |
2139 ift->port = ntohs(addr.sin_port); | |
2140 | |
2141 ift->watcher = gaim_input_add (ift->fd, GAIM_INPUT_READ, dcc_send_callback, ift); | |
3633 | 2142 printf("watcher is %d\n", ift->watcher); |
3622 | 2143 |
2144 snprintf(buf, sizeof(buf), "\001DCC SEND %s %s %d %d\001\n", name, ift->ip, ift->port, totsize); | |
2145 printf("Trying: %s\n", buf); | |
2146 irc_send_im (gc, ift->sn, buf, -1, 0); | |
2147 } | |
2148 | |
3616 | 2149 static void irc_file_transfer_in(struct gaim_connection *gc, |
2150 struct file_transfer *xfer, int offset) { | |
2151 | |
2152 struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); | |
2153 | |
2154 ift->xfer = xfer; | |
2155 proxy_connect(ift->ip, ift->port, dcc_recv_callback, ift); | |
2156 } | |
2157 | |
3029 | 2158 static void irc_start_chat(struct gaim_connection *gc, char *who) { |
2159 struct dcc_chat *chat; | |
2160 int len; | |
2161 struct sockaddr_in addr; | |
2162 char buf[200]; | |
2163 | |
2164 /* Create a socket */ | |
2165 chat = g_new0 (struct dcc_chat, 1); | |
2166 chat->fd = socket (AF_INET, SOCK_STREAM, 0); | |
2167 chat->gc = gc; | |
2168 g_snprintf (chat->nick, sizeof (chat->nick), "%s", who); | |
2169 if (chat->fd < 0) { | |
2170 dcc_chat_cancel (NULL,chat); | |
2171 return; | |
2172 } | |
2173 addr.sin_family = AF_INET; | |
2174 addr.sin_port = 0; | |
2175 addr.sin_addr.s_addr = INADDR_ANY; | |
2176 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr)); | |
2177 listen (chat->fd, 1); | |
2178 len = sizeof (addr); | |
2179 getsockname (chat->fd, (struct sockaddr *) &addr, &len); | |
2180 chat->port = ntohs (addr.sin_port); | |
2181 getlocalip(chat->ip_address); | |
2182 chat->inpa = | |
2183 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, | |
2184 chat); | |
3630 | 2185 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", |
3029 | 2186 chat->ip_address, chat->port); |
3033 | 2187 irc_send_im (gc, who, buf, -1, 0); |
3029 | 2188 } |
2189 | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2190 static void irc_get_info(struct gaim_connection *gc, char *who) |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2191 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2192 struct irc_data *idata = gc->proto_data; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2193 char buf[IRC_BUF_LEN]; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2194 |
2633
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2195 if (*who == '@') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2196 who++; |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2197 if (*who == '+') |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2198 who++; |
b740a33875c3
[gaim-migrate @ 2646]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2620
diff
changeset
|
2199 |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2200 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2201 irc_write(idata->fd, buf, strlen(buf)); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2202 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2203 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2204 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who) |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2205 { |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2206 GList *m = NULL; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2207 struct proto_buddy_menu *pbm; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2208 |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2209 pbm = g_new0(struct proto_buddy_menu, 1); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2210 pbm->label = _("Get Info"); |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2211 pbm->callback = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2212 pbm->gc = gc; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2213 m = g_list_append(m, pbm); |
3616 | 2214 |
3029 | 2215 pbm = g_new0(struct proto_buddy_menu, 1); |
2216 pbm->label = _("DCC Chat"); | |
2217 pbm->callback = irc_start_chat; | |
2218 pbm->gc = gc; | |
2219 m = g_list_append(m, pbm); | |
3633 | 2220 /* |
3616 | 2221 pbm = g_new0(struct proto_buddy_menu, 1); |
2222 pbm->label = _("DCC Send"); | |
2223 pbm->callback = irc_ask_send_file; | |
2224 pbm->gc = gc; | |
2225 m = g_list_append(m, pbm); | |
3633 | 2226 */ |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2227 return m; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2228 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2229 |
2086 | 2230 static struct prpl *my_protocol = NULL; |
2231 | |
3630 | 2232 G_MODULE_EXPORT void irc_init(struct prpl *ret) |
2086 | 2233 { |
3572 | 2234 struct proto_user_opt *puo; |
2086 | 2235 ret->protocol = PROTO_IRC; |
2100
a93aeb6f813d
[gaim-migrate @ 2110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
2236 ret->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD; |
3572 | 2237 ret->name = g_strdup("IRC"); |
2086 | 2238 ret->list_icon = irc_list_icon; |
2239 ret->login = irc_login; | |
2240 ret->close = irc_close; | |
2241 ret->send_im = irc_send_im; | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
2242 ret->add_buddy = irc_add_buddy; |
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2652
diff
changeset
|
2243 ret->remove_buddy = irc_remove_buddy; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
2244 ret->chat_info = irc_chat_info; |
2086 | 2245 ret->join_chat = irc_join_chat; |
2246 ret->chat_leave = irc_chat_leave; | |
2247 ret->chat_send = irc_chat_send; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2248 ret->away_states = irc_away_states; |
2086 | 2249 ret->set_away = irc_set_away; |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2250 ret->get_info = irc_get_info; |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
2251 ret->buddy_menu = irc_buddy_menu; |
2847
e49bd1479edd
[gaim-migrate @ 2860]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2831
diff
changeset
|
2252 ret->chat_invite = irc_chat_invite; |
3029 | 2253 ret->convo_closed = irc_convo_closed; |
3622 | 2254 ret->file_transfer_out = irc_file_transfer_out; |
3616 | 2255 ret->file_transfer_in = irc_file_transfer_in; |
2256 ret->file_transfer_data_chunk = irc_file_transfer_data_chunk; | |
2257 ret->file_transfer_done = irc_file_transfer_done; | |
2258 ret->file_transfer_cancel =irc_file_transfer_cancel; | |
3572 | 2259 |
2260 puo = g_new0(struct proto_user_opt, 1); | |
2261 puo->label = g_strdup("Server:"); | |
2262 puo->def = g_strdup("irc.openprojects.net"); | |
2263 puo->pos = USEROPT_SERV; | |
2264 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2265 | |
2266 puo = g_new0(struct proto_user_opt, 1); | |
2267 puo->label = g_strdup("Port:"); | |
2268 puo->def = g_strdup("6667"); | |
2269 puo->pos = USEROPT_PORT; | |
2270 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2271 | |
3616 | 2272 my_protocol = ret; |
2086 | 2273 } |
2274 | |
2275 #ifndef STATIC | |
3630 | 2276 G_MODULE_EXPORT void gaim_prpl_init(struct prpl* prpl) |
2086 | 2277 { |
3572 | 2278 irc_init(prpl); |
2279 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 2280 } |
2281 | |
2282 #endif |