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