Mercurial > pidgin
annotate plugins/irc.c @ 1144:b1454d019277
[gaim-migrate @ 1154]
yay. the UI for the permit/deny stuff is done. the rest should be easy. :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 27 Nov 2000 12:45:03 +0000 |
parents | f6e8953a9c5e |
children | 4291c96c5096 |
rev | line source |
---|---|
987 | 1 /* |
2 * gaim - IRC Protocol Plugin | |
3 * | |
4 * Copyright (C) 2000, Rob Flynn <rob@tgflinux.com> | |
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> | |
32 #include <string.h> | |
33 #include <stdlib.h> | |
34 #include <stdio.h> | |
35 #include <time.h> | |
36 #include <sys/socket.h> | |
37 #include <sys/stat.h> | |
38 #include "multi.h" | |
39 #include "prpl.h" | |
40 #include "gaim.h" | |
41 #include "gnome_applet_mgr.h" | |
42 | |
43 #include "pixmaps/cancel.xpm" | |
44 #include "pixmaps/ok.xpm" | |
45 | |
1011 | 46 #define IRC_BUF_LEN 4096 |
47 | |
1022 | 48 |
1011 | 49 static int chat_id = 0; |
50 | |
51 struct irc_channel { | |
52 int id; | |
53 gchar *name; | |
54 }; | |
55 | |
56 struct irc_data { | |
57 int fd; | |
58 | |
1022 | 59 int timer; |
60 | |
61 int totalblocks; | |
62 int recblocks; | |
63 | |
64 GSList *templist; | |
1011 | 65 GList *channels; |
66 }; | |
67 | |
1008 | 68 static char *irc_name() { |
69 return "IRC"; | |
70 } | |
71 | |
72 char *name() { | |
73 return "IRC"; | |
74 } | |
75 | |
76 char *description() { | |
77 return "Allows gaim to use the IRC protocol"; | |
78 } | |
79 | |
1011 | 80 void irc_join_chat( struct gaim_connection *gc, int id, char *name) { |
81 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
82 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1); | |
83 | |
84 g_snprintf(buf, IRC_BUF_LEN, "JOIN %s\n", name); | |
85 write(idata->fd, buf, strlen(buf)); | |
1008 | 86 |
1011 | 87 g_free(buf); |
88 } | |
89 | |
1022 | 90 void irc_update_user (struct gaim_connection *gc, char *name, int status) { |
91 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
92 struct irc_channel *u; | |
93 GSList *temp = idata->templist; | |
94 | |
95 /* Loop through our list */ | |
96 | |
97 while (temp) { | |
98 u = (struct irc_channel *)temp->data; | |
99 if (g_strcasecmp(u->name, name) == 0) { | |
100 u->id = status; | |
101 return; | |
102 } | |
103 | |
104 temp = g_slist_next(temp); | |
105 } | |
106 return; | |
107 } | |
108 | |
109 void irc_request_buddy_update ( struct gaim_connection *gc ) { | |
110 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
111 GSList *grp = gc->groups; |
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
112 GSList *person; |
1022 | 113 struct group *g; |
114 struct buddy *b; | |
115 struct irc_channel *u; | |
116 gchar buf[IRC_BUF_LEN+1]; | |
117 | |
118 if (idata->templist != NULL) | |
119 return; | |
120 | |
121 idata->recblocks = 0; | |
122 idata->totalblocks = 1; | |
123 | |
1105 | 124 /* First, let's check to see if we have anyone on our buddylist */ |
125 if (!grp) { | |
126 return; | |
127 } | |
128 | |
1022 | 129 /* Send the first part of our request */ |
130 write(idata->fd, "ISON", 4); | |
131 | |
132 /* Step through our list of groups */ | |
133 while (grp) { | |
134 | |
135 g = (struct group *)grp->data; | |
136 person = g->members; | |
137 | |
138 while (person) { | |
139 b = (struct buddy *)person->data; | |
140 | |
141 /* We will store our buddy info here. I know, this is cheap | |
142 * but hey, its the exact same data structure. Why should we | |
143 * bother with making another one */ | |
144 | |
145 u = g_new0(struct irc_channel, 1); | |
146 u->id = 0; /* Assume by default that they're offline */ | |
147 u->name = strdup(b->name); | |
148 | |
149 write(idata->fd, " ", 1); | |
150 write(idata->fd, u->name, strlen(u->name)); | |
151 idata->templist = g_slist_append(idata->templist, u); | |
152 | |
153 person = person->next; | |
154 } | |
155 | |
156 grp = g_slist_next(grp); | |
157 } | |
158 write(idata->fd, "\n", 1); | |
159 } | |
160 | |
161 | |
1011 | 162 void irc_send_im( struct gaim_connection *gc, char *who, char *message, int away) { |
163 | |
164 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
165 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1); | |
166 | |
167 /* Before we actually send this, we should check to see if they're trying | |
168 * To issue a /me command and handle it properly. */ | |
169 | |
170 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) { | |
171 /* We have /me!! We have /me!! :-) */ | |
172 | |
173 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1); | |
174 strcpy(temp, message+4); | |
175 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%cACTION %s%c\n", who, '\001', temp, '\001'); | |
176 g_free(temp); | |
177 } | |
178 else | |
179 { | |
180 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG %s :%s\n", who, message); | |
181 } | |
182 | |
183 write(idata->fd, buf, strlen(buf)); | |
184 | |
185 g_free(buf); | |
186 } | |
187 | |
188 int find_id_by_name(struct gaim_connection *gc, char *name) { | |
189 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1); | |
190 GList *templist; | |
191 struct irc_channel *channel; | |
192 | |
193 templist = ((struct irc_data *)gc->proto_data)->channels; | |
194 | |
195 while (templist) { | |
196 channel = (struct irc_channel *)templist->data; | |
197 | |
198 g_snprintf(temp, IRC_BUF_LEN, "#%s", channel->name); | |
199 | |
200 if (g_strcasecmp(temp, name) == 0) { | |
201 g_free(temp); | |
202 return channel->id; | |
203 } | |
204 | |
205 templist = templist -> next; | |
206 } | |
207 | |
208 g_free(temp); | |
209 | |
210 /* Return -1 if we have no ID */ | |
211 return -1; | |
212 } | |
213 | |
214 struct irc_channel * find_channel_by_name(struct gaim_connection *gc, char *name) { | |
215 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN + 1); | |
216 GList *templist; | |
217 struct irc_channel *channel; | |
218 | |
219 templist = ((struct irc_data *)gc->proto_data)->channels; | |
220 | |
221 while (templist) { | |
222 channel = (struct irc_channel *)templist->data; | |
223 | |
224 g_snprintf(temp, IRC_BUF_LEN, "%s", channel->name); | |
225 | |
226 if (g_strcasecmp(temp, name) == 0) { | |
227 g_free(temp); | |
228 return channel; | |
229 } | |
230 | |
231 templist = templist -> next; | |
232 } | |
233 | |
234 g_free(temp); | |
235 | |
236 /* If we found nothing, return nothing :-) */ | |
237 return NULL; | |
238 } | |
239 | |
240 struct irc_channel * find_channel_by_id (struct gaim_connection *gc, int id) { | |
241 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
242 struct irc_channel *channel; | |
243 | |
244 GList *temp; | |
245 | |
246 temp = idata->channels; | |
247 | |
248 while (temp) { | |
249 channel = (struct irc_channel *)temp->data; | |
250 | |
251 if (channel->id == id) { | |
252 /* We've found our man */ | |
253 return channel; | |
254 } | |
255 | |
256 temp = temp->next; | |
257 } | |
258 | |
259 | |
260 /* If we didnt find one, return NULL */ | |
261 return NULL; | |
262 } | |
263 | |
264 void irc_chat_send( struct gaim_connection *gc, int id, char *message) { | |
265 | |
266 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1021 | 267 struct irc_channel *channel = NULL; |
1011 | 268 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1); |
269 | |
270 /* First lets get our current channel */ | |
271 channel = find_channel_by_id(gc, id); | |
272 | |
273 | |
274 if (!channel) { | |
275 /* If for some reason we've lost our channel, let's bolt */ | |
1021 | 276 g_free(buf); |
1011 | 277 return; |
278 } | |
279 | |
280 | |
281 /* Before we actually send this, we should check to see if they're trying | |
282 * To issue a /me command and handle it properly. */ | |
283 | |
284 if ( (g_strncasecmp(message, "/me ", 4) == 0) && (strlen(message)>4)) { | |
285 /* We have /me!! We have /me!! :-) */ | |
286 | |
287 gchar *temp = (gchar *)g_malloc(IRC_BUF_LEN+1); | |
288 strcpy(temp, message+4); | |
289 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%cACTION %s%c\n", channel->name, '\001', temp, '\001'); | |
290 g_free(temp); | |
291 } | |
292 else | |
293 { | |
294 g_snprintf(buf, IRC_BUF_LEN, "PRIVMSG #%s :%s\n", channel->name, message); | |
295 } | |
296 | |
297 write(idata->fd, buf, strlen(buf)); | |
298 | |
299 /* Since AIM expects us to receive the message we send, we gotta fake it */ | |
300 serv_got_chat_in(gc, id, gc->username, 0, message); | |
301 | |
302 g_free(buf); | |
1008 | 303 } |
304 | |
1014 | 305 struct conversation * find_conversation_by_id( struct gaim_connection * gc, int id) { |
306 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
307 GSList *bc = gc->buddy_chats; | |
308 struct conversation *b = NULL; | |
309 | |
310 while (bc) { | |
311 b = (struct conversation *)bc->data; | |
312 if (id == b->id) { | |
313 break; | |
314 } | |
315 bc = bc->next; | |
316 b = NULL; | |
317 } | |
318 | |
319 if (!b) { | |
320 return NULL; | |
321 } | |
322 | |
323 return b; | |
324 } | |
325 | |
326 struct conversation * find_conversation_by_name( struct gaim_connection * gc, char *name) { | |
327 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
328 GSList *bc = gc->buddy_chats; | |
329 struct conversation *b = NULL; | |
330 | |
331 while (bc) { | |
332 b = (struct conversation *)bc->data; | |
333 | |
334 if (g_strcasecmp(name, b->name) == 0) { | |
335 break; | |
336 } | |
337 bc = bc->next; | |
338 b = NULL; | |
339 } | |
340 | |
341 if (!b) { | |
342 return NULL; | |
343 } | |
344 | |
345 return b; | |
346 } | |
347 | |
348 | |
349 | |
1011 | 350 void irc_callback ( struct gaim_connection * gc ) { |
351 | |
352 int i = 0; | |
353 char c; | |
354 gchar buf[4096]; | |
355 gchar **buf2; | |
356 int status; | |
357 struct irc_data *idata; | |
358 | |
359 idata = (struct irc_data *)gc->proto_data; | |
360 | |
361 do { | |
362 status = recv(idata->fd, &c, 1, 0); | |
363 | |
364 if (!status) | |
365 { | |
1105 | 366 return; |
1011 | 367 } |
368 buf[i] = c; | |
369 i++; | |
370 } while (c != '\n'); | |
371 | |
372 buf[i] = '\0'; | |
373 | |
374 /* And remove that damned trailing \n */ | |
375 g_strchomp(buf); | |
376 | |
1014 | 377 /* For now, lets display everything to the console too. Im such |
378 * a bitch */ | |
1011 | 379 printf("IRC:'%'s\n", buf); |
380 | |
1014 | 381 |
1105 | 382 |
383 /* Check for errors */ | |
384 | |
385 if (((strstr(buf, "ERROR :") && (!strstr(buf, "PRIVMSG ")) && | |
386 (!strstr(buf, "NOTICE ")) && (strlen(buf) > 7)))) { | |
387 | |
388 gchar *u_errormsg; | |
389 | |
390 /* Let's get our error message */ | |
391 u_errormsg = strdup(buf + 7); | |
392 | |
393 /* We got our error message. Now, let's reaise an | |
394 * error dialog */ | |
395 | |
396 do_error_dialog(u_errormsg, "Gaim: IRC Error"); | |
397 | |
398 /* And our necessary garbage collection */ | |
399 free(u_errormsg); | |
400 } | |
401 | |
1014 | 402 /* Parse the list of names that we receive when we first sign on to |
403 * a channel */ | |
404 | |
405 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && | |
406 (!strstr(buf, "NOTICE")))) { | |
407 gchar u_host[255]; | |
408 gchar u_command[32]; | |
409 gchar u_channel[128]; | |
410 gchar u_names[IRC_BUF_LEN + 1]; | |
411 struct conversation *convo = NULL; | |
412 int j; | |
413 | |
414 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
415 u_host[j] = buf[i]; | |
416 } | |
417 | |
418 u_host[j] = '\0'; i++; | |
419 | |
420 for (j = 0; buf[i] != ' '; j++, i++) { | |
421 u_command[j] = buf[i]; | |
422 } | |
423 | |
424 u_command[j] = '\0'; i++; | |
425 | |
426 for (j = 0; buf[i] != '#'; j++, i++) { | |
427 } | |
428 i++; | |
429 | |
430 for (j = 0; buf[i] != ':'; j++, i++) { | |
431 u_channel[j] = buf[i]; | |
432 } | |
433 | |
434 u_channel[j-1] = '\0'; i++; | |
435 | |
436 while ((buf[i] == ' ') || (buf[i] == ':')) { | |
437 i++; | |
438 } | |
439 | |
440 strcpy(u_names, buf + i); | |
441 | |
442 buf2 = g_strsplit(u_names, " ", 0); | |
443 | |
444 /* Let's get our conversation window */ | |
445 convo = find_conversation_by_name(gc, u_channel); | |
446 | |
447 if (!convo) { | |
448 return; | |
449 } | |
450 | |
451 /* Now that we've parsed the hell out of this big | |
452 * mess, let's try to split up the names properly */ | |
453 | |
454 for (i = 0; buf2[i] != NULL; i++) { | |
455 /* We shouldnt play with ourselves */ | |
456 if (g_strcasecmp(buf2[i], gc->username) != 0) { | |
457 /* Add the person to the list */ | |
458 add_chat_buddy(convo, buf2[i]); | |
459 } | |
460 } | |
1021 | 461 |
462 /* And free our pointers */ | |
463 g_strfreev (buf2); | |
1014 | 464 |
465 return; | |
466 | |
467 } | |
468 | |
1022 | 469 /* Receive a list of users that are currently online */ |
470 | |
471 if (((strstr(buf, " 303 ")) && (!strstr(buf, "PRIVMSG")) && | |
472 (!strstr(buf, "NOTICE")))) { | |
473 gchar u_host[255]; | |
474 gchar u_command[32]; | |
475 gchar u_names[IRC_BUF_LEN + 1]; | |
476 int j; | |
477 | |
478 for (j = 0, i = 0; buf[i] != ' '; j++, i++) { | |
479 u_host[j] = buf[i]; | |
480 } | |
481 | |
482 u_host[j] = '\0'; i++; | |
483 | |
484 for (j = 0; buf[i] != ' '; j++, i++) { | |
485 u_command[j] = buf[i]; | |
486 } | |
487 | |
488 u_command[j] = '\0'; i++; | |
489 | |
490 for (j = 0; buf[i] != ':'; j++, i++) { | |
491 /* My Nick */ | |
492 } | |
493 i++; | |
494 | |
495 strcpy(u_names, buf + i); | |
496 | |
497 buf2 = g_strsplit(u_names, " ", 0); | |
498 | |
499 /* Now that we've parsed the hell out of this big | |
500 * mess, let's try to split up the names properly */ | |
501 | |
502 for (i = 0; buf2[i] != NULL; i++) { | |
503 /* If we have a name here then our buddy is online. We should | |
504 * update our temporary gslist accordingly. When we achieve our maximum | |
505 * list of names then we should force an update */ | |
506 | |
507 irc_update_user(gc, buf2[i], 1); | |
508 } | |
509 | |
510 /* Increase our received blocks counter */ | |
511 idata->recblocks++; | |
512 | |
513 /* If we have our total number of blocks */ | |
514 if (idata->recblocks == idata->totalblocks) { | |
515 GSList *temp; | |
516 struct irc_channel *u; | |
517 | |
518 /* Let's grab our list of people and bring them all on or off line */ | |
519 temp = idata->templist; | |
520 | |
521 /* Loop */ | |
522 while (temp) { | |
523 | |
524 u = temp->data; | |
525 | |
526 /* Tell Gaim to bring the person on or off line */ | |
1046
4593605da0e2
[gaim-migrate @ 1056]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1022
diff
changeset
|
527 serv_got_update(gc, u->name, u->id, 0, 0, 0, 0, 0); |
1022 | 528 |
529 /* Grab the next entry */ | |
530 temp = g_slist_next(temp); | |
531 } | |
532 | |
533 /* And now, let's delete all of our entries */ | |
534 temp = idata->templist; | |
535 while (temp) { | |
536 u = temp->data; | |
537 g_free(u->name); | |
538 temp = g_slist_remove(temp, u); | |
539 } | |
540 | |
541 /* Reset our list */ | |
542 idata->totalblocks = 0; | |
543 idata->recblocks = 0; | |
544 | |
545 idata->templist = NULL; | |
546 | |
547 return; | |
548 } | |
549 | |
550 /* And free our pointers */ | |
551 g_strfreev (buf2); | |
552 | |
553 return; | |
554 | |
555 } | |
556 | |
1014 | 557 |
1011 | 558 if ( (strstr(buf, " JOIN ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
559 | |
560 gchar u_channel[128]; | |
1012 | 561 gchar u_nick[128]; |
562 | |
1011 | 563 struct irc_channel *channel; |
564 int id; | |
565 int j; | |
566 | |
1012 | 567 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
568 u_nick[j] = buf[i]; | |
569 } | |
570 | |
571 u_nick[j] = '\0'; i++; | |
572 | |
573 for (j = 0; buf[i] != '#'; j++, i++) { | |
1011 | 574 } |
575 | |
576 i++; | |
577 | |
578 strcpy(u_channel, buf+i); | |
579 | |
1014 | 580 /* Looks like we're going to join the channel for real |
581 * now. Let's create a valid channel structure and add | |
582 * it to our list. Let's make sure that | |
1011 | 583 * we are not already in a channel first */ |
584 | |
585 channel = find_channel_by_name(gc, u_channel); | |
586 | |
587 if (!channel) { | |
588 chat_id++; | |
589 | |
590 channel = g_new0(struct irc_channel, 1); | |
591 | |
592 channel->id = chat_id; | |
593 channel->name = strdup(u_channel); | |
594 | |
595 idata->channels = g_list_append(idata->channels, channel); | |
596 | |
597 serv_got_joined_chat(gc, chat_id, u_channel); | |
598 } else { | |
1014 | 599 struct conversation *convo = NULL; |
600 | |
601 /* Someone else joined. Find their conversation | |
602 * window */ | |
603 convo = find_conversation_by_id(gc, channel->id); | |
604 | |
605 /* And add their name to it */ | |
606 add_chat_buddy(convo, u_nick); | |
607 | |
1011 | 608 } |
609 | |
610 return; | |
611 } | |
612 | |
613 if ( (strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | |
614 | |
615 gchar u_channel[128]; | |
616 gchar u_nick[128]; | |
617 | |
1021 | 618 struct irc_channel *channel; |
1011 | 619 int id; |
620 int j; | |
621 GList *test = NULL; | |
622 | |
623 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
624 u_nick[j] = buf[i]; | |
625 } | |
626 u_nick[j] = '\0'; | |
627 | |
628 i++; | |
629 | |
630 for (j = 0; buf[i] != '#'; j++, i++) { | |
631 } | |
632 | |
633 i++; | |
634 | |
635 strcpy(u_channel, buf+i); | |
636 | |
637 | |
1014 | 638 /* Now, lets check to see if it was US that was leaving. |
639 * If so, do the correct thing by closing up all of our | |
640 * old channel stuff. Otherwise, | |
1011 | 641 * we should just print that someone left */ |
642 | |
1014 | 643 channel = find_channel_by_name(gc, u_channel); |
644 | |
645 if (!channel) { | |
646 return; | |
647 } | |
648 | |
1011 | 649 if (g_strcasecmp(u_nick, gc->username) == 0) { |
650 | |
1014 | 651 /* Looks like we're going to leave the channel for |
652 * real now. Let's create a valid channel structure | |
653 * and add it to our list */ | |
1011 | 654 |
655 serv_got_chat_left(gc, channel->id); | |
656 | |
657 idata->channels = g_list_remove(idata->channels, channel); | |
1014 | 658 } else { |
659 struct conversation *convo = NULL; | |
660 | |
661 /* Find their conversation window */ | |
662 convo = find_conversation_by_id(gc, channel->id); | |
663 | |
664 if (!convo) { | |
665 /* Some how the window doesn't exist. | |
666 * Let's get out of here */ | |
667 return ; | |
668 } | |
669 | |
670 /* And remove their name */ | |
671 remove_chat_buddy(convo, u_nick); | |
672 | |
1011 | 673 } |
674 | |
1014 | 675 /* Go Home! */ |
1011 | 676 return; |
677 } | |
678 | |
1012 | 679 if ( (strstr(buf, " PRIVMSG ")) && (buf[0] == ':')) { |
1011 | 680 gchar u_nick[128]; |
681 gchar u_host[255]; | |
682 gchar u_command[32]; | |
683 gchar u_channel[128]; | |
684 gchar u_message[IRC_BUF_LEN]; | |
685 int j; | |
686 int msgcode = 0; | |
687 | |
688 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | |
689 u_nick[j] = buf[i]; | |
690 } | |
691 | |
692 u_nick[j] = '\0'; i++; | |
693 | |
694 for (j = 0; buf[i] != ' '; j++, i++) { | |
695 u_host[j] = buf[i]; | |
696 } | |
697 | |
698 u_host[j] = '\0'; i++; | |
699 | |
700 for (j = 0; buf[i] != ' '; j++, i++) { | |
701 u_command[j] = buf[i]; | |
702 } | |
703 | |
704 u_command[j] = '\0'; i++; | |
705 | |
706 for (j = 0; buf[i] != ':'; j++, i++) { | |
707 u_channel[j] = buf[i]; | |
708 } | |
709 | |
710 u_channel[j-1] = '\0'; i++; | |
711 | |
712 | |
713 /* Now that everything is parsed, the rest of this baby must be our message */ | |
714 strncpy(u_message, buf + i, IRC_BUF_LEN); | |
715 | |
716 /* Now, lets check the message to see if there's anything special in it */ | |
717 if (u_message[0] == '\001') { | |
1017 | 718 if (g_strncasecmp(u_message, "\001VERSION", 8) == 0) { |
719 /* Looks like we have a version request. Let | |
720 * us handle it thusly */ | |
721 | |
722 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cVERSION GAIM %s:The Pimpin Penguin AIM Clone:www.marko.net/gaim%c\n", u_nick, '\001', VERSION, '\001'); | |
723 | |
724 write(idata->fd, buf, strlen(buf)); | |
725 | |
726 /* And get the heck out of dodge */ | |
727 return; | |
728 } | |
729 | |
730 if ((g_strncasecmp(u_message, "\001PING ", 6) == 0) && (strlen(u_message) > 6)) { | |
731 /* Someone's triyng to ping us. Let's respond */ | |
732 gchar u_arg[24]; | |
733 | |
734 strcpy(u_arg, u_message + 6); | |
735 u_arg[strlen(u_arg)-1] = '\0'; | |
736 | |
737 g_snprintf(buf, IRC_BUF_LEN, "NOTICE %s :%cPING %s%c\n", u_nick, '\001', u_arg, '\001'); | |
738 | |
739 write(idata->fd, buf, strlen(buf)); | |
740 | |
741 /* And get the heck out of dodge */ | |
742 return; | |
743 } | |
744 | |
1011 | 745 if (g_strncasecmp(u_message, "\001ACTION ", 8) == 0) { |
746 /* Looks like we have an action. Let's parse it a little */ | |
747 strcpy(buf, u_message); | |
748 | |
749 strcpy(u_message, "/me "); | |
750 for (j = 4, i = 8; buf[i] != '\001'; i++, j++) { | |
751 u_message[j] = buf[i]; | |
752 } | |
753 u_message[j] = '\0'; | |
754 } | |
755 } | |
756 | |
757 | |
758 /* Let's check to see if we have a channel on our hands */ | |
759 if (u_channel[0] == '#') { | |
760 /* Yup. We have a channel */ | |
761 int id; | |
762 | |
763 id = find_id_by_name(gc, u_channel); | |
764 if (id != -1) { | |
765 serv_got_chat_in(gc, id, u_nick, 0, u_message); | |
766 } | |
767 } | |
768 else { | |
769 /* Nope. Let's treat it as a private message */ | |
770 serv_got_im(gc, u_nick, u_message, 0); | |
771 } | |
772 | |
773 return; | |
774 } | |
775 | |
776 /* Let's parse PING requests so that we wont get booted for inactivity */ | |
777 | |
778 if (strncmp(buf, "PING :", 6) == 0) { | |
779 buf2 = g_strsplit(buf, ":", 1); | |
780 | |
781 /* Let's build a new response */ | |
782 g_snprintf(buf, IRC_BUF_LEN, "PONG :%s\n", buf2[1]); | |
783 write(idata->fd, buf, strlen(buf)); | |
784 | |
785 /* And clean up after ourselves */ | |
786 g_strfreev(buf2); | |
787 | |
788 return; | |
789 } | |
790 | |
791 } | |
792 | |
793 void irc_handler(gpointer data, gint source, GdkInputCondition condition) { | |
794 irc_callback(data); | |
795 } | |
796 | |
797 void irc_close(struct gaim_connection *gc) { | |
798 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
1021 | 799 GList *chats = idata->channels; |
800 struct irc_channel *cc; | |
801 | |
1011 | 802 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN); |
803 | |
1022 | 804 gtk_timeout_remove(idata->timer); |
805 | |
1021 | 806 g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [www.marko.net/gaim]\n"); |
1011 | 807 write(idata->fd, buf, strlen(buf)); |
808 | |
809 g_free(buf); | |
1021 | 810 |
811 while (chats) { | |
812 cc = (struct irc_channel *)chats->data; | |
813 g_free(cc->name); | |
814 chats = g_list_remove(chats, cc); | |
815 g_free(cc); | |
816 } | |
817 | |
818 if (gc->inpa) | |
819 gdk_input_remove(gc->inpa); | |
820 | |
1011 | 821 close(idata->fd); |
822 g_free(gc->proto_data); | |
823 } | |
824 | |
825 void irc_chat_leave(struct gaim_connection *gc, int id) { | |
826 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
827 struct irc_channel *channel; | |
828 gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN+1); | |
829 | |
830 channel = find_channel_by_id(gc, id); | |
831 | |
832 if (!channel) { | |
833 return; | |
834 } | |
835 | |
836 g_snprintf(buf, IRC_BUF_LEN, "PART #%s\n", channel->name); | |
837 write(idata->fd, buf, strlen(buf)); | |
838 | |
839 g_free(buf); | |
840 } | |
841 | |
842 void irc_login(struct aim_user *user) { | |
843 int fd; | |
844 struct hostent *host; | |
845 struct sockaddr_in site; | |
846 char buf[4096]; | |
847 | |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
848 struct gaim_connection *gc = new_gaim_conn(user); |
1011 | 849 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
850 char c; | |
851 int i; | |
852 int status; | |
853 | |
854 set_login_progress(gc, 1, buf); | |
855 | |
856 while (gtk_events_pending()) | |
857 gtk_main_iteration(); | |
1090
79cdc86ef4c6
[gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
858 if (!g_slist_find(connections, gc)) |
79cdc86ef4c6
[gaim-migrate @ 1100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
859 return; |
1011 | 860 |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
861 host = gethostbyname(user->proto_opt[0]); |
1011 | 862 if (!host) { |
863 hide_login_progress(gc, "Unable to resolve hostname"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
864 signoff(gc); |
1011 | 865 return; |
866 } | |
867 | |
868 site.sin_family = AF_INET; | |
869 site.sin_addr.s_addr = *(long *)(host->h_addr); | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
870 site.sin_port = htons(atoi(user->proto_opt[1])); |
1011 | 871 |
872 fd = socket(AF_INET, SOCK_STREAM, 0); | |
873 if (fd < 0) { | |
874 hide_login_progress(gc, "Unable to create socket"); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
875 signoff(gc); |
1011 | 876 return; |
877 } | |
878 | |
879 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) { | |
880 hide_login_progress(gc, "Unable to connect."); | |
1115
114cd406b022
[gaim-migrate @ 1125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1105
diff
changeset
|
881 signoff(gc); |
1011 | 882 return; |
883 } | |
884 | |
885 idata->fd = fd; | |
886 | |
887 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); | |
888 set_login_progress(gc, 2, buf); | |
889 | |
890 /* This is where we will attempt to sign on */ | |
891 | |
1105 | 892 g_snprintf(buf, 4096, "NICK %s\n USER %s localhost %s :GAIM (www.marko.net/gaim)\n", gc->username, getenv("USER"), user->proto_opt[0]); |
893 | |
894 printf("Sending: %s\n", buf); | |
1011 | 895 write(idata->fd, buf, strlen(buf)); |
896 | |
897 /* Now lets sign ourselves on */ | |
1089
f0f5c10cce63
[gaim-migrate @ 1099]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1075
diff
changeset
|
898 account_online(gc); |
1011 | 899 serv_finish_login(gc); |
900 | |
1022 | 901 if (bud_list_cache_exists(gc)) |
902 do_import(NULL, gc); | |
903 | |
904 | |
1011 | 905 gc->inpa = gdk_input_add(idata->fd, GDK_INPUT_READ, irc_handler, gc); |
1022 | 906 |
907 /* We want to update our buddlist every 20 seconds */ | |
908 idata->timer = gtk_timeout_add(20000, (GtkFunction)irc_request_buddy_update, gc); | |
909 | |
910 /* But first, let's go ahead and check our list */ | |
911 irc_request_buddy_update(gc); | |
1011 | 912 } |
1008 | 913 |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
914 static void irc_print_option(GtkEntry *entry, struct aim_user *user) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
915 if (gtk_object_get_user_data(GTK_OBJECT(entry))) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
916 g_snprintf(user->proto_opt[1], sizeof(user->proto_opt[1]), "%s", |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
917 gtk_entry_get_text(entry)); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
918 } else { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
919 g_snprintf(user->proto_opt[0], sizeof(user->proto_opt[0]), "%s", |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
920 gtk_entry_get_text(entry)); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
921 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
922 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
923 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
924 static void irc_user_opts(GtkWidget *book, struct aim_user *user) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
925 /* so here, we create the new notebook page */ |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
926 GtkWidget *vbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
927 GtkWidget *hbox; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
928 GtkWidget *label; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
929 GtkWidget *entry; |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
930 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
931 vbox = gtk_vbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
932 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
933 gtk_label_new("IRC Options")); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
934 gtk_widget_show(vbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
935 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
936 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
937 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
938 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
939 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
940 label = gtk_label_new("Server:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
941 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
942 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
943 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
944 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
945 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
946 gtk_signal_connect(GTK_OBJECT(entry), "changed", |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
947 GTK_SIGNAL_FUNC(irc_print_option), user); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
948 if (user->proto_opt[0][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
949 debug_printf("setting text %s\n", user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
950 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[0]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
951 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
952 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
953 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
954 hbox = gtk_hbox_new(FALSE, 0); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
955 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
956 gtk_widget_show(hbox); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
957 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
958 label = gtk_label_new("Port:"); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
959 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
960 gtk_widget_show(label); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
961 |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
962 entry = gtk_entry_new(); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
963 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
964 if (user->proto_opt[1][0]) { |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
965 debug_printf("setting text %s\n", user->proto_opt[1]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
966 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[1]); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
967 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
968 gtk_object_set_user_data(GTK_OBJECT(entry), user); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
969 gtk_signal_connect(GTK_OBJECT(entry), "changed", |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
970 GTK_SIGNAL_FUNC(irc_print_option), user); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
971 gtk_widget_show(entry); |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
972 } |
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
973 |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
974 static struct prpl *my_protocol = NULL; |
987 | 975 |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
976 void irc_init(struct prpl *ret) { |
1008 | 977 ret->protocol = PROTO_IRC; |
978 ret->name = irc_name; | |
1075
2fe18b2d6105
[gaim-migrate @ 1085]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
979 ret->user_opts = irc_user_opts; |
1008 | 980 ret->login = irc_login; |
1011 | 981 ret->close = irc_close; |
982 ret->send_im = irc_send_im; | |
987 | 983 ret->set_info = NULL; |
984 ret->get_info = NULL; | |
985 ret->set_away = NULL; | |
986 ret->get_away_msg = NULL; | |
987 ret->set_dir = NULL; | |
988 ret->get_dir = NULL; | |
989 ret->dir_search = NULL; | |
990 ret->set_idle = NULL; | |
991 ret->change_passwd = NULL; | |
992 ret->add_buddy = NULL; | |
993 ret->add_buddies = NULL; | |
994 ret->remove_buddy = NULL; | |
995 ret->add_permit = NULL; | |
996 ret->add_deny = NULL; | |
997 ret->warn = NULL; | |
998 ret->accept_chat = NULL; | |
1011 | 999 ret->join_chat = irc_join_chat; |
987 | 1000 ret->chat_invite = NULL; |
1011 | 1001 ret->chat_leave = irc_chat_leave; |
987 | 1002 ret->chat_whisper = NULL; |
1011 | 1003 ret->chat_send = irc_chat_send; |
987 | 1004 ret->keepalive = NULL; |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1005 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1006 my_protocol = ret; |
987 | 1007 } |
1008 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1009 char *gaim_plugin_init(GModule *handle) { |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1010 load_protocol(irc_init); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1011 return NULL; |
987 | 1012 } |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1013 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1014 void gaim_plugin_remove() { |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1015 struct prpl *p = find_prpl(PROTO_IRC); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1016 if (p == my_protocol) |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1017 unload_protocol(p); |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1046
diff
changeset
|
1018 } |