Mercurial > pidgin.yaz
annotate plugins/irc.c @ 1848:e246a4bd1141
[gaim-migrate @ 1858]
More bug fixen.
IRC colorus work properly too.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Tue, 15 May 2001 00:43:51 +0000 |
parents | 029cc08d9c54 |
children | 5cb89cf24f45 |
rev | line source |
---|---|
987 | 1 /* |
2 * gaim - IRC Protocol Plugin | |
3 * | |
1672 | 4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> |
987 | 5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #include "../config.h" | |
24 | |
25 | |
26 #include <netdb.h> | |
27 #include <gtk/gtk.h> | |
28 #include <unistd.h> | |
29 #include <errno.h> | |
30 #include <netinet/in.h> | |
31 #include <arpa/inet.h> | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
32 #include <fcntl.h> |
987 | 33 #include <string.h> |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
39 #include "multi.h" | |
40 #include "prpl.h" | |
41 #include "gaim.h" | |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
42 #include "proxy.h" |
987 | 43 |
1178 | 44 #include "pixmaps/free_icon.xpm" |
45 | |
1011 | 46 #define IRC_BUF_LEN 4096 |
47 | |
1022 | 48 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
49 #define USEROPT_SERV 0 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
50 #define USEROPT_PORT 1 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
51 #define USEROPT_PROXYSERV 2 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
52 #define USEROPT_PROXYPORT 3 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
53 #define USEROPT_PROXYTYPE 4 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
54 #define USEROPT_USER 5 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
55 #define USEROPT_PASS 6 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
56 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
57 |
1011 | 58 static int chat_id = 0; |
59 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
60 struct irc_channel { |
1011 | 61 int id; |
62 gchar *name; | |
63 }; | |
64 | |
65 struct irc_data { | |
66 int fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
67 int inpa; /* used for non-block logins */ |
1011 | 68 |
1022 | 69 int timer; |
70 | |
71 int totalblocks; | |
72 int recblocks; | |
73 | |
74 GSList *templist; | |
1011 | 75 GList *channels; |
76 }; | |
77 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
78 static char *irc_name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
79 { |
1008 | 80 return "IRC"; |
81 } | |
82 | |
1675 | 83 static void irc_get_info(struct gaim_connection *gc, char *who); |
84 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
85 char *name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
86 { |
1008 | 87 return "IRC"; |
88 } | |
89 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
90 char *description() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
91 { |
1008 | 92 return "Allows gaim to use the IRC protocol"; |
93 } | |
94 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
95 static void irc_join_chat(struct gaim_connection *gc, int id, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
96 { |
1011 | 97 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
98 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 99 |
100 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name); | |
101 write(idata->fd, buf, strlen(buf)); | |
1742 | 102 write(idata->fd, buf, strlen(buf)); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
103 |
1011 | 104 g_free(buf); |
105 } | |
106 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
107 static void irc_update_user(struct gaim_connection *gc, char *name, int status) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
108 { |
1022 | 109 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
110 struct irc_channel *u; | |
111 GSList *temp = idata->templist; | |
112 | |
113 /* Loop through our list */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
114 |
1022 | 115 while (temp) { |
116 u = (struct irc_channel *)temp->data; | |
117 if (g_strcasecmp(u->name, name) == 0) { | |
118 u->id = status; | |
119 return; | |
120 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
121 |
1022 | 122 temp = g_slist_next(temp); |
123 } | |
124 return; | |
125 } | |
126 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
127 static void irc_request_buddy_update(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
128 { |
1022 | 129 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
130 GSList *grp = gc->groups; |
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
131 GSList *person; |
1022 | 132 struct group *g; |
133 struct buddy *b; | |
134 struct irc_channel *u; | |
135 | |
136 if (idata->templist != NULL) | |
137 return; | |
138 | |
139 idata->recblocks = 0; | |
140 idata->totalblocks = 1; | |
141 | |
1105 | 142 /* First, let's check to see if we have anyone on our buddylist */ |
143 if (!grp) { | |
144 return; | |
145 } | |
146 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
147 /* Send the first part of our request */ |
1022 | 148 write(idata->fd, "ISON", 4); |
149 | |
150 /* Step through our list of groups */ | |
151 while (grp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
152 |
1022 | 153 g = (struct group *)grp->data; |
154 person = g->members; | |
155 | |
156 while (person) { | |
157 b = (struct buddy *)person->data; | |
158 | |
159 /* We will store our buddy info here. I know, this is cheap | |
160 * but hey, its the exact same data structure. Why should we | |
161 * bother with making another one */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
162 |
1022 | 163 u = g_new0(struct irc_channel, 1); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
164 u->id = 0; /* Assume by default that they're offline */ |
1022 | 165 u->name = strdup(b->name); |
166 | |
167 write(idata->fd, " ", 1); | |
168 write(idata->fd, u->name, strlen(u->name)); | |
169 idata->templist = g_slist_append(idata->templist, u); | |
170 | |
171 person = person->next; | |
172 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
173 |
1022 | 174 grp = g_slist_next(grp); |
175 } | |
176 write(idata->fd, "\n", 1); | |
177 } | |
178 | |
179 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
180 static void irc_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
181 { |
1011 | 182 |
1742 | 183 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
184 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 185 |
1847 | 186 if (who[0] == '@' || who[0] == '+') { |
187 | |
188 /* If the user trys to msg an op or a voice from the channel, the convo will try | |
189 * to send it to @nick or +nick... needless to say, this is undesirable. | |
190 */ | |
191 who++; | |
192 } | |
193 | |
1011 | 194 /* Before we actually send this, we should check to see if they're trying |
1674 | 195 * To issue a command and handle it properly. */ |
1011 | 196 |
1674 | 197 if (message[0] == '/') |
198 { | |
199 /* I'll change the implementation of this a little later :-) */ | |
200 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
201 /* We have /me!! We have /me!! :-) */ | |
1011 | 202 |
1674 | 203 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
204 strcpy(temp, message + 4); | |
205 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%cACTION %s%c\n", who, '\001', temp, '\001'); | |
206 g_free(temp); | |
207 } | |
1675 | 208 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { |
209 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
210 strcpy(temp, message + 7); | |
211 irc_get_info(gc, temp); | |
212 g_free(temp); | |
213 | |
214 return; | |
215 } | |
216 | |
1674 | 217 } |
218 else { | |
1011 | 219 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%s\n", who, message); |
220 } | |
221 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
222 write(idata->fd, buf, strlen(buf)); |
1011 | 223 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
224 g_free(buf); |
1011 | 225 } |
226 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
227 static int find_id_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
228 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
229 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 230 GList *templist; |
231 struct irc_channel *channel; | |
232 | |
233 templist = ((struct irc_data *)gc->proto_data)->channels; | |
234 | |
235 while (templist) { | |
236 channel = (struct irc_channel *)templist->data; | |
237 | |
238 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name); | |
239 | |
240 if (g_strcasecmp(temp, name) == 0) { | |
241 g_free(temp); | |
242 return channel->id; | |
243 } | |
244 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
245 templist = templist->next; |
1011 | 246 } |
247 | |
248 g_free(temp); | |
249 | |
250 /* Return -1 if we have no ID */ | |
251 return -1; | |
252 } | |
253 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
254 static struct irc_channel *find_channel_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
255 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
256 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 257 GList *templist; |
258 struct irc_channel *channel; | |
259 | |
260 templist = ((struct irc_data *)gc->proto_data)->channels; | |
261 | |
262 while (templist) { | |
263 channel = (struct irc_channel *)templist->data; | |
264 | |
265 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name); | |
266 | |
267 if (g_strcasecmp(temp, name) == 0) { | |
268 g_free(temp); | |
269 return channel; | |
270 } | |
271 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
272 templist = templist->next; |
1011 | 273 } |
274 | |
275 g_free(temp); | |
276 | |
277 /* If we found nothing, return nothing :-) */ | |
278 return NULL; | |
279 } | |
280 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
281 static struct irc_channel *find_channel_by_id(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
282 { |
1011 | 283 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
284 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
285 |
1011 | 286 GList *temp; |
287 | |
288 temp = idata->channels; | |
289 | |
290 while (temp) { | |
291 channel = (struct irc_channel *)temp->data; | |
292 | |
293 if (channel->id == id) { | |
294 /* We've found our man */ | |
295 return channel; | |
296 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
297 |
1011 | 298 temp = temp->next; |
299 } | |
300 | |
301 | |
302 /* If we didnt find one, return NULL */ | |
303 return NULL; | |
304 } | |
305 | |
1847 | 306 static void irc_chat_leave(struct gaim_connection *gc, int id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
307 static void irc_chat_send(struct gaim_connection *gc, int id, char *message) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
308 { |
1011 | 309 |
1742 | 310 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 311 struct irc_channel *channel = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
312 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1742 | 313 char **kick; |
314 gboolean is_command = FALSE; | |
1011 | 315 /* First lets get our current channel */ |
316 channel = find_channel_by_id(gc, id); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
317 |
1011 | 318 |
319 if (!channel) { | |
320 /* If for some reason we've lost our channel, let's bolt */ | |
1021 | 321 g_free(buf); |
1011 | 322 return; |
323 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
324 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
325 |
1011 | 326 /* Before we actually send this, we should check to see if they're trying |
1675 | 327 * To issue a command and handle it properly. */ |
1011 | 328 |
1675 | 329 if (message[0] == '/') |
1742 | 330 { |
331 | |
332 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
333 /* We have /me!! We have /me!! :-) */ | |
334 | |
335 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
336 strcpy(temp, message + 4); | |
337 | |
338 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, | |
339 '\001'); | |
340 g_free(temp); | |
341 } | |
342 else if ((g_strncasecmp(message, "/op ", 4) == 0) && (strlen(message) > 4)) { | |
343 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
344 strcpy(temp, message + 4); | |
345 | |
346 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +o %s\n", channel->name, temp); | |
347 | |
348 g_free(temp); | |
349 is_command = TRUE; | |
350 | |
351 } | |
352 else if ((g_strncasecmp(message, "/deop ", 6) == 0) && (strlen(message) > 6)) { | |
353 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
354 strcpy(temp, message + 6); | |
355 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -o %s\n", channel->name, temp); | |
356 | |
357 g_free(temp); | |
358 is_command = TRUE; | |
1675 | 359 } |
1742 | 360 |
361 else if ((g_strncasecmp(message, "/voice ", 7) == 0) && (strlen(message) > 7)) { | |
362 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
363 strcpy(temp, message + 7); | |
364 | |
365 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s +v %s\n", channel->name, temp); | |
366 | |
367 g_free(temp); | |
368 is_command = TRUE; | |
369 | |
370 } | |
371 else if ((g_strncasecmp(message, "/devoice ", 9) == 0) && (strlen(message) > 9)) { | |
372 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
373 strcpy(temp, message + 6); | |
374 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s -v %s\n", channel->name, temp); | |
375 | |
376 g_free(temp); | |
377 is_command = TRUE; | |
378 } | |
379 else if ((g_strncasecmp(message, "/mode ", 6) == 0) && (strlen(message) > 6)) { | |
380 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
381 strcpy(temp, message + 6); | |
382 g_snprintf(buf, IRC_BUF_LEN, "MODE #%s %s\n", channel->name, temp); | |
383 g_free(temp); | |
384 is_command = TRUE; | |
385 } | |
386 | |
387 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { | |
388 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
389 | |
390 strcpy(temp, message + 7); | |
391 irc_get_info(gc, temp); | |
392 g_free(temp); | |
1847 | 393 is_command = TRUE; |
1742 | 394 |
395 } | |
396 | |
1847 | 397 else if (!g_strncasecmp(message, "/part", 5) && (strlen(message) == 5)) { |
398 | |
399 /* If I'm not mistaken, the chat_leave command was coded under the | |
400 * pretense that it would only occur when someone closed the window. | |
401 * For this reason, the /part command will not close the window. Nor | |
402 * will the window close when the user is /kicked. I'll let you decide | |
403 * the best way to fix it--I'd imagine it'd just be a little line like | |
404 * if (convo) close (convo), but I'll let you decide where to put it. | |
405 */ | |
406 | |
407 irc_chat_leave(gc, id); | |
408 is_command = TRUE; | |
409 return; | |
410 | |
411 | |
412 } | |
413 | |
414 else if (!g_strncasecmp(message, "/join ", 6) && (strlen(message) > 6)) { | |
415 | |
416 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
417 | |
418 strcpy(temp, message + 6); | |
419 | |
420 | |
421 irc_join_chat(gc, 0, temp); | |
422 g_free(temp); | |
423 is_command = TRUE; | |
424 return; | |
425 } | |
426 | |
1742 | 427 else if (!g_strncasecmp(message, "/raw ", 5) && (strlen(message) > 5)){ |
428 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
429 strcpy(temp, message + 5); | |
430 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
431 g_free(temp); | |
432 is_command = TRUE; | |
433 } | |
1847 | 434 |
1742 | 435 else if (!g_strncasecmp(message, "/quote ", 7) && (strlen(message) >7)) { |
436 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
437 strcpy(temp, message + 7); | |
438 g_snprintf(buf, IRC_BUF_LEN, "%s\r\n", temp); | |
439 g_free(temp); | |
440 is_command = TRUE; | |
441 } | |
442 | |
443 else if (!g_strncasecmp(message, "/kick ", 6) && (strlen(message) > 6)) { | |
444 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
445 strcpy(temp, message + 6); | |
446 kick = g_strsplit(temp, " ", 2); | |
447 g_snprintf(buf, IRC_BUF_LEN, "KICK #%s %s :%s\r\n", channel->name, kick[0], kick[1]); | |
448 g_free(temp); | |
449 is_command = TRUE; | |
450 } | |
451 | |
452 /* FIXME: I'll go back in and grab this later. -- Rob */ | |
453 /* | |
454 I THOUGHT THIS WOULD WORK, BUT I WAS WRONG. WOULD SOMEONE KINDLY FIX IT? | |
1675 | 455 |
1742 | 456 |
457 else if (!g_strncasecmp(message, "/help", 5)) { | |
458 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
459 strcpy(temp, message + 5); | |
460 if (temp == "") { | |
461 | |
462 serv_got_chat_in(gc, id, "gAIM", 0, "Available Commands:"); | |
463 serv_got_chat_in(gc, id, "gAIM", 0, " "); | |
464 serv_got_chat_in(gc, id, "gAIM", 0, "<b>op voice kick </b>"); | |
465 serv_got_chat_in(gc, id, "gAIM", 0, "<b>deop devoice whois</b>"); | |
466 serv_got_chat_in(gc, id, "gAIM", 0, "<b>me raw quote</b>"); | |
467 serv_got_chat_in(gc, id, "gAIM", 0, "<b>mode</b>"); | |
468 } | |
469 else { | |
470 serv_got_chat_in(gc, id, "gAIM", 0, "Usage: "); | |
471 if (temp == "op") | |
472 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/op <nick></b> - Gives operator status to user."); | |
473 else if (temp == "deop") | |
474 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/deop <nick></b> - Removes operator status from user."); | |
475 else if (temp == "me") | |
476 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/me <action></b> - Sends an action to the channel."); | |
477 else if (temp == "mode") | |
478 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/mode {[+|-}|o|p|s|i|t|n|b|v} [<limit][<nick>][<ban mask]</b> - Changes channel and user modes."); | |
479 else if (temp == "voice") | |
480 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/voice <nick></b> - Gives voice status to user."); | |
481 else if (temp == "devoice") | |
482 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/devoice <nick></b> - Removes voice status from user."); | |
483 else if (temp == "raw") | |
484 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
485 else if (temp == "kick") | |
486 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/kick [<comment>]</b> - Kicks a user out of the channel."); | |
487 else if (temp == "whois") | |
488 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/whois <nick></b> - Gets information about user."); | |
489 else if (temp == "quote") | |
490 serv_got_chat_in(gc, id, "gAIM", 0, "<b>/raw <text></b> - Sends raw text to the server."); | |
491 else | |
492 serv_got_chat_in(gc, id, "gAIM", 0, "No such command."); | |
493 } | |
494 | |
495 g_free(temp); | |
496 is_command = TRUE; | |
497 } | |
498 */ | |
499 | |
500 } | |
501 | |
1675 | 502 else { |
1742 | 503 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%s\n", channel->name, message); |
504 | |
505 } | |
506 | |
507 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
508 write(idata->fd, buf, strlen(buf)); |
1742 | 509 |
1011 | 510 /* Since AIM expects us to receive the message we send, we gotta fake it */ |
1742 | 511 if (is_command==FALSE) |
1764 | 512 serv_got_chat_in(gc, id, gc->username, 0, message, time((time_t)NULL)); |
1742 | 513 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
514 g_free(buf); |
1742 | 515 |
516 | |
1008 | 517 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
518 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
519 { |
1014 | 520 GSList *bc = gc->buddy_chats; |
521 struct conversation *b = NULL; | |
522 | |
523 while (bc) { | |
524 b = (struct conversation *)bc->data; | |
525 if (id == b->id) { | |
526 break; | |
527 } | |
528 bc = bc->next; | |
529 b = NULL; | |
530 } | |
531 | |
532 if (!b) { | |
533 return NULL; | |
534 } | |
535 | |
536 return b; | |
537 } | |
538 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
539 static struct conversation *find_conversation_by_name(struct gaim_connection *gc, char *name) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
540 { |
1014 | 541 GSList *bc = gc->buddy_chats; |
542 struct conversation *b = NULL; | |
543 | |
544 while (bc) { | |
545 b = (struct conversation *)bc->data; | |
546 | |
547 if (g_strcasecmp(name, b->name) == 0) { | |
548 break; | |
549 } | |
550 bc = bc->next; | |
551 b = NULL; | |
552 } | |
553 | |
554 if (!b) { | |
555 return NULL; | |
556 } | |
557 | |
558 return b; | |
559 } | |
560 | |
561 | |
562 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
563 static void irc_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
564 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
565 struct gaim_connection *gc = data; |
1011 | 566 int i = 0; |
567 gchar buf[4096]; | |
568 gchar **buf2; | |
569 struct irc_data *idata; | |
1742 | 570 |
571 idata = (struct irc_data *)gc->proto_data; | |
1011 | 572 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
573 |
1011 | 574 do { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
575 if (read(idata->fd, buf + i, 1) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
576 hide_login_progress(gc, "Read error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
577 signoff(gc); |
1105 | 578 return; |
1011 | 579 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
580 } while (buf[i++] != '\n'); |
1011 | 581 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
582 buf[--i] = '\0'; |
1301 | 583 g_strchomp(buf); |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
584 g_print("%s\n", buf); |
1105 | 585 |
586 /* Check for errors */ | |
587 | |
588 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) && | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
589 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) { |
1105 | 590 |
591 gchar *u_errormsg; | |
592 | |
593 /* Let's get our error message */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
594 u_errormsg = g_strdup(buf + 7); |
1105 | 595 |
596 /* We got our error message. Now, let's reaise an | |
597 * error dialog */ | |
598 | |
599 do_error_dialog(u_errormsg, "Gaim: IRC Error"); | |
600 | |
601 /* And our necessary garbage collection */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
602 g_free(u_errormsg); |
1847 | 603 return; |
1105 | 604 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
605 |
1673 | 606 /* This should be a whois response. I only care about the first (311) one. I might do |
607 * the other's later. They're boring. */ | |
608 | |
609 if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
610 char **res; | |
611 | |
612 res = g_strsplit(buf, " ", 7); | |
613 | |
614 if (!strcmp(res[1], "311")) | |
615 { | |
616 char buf[8192]; | |
617 | |
618 g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>" | |
619 "<b>Host:</b> %s@%s<br>" | |
620 "<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1); | |
621 | |
622 g_show_info_text(buf); | |
623 } | |
624 | |
625 g_strfreev(res); | |
1847 | 626 return; |
1673 | 627 } |
628 | |
1676 | 629 /* Autoresponse to an away message */ |
630 if (((strstr(buf, " 301 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
631 char **res; | |
632 | |
633 res = g_strsplit(buf, " ", 5); | |
634 | |
635 if (!strcmp(res[1], "301")) | |
1764 | 636 serv_got_im(gc, res[3], res[4] + 1, 1, time((time_t)NULL)); |
1676 | 637 |
638 g_strfreev(res); | |
1847 | 639 return; |
1676 | 640 } |
641 | |
1014 | 642 /* Parse the list of names that we receive when we first sign on to |
643 * a channel */ | |
644 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
645 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1014 | 646 gchar u_host[255]; |
647 gchar u_command[32]; | |
648 gchar u_channel[128]; | |
649 gchar u_names[IRC_BUF_LEN + 1]; | |
650 struct conversation *convo = NULL; | |
651 int j; | |
652 | |
653 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
654 u_host[j] = buf[i]; | |
655 } | |
656 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
657 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
658 i++; |
1014 | 659 |
660 for (j = 0; buf[i] != ' '; j++, i++) { | |
661 u_command[j] = buf[i]; | |
662 } | |
663 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
664 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
665 i++; |
1014 | 666 |
667 for (j = 0; buf[i] != '#'; j++, i++) { | |
668 } | |
669 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
670 |
1014 | 671 for (j = 0; buf[i] != ':'; j++, i++) { |
672 u_channel[j] = buf[i]; | |
673 } | |
674 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
675 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
676 i++; |
1014 | 677 |
678 while ((buf[i] == ' ') || (buf[i] == ':')) { | |
679 i++; | |
680 } | |
681 | |
682 strcpy(u_names, buf + i); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
683 |
1014 | 684 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
685 |
1014 | 686 /* Let's get our conversation window */ |
687 convo = find_conversation_by_name(gc, u_channel); | |
688 | |
689 if (!convo) { | |
690 return; | |
691 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
692 |
1014 | 693 /* Now that we've parsed the hell out of this big |
694 * mess, let's try to split up the names properly */ | |
695 | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
696 for (i = 0; buf2[i] != NULL; i++) |
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
697 add_chat_buddy(convo, buf2[i]); |
1021 | 698 |
699 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
700 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
701 |
1014 | 702 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
703 |
1014 | 704 } |
705 | |
1022 | 706 /* Receive a list of users that are currently online */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
707 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
708 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1022 | 709 gchar u_host[255]; |
710 gchar u_command[32]; | |
711 gchar u_names[IRC_BUF_LEN + 1]; | |
712 int j; | |
713 | |
714 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
715 u_host[j] = buf[i]; | |
716 } | |
717 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
718 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
719 i++; |
1022 | 720 |
721 for (j = 0; buf[i] != ' '; j++, i++) { | |
722 u_command[j] = buf[i]; | |
723 } | |
724 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
725 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
726 i++; |
1022 | 727 |
728 for (j = 0; buf[i] != ':'; j++, i++) { | |
729 /* My Nick */ | |
730 } | |
731 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
732 |
1022 | 733 strcpy(u_names, buf + i); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
734 |
1022 | 735 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
736 |
1022 | 737 /* Now that we've parsed the hell out of this big |
738 * mess, let's try to split up the names properly */ | |
739 | |
740 for (i = 0; buf2[i] != NULL; i++) { | |
741 /* If we have a name here then our buddy is online. We should | |
742 * update our temporary gslist accordingly. When we achieve our maximum | |
743 * list of names then we should force an update */ | |
744 | |
745 irc_update_user(gc, buf2[i], 1); | |
746 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
747 |
1022 | 748 /* Increase our received blocks counter */ |
749 idata->recblocks++; | |
750 | |
751 /* If we have our total number of blocks */ | |
752 if (idata->recblocks == idata->totalblocks) { | |
753 GSList *temp; | |
754 struct irc_channel *u; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
755 |
1022 | 756 /* Let's grab our list of people and bring them all on or off line */ |
757 temp = idata->templist; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
758 |
1022 | 759 /* Loop */ |
760 while (temp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
761 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
762 u = temp->data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
763 |
1022 | 764 /* Tell Gaim to bring the person on or off line */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
765 serv_got_update(gc, u->name, u->id, 0, 0, 0, 0, 0); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
766 |
1022 | 767 /* Grab the next entry */ |
768 temp = g_slist_next(temp); | |
769 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
770 |
1022 | 771 /* And now, let's delete all of our entries */ |
772 temp = idata->templist; | |
773 while (temp) { | |
774 u = temp->data; | |
775 g_free(u->name); | |
776 temp = g_slist_remove(temp, u); | |
777 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
778 |
1022 | 779 /* Reset our list */ |
780 idata->totalblocks = 0; | |
781 idata->recblocks = 0; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
782 |
1022 | 783 idata->templist = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
784 |
1022 | 785 return; |
786 } | |
787 | |
788 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
789 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
790 |
1022 | 791 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
792 |
1022 | 793 } |
794 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
795 |
1847 | 796 if ((strstr(buf, " MODE ")) && (strstr(buf, "!")) && (strstr(buf, "+v") || strstr(buf, "-v") || strstr(buf, "-o") || strstr(buf, "+o")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
797 | |
798 gchar u_channel[128]; | |
799 gchar u_nick[128]; | |
800 | |
801 gchar u_mode[5]; | |
802 char **people; | |
803 gchar *temp, *temp_new; | |
804 | |
805 | |
806 struct irc_channel *channel; | |
807 int j; | |
808 temp = NULL; | |
809 temp_new = NULL; | |
810 | |
811 | |
812 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
813 u_nick[j] = buf[i]; | |
814 } | |
815 u_nick[j] = '\0'; | |
816 i++; | |
817 | |
818 for (j = 0; buf[i] != '#'; j++, i++) { | |
819 } | |
820 i++; | |
821 | |
822 for (j = 0; buf[i] != ' '; j++, i++) { | |
823 u_channel[j] = buf[i]; | |
824 } | |
825 | |
826 u_channel[j] = '\0'; | |
827 i++; | |
828 | |
829 for (j = 0; buf[i] != ' '; j++, i++) { | |
830 u_mode[j] = buf[i]; | |
831 } | |
832 u_mode[j] = '\0'; | |
833 i++; | |
834 | |
835 | |
836 | |
837 | |
838 people = g_strsplit(buf + i, " ", 3); | |
839 | |
840 | |
841 | |
842 channel = find_channel_by_name(gc, u_channel); | |
843 | |
844 if (!channel) { | |
845 return; | |
846 } | |
847 | |
848 for (j = 0; j < strlen(u_mode) - 1 ; j++) | |
849 { | |
850 | |
851 | |
852 struct conversation *convo = NULL; | |
853 convo = find_conversation_by_id(gc, channel->id); | |
854 | |
855 | |
856 | |
1848 | 857 temp = (gchar *)g_malloc(strlen(people[j]) + 3); |
858 temp_new = (gchar *)g_malloc(strlen(people[j]) + 3); | |
1847 | 859 g_snprintf(temp, strlen(people[j]) + 2, "@%s", people[j]); |
860 | |
861 if (u_mode[1] == 'v' && u_mode[0] == '+') { | |
862 g_snprintf(temp_new, strlen(people[j]) + 2, "+%s", people[j]); | |
863 } | |
864 else if (u_mode[1] == 'o' && u_mode[0] == '+') { | |
865 g_snprintf(temp_new, strlen(people[j]) + 2, "@%s", people[j]); | |
866 } | |
867 | |
868 else if (u_mode[0] == '-') { | |
869 g_snprintf(temp_new, strlen(people[j]) + 1, "%s", people[j]); | |
870 } | |
871 | |
872 | |
873 | |
874 rename_chat_buddy(convo, temp, temp_new); | |
875 g_snprintf(temp, strlen(people[j]) + 2, "+%s", people[j]); | |
876 rename_chat_buddy(convo, temp, temp_new); | |
877 | |
878 rename_chat_buddy(convo, people[j], temp_new); | |
879 | |
880 | |
881 | |
882 | |
883 | |
884 } | |
885 if (temp) | |
886 g_free(temp); | |
887 if (temp_new) | |
888 g_free(temp_new); | |
889 | |
890 return; | |
891 } | |
892 | |
893 | |
894 if ((strstr(buf, " KICK ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | |
895 gchar u_channel[128]; | |
896 gchar u_nick[128]; | |
897 gchar u_comment[128]; | |
898 gchar u_who[128]; | |
899 | |
900 int id; | |
901 | |
902 gchar *temp; | |
903 | |
904 | |
905 | |
906 struct irc_channel *channel; | |
907 int j; | |
908 | |
909 temp = NULL; | |
910 | |
911 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
912 u_nick[j] = buf[i]; | |
913 } | |
914 u_nick[j] = '\0'; | |
915 i++; | |
916 | |
917 for (j = 0; buf[i] != '#'; j++, i++) { | |
918 } | |
919 i++; | |
920 | |
921 for (j = 0; buf[i] != ' '; j++, i++) { | |
922 u_channel[j] = buf[i]; | |
923 } | |
924 | |
925 u_channel[j] = '\0'; | |
926 i++; | |
927 | |
928 for (j = 0; buf[i] != ' '; j++, i++) { | |
929 u_who[j] = buf[i]; | |
930 } | |
931 u_who[j] = '\0'; | |
932 i++; | |
933 i++; | |
934 strcpy(u_comment, buf + i); | |
935 g_strchomp(u_comment); | |
936 | |
937 channel = find_channel_by_name(gc, u_channel); | |
938 | |
939 if (!channel) { | |
940 return; | |
941 } | |
942 | |
943 | |
944 id = find_id_by_name(gc, u_channel); | |
945 | |
946 | |
947 if (g_strcasecmp(u_nick, gc->username) == 0) { | |
948 | |
949 /* It looks like you've been naughty! */ | |
950 | |
951 serv_got_chat_left(gc, channel->id); | |
952 | |
953 idata->channels = g_list_remove(idata->channels, channel); | |
954 } | |
955 else { | |
956 struct conversation *convo = NULL; | |
957 | |
958 /* Find their conversation window */ | |
959 convo = find_conversation_by_id(gc, channel->id); | |
960 | |
961 if (!convo) { | |
962 /* Some how the window doesn't exist. | |
963 * Let's get out of here */ | |
964 return; | |
965 } | |
966 | |
967 /* And remove their name */ | |
968 /* If the person is an op or voice, this won't work. | |
969 * so we'll just do a nice hack and remove nick and | |
970 * @nick and +nick. Truly wasteful. | |
971 */ | |
972 | |
1848 | 973 temp = (gchar *) g_malloc(strlen(u_who) + 3); |
1847 | 974 g_snprintf(temp, strlen(u_who) + 2, "@%s", u_who); |
975 remove_chat_buddy(convo, temp); | |
1848 | 976 g_free(temp); |
977 temp = (gchar *) g_malloc(strlen(u_who) + 3); | |
1847 | 978 g_snprintf(temp, strlen(u_who) + 2, "+%s", u_who); |
979 remove_chat_buddy(convo, temp); | |
980 remove_chat_buddy(convo, u_who); | |
981 | |
1848 | 982 g_free(temp); |
1847 | 983 |
984 } | |
985 | |
986 /* Go Home! */ | |
987 return; | |
988 } | |
989 | |
990 | |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
991 if ((strstr(buf, " JOIN ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 992 |
993 gchar u_channel[128]; | |
1012 | 994 gchar u_nick[128]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
995 |
1011 | 996 struct irc_channel *channel; |
997 int j; | |
998 | |
1012 | 999 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
1000 u_nick[j] = buf[i]; | |
1001 } | |
1002 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1003 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1004 i++; |
1012 | 1005 |
1006 for (j = 0; buf[i] != '#'; j++, i++) { | |
1011 | 1007 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1008 |
1011 | 1009 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1010 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1011 strcpy(u_channel, buf + i); |
1011 | 1012 |
1301 | 1013 g_strchomp(u_channel); |
1014 | |
1014 | 1015 /* Looks like we're going to join the channel for real |
1016 * now. Let's create a valid channel structure and add | |
1017 * it to our list. Let's make sure that | |
1011 | 1018 * we are not already in a channel first */ |
1019 | |
1020 channel = find_channel_by_name(gc, u_channel); | |
1021 | |
1022 if (!channel) { | |
1301 | 1023 |
1011 | 1024 chat_id++; |
1025 | |
1026 channel = g_new0(struct irc_channel, 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1027 |
1011 | 1028 channel->id = chat_id; |
1029 channel->name = strdup(u_channel); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1030 |
1011 | 1031 idata->channels = g_list_append(idata->channels, channel); |
1032 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1033 serv_got_joined_chat(gc, chat_id, u_channel); |
1011 | 1034 } else { |
1014 | 1035 struct conversation *convo = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1036 |
1014 | 1037 /* Someone else joined. Find their conversation |
1038 * window */ | |
1039 convo = find_conversation_by_id(gc, channel->id); | |
1040 | |
1041 /* And add their name to it */ | |
1042 add_chat_buddy(convo, u_nick); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1043 |
1011 | 1044 } |
1045 | |
1046 return; | |
1047 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1048 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1049 if ((strstr(buf, " NICK ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1050 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1051 gchar old[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1052 gchar new[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1053 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1054 GList *templist; |
1847 | 1055 gchar *temp, *temp_new; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1056 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1057 int j; |
1847 | 1058 temp = temp_new = NULL; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1059 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1060 old[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1061 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1062 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1063 old[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1064 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1065 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1066 for (j = 0; buf[i] != ':'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1067 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1068 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1069 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1070 strcpy(new, buf + i); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1071 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1072 g_strchomp(new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1073 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1074 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1075 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1076 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1077 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1078 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1079 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1080 convo = find_conversation_by_id(gc, channel->id); |
1847 | 1081 |
1082 /* If the person is an op or voice, this won't work. | |
1083 * so we'll just do a nice hack and rename nick and | |
1084 * @nick and +nick. Truly wasteful. | |
1085 */ | |
1086 | |
1087 temp = (gchar *)g_malloc(strlen(old) + 5); | |
1088 temp_new = (gchar *)g_malloc(strlen(new) + 5); | |
1089 g_snprintf(temp_new, strlen(new) + 2, "@%s", new); | |
1090 g_snprintf(temp, strlen(old) + 2, "@%s", old); | |
1091 rename_chat_buddy(convo, temp, temp_new); | |
1092 g_snprintf(temp, strlen(old) + 2, "+%s", old); | |
1093 g_snprintf(temp_new, strlen(new) + 2, "+%s", new); | |
1094 rename_chat_buddy(convo, temp, temp_new); | |
1095 rename_chat_buddy(convo, old, new); | |
1096 if (temp) | |
1097 g_free(temp); | |
1098 if (temp_new) | |
1099 g_free(temp_new); | |
1100 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1101 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1102 } |
1847 | 1103 return; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1104 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1105 |
1847 | 1106 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1107 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (strstr(buf, "!")) && (!strstr(buf, " NOTICE "))) { |
1847 | 1108 |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1109 gchar u_nick[128]; |
1847 | 1110 gchar *temp; |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1111 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1112 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1113 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1114 int j; |
1847 | 1115 |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1116 |
1847 | 1117 temp = NULL; |
1118 for (j = 0, i = 1 ; buf[i] != '!'; j++, i++) { | |
1119 u_nick[j] = buf[i]; | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1120 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1121 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1122 u_nick[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1123 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1124 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1125 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1126 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1127 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1128 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1129 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1130 convo = find_conversation_by_id(gc, channel->id); |
1847 | 1131 |
1132 /* If the person is an op or voice, this won't work. | |
1133 * so we'll just do a nice hack and remove nick and | |
1134 * @nick and +nick. Truly wasteful. | |
1135 */ | |
1136 | |
1137 temp = (gchar *) g_malloc(strlen(u_nick) + 2); | |
1138 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1139 remove_chat_buddy(convo, temp); | |
1848 | 1140 g_free(temp); |
1141 temp = (gchar *) g_malloc(strlen(u_nick) + 2); | |
1847 | 1142 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); |
1143 remove_chat_buddy(convo, temp); | |
1144 remove_chat_buddy(convo, u_nick); | |
1145 | |
1146 | |
1147 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1148 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1149 } |
1847 | 1150 |
1848 | 1151 g_free(temp); |
1847 | 1152 |
1153 return; | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1154 } |
1847 | 1155 |
1156 | |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1157 |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
1158 if ((strstr(buf, " PART ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 1159 |
1847 | 1160 gchar u_channel[128]; |
1011 | 1161 gchar u_nick[128]; |
1847 | 1162 gchar *temp; |
1021 | 1163 struct irc_channel *channel; |
1011 | 1164 int j; |
1847 | 1165 temp = NULL; |
1011 | 1166 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
1167 u_nick[j] = buf[i]; | |
1168 } | |
1169 u_nick[j] = '\0'; | |
1170 | |
1171 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1172 |
1011 | 1173 for (j = 0; buf[i] != '#'; j++, i++) { |
1174 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1175 |
1011 | 1176 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1177 |
1847 | 1178 for (j = 0; buf[i] != ' '; j++, i++) { |
1179 if (buf[i] == '\0') { | |
1180 break; | |
1181 } | |
1182 u_channel[j] = buf[i]; | |
1183 } | |
1184 u_channel[j] = '\0'; | |
1185 | |
1186 /* Now, lets check to see if it was US that was leaving. | |
1014 | 1187 * If so, do the correct thing by closing up all of our |
1188 * old channel stuff. Otherwise, | |
1011 | 1189 * we should just print that someone left */ |
1190 | |
1014 | 1191 channel = find_channel_by_name(gc, u_channel); |
1192 | |
1193 if (!channel) { | |
1847 | 1194 return; |
1014 | 1195 } |
1847 | 1196 |
1011 | 1197 if (g_strcasecmp(u_nick, gc->username) == 0) { |
1848 | 1198 |
1199 /* Looks like we're going to leave the channel for | |
1200 * real now. Let's create a valid channel structure | |
1201 * and add it to our list */ | |
1202 | |
1203 serv_got_chat_left(gc, channel->id); | |
1204 | |
1205 idata->channels = g_list_remove(idata->channels, channel); | |
1206 } | |
1207 else { | |
1208 struct conversation *convo = NULL; | |
1209 | |
1210 /* Find their conversation window */ | |
1211 convo = find_conversation_by_id(gc, channel->id); | |
1212 | |
1213 if (!convo) { | |
1014 | 1214 /* Some how the window doesn't exist. |
1215 * Let's get out of here */ | |
1848 | 1216 return; |
1217 } | |
1218 | |
1219 /* And remove their name */ | |
1220 /* If the person is an op or voice, this won't work. | |
1221 * so we'll just do a nice hack and remove nick and | |
1222 * @nick and +nick. Truly wasteful. | |
1223 */ | |
1224 | |
1225 temp = (gchar *) g_malloc(strlen(u_nick) + 3); | |
1226 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1227 remove_chat_buddy(convo, temp); | |
1228 g_free(temp); | |
1229 temp = (gchar *) g_malloc(strlen(u_nick) + 3); | |
1230 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); | |
1231 remove_chat_buddy(convo, temp); | |
1232 g_free(temp); | |
1233 remove_chat_buddy(convo, u_nick); | |
1234 | |
1235 | |
1011 | 1236 } |
1848 | 1237 |
1014 | 1238 /* Go Home! */ |
1011 | 1239 return; |
1240 } | |
1848 | 1241 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1242 if ((strstr(buf, " NOTICE ")) && (buf[0] == ':')) { |
1178 | 1243 gchar u_nick[128]; |
1244 gchar u_host[255]; | |
1245 gchar u_command[32]; | |
1246 gchar u_channel[128]; | |
1247 gchar u_message[IRC_BUF_LEN]; | |
1248 int j; | |
1249 | |
1250 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
1251 u_nick[j] = buf[i]; | |
1252 } | |
1253 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1254 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1255 i++; |
1178 | 1256 |
1257 for (j = 0; buf[i] != ' '; j++, i++) { | |
1258 u_host[j] = buf[i]; | |
1259 } | |
1260 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1261 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1262 i++; |
1178 | 1263 |
1264 for (j = 0; buf[i] != ' '; j++, i++) { | |
1265 u_command[j] = buf[i]; | |
1266 } | |
1267 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1268 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1269 i++; |
1178 | 1270 |
1271 for (j = 0; buf[i] != ':'; j++, i++) { | |
1272 u_channel[j] = buf[i]; | |
1273 } | |
1274 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1275 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1276 i++; |
1178 | 1277 |
1278 | |
1279 /* Now that everything is parsed, the rest of this baby must be our message */ | |
1280 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1281 | |
1282 /* Now, lets check the message to see if there's anything special in it */ | |
1283 if (u_message[0] == '\001') { | |
1284 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
1285 /* Someone's triyng to ping us. Let's respond */ | |
1286 gchar u_arg[24]; | |
1287 gchar u_buf[200]; | |
1393 | 1288 unsigned long tend= time((time_t *)NULL); |
1289 unsigned long tstart; | |
1290 | |
1291 printf("LA: %s\n", buf); | |
1178 | 1292 |
1293 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1294 u_arg[strlen(u_arg) - 1] = '\0'; |
1178 | 1295 |
1393 | 1296 tstart = atol(u_arg); |
1297 | |
1298 g_snprintf(u_buf, sizeof(u_buf), "Ping Reply From %s: [%ld seconds]", u_nick, tend-tstart); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1299 |
1178 | 1300 do_error_dialog(u_buf, "Gaim IRC - Ping Reply"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1301 |
1178 | 1302 return; |
1303 } | |
1304 } | |
1305 | |
1306 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1307 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1308 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1309 if ((strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) { |
1847 | 1310 gchar u_nick[128]; |
1311 gchar u_host[255]; | |
1312 gchar u_command[32]; | |
1313 gchar u_channel[128]; | |
1314 gchar u_message[IRC_BUF_LEN]; | |
1848 | 1315 gboolean is_closing; |
1316 | |
1847 | 1317 int j; |
1318 | |
1319 | |
1320 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
1321 u_nick[j] = buf[i]; | |
1322 } | |
1323 | |
1324 u_nick[j] = '\0'; | |
1325 i++; | |
1326 | |
1327 for (j = 0; buf[i] != ' '; j++, i++) { | |
1328 u_host[j] = buf[i]; | |
1329 } | |
1330 | |
1331 u_host[j] = '\0'; | |
1332 i++; | |
1333 | |
1334 for (j = 0; buf[i] != ' '; j++, i++) { | |
1335 u_command[j] = buf[i]; | |
1336 } | |
1337 | |
1338 u_command[j] = '\0'; | |
1339 i++; | |
1340 | |
1341 for (j = 0; buf[i] != ':'; j++, i++) { | |
1342 u_channel[j] = buf[i]; | |
1343 } | |
1344 | |
1345 u_channel[j - 1] = '\0'; | |
1346 i++; | |
1347 | |
1348 | |
1349 /* Now that everything is parsed, the rest of this baby must be our message */ | |
1350 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1351 | |
1352 /* Now, lets check the message to see if there's anything special in it */ | |
1353 if (u_message[0] == '\001') { | |
1354 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) { | |
1017 | 1355 /* Looks like we have a version request. Let |
1356 * us handle it thusly */ | |
1847 | 1357 |
1358 g_snprintf(buf, IRC_BUF_LEN, | |
1359 "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:%s%c\n", | |
1360 u_nick, '\001', VERSION, WEBSITE, '\001'); | |
1361 | |
1362 write(idata->fd, buf, strlen(buf)); | |
1363 | |
1017 | 1364 /* And get the heck out of dodge */ |
1847 | 1365 return; |
1366 } | |
1367 | |
1368 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
1017 | 1369 /* Someone's triyng to ping us. Let's respond */ |
1847 | 1370 gchar u_arg[24]; |
1371 | |
1372 strcpy(u_arg, u_message + 6); | |
1373 u_arg[strlen(u_arg) - 1] = '\0'; | |
1374 | |
1375 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', | |
1376 u_arg, '\001'); | |
1377 | |
1378 write(idata->fd, buf, strlen(buf)); | |
1379 | |
1017 | 1380 /* And get the heck out of dodge */ |
1847 | 1381 return; |
1382 } | |
1383 | |
1384 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) { | |
1011 | 1385 /* Looks like we have an action. Let's parse it a little */ |
1847 | 1386 strcpy(buf, u_message); |
1387 | |
1388 strcpy(u_message, "/me "); | |
1389 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) { | |
1390 u_message[j] = buf[i]; | |
1391 } | |
1392 u_message[j] = '\0'; | |
1393 } | |
1394 } | |
1011 | 1395 |
1396 | |
1847 | 1397 /* OK, It is a chat or IM message. Here, let's translate the IRC formatting into |
1398 * good ol' fashioned gtkimhtml style hypertext markup. */ | |
1399 | |
1848 | 1400 |
1401 is_closing = FALSE; | |
1402 | |
1847 | 1403 while(strchr(u_message, '\002')) { // \002 = ^B |
1404 gchar *current; | |
1405 gchar *temp, *free_here; | |
1406 | |
1407 | |
1408 temp = g_strdup(strchr(u_message, '\002')); | |
1409 free_here = temp; | |
1410 temp++; | |
1411 | |
1412 current = strchr(u_message, '\002'); | |
1413 *current = '<'; | |
1414 current++; | |
1848 | 1415 if (is_closing) { |
1416 *current = '/'; | |
1417 current++; | |
1418 } | |
1847 | 1419 *current = 'b'; |
1420 current++; | |
1421 *current = '>'; | |
1422 current++; | |
1423 | |
1424 | |
1425 while (*temp != '\0') { | |
1426 *current = *temp; | |
1427 current++; | |
1428 temp++; | |
1429 } | |
1430 *current = '\0'; | |
1431 g_free(free_here); | |
1432 | |
1848 | 1433 is_closing = !is_closing; |
1847 | 1434 } |
1848 | 1435 |
1436 is_closing = FALSE; | |
1847 | 1437 while(strchr(u_message, '\037')) { // \037 = ^_ |
1438 gchar *current; | |
1439 gchar *temp, *free_here; | |
1440 | |
1441 | |
1442 temp = g_strdup(strchr(u_message, '\037')); | |
1443 free_here = temp; | |
1444 temp++; | |
1445 | |
1446 current = strchr(u_message, '\037'); | |
1447 *current = '<'; | |
1448 current++; | |
1848 | 1449 if (is_closing) { |
1450 *current = '/'; | |
1451 current++; | |
1452 } | |
1847 | 1453 *current = 'u'; |
1454 current++; | |
1455 *current = '>'; | |
1456 current++; | |
1457 | |
1458 | |
1459 while (*temp != '\0') { | |
1460 *current = *temp; | |
1461 current++; | |
1462 temp++; | |
1463 } | |
1464 *current = '\0'; | |
1848 | 1465 g_free(free_here); |
1466 is_closing = !is_closing; | |
1467 | |
1468 } | |
1469 | |
1470 while(strchr(u_message, '\003')) { // \003 = ^C | |
1471 | |
1472 /* This is color formatting. IRC uses its own weird little system | |
1473 * that we must translate to HTML. */ | |
1474 | |
1475 | |
1476 /* The format is something like this: | |
1477 * ^C5 or ^C5,3 | |
1478 * The number before the comma is the foreground color, after is the | |
1479 * background color. Either number can be 1 or two digits. | |
1480 */ | |
1481 | |
1482 gchar *current; | |
1483 gchar *temp, *free_here; | |
1484 gchar *font_tag, *body_tag; | |
1485 int fg_color, bg_color; | |
1486 | |
1487 temp = g_strdup(strchr(u_message, '\003')); | |
1488 free_here = temp; | |
1489 temp++; | |
1490 | |
1491 fg_color = bg_color = -1; | |
1492 body_tag = font_tag = ""; | |
1493 | |
1494 /* Parsing the color information: */ | |
1495 do { | |
1496 if (!isdigit(*temp)) break; // This translates to </font> | |
1497 fg_color = (int)(*temp - 48); | |
1498 temp++; | |
1499 if (isdigit(*temp)) { | |
1500 fg_color = (fg_color * 10) + (int)(*temp - 48); | |
1501 temp++; | |
1502 } | |
1503 if (*temp != ',') break; | |
1504 temp++; | |
1505 if (!isdigit(*temp)) break; // This translates to </font> | |
1506 bg_color = (int)(*temp - 48); | |
1507 temp++; | |
1508 if (isdigit(*temp)) { | |
1509 bg_color = (bg_color * 10) + (int)(*temp - 48); | |
1510 temp++; | |
1511 } | |
1512 }while (FALSE); | |
1513 | |
1514 if (fg_color > 15) | |
1515 fg_color = fg_color % 16; | |
1516 if (bg_color > 15) | |
1517 bg_color = bg_color % 16; | |
1518 | |
1519 switch (fg_color) { | |
1520 case -1: | |
1521 font_tag = "</font></body>"; | |
1522 break; | |
1523 case 0: // WHITE | |
1524 font_tag = "<font color=\"#ffffff\">"; | |
1525 /* If no background color is specified, we're going to make it black anyway. | |
1526 * That's probably what the sender anticipated the background color to be. | |
1527 * White on white would be illegible. | |
1528 */ | |
1529 if (bg_color == -1) { | |
1530 body_tag = "<body bgcolor=\"#000000\">"; | |
1531 } | |
1532 break; | |
1533 case 1: // BLACK | |
1534 font_tag = "<font color=\"#000000\">"; | |
1535 break; | |
1536 case 2: // NAVY BLUE | |
1537 font_tag = "<font color=\"#000066\">"; | |
1538 break; | |
1539 case 3: // GREEN | |
1540 font_tag = "<font color=\"#006600\">"; | |
1541 break; | |
1542 case 4: // RED | |
1543 font_tag = "<font color=\"#ff0000\">"; | |
1544 break; | |
1545 case 5: // MAROON | |
1546 font_tag = "<font color=\"#660000\">"; | |
1547 break; | |
1548 case 6: // PURPLE | |
1549 font_tag = "<font color=\"#660066\">"; | |
1550 break; | |
1551 case 7: // DISGUSTING PUKE COLOR | |
1552 font_tag = "<font color=\"#666600\">"; | |
1553 break; | |
1554 case 8: // YELLOW | |
1555 font_tag = "<font color=\"#cccc00\">"; | |
1556 break; | |
1557 case 9: // LIGHT GREEN | |
1558 font_tag = "<font color=\"#33cc33\">"; | |
1559 break; | |
1560 case 10: // TEAL | |
1561 font_tag = "<font color=\"#00acac\">"; | |
1562 break; | |
1563 case 11: // CYAN | |
1564 font_tag = "<font color=\"#00ccac\">"; | |
1565 break; | |
1566 case 12: // BLUE | |
1567 font_tag = "<font color=\"#0000ff\">"; | |
1568 break; | |
1569 case 13: // PINK | |
1570 font_tag = "<font color=\"#cc00cc\">"; | |
1571 break; | |
1572 case 14: // GREY | |
1573 font_tag = "<font color=\"#666666\">"; | |
1574 break; | |
1575 case 15: // SILVER | |
1576 font_tag = "<font color=\"#00ccac\">"; | |
1577 break; | |
1578 } | |
1579 | |
1580 switch (bg_color) { | |
1581 case 0: // WHITE | |
1582 body_tag = "<body bgcolor=\"#ffffff\">"; | |
1583 break; | |
1584 case 1: // BLACK | |
1585 body_tag = "<body bgcolor=\"#000000\">"; | |
1586 break; | |
1587 case 2: // NAVY BLUE | |
1588 body_tag = "<body bgcolor=\"#000066\">"; | |
1589 break; | |
1590 case 3: // GREEN | |
1591 body_tag = "<body bgcolor=\"#006600\">"; | |
1592 break; | |
1593 case 4: // RED | |
1594 body_tag = "<body bgcolor=\"#ff0000\">"; | |
1595 break; | |
1596 case 5: // MAROON | |
1597 body_tag = "<body bgcolor=\"#660000\">"; | |
1598 break; | |
1599 case 6: // PURPLE | |
1600 body_tag = "<body bgcolor=\"#660066\">"; | |
1601 break; | |
1602 case 7: // DISGUSTING PUKE COLOR | |
1603 body_tag = "<body bgcolor=\"#666600\">"; | |
1604 break; | |
1605 case 8: // YELLOW | |
1606 body_tag = "<body bgcolor=\"#cccc00\">"; | |
1607 break; | |
1608 case 9: // LIGHT GREEN | |
1609 body_tag = "<body bgcolor=\"#33cc33\">"; | |
1610 break; | |
1611 case 10: // TEAL | |
1612 body_tag = "<body bgcolor=\"#00acac\">"; | |
1613 break; | |
1614 case 11: // CYAN | |
1615 body_tag = "<body bgcolor=\"#00ccac\">"; | |
1616 break; | |
1617 case 12: // BLUE | |
1618 body_tag = "<body bgcolor=\"#0000ff\">"; | |
1619 break; | |
1620 case 13: // PINK | |
1621 body_tag = "<body bgcolor=\"#cc00cc\">"; | |
1622 break; | |
1623 case 14: // GREY | |
1624 body_tag = "<body bgcolor=\"#666666\">"; | |
1625 break; | |
1626 case 15: // SILVER | |
1627 body_tag = "<body bgcolor=\"#00ccac\">"; | |
1628 break; | |
1629 } | |
1630 | |
1631 current = strchr(u_message, '\003'); | |
1632 | |
1633 while (*body_tag != '\0') { | |
1634 *current = *body_tag; | |
1635 current++; | |
1636 body_tag++; | |
1637 } | |
1638 | |
1639 while (*font_tag != '\0') { | |
1640 *current = *font_tag; | |
1641 current++; | |
1642 font_tag++; | |
1643 } | |
1644 | |
1645 while (*temp != '\0') { | |
1646 *current = *temp; | |
1647 current++; | |
1648 temp++; | |
1649 } | |
1650 *current = '\0'; | |
1651 g_free(free_here); | |
1652 is_closing = !is_closing; | |
1653 | |
1847 | 1654 } |
1011 | 1655 |
1847 | 1656 while(strchr(u_message, '\017')) { // \017 = ^O |
1657 gchar *current; | |
1658 gchar *temp, *free_here; | |
1659 | |
1660 | |
1661 temp = g_strdup(strchr(u_message, '\017')); | |
1662 free_here = temp; | |
1663 temp++; | |
1664 | |
1665 current = strchr(u_message, '\017'); | |
1666 *current = '<'; | |
1667 current++; | |
1668 *current = '/'; | |
1669 current++; | |
1670 *current = 'b'; | |
1671 current++; | |
1672 *current = '>'; | |
1673 current++; | |
1674 *current = '<'; | |
1675 current++; | |
1676 *current = '/'; | |
1677 current++; | |
1678 *current = 'u'; | |
1679 current++; | |
1680 *current = '>'; | |
1681 current++; | |
1682 | |
1683 while (*temp != '\0') { | |
1684 *current = *temp; | |
1685 current++; | |
1686 temp++; | |
1687 } | |
1688 *current = '\0'; | |
1689 g_free(free_here); | |
1690 } | |
1691 | |
1692 /* Let's check to see if we have a channel on our hands */ | |
1693 if (u_channel[0] == '#') { | |
1694 /* Yup. We have a channel */ | |
1695 int id; | |
1696 | |
1697 id = find_id_by_name(gc, u_channel); | |
1698 if (id != -1) { | |
1699 serv_got_chat_in(gc, id, u_nick, 0, u_message, time((time_t)NULL)); | |
1700 | |
1701 } | |
1702 | |
1703 } else { | |
1704 /* Nope. Let's treat it as a private message */ | |
1705 | |
1706 gchar *temp; | |
1707 temp = NULL; | |
1708 | |
1709 temp = (gchar *) g_malloc(strlen(u_nick) + 5); | |
1710 g_snprintf(temp, strlen(u_nick) + 2, "@%s", u_nick); | |
1711 | |
1712 | |
1713 /* If I get a message from SeanEgn, and I already have a window | |
1714 * open for him as @SeanEgn or +SeanEgn, this will keep it in the | |
1715 * same window. Unfortunately, if SeanEgn loses his op status | |
1716 * (a sad thing indeed), the messages will still appear to come from | |
1717 * @SeanEgn, until that convo is closed. | |
1718 */ | |
1719 | |
1720 if (find_conversation(temp)){ | |
1721 serv_got_im(gc, temp, u_message, 0, time((time_t)NULL)); | |
1848 | 1722 g_free(temp); |
1723 return; | |
1847 | 1724 } |
1725 else { | |
1726 g_snprintf(temp, strlen(u_nick) + 2, "+%s", u_nick); | |
1727 if (find_conversation(temp)) { | |
1728 serv_got_im(gc, temp, u_message, 0, time((time_t)NULL)); | |
1848 | 1729 g_free(temp); |
1730 return; | |
1847 | 1731 } |
1732 else { | |
1733 g_free(temp); | |
1734 serv_got_im(gc, u_nick, u_message, 0, time((time_t)NULL)); | |
1848 | 1735 return; |
1847 | 1736 } |
1737 } | |
1738 } | |
1739 | |
1740 return; | |
1011 | 1741 } |
1847 | 1742 |
1011 | 1743 /* Let's parse PING requests so that we wont get booted for inactivity */ |
1744 | |
1745 if (strncmp(buf, "PING :", 6) == 0) { | |
1746 buf2 = g_strsplit(buf, ":", 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1747 |
1011 | 1748 /* Let's build a new response */ |
1749 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]); | |
1750 write(idata->fd, buf, strlen(buf)); | |
1751 | |
1752 /* And clean up after ourselves */ | |
1753 g_strfreev(buf2); | |
1754 | |
1755 return; | |
1756 } | |
1757 | |
1758 } | |
1759 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1760 static void irc_close(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1761 { |
1011 | 1762 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 1763 GList *chats = idata->channels; |
1764 struct irc_channel *cc; | |
1765 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1766 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN); |
1011 | 1767 |
1847 | 1768 g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [%s]\n", WEBSITE); |
1011 | 1769 write(idata->fd, buf, strlen(buf)); |
1770 | |
1771 g_free(buf); | |
1021 | 1772 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1773 if (idata->timer) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1774 gtk_timeout_remove(idata->timer); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1775 |
1021 | 1776 while (chats) { |
1777 cc = (struct irc_channel *)chats->data; | |
1778 g_free(cc->name); | |
1779 chats = g_list_remove(chats, cc); | |
1780 g_free(cc); | |
1781 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1782 |
1021 | 1783 if (gc->inpa) |
1784 gdk_input_remove(gc->inpa); | |
1785 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1786 if (idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1787 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1788 |
1011 | 1789 close(idata->fd); |
1790 g_free(gc->proto_data); | |
1791 } | |
1792 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1793 static void irc_chat_leave(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1794 { |
1011 | 1795 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1796 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1797 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1798 |
1011 | 1799 channel = find_channel_by_id(gc, id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1800 |
1011 | 1801 if (!channel) { |
1802 return; | |
1803 } | |
1804 | |
1805 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name); | |
1806 write(idata->fd, buf, strlen(buf)); | |
1807 | |
1808 g_free(buf); | |
1809 } | |
1810 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1811 static void irc_login_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1812 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1813 struct gaim_connection *gc = data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1814 struct irc_data *idata = gc->proto_data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1815 char buf[4096]; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1816 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1817 if (source == -1) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1818 hide_login_progress(gc, "Write error"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1819 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1820 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1821 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1822 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1823 if (idata->fd == 0) |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1824 idata->fd = source; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1825 |
1847 | 1826 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (%s)\n", |
1827 gc->username, g_get_user_name(), gc->user->proto_opt[USEROPT_SERV], WEBSITE); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1828 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1829 if (write(idata->fd, buf, strlen(buf)) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1830 hide_login_progress(gc, "Write error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1831 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1832 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1833 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1834 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1835 idata->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_callback, gc); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1836 idata->inpa = 0; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1837 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1838 /* Now lets sign ourselves on */ |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1839 account_online(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1840 serv_finish_login(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1841 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1842 if (bud_list_cache_exists(gc)) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1843 do_import(NULL, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1844 |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
1845 /* we don't call this now because otherwise some IRC servers might not like us */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1846 idata->timer = gtk_timeout_add(20000, (GtkFunction)irc_request_buddy_update, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1847 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1848 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1849 static void irc_login(struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1850 { |
1011 | 1851 char buf[4096]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1852 |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
1853 struct gaim_connection *gc = new_gaim_conn(user); |
1011 | 1854 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1855 | |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1856 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1857 set_login_progress(gc, 2, buf); |
1011 | 1858 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1859 idata->fd = proxy_connect(user->proto_opt[USEROPT_SERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1860 user->proto_opt[USEROPT_PORT][0] ? atoi(user->proto_opt[USEROPT_PORT]) : 6667, |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1861 user->proto_opt[USEROPT_PROXYSERV], atoi(user->proto_opt[USEROPT_PROXYPORT]), |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1862 atoi(user->proto_opt[USEROPT_PROXYTYPE]), |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1863 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1864 irc_login_callback, gc); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1865 if (idata->fd < 0) { |
1011 | 1866 hide_login_progress(gc, "Unable to create socket"); |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1867 signoff(gc); |
1011 | 1868 return; |
1869 } | |
1870 } | |
1008 | 1871 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1872 static void irc_print_option(GtkEntry *entry, struct aim_user *user) |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1873 { |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1874 int entrynum; |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1875 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1876 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1877 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1878 if (entrynum == USEROPT_SERV) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1879 g_snprintf(user->proto_opt[USEROPT_SERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1880 sizeof(user->proto_opt[USEROPT_SERV]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1881 } else if (entrynum == USEROPT_PORT) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1882 g_snprintf(user->proto_opt[USEROPT_PORT], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1883 sizeof(user->proto_opt[USEROPT_PORT]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1884 } else if (entrynum == USEROPT_PROXYSERV) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1885 g_snprintf(user->proto_opt[USEROPT_PROXYSERV], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1886 sizeof(user->proto_opt[USEROPT_PROXYSERV]), "%s", gtk_entry_get_text(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1887 } else if (entrynum == USEROPT_PROXYPORT) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1888 g_snprintf(user->proto_opt[USEROPT_PROXYPORT], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1889 sizeof(user->proto_opt[USEROPT_PROXYPORT]), "%s", gtk_entry_get_text(entry)); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1890 } else if (entrynum == USEROPT_USER) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1891 g_snprintf(user->proto_opt[USEROPT_USER], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1892 sizeof(user->proto_opt[USEROPT_USER]), "%s", gtk_entry_get_text(entry)); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1893 } else if (entrynum == USEROPT_PASS) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1894 g_snprintf(user->proto_opt[USEROPT_PASS], |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1895 sizeof(user->proto_opt[USEROPT_PASS]), "%s", gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1896 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1897 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1898 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1899 static void irc_print_optionrad(GtkRadioButton * entry, struct aim_user *user) |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1900 { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1901 int entrynum; |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1902 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1903 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1904 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1905 g_snprintf(user->proto_opt[USEROPT_PROXYTYPE], |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1906 sizeof(user->proto_opt[USEROPT_PROXYTYPE]), "%d", entrynum); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1907 } |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1908 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1909 static void irc_user_opts(GtkWidget * book, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1910 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1911 /* so here, we create the new notebook page */ |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1912 GtkWidget *vbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1913 GtkWidget *hbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1914 GtkWidget *label; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1915 GtkWidget *entry; |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1916 GtkWidget *first, *opt; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1917 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1918 vbox = gtk_vbox_new(FALSE, 5); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1919 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1920 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("IRC Options")); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1921 gtk_widget_show(vbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1922 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1923 hbox = gtk_hbox_new(FALSE, 5); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1924 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1925 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1926 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1927 label = gtk_label_new("Server:"); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1928 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1929 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1930 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1931 entry = gtk_entry_new(); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1932 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1933 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SERV); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1934 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1935 if (user->proto_opt[USEROPT_SERV][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1936 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1937 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SERV]); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1938 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1939 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1940 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1941 hbox = gtk_hbox_new(FALSE, 0); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1942 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1943 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1944 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1945 label = gtk_label_new("Port:"); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1946 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1947 gtk_widget_show(label); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1948 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1949 entry = gtk_entry_new(); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1950 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1951 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PORT); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1952 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1953 if (user->proto_opt[USEROPT_PORT][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1954 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PORT]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1955 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PORT]); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1956 } else |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1957 gtk_entry_set_text(GTK_ENTRY(entry), "9898"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1958 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1959 gtk_widget_show(entry); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
1960 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1961 hbox = gtk_hbox_new(TRUE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1962 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1963 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1964 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1965 first = gtk_radio_button_new_with_label(NULL, "No proxy"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1966 gtk_box_pack_start(GTK_BOX(hbox), first, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1967 gtk_object_set_user_data(GTK_OBJECT(first), (void *)PROXY_NONE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1968 gtk_signal_connect(GTK_OBJECT(first), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1969 gtk_widget_show(first); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1970 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_NONE) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1971 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(first), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1972 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1973 opt = |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1974 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 4"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1975 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1976 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS4); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1977 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1978 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1979 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS4) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1980 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1981 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1982 hbox = gtk_hbox_new(TRUE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1983 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1984 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1985 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1986 opt = |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1987 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 5"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1988 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1989 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS5); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1990 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1991 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1992 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS5) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1993 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1994 |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1995 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "HTTP"); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1996 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1997 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_HTTP); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1998 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(irc_print_optionrad), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
1999 gtk_widget_show(opt); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2000 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_HTTP) |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2001 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2002 |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2003 hbox = gtk_hbox_new(FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2004 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2005 gtk_widget_show(hbox); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2006 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2007 label = gtk_label_new("Proxy Host:"); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2008 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2009 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2010 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2011 entry = gtk_entry_new(); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2012 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2013 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYSERV); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2014 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2015 if (user->proto_opt[USEROPT_PROXYSERV][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2016 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYSERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2017 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYSERV]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2018 } |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2019 gtk_widget_show(entry); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2020 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2021 hbox = gtk_hbox_new(FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2022 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2023 gtk_widget_show(hbox); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2024 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2025 label = gtk_label_new("Proxy Port:"); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2026 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2027 gtk_widget_show(label); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2028 |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2029 entry = gtk_entry_new(); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2030 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2031 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYPORT); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2032 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2033 if (user->proto_opt[USEROPT_PROXYPORT][0]) { |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2034 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYPORT]); |
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2035 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYPORT]); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2036 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2037 gtk_widget_show(entry); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2038 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2039 hbox = gtk_hbox_new(FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2040 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2041 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2042 |
1844
9845deede1e9
[gaim-migrate @ 1854]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1843
diff
changeset
|
2043 label = gtk_label_new("Proxy User:"); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2044 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2045 gtk_widget_show(label); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2046 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2047 entry = gtk_entry_new(); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2048 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2049 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_USER); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2050 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2051 if (user->proto_opt[USEROPT_USER][0]) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2052 debug_printf("setting text %s\n", user->proto_opt[USEROPT_USER]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2053 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_USER]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2054 } |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2055 gtk_widget_show(entry); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2056 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2057 hbox = gtk_hbox_new(FALSE, 5); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2058 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2059 gtk_widget_show(hbox); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2060 |
1844
9845deede1e9
[gaim-migrate @ 1854]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1843
diff
changeset
|
2061 label = gtk_label_new("Proxy Password:"); |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2062 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2063 gtk_widget_show(label); |
1842
1d137dde946f
[gaim-migrate @ 1852]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1831
diff
changeset
|
2064 |
1843
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2065 entry = gtk_entry_new(); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2066 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2067 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2068 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PASS); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2069 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2070 if (user->proto_opt[USEROPT_PASS][0]) { |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2071 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PASS]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2072 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PASS]); |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2073 } |
4dbd8533d209
[gaim-migrate @ 1853]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1842
diff
changeset
|
2074 gtk_widget_show(entry); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2075 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2076 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2077 static char **irc_list_icon(int uc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2078 { |
1178 | 2079 return free_icon_xpm; |
2080 } | |
2081 | |
2082 /* Send out a ping request to the specified user */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2083 static void irc_send_ping(GtkObject * w, char *who) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2084 { |
1178 | 2085 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); |
2086 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2087 char buf[BUF_LEN]; | |
2088 | |
1393 | 2089 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001'); |
1178 | 2090 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2091 write(idata->fd, buf, strlen(buf)); |
1178 | 2092 } |
2093 | |
1673 | 2094 /* Do a whois check on someone :-) */ |
2095 static void irc_get_info(struct gaim_connection *gc, char *who) | |
2096 { | |
2097 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2098 char buf[BUF_LEN]; | |
2099 | |
1831
1b61db419774
[gaim-migrate @ 1841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
2100 if (((who[0] == '@') || (who[0] == '+')) && (strlen(who)>1)) |
1673 | 2101 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); |
2102 else | |
2103 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); | |
2104 write(idata->fd, buf, strlen(buf)); | |
2105 } | |
2106 | |
2107 static void irc_send_whois(GtkObject * w, char *who) | |
2108 { | |
2109 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); | |
2110 irc_get_info(gc, who); | |
2111 } | |
1178 | 2112 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2113 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who) |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2114 { |
1178 | 2115 GtkWidget *button; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2116 |
1178 | 2117 button = gtk_menu_item_new_with_label("Ping"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2118 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who); |
1178 | 2119 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
2120 gtk_menu_append(GTK_MENU(menu), button); | |
2121 gtk_widget_show(button); | |
1673 | 2122 |
2123 button = gtk_menu_item_new_with_label("Whois"); | |
2124 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who); | |
2125 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
2126 gtk_menu_append(GTK_MENU(menu), button); | |
2127 gtk_widget_show(button); | |
1178 | 2128 } |
2129 | |
2130 | |
1676 | 2131 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) |
2132 { | |
2133 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
2134 char buf[BUF_LEN]; | |
2135 | |
2136 if (msg) | |
2137 g_snprintf(buf, BUF_LEN, "AWAY :%s\n", msg); | |
2138 else | |
2139 g_snprintf(buf, BUF_LEN, "AWAY\n"); | |
2140 | |
2141 write(idata->fd, buf, strlen(buf)); | |
2142 } | |
2143 | |
1678 | 2144 static void irc_fake_buddy(struct gaim_connection *gc, char *who) |
2145 { | |
2146 /* Heh, there is no buddy list. We fake it. | |
2147 * I just need this here so the add and remove buttons will | |
2148 * show up */ | |
2149 } | |
2150 | |
2151 | |
2152 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2153 static struct prpl *my_protocol = NULL; |
987 | 2154 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2155 static void irc_init(struct prpl *ret) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2156 { |
1008 | 2157 ret->protocol = PROTO_IRC; |
2158 ret->name = irc_name; | |
1178 | 2159 ret->list_icon = irc_list_icon; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2160 ret->buddy_menu = irc_buddy_menu; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
2161 ret->user_opts = irc_user_opts; |
1008 | 2162 ret->login = irc_login; |
1011 | 2163 ret->close = irc_close; |
2164 ret->send_im = irc_send_im; | |
2165 ret->join_chat = irc_join_chat; | |
2166 ret->chat_leave = irc_chat_leave; | |
2167 ret->chat_send = irc_chat_send; | |
1673 | 2168 ret->get_info = irc_get_info; |
1676 | 2169 ret->set_away = irc_set_away; |
1678 | 2170 ret->add_buddy = irc_fake_buddy; |
2171 ret->remove_buddy = irc_fake_buddy; | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2172 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2173 my_protocol = ret; |
987 | 2174 } |
2175 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2176 char *gaim_plugin_init(GModule * handle) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2177 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1394
diff
changeset
|
2178 load_protocol(irc_init, sizeof(struct prpl)); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2179 return NULL; |
987 | 2180 } |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2181 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2182 void gaim_plugin_remove() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
2183 { |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2184 struct prpl *p = find_prpl(PROTO_IRC); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2185 if (p == my_protocol) |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2186 unload_protocol(p); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
2187 } |