Mercurial > pidgin
annotate plugins/irc.c @ 1717:1c8e109f8934
[gaim-migrate @ 1727]
Laddy Daa
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sat, 14 Apr 2001 07:51:55 +0000 |
parents | 1573a65fd0cd |
children | 34369ed4e212 |
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" | |
42 | |
1178 | 43 #include "pixmaps/free_icon.xpm" |
44 | |
1011 | 45 #define IRC_BUF_LEN 4096 |
46 | |
1022 | 47 |
1011 | 48 static int chat_id = 0; |
49 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
50 struct irc_channel { |
1011 | 51 int id; |
52 gchar *name; | |
53 }; | |
54 | |
55 struct irc_data { | |
56 int fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
57 int inpa; /* used for non-block logins */ |
1011 | 58 |
1022 | 59 int timer; |
60 | |
61 int totalblocks; | |
62 int recblocks; | |
63 | |
64 GSList *templist; | |
1011 | 65 GList *channels; |
66 }; | |
67 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
68 static char *irc_name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
69 { |
1008 | 70 return "IRC"; |
71 } | |
72 | |
1675 | 73 static void irc_get_info(struct gaim_connection *gc, char *who); |
74 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
75 char *name() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
76 { |
1008 | 77 return "IRC"; |
78 } | |
79 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
80 char *description() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
81 { |
1008 | 82 return "Allows gaim to use the IRC protocol"; |
83 } | |
84 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
85 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
|
86 { |
1011 | 87 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
88 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 89 |
90 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name); | |
91 write(idata->fd, buf, strlen(buf)); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
92 |
1011 | 93 g_free(buf); |
94 } | |
95 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
96 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
|
97 { |
1022 | 98 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
99 struct irc_channel *u; | |
100 GSList *temp = idata->templist; | |
101 | |
102 /* Loop through our list */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
103 |
1022 | 104 while (temp) { |
105 u = (struct irc_channel *)temp->data; | |
106 if (g_strcasecmp(u->name, name) == 0) { | |
107 u->id = status; | |
108 return; | |
109 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
110 |
1022 | 111 temp = g_slist_next(temp); |
112 } | |
113 return; | |
114 } | |
115 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
116 static void irc_request_buddy_update(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
117 { |
1022 | 118 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
119 GSList *grp = gc->groups; |
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
120 GSList *person; |
1022 | 121 struct group *g; |
122 struct buddy *b; | |
123 struct irc_channel *u; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
124 gchar buf[IRC_BUF_LEN + 1]; |
1022 | 125 |
126 if (idata->templist != NULL) | |
127 return; | |
128 | |
129 idata->recblocks = 0; | |
130 idata->totalblocks = 1; | |
131 | |
1105 | 132 /* First, let's check to see if we have anyone on our buddylist */ |
133 if (!grp) { | |
134 return; | |
135 } | |
136 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
137 /* Send the first part of our request */ |
1022 | 138 write(idata->fd, "ISON", 4); |
139 | |
140 /* Step through our list of groups */ | |
141 while (grp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
142 |
1022 | 143 g = (struct group *)grp->data; |
144 person = g->members; | |
145 | |
146 while (person) { | |
147 b = (struct buddy *)person->data; | |
148 | |
149 /* We will store our buddy info here. I know, this is cheap | |
150 * but hey, its the exact same data structure. Why should we | |
151 * bother with making another one */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
152 |
1022 | 153 u = g_new0(struct irc_channel, 1); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
154 u->id = 0; /* Assume by default that they're offline */ |
1022 | 155 u->name = strdup(b->name); |
156 | |
157 write(idata->fd, " ", 1); | |
158 write(idata->fd, u->name, strlen(u->name)); | |
159 idata->templist = g_slist_append(idata->templist, u); | |
160 | |
161 person = person->next; | |
162 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
163 |
1022 | 164 grp = g_slist_next(grp); |
165 } | |
166 write(idata->fd, "\n", 1); | |
167 } | |
168 | |
169 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
170 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
|
171 { |
1011 | 172 |
173 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
174 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 175 |
176 /* Before we actually send this, we should check to see if they're trying | |
1674 | 177 * To issue a command and handle it properly. */ |
1011 | 178 |
1674 | 179 if (message[0] == '/') |
180 { | |
181 /* I'll change the implementation of this a little later :-) */ | |
182 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
183 /* We have /me!! We have /me!! :-) */ | |
1011 | 184 |
1674 | 185 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
186 strcpy(temp, message + 4); | |
187 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%cACTION %s%c\n", who, '\001', temp, '\001'); | |
188 g_free(temp); | |
189 } | |
1675 | 190 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { |
191 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
192 strcpy(temp, message + 7); | |
193 irc_get_info(gc, temp); | |
194 g_free(temp); | |
195 | |
196 return; | |
197 } | |
198 | |
1674 | 199 } |
200 else { | |
1011 | 201 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%s\n", who, message); |
202 } | |
203 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
204 write(idata->fd, buf, strlen(buf)); |
1011 | 205 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
206 g_free(buf); |
1011 | 207 } |
208 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
209 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
|
210 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
211 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 212 GList *templist; |
213 struct irc_channel *channel; | |
214 | |
215 templist = ((struct irc_data *)gc->proto_data)->channels; | |
216 | |
217 while (templist) { | |
218 channel = (struct irc_channel *)templist->data; | |
219 | |
220 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name); | |
221 | |
222 if (g_strcasecmp(temp, name) == 0) { | |
223 g_free(temp); | |
224 return channel->id; | |
225 } | |
226 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
227 templist = templist->next; |
1011 | 228 } |
229 | |
230 g_free(temp); | |
231 | |
232 /* Return -1 if we have no ID */ | |
233 return -1; | |
234 } | |
235 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
236 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
|
237 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
238 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 239 GList *templist; |
240 struct irc_channel *channel; | |
241 | |
242 templist = ((struct irc_data *)gc->proto_data)->channels; | |
243 | |
244 while (templist) { | |
245 channel = (struct irc_channel *)templist->data; | |
246 | |
247 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name); | |
248 | |
249 if (g_strcasecmp(temp, name) == 0) { | |
250 g_free(temp); | |
251 return channel; | |
252 } | |
253 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
254 templist = templist->next; |
1011 | 255 } |
256 | |
257 g_free(temp); | |
258 | |
259 /* If we found nothing, return nothing :-) */ | |
260 return NULL; | |
261 } | |
262 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
263 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
|
264 { |
1011 | 265 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
266 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
267 |
1011 | 268 GList *temp; |
269 | |
270 temp = idata->channels; | |
271 | |
272 while (temp) { | |
273 channel = (struct irc_channel *)temp->data; | |
274 | |
275 if (channel->id == id) { | |
276 /* We've found our man */ | |
277 return channel; | |
278 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
279 |
1011 | 280 temp = temp->next; |
281 } | |
282 | |
283 | |
284 /* If we didnt find one, return NULL */ | |
285 return NULL; | |
286 } | |
287 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
288 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
|
289 { |
1011 | 290 |
291 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1021 | 292 struct irc_channel *channel = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
293 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
1011 | 294 |
295 /* First lets get our current channel */ | |
296 channel = find_channel_by_id(gc, id); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
297 |
1011 | 298 |
299 if (!channel) { | |
300 /* If for some reason we've lost our channel, let's bolt */ | |
1021 | 301 g_free(buf); |
1011 | 302 return; |
303 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
304 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
305 |
1011 | 306 /* Before we actually send this, we should check to see if they're trying |
1675 | 307 * To issue a command and handle it properly. */ |
1011 | 308 |
1675 | 309 if (message[0] == '/') |
310 { | |
311 if ((g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message) > 4)) { | |
312 /* We have /me!! We have /me!! :-) */ | |
1011 | 313 |
1675 | 314 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
315 strcpy(temp, message + 4); | |
316 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, | |
317 '\001'); | |
318 g_free(temp); | |
319 } | |
320 else if (!g_strncasecmp(message, "/whois ", 7) && (strlen(message) > 7)) { | |
321 gchar *temp = (gchar *) g_malloc(IRC_BUF_LEN + 1); | |
322 | |
323 strcpy(temp, message + 7); | |
324 irc_get_info(gc, temp); | |
325 g_free(temp); | |
326 | |
327 return; | |
328 } | |
329 } | |
330 else { | |
1011 | 331 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%s\n", channel->name, message); |
332 } | |
333 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
334 write(idata->fd, buf, strlen(buf)); |
1011 | 335 |
336 /* Since AIM expects us to receive the message we send, we gotta fake it */ | |
337 serv_got_chat_in(gc, id, gc->username, 0, message); | |
338 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
339 g_free(buf); |
1008 | 340 } |
341 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
342 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
|
343 { |
1014 | 344 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
345 GSList *bc = gc->buddy_chats; | |
346 struct conversation *b = NULL; | |
347 | |
348 while (bc) { | |
349 b = (struct conversation *)bc->data; | |
350 if (id == b->id) { | |
351 break; | |
352 } | |
353 bc = bc->next; | |
354 b = NULL; | |
355 } | |
356 | |
357 if (!b) { | |
358 return NULL; | |
359 } | |
360 | |
361 return b; | |
362 } | |
363 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
364 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
|
365 { |
1014 | 366 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
367 GSList *bc = gc->buddy_chats; | |
368 struct conversation *b = NULL; | |
369 | |
370 while (bc) { | |
1301 | 371 int x; |
1014 | 372 b = (struct conversation *)bc->data; |
373 | |
374 if (g_strcasecmp(name, b->name) == 0) { | |
375 break; | |
376 } | |
377 bc = bc->next; | |
378 b = NULL; | |
379 } | |
380 | |
381 if (!b) { | |
382 return NULL; | |
383 } | |
384 | |
385 return b; | |
386 } | |
387 | |
388 | |
389 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
390 static void irc_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
391 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
392 struct gaim_connection *gc = data; |
1011 | 393 int i = 0; |
394 gchar buf[4096]; | |
395 gchar **buf2; | |
396 struct irc_data *idata; | |
397 | |
398 idata = (struct irc_data *)gc->proto_data; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
399 |
1011 | 400 do { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
401 if (read(idata->fd, buf + i, 1) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
402 hide_login_progress(gc, "Read error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
403 signoff(gc); |
1105 | 404 return; |
1011 | 405 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
406 } while (buf[i++] != '\n'); |
1011 | 407 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
408 buf[--i] = '\0'; |
1301 | 409 g_strchomp(buf); |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
410 g_print("%s\n", buf); |
1105 | 411 |
412 /* Check for errors */ | |
413 | |
414 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) && | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
415 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) { |
1105 | 416 |
417 gchar *u_errormsg; | |
418 | |
419 /* Let's get our error message */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
420 u_errormsg = g_strdup(buf + 7); |
1105 | 421 |
422 /* We got our error message. Now, let's reaise an | |
423 * error dialog */ | |
424 | |
425 do_error_dialog(u_errormsg, "Gaim: IRC Error"); | |
426 | |
427 /* And our necessary garbage collection */ | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
428 g_free(u_errormsg); |
1105 | 429 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
430 |
1673 | 431 /* This should be a whois response. I only care about the first (311) one. I might do |
432 * the other's later. They're boring. */ | |
433 | |
434 if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
435 char **res; | |
436 | |
437 res = g_strsplit(buf, " ", 7); | |
438 | |
439 if (!strcmp(res[1], "311")) | |
440 { | |
441 char buf[8192]; | |
442 | |
443 g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>" | |
444 "<b>Host:</b> %s@%s<br>" | |
445 "<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1); | |
446 | |
447 g_show_info_text(buf); | |
448 } | |
449 | |
450 g_strfreev(res); | |
451 } | |
452 | |
1676 | 453 /* Autoresponse to an away message */ |
454 if (((strstr(buf, " 301 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { | |
455 char **res; | |
456 | |
457 res = g_strsplit(buf, " ", 5); | |
458 | |
459 if (!strcmp(res[1], "301")) | |
460 serv_got_im(gc, res[3], res[4] + 1, 1); | |
461 | |
462 g_strfreev(res); | |
463 } | |
464 | |
1014 | 465 /* Parse the list of names that we receive when we first sign on to |
466 * a channel */ | |
467 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
468 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1014 | 469 gchar u_host[255]; |
470 gchar u_command[32]; | |
471 gchar u_channel[128]; | |
472 gchar u_names[IRC_BUF_LEN + 1]; | |
473 struct conversation *convo = NULL; | |
474 int j; | |
475 | |
476 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
477 u_host[j] = buf[i]; | |
478 } | |
479 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
480 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
481 i++; |
1014 | 482 |
483 for (j = 0; buf[i] != ' '; j++, i++) { | |
484 u_command[j] = buf[i]; | |
485 } | |
486 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
487 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
488 i++; |
1014 | 489 |
490 for (j = 0; buf[i] != '#'; j++, i++) { | |
491 } | |
492 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
493 |
1014 | 494 for (j = 0; buf[i] != ':'; j++, i++) { |
495 u_channel[j] = buf[i]; | |
496 } | |
497 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
498 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
499 i++; |
1014 | 500 |
501 while ((buf[i] == ' ') || (buf[i] == ':')) { | |
502 i++; | |
503 } | |
504 | |
505 strcpy(u_names, buf + i); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
506 |
1014 | 507 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
508 |
1014 | 509 /* Let's get our conversation window */ |
510 convo = find_conversation_by_name(gc, u_channel); | |
511 | |
512 if (!convo) { | |
513 return; | |
514 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
515 |
1014 | 516 /* Now that we've parsed the hell out of this big |
517 * mess, let's try to split up the names properly */ | |
518 | |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
519 for (i = 0; buf2[i] != NULL; i++) |
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
520 add_chat_buddy(convo, buf2[i]); |
1021 | 521 |
522 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
523 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
524 |
1014 | 525 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
526 |
1014 | 527 } |
528 | |
1022 | 529 /* Receive a list of users that are currently online */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
530 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
531 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { |
1022 | 532 gchar u_host[255]; |
533 gchar u_command[32]; | |
534 gchar u_names[IRC_BUF_LEN + 1]; | |
535 int j; | |
536 | |
537 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
538 u_host[j] = buf[i]; | |
539 } | |
540 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
541 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
542 i++; |
1022 | 543 |
544 for (j = 0; buf[i] != ' '; j++, i++) { | |
545 u_command[j] = buf[i]; | |
546 } | |
547 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
548 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
549 i++; |
1022 | 550 |
551 for (j = 0; buf[i] != ':'; j++, i++) { | |
552 /* My Nick */ | |
553 } | |
554 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
555 |
1022 | 556 strcpy(u_names, buf + i); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
557 |
1022 | 558 buf2 = g_strsplit(u_names, " ", 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
559 |
1022 | 560 /* Now that we've parsed the hell out of this big |
561 * mess, let's try to split up the names properly */ | |
562 | |
563 for (i = 0; buf2[i] != NULL; i++) { | |
564 /* If we have a name here then our buddy is online. We should | |
565 * update our temporary gslist accordingly. When we achieve our maximum | |
566 * list of names then we should force an update */ | |
567 | |
568 irc_update_user(gc, buf2[i], 1); | |
569 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
570 |
1022 | 571 /* Increase our received blocks counter */ |
572 idata->recblocks++; | |
573 | |
574 /* If we have our total number of blocks */ | |
575 if (idata->recblocks == idata->totalblocks) { | |
576 GSList *temp; | |
577 struct irc_channel *u; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
578 |
1022 | 579 /* Let's grab our list of people and bring them all on or off line */ |
580 temp = idata->templist; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
581 |
1022 | 582 /* Loop */ |
583 while (temp) { | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
584 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
585 u = temp->data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
586 |
1022 | 587 /* Tell Gaim to bring the person on or off line */ |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
588 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
|
589 |
1022 | 590 /* Grab the next entry */ |
591 temp = g_slist_next(temp); | |
592 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
593 |
1022 | 594 /* And now, let's delete all of our entries */ |
595 temp = idata->templist; | |
596 while (temp) { | |
597 u = temp->data; | |
598 g_free(u->name); | |
599 temp = g_slist_remove(temp, u); | |
600 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
601 |
1022 | 602 /* Reset our list */ |
603 idata->totalblocks = 0; | |
604 idata->recblocks = 0; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
605 |
1022 | 606 idata->templist = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
607 |
1022 | 608 return; |
609 } | |
610 | |
611 /* And free our pointers */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
612 g_strfreev(buf2); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
613 |
1022 | 614 return; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
615 |
1022 | 616 } |
617 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
618 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
619 if ((strstr(buf, " JOIN ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 620 |
621 gchar u_channel[128]; | |
1012 | 622 gchar u_nick[128]; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
623 |
1011 | 624 struct irc_channel *channel; |
625 int id; | |
626 int j; | |
627 | |
1012 | 628 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
629 u_nick[j] = buf[i]; | |
630 } | |
631 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
632 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
633 i++; |
1012 | 634 |
635 for (j = 0; buf[i] != '#'; j++, i++) { | |
1011 | 636 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
637 |
1011 | 638 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
639 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
640 strcpy(u_channel, buf + i); |
1011 | 641 |
1301 | 642 g_strchomp(u_channel); |
643 | |
1014 | 644 /* Looks like we're going to join the channel for real |
645 * now. Let's create a valid channel structure and add | |
646 * it to our list. Let's make sure that | |
1011 | 647 * we are not already in a channel first */ |
648 | |
649 channel = find_channel_by_name(gc, u_channel); | |
650 | |
651 if (!channel) { | |
1301 | 652 |
1011 | 653 chat_id++; |
654 | |
655 channel = g_new0(struct irc_channel, 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
656 |
1011 | 657 channel->id = chat_id; |
658 channel->name = strdup(u_channel); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
659 |
1011 | 660 idata->channels = g_list_append(idata->channels, channel); |
661 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
662 serv_got_joined_chat(gc, chat_id, u_channel); |
1011 | 663 } else { |
1014 | 664 struct conversation *convo = NULL; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
665 |
1014 | 666 /* Someone else joined. Find their conversation |
667 * window */ | |
668 convo = find_conversation_by_id(gc, channel->id); | |
669 | |
670 /* And add their name to it */ | |
671 add_chat_buddy(convo, u_nick); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
672 |
1011 | 673 } |
674 | |
675 return; | |
676 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
677 |
1504
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
678 if ((strstr(buf, " NICK ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
679 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
680 gchar old[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
681 gchar new[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
682 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
683 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
684 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
685 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
686 int id; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
687 int j; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
688 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
689 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
690 old[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
691 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
692 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
693 old[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
694 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
695 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
696 for (j = 0; buf[i] != ':'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
697 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
698 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
699 i++; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
700 strcpy(new, buf + i); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
701 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
702 g_strchomp(new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
703 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
704 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
705 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
706 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
707 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
708 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
709 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
710 convo = find_conversation_by_id(gc, channel->id); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
711 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
712 rename_chat_buddy(convo, old, new); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
713 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
714 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
715 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
716 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
717 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
718 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
719 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
720 gchar u_nick[128]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
721 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
722 GList *templist; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
723 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
724 struct irc_channel *channel; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
725 int j; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
726 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
727 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
728 u_nick[j] = buf[i]; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
729 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
730 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
731 u_nick[j] = '\0'; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
732 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
733 templist = ((struct irc_data *)gc->proto_data)->channels; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
734 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
735 while (templist) { |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
736 struct conversation *convo = NULL; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
737 channel = templist->data; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
738 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
739 convo = find_conversation_by_id(gc, channel->id); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
740 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
741 remove_chat_buddy(convo, u_nick); |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
742 |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
743 templist = templist->next; |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
744 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
745 } |
cac3efeb4d9c
[gaim-migrate @ 1514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
746 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
747 if ((strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
1011 | 748 |
749 gchar u_channel[128]; | |
750 gchar u_nick[128]; | |
751 | |
1021 | 752 struct irc_channel *channel; |
1011 | 753 int id; |
754 int j; | |
755 GList *test = NULL; | |
756 | |
757 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
758 u_nick[j] = buf[i]; | |
759 } | |
760 u_nick[j] = '\0'; | |
761 | |
762 i++; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
763 |
1011 | 764 for (j = 0; buf[i] != '#'; j++, i++) { |
765 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
766 |
1011 | 767 i++; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
768 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
769 strcpy(u_channel, buf + i); |
1011 | 770 |
771 | |
1014 | 772 /* Now, lets check to see if it was US that was leaving. |
773 * If so, do the correct thing by closing up all of our | |
774 * old channel stuff. Otherwise, | |
1011 | 775 * we should just print that someone left */ |
776 | |
1014 | 777 channel = find_channel_by_name(gc, u_channel); |
778 | |
779 if (!channel) { | |
780 return; | |
781 } | |
782 | |
1011 | 783 if (g_strcasecmp(u_nick, gc->username) == 0) { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
784 |
1014 | 785 /* Looks like we're going to leave the channel for |
786 * real now. Let's create a valid channel structure | |
787 * and add it to our list */ | |
1011 | 788 |
789 serv_got_chat_left(gc, channel->id); | |
790 | |
791 idata->channels = g_list_remove(idata->channels, channel); | |
1014 | 792 } else { |
793 struct conversation *convo = NULL; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
794 |
1014 | 795 /* Find their conversation window */ |
796 convo = find_conversation_by_id(gc, channel->id); | |
797 | |
798 if (!convo) { | |
799 /* Some how the window doesn't exist. | |
800 * Let's get out of here */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
801 return; |
1014 | 802 } |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
803 |
1014 | 804 /* And remove their name */ |
805 remove_chat_buddy(convo, u_nick); | |
806 | |
1011 | 807 } |
808 | |
1014 | 809 /* Go Home! */ |
1011 | 810 return; |
811 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
812 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
813 if ((strstr(buf, " NOTICE ")) && (buf[0] == ':')) { |
1178 | 814 gchar u_nick[128]; |
815 gchar u_host[255]; | |
816 gchar u_command[32]; | |
817 gchar u_channel[128]; | |
818 gchar u_message[IRC_BUF_LEN]; | |
819 int j; | |
820 int msgcode = 0; | |
821 | |
822 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
823 u_nick[j] = buf[i]; | |
824 } | |
825 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
826 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
827 i++; |
1178 | 828 |
829 for (j = 0; buf[i] != ' '; j++, i++) { | |
830 u_host[j] = buf[i]; | |
831 } | |
832 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
833 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
834 i++; |
1178 | 835 |
836 for (j = 0; buf[i] != ' '; j++, i++) { | |
837 u_command[j] = buf[i]; | |
838 } | |
839 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
840 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
841 i++; |
1178 | 842 |
843 for (j = 0; buf[i] != ':'; j++, i++) { | |
844 u_channel[j] = buf[i]; | |
845 } | |
846 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
847 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
848 i++; |
1178 | 849 |
850 | |
851 /* Now that everything is parsed, the rest of this baby must be our message */ | |
852 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
853 | |
854 /* Now, lets check the message to see if there's anything special in it */ | |
855 if (u_message[0] == '\001') { | |
856 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
857 /* Someone's triyng to ping us. Let's respond */ | |
858 gchar u_arg[24]; | |
859 gchar u_buf[200]; | |
1393 | 860 unsigned long tend= time((time_t *)NULL); |
861 unsigned long tstart; | |
862 | |
863 printf("LA: %s\n", buf); | |
1178 | 864 |
865 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
866 u_arg[strlen(u_arg) - 1] = '\0'; |
1178 | 867 |
1393 | 868 tstart = atol(u_arg); |
869 | |
870 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
|
871 |
1178 | 872 do_error_dialog(u_buf, "Gaim IRC - Ping Reply"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
873 |
1178 | 874 return; |
875 } | |
876 } | |
877 | |
878 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
879 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
880 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
881 if ((strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) { |
1011 | 882 gchar u_nick[128]; |
883 gchar u_host[255]; | |
884 gchar u_command[32]; | |
885 gchar u_channel[128]; | |
886 gchar u_message[IRC_BUF_LEN]; | |
887 int j; | |
888 int msgcode = 0; | |
889 | |
890 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
891 u_nick[j] = buf[i]; | |
892 } | |
893 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
894 u_nick[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
895 i++; |
1011 | 896 |
897 for (j = 0; buf[i] != ' '; j++, i++) { | |
898 u_host[j] = buf[i]; | |
899 } | |
900 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
901 u_host[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
902 i++; |
1011 | 903 |
904 for (j = 0; buf[i] != ' '; j++, i++) { | |
905 u_command[j] = buf[i]; | |
906 } | |
907 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
908 u_command[j] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
909 i++; |
1011 | 910 |
911 for (j = 0; buf[i] != ':'; j++, i++) { | |
912 u_channel[j] = buf[i]; | |
913 } | |
914 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
915 u_channel[j - 1] = '\0'; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
916 i++; |
1011 | 917 |
918 | |
919 /* Now that everything is parsed, the rest of this baby must be our message */ | |
920 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
921 |
1011 | 922 /* Now, lets check the message to see if there's anything special in it */ |
923 if (u_message[0] == '\001') { | |
1017 | 924 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) { |
925 /* Looks like we have a version request. Let | |
926 * us handle it thusly */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
927 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
928 g_snprintf(buf, IRC_BUF_LEN, |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
929 "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:www.marko.net/gaim%c\n", |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
930 u_nick, '\001', VERSION, '\001'); |
1017 | 931 |
932 write(idata->fd, buf, strlen(buf)); | |
933 | |
934 /* And get the heck out of dodge */ | |
935 return; | |
936 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
937 |
1017 | 938 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { |
939 /* Someone's triyng to ping us. Let's respond */ | |
940 gchar u_arg[24]; | |
941 | |
942 strcpy(u_arg, u_message + 6); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
943 u_arg[strlen(u_arg) - 1] = '\0'; |
1017 | 944 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
945 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
946 u_arg, '\001'); |
1017 | 947 |
948 write(idata->fd, buf, strlen(buf)); | |
949 | |
950 /* And get the heck out of dodge */ | |
951 return; | |
952 } | |
953 | |
1011 | 954 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) { |
955 /* Looks like we have an action. Let's parse it a little */ | |
956 strcpy(buf, u_message); | |
957 | |
958 strcpy(u_message, "/me "); | |
959 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) { | |
960 u_message[j] = buf[i]; | |
961 } | |
962 u_message[j] = '\0'; | |
963 } | |
964 } | |
965 | |
966 | |
967 /* Let's check to see if we have a channel on our hands */ | |
968 if (u_channel[0] == '#') { | |
969 /* Yup. We have a channel */ | |
970 int id; | |
971 | |
972 id = find_id_by_name(gc, u_channel); | |
973 if (id != -1) { | |
974 serv_got_chat_in(gc, id, u_nick, 0, u_message); | |
975 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
976 } else { |
1011 | 977 /* Nope. Let's treat it as a private message */ |
978 serv_got_im(gc, u_nick, u_message, 0); | |
979 } | |
980 | |
981 return; | |
982 } | |
983 | |
984 /* Let's parse PING requests so that we wont get booted for inactivity */ | |
985 | |
986 if (strncmp(buf, "PING :", 6) == 0) { | |
987 buf2 = g_strsplit(buf, ":", 1); | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
988 |
1011 | 989 /* Let's build a new response */ |
990 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]); | |
991 write(idata->fd, buf, strlen(buf)); | |
992 | |
993 /* And clean up after ourselves */ | |
994 g_strfreev(buf2); | |
995 | |
996 return; | |
997 } | |
998 | |
999 } | |
1000 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1001 static void irc_close(struct gaim_connection *gc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1002 { |
1011 | 1003 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1021 | 1004 GList *chats = idata->channels; |
1005 struct irc_channel *cc; | |
1006 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1007 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN); |
1011 | 1008 |
1021 | 1009 g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [www.marko.net/gaim]\n"); |
1011 | 1010 write(idata->fd, buf, strlen(buf)); |
1011 | |
1012 g_free(buf); | |
1021 | 1013 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1014 if (idata->timer) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1015 gtk_timeout_remove(idata->timer); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1016 |
1021 | 1017 while (chats) { |
1018 cc = (struct irc_channel *)chats->data; | |
1019 g_free(cc->name); | |
1020 chats = g_list_remove(chats, cc); | |
1021 g_free(cc); | |
1022 } | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1023 |
1021 | 1024 if (gc->inpa) |
1025 gdk_input_remove(gc->inpa); | |
1026 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1027 if (idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1028 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1029 |
1011 | 1030 close(idata->fd); |
1031 g_free(gc->proto_data); | |
1032 } | |
1033 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1034 static void irc_chat_leave(struct gaim_connection *gc, int id) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1035 { |
1011 | 1036 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1037 struct irc_channel *channel; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1038 gchar *buf = (gchar *) g_malloc(IRC_BUF_LEN + 1); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1039 |
1011 | 1040 channel = find_channel_by_id(gc, id); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1041 |
1011 | 1042 if (!channel) { |
1043 return; | |
1044 } | |
1045 | |
1046 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name); | |
1047 write(idata->fd, buf, strlen(buf)); | |
1048 | |
1049 g_free(buf); | |
1050 } | |
1051 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1052 static void irc_login_callback(gpointer data, gint source, GdkInputCondition condition) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1053 { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1054 struct gaim_connection *gc = data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1055 struct irc_data *idata = gc->proto_data; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1056 char buf[4096]; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1057 int len, error = ETIMEDOUT; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1058 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1059 len = sizeof(error); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1060 if (getsockopt(idata->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1061 error = errno; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1062 if (error) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1063 hide_login_progress(gc, "Couldn't connect"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1064 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1065 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1066 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1067 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1068 fcntl(idata->fd, F_SETFL, 0); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1069 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1070 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (www.marko.net/gaim)\n", |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1071 gc->username, g_get_user_name(), gc->user->proto_opt[0]); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1072 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1073 if (write(idata->fd, buf, strlen(buf)) < 0) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1074 hide_login_progress(gc, "Write error"); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1075 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1076 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1077 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1078 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1079 gdk_input_remove(idata->inpa); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1080 idata->inpa = 0; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1081 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1082 /* Now lets sign ourselves on */ |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1083 account_online(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1084 serv_finish_login(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1085 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1086 if (bud_list_cache_exists(gc)) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1087 do_import(NULL, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1088 |
1269
677e2c9e8baf
[gaim-migrate @ 1279]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1266
diff
changeset
|
1089 /* 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
|
1090 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
|
1091 } |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1092 |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1093 static void irc_login(struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1094 { |
1011 | 1095 int fd; |
1096 struct hostent *host; | |
1097 struct sockaddr_in site; | |
1098 char buf[4096]; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1099 |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
1100 struct gaim_connection *gc = new_gaim_conn(user); |
1011 | 1101 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1102 char c; | |
1103 int i; | |
1104 int status; | |
1105 | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1106 host = gethostbyname(user->proto_opt[0]); |
1011 | 1107 if (!host) { |
1108 hide_login_progress(gc, "Unable to resolve hostname"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1109 signoff(gc); |
1011 | 1110 return; |
1111 } | |
1112 | |
1113 site.sin_family = AF_INET; | |
1114 site.sin_addr.s_addr = *(long *)(host->h_addr); | |
1304 | 1115 |
1116 if (user->proto_opt[1][0]) | |
1117 site.sin_port = htons(atoi(user->proto_opt[1])); | |
1118 else { | |
1119 site.sin_port = htons(6667); | |
1120 g_snprintf(user->proto_opt[1], 5, "6667"); | |
1121 } | |
1011 | 1122 |
1123 fd = socket(AF_INET, SOCK_STREAM, 0); | |
1124 if (fd < 0) { | |
1125 hide_login_progress(gc, "Unable to create socket"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
1126 signoff(gc); |
1011 | 1127 return; |
1128 } | |
1129 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1130 fcntl(fd, F_SETFL, O_NONBLOCK); |
1011 | 1131 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) { |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1132 if ((errno == EINPROGRESS) || (errno == EINTR)) { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1133 idata->inpa = gdk_input_add(idata->fd, GDK_INPUT_WRITE, irc_login_callback, gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1134 } else { |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1135 hide_login_progress(gc, "Unable to connect."); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1136 signoff(gc); |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1137 return; |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1138 } |
1011 | 1139 } |
1140 | |
1141 idata->fd = fd; | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1142 |
1011 | 1143 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
1144 set_login_progress(gc, 2, buf); | |
1145 | |
1146 /* This is where we will attempt to sign on */ | |
1147 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1148 if (!idata->inpa) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1149 irc_login_callback(gc, idata->fd, GDK_INPUT_READ); |
1022 | 1150 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1151 gc->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_callback, gc); |
1011 | 1152 } |
1008 | 1153 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1154 static void irc_print_option(GtkEntry * entry, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1155 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1156 if (gtk_object_get_user_data(GTK_OBJECT(entry))) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1157 g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s", |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1158 gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1159 } else { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1160 g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s", |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1161 gtk_entry_get_text(entry)); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1162 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1163 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1164 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1165 static void irc_user_opts(GtkWidget * book, struct aim_user *user) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1166 { |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1167 /* so here, we create the new notebook page */ |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1168 GtkWidget *vbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1169 GtkWidget *hbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1170 GtkWidget *label; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1171 GtkWidget *entry; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1172 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1173 vbox = gtk_vbox_new(FALSE, 0); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1174 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
|
1175 gtk_widget_show(vbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1176 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1177 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1178 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1179 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1180 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1181 label = gtk_label_new("Server:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1182 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1183 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1184 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1185 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1186 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1187 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1188 if (user->proto_opt[0][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1189 debug_printf("setting text %s\n", user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1190 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1191 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1192 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1193 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1194 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1195 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1196 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1197 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1198 label = gtk_label_new("Port:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1199 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1200 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1201 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1202 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1203 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1204 if (user->proto_opt[1][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1205 debug_printf("setting text %s\n", user->proto_opt[1]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1206 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]); |
1304 | 1207 } else { |
1208 gtk_entry_set_text(GTK_ENTRY(entry), "6667"); | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1209 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1210 gtk_object_set_user_data(GTK_OBJECT(entry), user); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1211 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(irc_print_option), user); |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1212 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1213 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1214 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1215 static char **irc_list_icon(int uc) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1216 { |
1178 | 1217 return free_icon_xpm; |
1218 } | |
1219 | |
1220 /* Send out a ping request to the specified user */ | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1221 static void irc_send_ping(GtkObject * w, char *who) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1222 { |
1178 | 1223 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); |
1224 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1225 char buf[BUF_LEN]; | |
1226 | |
1393 | 1227 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001'); |
1178 | 1228 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1229 write(idata->fd, buf, strlen(buf)); |
1178 | 1230 } |
1231 | |
1673 | 1232 /* Do a whois check on someone :-) */ |
1233 static void irc_get_info(struct gaim_connection *gc, char *who) | |
1234 { | |
1235 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1236 char buf[BUF_LEN]; | |
1237 | |
1238 if ((who[0] == '@') || (who[0] == '+') && (strlen(who)>1)) | |
1239 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); | |
1240 else | |
1241 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); | |
1242 write(idata->fd, buf, strlen(buf)); | |
1243 } | |
1244 | |
1245 static void irc_send_whois(GtkObject * w, char *who) | |
1246 { | |
1247 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); | |
1248 irc_get_info(gc, who); | |
1249 } | |
1178 | 1250 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1251 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
|
1252 { |
1178 | 1253 GtkWidget *button; |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1254 |
1178 | 1255 button = gtk_menu_item_new_with_label("Ping"); |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1256 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who); |
1178 | 1257 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
1258 gtk_menu_append(GTK_MENU(menu), button); | |
1259 gtk_widget_show(button); | |
1673 | 1260 |
1261 button = gtk_menu_item_new_with_label("Whois"); | |
1262 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who); | |
1263 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
1264 gtk_menu_append(GTK_MENU(menu), button); | |
1265 gtk_widget_show(button); | |
1178 | 1266 } |
1267 | |
1268 | |
1676 | 1269 static void irc_set_away(struct gaim_connection *gc, char *state, char *msg) |
1270 { | |
1271 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1272 char buf[BUF_LEN]; | |
1273 | |
1274 if (msg) | |
1275 g_snprintf(buf, BUF_LEN, "AWAY :%s\n", msg); | |
1276 else | |
1277 g_snprintf(buf, BUF_LEN, "AWAY\n"); | |
1278 | |
1279 write(idata->fd, buf, strlen(buf)); | |
1280 } | |
1281 | |
1678 | 1282 static void irc_fake_buddy(struct gaim_connection *gc, char *who) |
1283 { | |
1284 /* Heh, there is no buddy list. We fake it. | |
1285 * I just need this here so the add and remove buttons will | |
1286 * show up */ | |
1287 } | |
1288 | |
1289 | |
1290 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1291 static struct prpl *my_protocol = NULL; |
987 | 1292 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1293 static void irc_init(struct prpl *ret) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1294 { |
1008 | 1295 ret->protocol = PROTO_IRC; |
1296 ret->name = irc_name; | |
1178 | 1297 ret->list_icon = irc_list_icon; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1298 ret->buddy_menu = irc_buddy_menu; |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
1299 ret->user_opts = irc_user_opts; |
1008 | 1300 ret->login = irc_login; |
1011 | 1301 ret->close = irc_close; |
1302 ret->send_im = irc_send_im; | |
1303 ret->join_chat = irc_join_chat; | |
1304 ret->chat_leave = irc_chat_leave; | |
1305 ret->chat_send = irc_chat_send; | |
1673 | 1306 ret->get_info = irc_get_info; |
1676 | 1307 ret->set_away = irc_set_away; |
1678 | 1308 ret->add_buddy = irc_fake_buddy; |
1309 ret->remove_buddy = irc_fake_buddy; | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1310 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1311 my_protocol = ret; |
987 | 1312 } |
1313 | |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1314 char *gaim_plugin_init(GModule * handle) |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1315 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1394
diff
changeset
|
1316 load_protocol(irc_init, sizeof(struct prpl)); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1317 return NULL; |
987 | 1318 } |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1319 |
1266
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1320 void gaim_plugin_remove() |
aac04affc65d
[gaim-migrate @ 1276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1265
diff
changeset
|
1321 { |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1322 struct prpl *p = find_prpl(PROTO_IRC); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1323 if (p == my_protocol) |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1324 unload_protocol(p); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1325 } |