Mercurial > pidgin
comparison src/oscar.c @ 1868:a49ed23b3c02
[gaim-migrate @ 1878]
proxy stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 20 May 2001 12:06:06 +0000 |
parents | b1d62fe22d74 |
children | 4836d30127df |
comparison
equal
deleted
inserted
replaced
1867:b508cbbe9c48 | 1868:a49ed23b3c02 |
---|---|
39 #include <sys/stat.h> | 39 #include <sys/stat.h> |
40 #include "multi.h" | 40 #include "multi.h" |
41 #include "prpl.h" | 41 #include "prpl.h" |
42 #include "gaim.h" | 42 #include "gaim.h" |
43 #include "aim.h" | 43 #include "aim.h" |
44 #include "proxy.h" | |
44 | 45 |
45 /*#include "pixmaps/cancel.xpm"*/ | 46 /*#include "pixmaps/cancel.xpm"*/ |
46 #include "pixmaps/admin_icon.xpm" | 47 #include "pixmaps/admin_icon.xpm" |
47 #include "pixmaps/aol_icon.xpm" | 48 #include "pixmaps/aol_icon.xpm" |
48 #include "pixmaps/away_icon.xpm" | 49 #include "pixmaps/away_icon.xpm" |
50 #include "pixmaps/free_icon.xpm" | 51 #include "pixmaps/free_icon.xpm" |
51 | 52 |
52 /* constants to identify proto_opts */ | 53 /* constants to identify proto_opts */ |
53 #define USEROPT_AUTH 0 | 54 #define USEROPT_AUTH 0 |
54 #define USEROPT_AUTHPORT 1 | 55 #define USEROPT_AUTHPORT 1 |
55 #define USEROPT_SOCKSHOST 2 | 56 #define USEROPT_PROXYHOST 2 |
56 #define USEROPT_SOCKSPORT 3 | 57 #define USEROPT_PROXYPORT 3 |
58 #define USEROPT_PROXYTYPE 4 | |
59 #define USEROPT_USER 5 | |
60 #define USEROPT_PASS 6 | |
57 | 61 |
58 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" | 62 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
59 | 63 |
60 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_IMIMAGE; | 64 static int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_IMIMAGE; |
61 | 65 |
62 static GtkWidget *join_chat_spin = NULL; | 66 static GtkWidget *join_chat_spin = NULL; |
63 static GtkWidget *join_chat_entry = NULL; | 67 static GtkWidget *join_chat_entry = NULL; |
64 | 68 |
65 struct oscar_data { | 69 struct oscar_data { |
89 int exchange; | 93 int exchange; |
90 int fd; /* this is redundant since we have the conn below */ | 94 int fd; /* this is redundant since we have the conn below */ |
91 struct aim_conn_t *conn; | 95 struct aim_conn_t *conn; |
92 int inpa; | 96 int inpa; |
93 int id; | 97 int id; |
98 struct gaim_connection *gc; /* i hate this. */ | |
99 gpointer priv; /* don't ask. */ | |
94 }; | 100 }; |
95 | 101 |
96 struct direct_im { | 102 struct direct_im { |
97 struct gaim_connection *gc; | 103 struct gaim_connection *gc; |
98 char name[80]; | 104 char name[80]; |
402 debug_printf("\n"); | 408 debug_printf("\n"); |
403 g_free(t); | 409 g_free(t); |
404 g_free(s); | 410 g_free(s); |
405 } | 411 } |
406 | 412 |
407 void oscar_login(struct aim_user *user) { | 413 static void oscar_login_connect(gpointer data, gint source, GdkInputCondition cond) |
414 { | |
415 struct gaim_connection *gc = data; | |
416 struct oscar_data *odata = gc->proto_data; | |
417 struct aim_session_t *sess = odata->sess; | |
418 struct aim_conn_t *conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | |
419 | |
420 if (source < 0) { | |
421 hide_login_progress(gc, _("Couldn't connect to host")); | |
422 signoff(gc); | |
423 return; | |
424 } | |
425 | |
426 if (conn->fd != source) | |
427 conn->fd = source; | |
428 | |
429 aim_request_login(sess, conn, gc->username); | |
430 | |
431 gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
432 oscar_callback, conn); | |
433 | |
434 debug_printf(_("Password sent, waiting for response\n")); | |
435 } | |
436 | |
437 static void oscar_login(struct aim_user *user) { | |
408 struct aim_session_t *sess; | 438 struct aim_session_t *sess; |
409 struct aim_conn_t *conn; | 439 struct aim_conn_t *conn; |
410 char buf[256]; | 440 char buf[256]; |
411 char *finalauth = NULL; | |
412 struct gaim_connection *gc = new_gaim_conn(user); | 441 struct gaim_connection *gc = new_gaim_conn(user); |
413 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); | 442 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); |
414 odata->create_exchange = 0; | 443 odata->create_exchange = 0; |
415 | 444 |
416 debug_printf(_("Logging in %s\n"), user->username); | 445 debug_printf(_("Logging in %s\n"), user->username); |
417 | 446 |
418 sess = g_new0(struct aim_session_t, 1); | 447 sess = g_new0(struct aim_session_t, 1); |
419 | 448 |
420 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | 449 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); |
421 aim_setdebuggingcb(sess, oscar_debug); | 450 aim_setdebuggingcb(sess, oscar_debug); |
422 | |
423 if (user->proto_opt[USEROPT_SOCKSHOST][0]) { | |
424 char *finalproxy; | |
425 if (user->proto_opt[USEROPT_SOCKSPORT][0]) | |
426 finalproxy = g_strconcat(user->proto_opt[USEROPT_SOCKSHOST], ":", | |
427 user->proto_opt[USEROPT_SOCKSPORT], NULL); | |
428 else | |
429 finalproxy = g_strdup(user->proto_opt[USEROPT_SOCKSHOST]); | |
430 aim_setupproxy(sess, finalproxy, NULL, NULL); | |
431 g_free(finalproxy); | |
432 } | |
433 | |
434 if (user->proto_opt[USEROPT_AUTH][0]) { | |
435 if (user->proto_opt[USEROPT_AUTHPORT][0]) | |
436 finalauth = g_strconcat(user->proto_opt[USEROPT_AUTH], ":", | |
437 user->proto_opt[USEROPT_AUTHPORT], NULL); | |
438 else | |
439 finalauth = g_strdup(user->proto_opt[USEROPT_AUTH]); | |
440 } | |
441 | 451 |
442 /* we need an immediate queue because we don't use a while-loop to | 452 /* we need an immediate queue because we don't use a while-loop to |
443 * see if things need to be sent. */ | 453 * see if things need to be sent. */ |
444 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | 454 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
445 odata->sess = sess; | 455 odata->sess = sess; |
446 sess->aux_data = gc; | 456 sess->aux_data = gc; |
447 | 457 |
448 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, finalauth ? finalauth : FAIM_LOGIN_SERVER); | 458 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
449 | |
450 if (finalauth) | |
451 g_free(finalauth); | |
452 | |
453 if (conn == NULL) { | 459 if (conn == NULL) { |
454 debug_printf(_("internal connection error\n")); | 460 debug_printf(_("internal connection error\n")); |
455 hide_login_progress(gc, _("Unable to login to AIM")); | 461 hide_login_progress(gc, _("Unable to login to AIM")); |
456 signoff(gc); | 462 signoff(gc); |
457 return; | 463 return; |
458 } else if (conn->fd == -1) { | 464 } |
459 if (conn->status & AIM_CONN_STATUS_RESOLVERR) { | 465 |
460 char *crh = _("couldn't resolve host"); | 466 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); |
461 debug_printf("%s\n", crh); | 467 set_login_progress(gc, 2, buf); |
462 hide_login_progress(gc, crh); | 468 |
463 } else if (conn->status & AIM_CONN_STATUS_CONNERR) { | 469 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
464 char *cch = _("couldn't connect to host"); | 470 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
465 debug_printf("%s\n", cch); | 471 |
466 hide_login_progress(gc, cch); | 472 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? |
467 } | 473 user->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, |
474 user->proto_opt[USEROPT_AUTHPORT][0] ? | |
475 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
476 user->proto_opt[USEROPT_PROXYHOST], | |
477 atoi(user->proto_opt[USEROPT_PROXYPORT]), | |
478 atoi(user->proto_opt[USEROPT_PROXYTYPE]), | |
479 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], | |
480 oscar_login_connect, gc); | |
481 if (!user->gc || (conn->fd < 0)) { | |
482 hide_login_progress(gc, _("Couldn't connect to host")); | |
468 signoff(gc); | 483 signoff(gc); |
469 return; | 484 return; |
470 } | 485 } |
471 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | 486 } |
472 set_login_progress(gc, 2, buf); | 487 |
473 | 488 static void oscar_close(struct gaim_connection *gc) { |
474 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
475 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
476 aim_request_login(sess, conn, gc->username); | |
477 | |
478 gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
479 oscar_callback, conn); | |
480 | |
481 debug_printf(_("Password sent, waiting for response\n")); | |
482 } | |
483 | |
484 void oscar_close(struct gaim_connection *gc) { | |
485 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | 489 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
486 GSList *c = odata->oscar_chats; | 490 GSList *c = odata->oscar_chats; |
487 struct chat_connection *n; | 491 struct chat_connection *n; |
488 if (gc->protocol != PROTO_OSCAR) return; | 492 if (gc->protocol != PROTO_OSCAR) return; |
489 | 493 |
508 g_free(gc->proto_data); | 512 g_free(gc->proto_data); |
509 gc->proto_data = NULL; | 513 gc->proto_data = NULL; |
510 debug_printf(_("Signed off.\n")); | 514 debug_printf(_("Signed off.\n")); |
511 } | 515 } |
512 | 516 |
517 static void oscar_bos_connect(gpointer data, gint source, GdkInputCondition cond) { | |
518 struct gaim_connection *gc = data; | |
519 struct oscar_data *odata = gc->proto_data; | |
520 struct aim_session_t *sess = odata->sess; | |
521 struct aim_conn_t *bosconn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); | |
522 | |
523 if (source < 0) { | |
524 if (bosconn->priv) | |
525 g_free(bosconn->priv); | |
526 bosconn->priv = NULL; | |
527 hide_login_progress(gc, _("Could Not Connect")); | |
528 signoff(gc); | |
529 return; | |
530 } | |
531 | |
532 if (bosconn->fd != source) | |
533 bosconn->fd = source; | |
534 | |
535 aim_auth_sendcookie(sess, bosconn, bosconn->priv); | |
536 g_free(bosconn->priv); | |
537 bosconn->priv = NULL; | |
538 gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
539 oscar_callback, bosconn); | |
540 set_login_progress(gc, 4, _("Connection established, cookie sent")); | |
541 } | |
542 | |
513 int gaim_parse_auth_resp(struct aim_session_t *sess, | 543 int gaim_parse_auth_resp(struct aim_session_t *sess, |
514 struct command_rx_struct *command, ...) { | 544 struct command_rx_struct *command, ...) { |
515 va_list ap; | 545 va_list ap; |
516 struct aim_conn_t *bosconn = NULL; | 546 struct aim_conn_t *bosconn = NULL; |
517 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL; | 547 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL; |
519 int errorcode = 0, regstatus = 0; | 549 int errorcode = 0, regstatus = 0; |
520 int latestbuild = 0, latestbetabuild = 0; | 550 int latestbuild = 0, latestbetabuild = 0; |
521 char *latestrelease = NULL, *latestbeta = NULL; | 551 char *latestrelease = NULL, *latestbeta = NULL; |
522 char *latestreleaseurl = NULL, *latestbetaurl = NULL; | 552 char *latestreleaseurl = NULL, *latestbetaurl = NULL; |
523 char *latestreleaseinfo = NULL, *latestbetainfo = NULL; | 553 char *latestreleaseinfo = NULL, *latestbetainfo = NULL; |
554 int i; char *host; int port = FAIM_LOGIN_PORT; | |
555 struct aim_user *user; | |
524 | 556 |
525 struct gaim_connection *gc = sess->aux_data; | 557 struct gaim_connection *gc = sess->aux_data; |
558 user = gc->user; | |
526 | 559 |
527 va_start(ap, command); | 560 va_start(ap, command); |
528 sn = va_arg(ap, char *); | 561 sn = va_arg(ap, char *); |
529 errorcode = va_arg(ap, int); | 562 errorcode = va_arg(ap, int); |
530 errurl = va_arg(ap, char *); | 563 errurl = va_arg(ap, char *); |
591 latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo); | 624 latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo); |
592 debug_printf("Closing auth connection...\n"); | 625 debug_printf("Closing auth connection...\n"); |
593 gdk_input_remove(gc->inpa); | 626 gdk_input_remove(gc->inpa); |
594 aim_conn_kill(sess, &command->conn); | 627 aim_conn_kill(sess, &command->conn); |
595 | 628 |
596 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip); | 629 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); |
597 if (bosconn == NULL) { | 630 if (bosconn == NULL) { |
598 hide_login_progress(gc, _("Internal Error")); | 631 hide_login_progress(gc, _("Internal Error")); |
599 signoff(gc); | |
600 return -1; | |
601 } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) { | |
602 hide_login_progress(gc, _("Could Not Connect")); | |
603 signoff(gc); | 632 signoff(gc); |
604 return -1; | 633 return -1; |
605 } | 634 } |
606 | 635 |
607 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); | 636 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
628 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); | 657 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
629 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | 658 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); |
630 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | 659 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); |
631 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | 660 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); |
632 | 661 |
633 aim_auth_sendcookie(sess, bosconn, cookie); | |
634 ((struct oscar_data *)gc->proto_data)->conn = bosconn; | 662 ((struct oscar_data *)gc->proto_data)->conn = bosconn; |
635 gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 663 for (i = 0; i < (int)strlen(bosip); i++) { |
636 oscar_callback, bosconn); | 664 if (bosip[i] == ':') { |
637 set_login_progress(gc, 4, _("Connection established, cookie sent")); | 665 port = atoi(&(bosip[i+1])); |
666 break; | |
667 } | |
668 } | |
669 host = g_strndup(bosip, i); | |
670 bosconn->priv = g_memdup(cookie, AIM_COOKIELEN); | |
671 bosconn->fd = proxy_connect(host, port, | |
672 gc->user->proto_opt[USEROPT_PROXYHOST], | |
673 atoi(gc->user->proto_opt[USEROPT_PROXYPORT]), | |
674 atoi(gc->user->proto_opt[USEROPT_PROXYTYPE]), | |
675 gc->user->proto_opt[USEROPT_USER], gc->user->proto_opt[USEROPT_PASS], | |
676 oscar_bos_connect, gc); | |
677 g_free(host); | |
678 if (!user->gc || (bosconn->fd < 0)) { | |
679 if (bosconn->priv) | |
680 g_free(bosconn->priv); | |
681 bosconn->priv = NULL; | |
682 hide_login_progress(gc, _("Could Not Connect")); | |
683 signoff(gc); | |
684 return -1; | |
685 } | |
638 return 1; | 686 return 1; |
639 } | 687 } |
640 | 688 |
641 struct pieceofcrap { | 689 struct pieceofcrap { |
642 struct gaim_connection *gc; | 690 struct gaim_connection *gc; |
643 unsigned long offset; | 691 unsigned long offset; |
644 unsigned long len; | 692 unsigned long len; |
645 char *modname; | 693 char *modname; |
694 int fd; | |
646 struct aim_conn_t *conn; | 695 struct aim_conn_t *conn; |
647 struct aim_conn_t *mainconn; | |
648 unsigned int inpa; | 696 unsigned int inpa; |
649 }; | 697 }; |
650 | 698 |
651 void damn_you(gpointer data, gint source, GdkInputCondition c) | 699 static void damn_you(gpointer data, gint source, GdkInputCondition c) |
652 { | 700 { |
653 struct pieceofcrap *pos = data; | 701 struct pieceofcrap *pos = data; |
654 struct oscar_data *od = pos->gc->proto_data; | 702 struct oscar_data *od = pos->gc->proto_data; |
655 char in = '\0'; | 703 char in = '\0'; |
656 int x = 0; | 704 int x = 0; |
657 char m[17]; | 705 char m[17]; |
658 if (c == GDK_INPUT_WRITE) { | 706 |
659 char buf[BUF_LONG]; | 707 while (read(pos->fd, &in, 1) == 1) { |
660 if (aim_conn_completeconnect(od->sess, pos->conn) < 0) { | |
661 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
662 " You may be disconnected shortly.", "Login Error"); | |
663 gdk_input_remove(pos->inpa); | |
664 close(pos->conn->fd); | |
665 aim_conn_kill(od->sess, &pos->conn); | |
666 g_free(pos); | |
667 return; | |
668 } | |
669 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
670 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
671 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
672 write(pos->conn->fd, buf, strlen(buf)); | |
673 if (pos->modname) | |
674 g_free(pos->modname); | |
675 gdk_input_remove(pos->inpa); | |
676 pos->inpa = gdk_input_add(pos->conn->fd, GDK_INPUT_READ, damn_you, pos); | |
677 return; | |
678 } | |
679 | |
680 while (read(pos->conn->fd, &in, 1) == 1) { | |
681 if (in == '\n') | 708 if (in == '\n') |
682 x++; | 709 x++; |
683 else if (in != '\r') | 710 else if (in != '\r') |
684 x = 0; | 711 x = 0; |
685 if (x == 2) | 712 if (x == 2) |
688 } | 715 } |
689 if (in != '\n') { | 716 if (in != '\n') { |
690 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | 717 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." |
691 " You may be disconnected shortly.", "Login Error"); | 718 " You may be disconnected shortly.", "Login Error"); |
692 gdk_input_remove(pos->inpa); | 719 gdk_input_remove(pos->inpa); |
693 close(pos->conn->fd); | 720 close(pos->fd); |
694 aim_conn_kill(od->sess, &pos->conn); | |
695 g_free(pos); | 721 g_free(pos); |
696 return; | 722 return; |
697 } | 723 } |
698 read(pos->conn->fd, m, 16); | 724 read(pos->fd, m, 16); |
699 m[16] = '\0'; | 725 m[16] = '\0'; |
700 debug_printf("Sending hash: "); | 726 debug_printf("Sending hash: "); |
701 for (x = 0; x < 16; x++) | 727 for (x = 0; x < 16; x++) |
702 debug_printf("%02x ", (unsigned char)m[x]); | 728 debug_printf("%02x ", (unsigned char)m[x]); |
703 debug_printf("\n"); | 729 debug_printf("\n"); |
704 gdk_input_remove(pos->inpa); | 730 gdk_input_remove(pos->inpa); |
705 close(pos->conn->fd); | 731 close(pos->fd); |
706 aim_conn_kill(od->sess, &pos->conn); | 732 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); |
707 aim_sendmemblock(od->sess, pos->mainconn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
708 g_free(pos); | 733 g_free(pos); |
734 } | |
735 | |
736 static void straight_to_hell(gpointer data, gint source, GdkInputCondition cond) { | |
737 struct pieceofcrap *pos = data; | |
738 char buf[BUF_LONG]; | |
739 | |
740 if (source < 0) { | |
741 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
742 " You may be disconnected shortly.", "Login Error"); | |
743 if (pos->modname) | |
744 g_free(pos->modname); | |
745 g_free(pos); | |
746 return; | |
747 } | |
748 | |
749 if (pos->fd != source) | |
750 pos->fd = source; | |
751 | |
752 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
753 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
754 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
755 write(pos->fd, buf, strlen(buf)); | |
756 if (pos->modname) | |
757 g_free(pos->modname); | |
758 pos->inpa = gdk_input_add(pos->fd, GDK_INPUT_READ, damn_you, pos); | |
759 return; | |
709 } | 760 } |
710 | 761 |
711 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | 762 /* size of icbmui.ocm, the largest module in AIM 3.5 */ |
712 #define AIM_MAX_FILE_SIZE 98304 | 763 #define AIM_MAX_FILE_SIZE 98304 |
713 | 764 |
714 int gaim_memrequest(struct aim_session_t *sess, | 765 int gaim_memrequest(struct aim_session_t *sess, |
715 struct command_rx_struct *command, ...) { | 766 struct command_rx_struct *command, ...) { |
767 struct gaim_connection *gc = sess->aux_data; | |
716 va_list ap; | 768 va_list ap; |
717 struct pieceofcrap *pos; | 769 struct pieceofcrap *pos; |
718 unsigned long offset, len; | 770 unsigned long offset, len; |
719 char *modname; | 771 char *modname; |
772 int fd; | |
720 | 773 |
721 va_start(ap, command); | 774 va_start(ap, command); |
722 offset = va_arg(ap, unsigned long); | 775 offset = va_arg(ap, unsigned long); |
723 len = va_arg(ap, unsigned long); | 776 len = va_arg(ap, unsigned long); |
724 modname = va_arg(ap, char *); | 777 modname = va_arg(ap, char *); |
725 va_end(ap); | 778 va_end(ap); |
726 | 779 |
780 debug_printf("offset: %d, len: %d, file: %s\n", offset, len, modname ? modname : "aim.exe"); | |
727 if (len == 0) { | 781 if (len == 0) { |
728 debug_printf("len is 0, hashing NULL\n"); | 782 debug_printf("len is 0, hashing NULL\n"); |
729 aim_sendmemblock(sess, command->conn, offset, len, NULL, | 783 aim_sendmemblock(sess, command->conn, offset, len, NULL, |
730 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | 784 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
731 return 1; | 785 return 1; |
757 } | 811 } |
758 */ | 812 */ |
759 | 813 |
760 pos = g_new0(struct pieceofcrap, 1); | 814 pos = g_new0(struct pieceofcrap, 1); |
761 pos->gc = sess->aux_data; | 815 pos->gc = sess->aux_data; |
762 pos->mainconn = command->conn; | 816 pos->conn = command->conn; |
763 | 817 |
764 pos->offset = offset; | 818 pos->offset = offset; |
765 pos->len = len; | 819 pos->len = len; |
766 pos->modname = modname ? g_strdup(modname) : NULL; | 820 pos->modname = modname ? g_strdup(modname) : NULL; |
767 | 821 |
768 pos->conn = aim_newconn(sess, 0, "gaim.sourceforge.net:80"); | 822 fd = proxy_connect("gaim.sourceforge.net", 80, |
769 pos->inpa = gdk_input_add(pos->conn->fd, GDK_INPUT_WRITE, damn_you, pos); | 823 gc->user->proto_opt[USEROPT_PROXYHOST], |
824 atoi(gc->user->proto_opt[USEROPT_PROXYPORT]), | |
825 atoi(gc->user->proto_opt[USEROPT_PROXYTYPE]), | |
826 gc->user->proto_opt[USEROPT_USER], gc->user->proto_opt[USEROPT_PASS], | |
827 straight_to_hell, pos); | |
828 if (fd < 0) { | |
829 if (pos->modname) | |
830 g_free(pos->modname); | |
831 g_free(pos); | |
832 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
833 " You may be disconnected shortly.", "Login Error"); | |
834 } | |
835 pos->fd = fd; | |
770 | 836 |
771 return 1; | 837 return 1; |
772 } | 838 } |
773 | 839 |
774 void some_name(char *buf) | 840 void some_name(char *buf) |
862 break; | 928 break; |
863 } | 929 } |
864 return 1; | 930 return 1; |
865 } | 931 } |
866 | 932 |
933 static void oscar_chatnav_connect(gpointer data, gint source, GdkInputCondition cond) | |
934 { | |
935 struct gaim_connection *gc = data; | |
936 struct oscar_data *odata = gc->proto_data; | |
937 struct aim_session_t *sess = odata->sess; | |
938 struct aim_conn_t *tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV); | |
939 | |
940 if (source < 0) { | |
941 if (tstconn->priv) | |
942 g_free(tstconn->priv); | |
943 tstconn->priv = NULL; | |
944 aim_conn_kill(sess, &tstconn); | |
945 debug_printf("unable to connect to chatnav server\n"); | |
946 return; | |
947 } | |
948 | |
949 if (tstconn->fd != source) | |
950 tstconn->fd = source; | |
951 | |
952 aim_auth_sendcookie(sess, tstconn, tstconn->priv); | |
953 g_free(tstconn->priv); | |
954 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
955 oscar_callback, tstconn); | |
956 debug_printf("chatnav: connected\n"); | |
957 } | |
958 | |
959 static void oscar_auth_connect(gpointer data, gint source, GdkInputCondition cond) | |
960 { | |
961 struct gaim_connection *gc = data; | |
962 struct oscar_data *odata = gc->proto_data; | |
963 struct aim_session_t *sess = odata->sess; | |
964 struct aim_conn_t *tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | |
965 | |
966 if (source < 0) { | |
967 if (tstconn->priv) | |
968 g_free(tstconn->priv); | |
969 tstconn->priv = NULL; | |
970 aim_conn_kill(sess, &tstconn); | |
971 debug_printf("unable to connect to authorizer\n"); | |
972 return; | |
973 } | |
974 | |
975 if (tstconn->fd != source) | |
976 tstconn->fd = source; | |
977 | |
978 aim_auth_sendcookie(sess, tstconn, tstconn->priv); | |
979 g_free(tstconn->priv); | |
980 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
981 oscar_callback, tstconn); | |
982 debug_printf("chatnav: connected\n"); | |
983 } | |
984 | |
985 static void oscar_chat_connect(gpointer data, gint source, GdkInputCondition cond) | |
986 { | |
987 struct chat_connection *ccon = data; | |
988 struct gaim_connection *gc = ccon->gc; | |
989 struct oscar_data *odata = gc->proto_data; | |
990 struct aim_session_t *sess = odata->sess; | |
991 struct aim_conn_t *tstconn = ccon->conn; | |
992 | |
993 if (source < 0) { | |
994 aim_conn_kill(sess, &tstconn); | |
995 g_free(ccon->priv); | |
996 g_free(ccon->show); | |
997 g_free(ccon->name); | |
998 g_free(ccon); | |
999 } | |
1000 | |
1001 if (ccon->fd != source) | |
1002 ccon->fd = tstconn->fd = source; | |
1003 | |
1004 ccon->inpa = gdk_input_add(tstconn->fd, | |
1005 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
1006 oscar_callback, tstconn); | |
1007 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | |
1008 aim_chat_attachname(tstconn, ccon->name); | |
1009 aim_auth_sendcookie(sess, tstconn, ccon->priv); | |
1010 g_free(ccon->priv); | |
1011 } | |
867 int gaim_handle_redirect(struct aim_session_t *sess, | 1012 int gaim_handle_redirect(struct aim_session_t *sess, |
868 struct command_rx_struct *command, ...) { | 1013 struct command_rx_struct *command, ...) { |
869 va_list ap; | 1014 va_list ap; |
870 int serviceid; | 1015 int serviceid; |
871 char *ip; | 1016 char *ip; |
872 unsigned char *cookie; | 1017 unsigned char *cookie; |
873 struct gaim_connection *gc = sess->aux_data; | 1018 struct gaim_connection *gc = sess->aux_data; |
874 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | 1019 struct aim_user *user = gc->user; |
1020 struct aim_conn_t *tstconn; | |
1021 int i; | |
1022 char *host; int port = FAIM_LOGIN_PORT, fd; | |
875 | 1023 |
876 va_start(ap, command); | 1024 va_start(ap, command); |
877 serviceid = va_arg(ap, int); | 1025 serviceid = va_arg(ap, int); |
878 ip = va_arg(ap, char *); | 1026 ip = va_arg(ap, char *); |
879 cookie = va_arg(ap, unsigned char *); | 1027 cookie = va_arg(ap, unsigned char *); |
880 | 1028 |
1029 for (i = 0; i < (int)strlen(ip); i++) { | |
1030 if (ip[i] == ':') { | |
1031 port = atoi(&(ip[i+1])); | |
1032 break; | |
1033 } | |
1034 } | |
1035 host = g_strndup(ip, i); | |
1036 | |
881 switch(serviceid) { | 1037 switch(serviceid) { |
882 case 0x7: /* Authorizer */ | 1038 case 0x7: /* Authorizer */ |
883 debug_printf("Reconnecting with authorizor...\n"); | 1039 debug_printf("Reconnecting with authorizor...\n"); |
884 { | 1040 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
885 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); | 1041 if (tstconn == NULL) { |
886 if (tstconn == NULL || tstconn->status & AIM_CONN_STATUS_RESOLVERR) | |
887 debug_printf("unable to reconnect with authorizer\n"); | 1042 debug_printf("unable to reconnect with authorizer\n"); |
888 else { | 1043 g_free(host); |
889 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
890 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, gaim_rateresp, 0); | |
891 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); | |
892 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
893 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
894 odata->paspa = gdk_input_add(tstconn->fd, | |
895 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
896 oscar_callback, tstconn); | |
897 aim_auth_sendcookie(sess, tstconn, cookie); | |
898 } | |
899 } | |
900 break; | |
901 case 0xd: /* ChatNav */ | |
902 { | |
903 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); | |
904 if (tstconn == NULL || tstconn->status & AIM_CONN_STATUS_RESOLVERR) { | |
905 debug_printf("unable to connect to chatnav server\n"); | |
906 return 1; | 1044 return 1; |
907 } | 1045 } |
908 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | 1046 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
909 aim_auth_sendcookie(sess, tstconn, cookie); | 1047 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, gaim_rateresp, 0); |
910 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 1048 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
911 oscar_callback, tstconn); | 1049 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); |
1050 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1051 | |
1052 tstconn->priv = g_memdup(cookie, AIM_COOKIELEN); | |
1053 fd = proxy_connect(host, port, user->proto_opt[USEROPT_PROXYHOST], | |
1054 atoi(user->proto_opt[USEROPT_PROXYPORT]), | |
1055 atoi(user->proto_opt[USEROPT_PROXYTYPE]), | |
1056 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], | |
1057 oscar_auth_connect, gc); | |
1058 if (fd < 0) { | |
1059 if (tstconn->priv) | |
1060 g_free(tstconn->priv); | |
1061 aim_conn_kill(sess, &tstconn); | |
1062 debug_printf("unable to reconnect with authorizer\n"); | |
1063 g_free(host); | |
1064 return 1; | |
912 } | 1065 } |
913 debug_printf("chatnav: connected\n"); | 1066 tstconn->fd = fd; |
1067 break; | |
1068 case 0xd: /* ChatNav */ | |
1069 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1070 if (tstconn == NULL) { | |
1071 debug_printf("unable to connect to chatnav server\n"); | |
1072 g_free(host); | |
1073 return 1; | |
1074 } | |
1075 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
1076 | |
1077 tstconn->priv = g_memdup(cookie, AIM_COOKIELEN); | |
1078 fd = proxy_connect(host, port, user->proto_opt[USEROPT_PROXYHOST], | |
1079 atoi(user->proto_opt[USEROPT_PROXYPORT]), | |
1080 atoi(user->proto_opt[USEROPT_PROXYTYPE]), | |
1081 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], | |
1082 oscar_chatnav_connect, gc); | |
1083 if (fd < 0) { | |
1084 if (tstconn->priv) | |
1085 g_free(tstconn->priv); | |
1086 aim_conn_kill(sess, &tstconn); | |
1087 debug_printf("unable to connect to chatnav server\n"); | |
1088 g_free(host); | |
1089 return 1; | |
1090 } | |
1091 tstconn->fd = fd; | |
914 break; | 1092 break; |
915 case 0xe: /* Chat */ | 1093 case 0xe: /* Chat */ |
916 { | 1094 { |
917 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); | |
918 char *roomname = va_arg(ap, char *); | 1095 char *roomname = va_arg(ap, char *); |
919 int exchange = va_arg(ap, int); | 1096 int exchange = va_arg(ap, int); |
920 struct chat_connection *ccon; | 1097 struct chat_connection *ccon; |
921 if (tstconn == NULL || tstconn->status & AIM_CONN_STATUS_RESOLVERR) { | 1098 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1099 if (tstconn == NULL) { | |
922 debug_printf("unable to connect to chat server\n"); | 1100 debug_printf("unable to connect to chat server\n"); |
1101 g_free(host); | |
923 return 1; | 1102 return 1; |
924 } | 1103 } |
925 debug_printf("Connected to chat room %s exchange %d\n", roomname, exchange); | 1104 |
926 | 1105 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
927 ccon = g_new0(struct chat_connection, 1); | 1106 ccon = g_new0(struct chat_connection, 1); |
928 ccon->conn = tstconn; | 1107 ccon->conn = tstconn; |
929 ccon->fd = tstconn->fd; | 1108 ccon->gc = gc; |
1109 ccon->fd = -1; | |
930 ccon->name = g_strdup(roomname); | 1110 ccon->name = g_strdup(roomname); |
931 ccon->exchange = exchange; | 1111 ccon->exchange = exchange; |
932 ccon->show = extract_name(roomname); | 1112 ccon->show = extract_name(roomname); |
933 | 1113 |
934 ccon->inpa = gdk_input_add(tstconn->fd, | 1114 ccon->priv = g_memdup(cookie, AIM_COOKIELEN); |
935 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 1115 fd = proxy_connect(host, port, user->proto_opt[USEROPT_PROXYHOST], |
936 oscar_callback, tstconn); | 1116 atoi(user->proto_opt[USEROPT_PROXYPORT]), |
937 | 1117 atoi(user->proto_opt[USEROPT_PROXYTYPE]), |
938 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | 1118 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], |
939 | 1119 oscar_chat_connect, ccon); |
940 aim_chat_attachname(tstconn, roomname); | 1120 if (fd < 0) { |
941 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | 1121 aim_conn_kill(sess, &tstconn); |
942 aim_auth_sendcookie(sess, tstconn, cookie); | 1122 debug_printf("unable to connect to chat server\n"); |
1123 g_free(host); | |
1124 g_free(ccon->priv); | |
1125 g_free(ccon->show); | |
1126 g_free(ccon->name); | |
1127 g_free(ccon); | |
1128 return 1; | |
1129 } | |
1130 ccon->fd = tstconn->fd = fd; | |
1131 debug_printf("Connected to chat room %s exchange %d\n", roomname, exchange); | |
943 } | 1132 } |
944 break; | 1133 break; |
945 default: /* huh? */ | 1134 default: /* huh? */ |
946 debug_printf("got redirect for unknown service 0x%04x\n", serviceid); | 1135 debug_printf("got redirect for unknown service 0x%04x\n", serviceid); |
947 break; | 1136 break; |
948 } | 1137 } |
949 | 1138 |
950 va_end(ap); | 1139 va_end(ap); |
951 | 1140 |
1141 g_free(host); | |
952 return 1; | 1142 return 1; |
953 } | 1143 } |
954 | 1144 |
955 int gaim_parse_oncoming(struct aim_session_t *sess, | 1145 int gaim_parse_oncoming(struct aim_session_t *sess, |
956 struct command_rx_struct *command, ...) { | 1146 struct command_rx_struct *command, ...) { |
1022 struct direct_im *dim = data; | 1212 struct direct_im *dim = data; |
1023 struct gaim_connection *gc = dim->gc; | 1213 struct gaim_connection *gc = dim->gc; |
1024 struct oscar_data *od = gc->proto_data; | 1214 struct oscar_data *od = gc->proto_data; |
1025 char buf[256]; | 1215 char buf[256]; |
1026 | 1216 |
1217 if (source < 0) { | |
1218 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
1219 g_free(dim); | |
1220 return; | |
1221 } | |
1222 | |
1223 if (dim->conn->fd != source) | |
1224 dim->conn->fd = source; | |
1225 | |
1027 if (!(dim->cnv = find_conversation(dim->name))) dim->cnv = new_conversation(dim->name); | 1226 if (!(dim->cnv = find_conversation(dim->name))) dim->cnv = new_conversation(dim->name); |
1028 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | 1227 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); |
1029 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | 1228 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
1030 | 1229 |
1031 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", | 1230 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", |
1032 GTK_SIGNAL_FUNC(delete_direct_im), dim); | 1231 GTK_SIGNAL_FUNC(delete_direct_im), dim); |
1033 | 1232 |
1233 dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
1234 oscar_callback, dim->conn); | |
1235 } | |
1236 | |
1237 static int accept_direct_im(gpointer w, struct ask_direct *d) { | |
1238 struct gaim_connection *gc = d->gc; | |
1239 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1240 struct direct_im *dim; | |
1241 char *host; int port = FAIM_LOGIN_PORT; | |
1242 int i; | |
1243 | |
1244 debug_printf("Accepted DirectIM.\n"); | |
1245 | |
1246 dim = find_direct_im(od, d->sn); | |
1247 if (dim) { | |
1248 cancel_direct_im(w, d); /* 40 */ | |
1249 return TRUE; | |
1250 } | |
1251 dim = g_new0(struct direct_im, 1); | |
1252 dim->gc = d->gc; | |
1253 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
1254 | |
1255 if ((dim->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL)) == NULL) { | |
1256 g_free(dim); | |
1257 cancel_direct_im(w, d); | |
1258 return TRUE; | |
1259 } | |
1260 dim->conn->subtype = AIM_CONN_SUBTYPE_OFT_DIRECTIM; | |
1261 dim->conn->priv = d->priv; | |
1034 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | 1262 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
1035 gaim_directim_incoming, 0); | 1263 gaim_directim_incoming, 0); |
1036 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, | 1264 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, |
1037 gaim_directim_disconnect, 0); | 1265 gaim_directim_disconnect, 0); |
1038 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | 1266 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
1039 gaim_directim_typing, 0); | 1267 gaim_directim_typing, 0); |
1040 | 1268 |
1041 gdk_input_remove(dim->watcher); | 1269 for (i = 0; i < (int)strlen(d->priv->ip); i++) { |
1042 dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 1270 if (d->priv->ip[i] == ':') { |
1043 oscar_callback, dim->conn); | 1271 port = atoi(&(d->priv->ip[i+1])); |
1044 } | 1272 break; |
1045 | 1273 } |
1046 static int accept_direct_im(gpointer w, struct ask_direct *d) { | 1274 } |
1047 struct gaim_connection *gc = d->gc; | 1275 host = g_strndup(d->priv->ip, i); |
1048 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 1276 dim->conn->fd = proxy_connect(host, port, |
1049 struct direct_im *dim; | 1277 gc->user->proto_opt[USEROPT_PROXYHOST], |
1050 | 1278 atoi(gc->user->proto_opt[USEROPT_PROXYPORT]), |
1051 debug_printf("Accepted DirectIM.\n"); | 1279 atoi(gc->user->proto_opt[USEROPT_PROXYTYPE]), |
1052 | 1280 gc->user->proto_opt[USEROPT_USER], |
1053 dim = find_direct_im(od, d->sn); | 1281 gc->user->proto_opt[USEROPT_PASS], |
1054 if (dim) { | 1282 oscar_directim_callback, dim); |
1055 cancel_direct_im(w, d); /* 40 */ | 1283 g_free(host); |
1056 return TRUE; | 1284 if (dim->conn->fd < 0) { |
1057 } | 1285 aim_conn_kill(od->sess, &dim->conn); |
1058 dim = g_new0(struct direct_im, 1); | |
1059 dim->gc = d->gc; | |
1060 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
1061 | |
1062 if ((dim->conn = aim_directim_connect(od->sess, od->conn, d->priv)) == NULL) { | |
1063 od->sess->flags ^= AIM_SESS_FLAGS_NONBLOCKCONNECT; | |
1064 g_free(dim); | 1286 g_free(dim); |
1065 cancel_direct_im(w, d); | 1287 cancel_direct_im(w, d); |
1066 return TRUE; | 1288 return TRUE; |
1067 } | 1289 } |
1068 | 1290 |
1069 od->direct_ims = g_slist_append(od->direct_ims, dim); | 1291 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1070 | |
1071 dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_WRITE, oscar_directim_callback, dim); | |
1072 | 1292 |
1073 cancel_direct_im(w, d); | 1293 cancel_direct_im(w, d); |
1074 | 1294 |
1075 return TRUE; | 1295 return TRUE; |
1076 } | 1296 } |
2536 g_free(n); | 2756 g_free(n); |
2537 } | 2757 } |
2538 | 2758 |
2539 | 2759 |
2540 /* weeee */ | 2760 /* weeee */ |
2541 static void oscar_print_option(GtkEntry *entry, struct aim_user *user) { | 2761 static void oscar_print_option(GtkEntry *entry, struct aim_user *user) |
2542 int entrynum; | 2762 { |
2543 | 2763 int entrynum; |
2544 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); | 2764 |
2545 | 2765 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
2766 | |
2546 if (entrynum == USEROPT_AUTH) { | 2767 if (entrynum == USEROPT_AUTH) { |
2547 g_snprintf(user->proto_opt[USEROPT_AUTH], | 2768 g_snprintf(user->proto_opt[USEROPT_AUTH], |
2548 sizeof(user->proto_opt[USEROPT_AUTH]), | 2769 sizeof(user->proto_opt[USEROPT_AUTH]), "%s", gtk_entry_get_text(entry)); |
2549 "%s", gtk_entry_get_text(entry)); | |
2550 } else if (entrynum == USEROPT_AUTHPORT) { | 2770 } else if (entrynum == USEROPT_AUTHPORT) { |
2551 g_snprintf(user->proto_opt[USEROPT_AUTHPORT], | 2771 g_snprintf(user->proto_opt[USEROPT_AUTHPORT], |
2552 sizeof(user->proto_opt[USEROPT_AUTHPORT]), | 2772 sizeof(user->proto_opt[USEROPT_AUTHPORT]), "%s", gtk_entry_get_text(entry)); |
2553 "%s", gtk_entry_get_text(entry)); | 2773 } else if (entrynum == USEROPT_PROXYHOST) { |
2554 } else if (entrynum == USEROPT_SOCKSHOST) { | 2774 g_snprintf(user->proto_opt[USEROPT_PROXYHOST], |
2555 g_snprintf(user->proto_opt[USEROPT_SOCKSHOST], | 2775 sizeof(user->proto_opt[USEROPT_PROXYHOST]), "%s", gtk_entry_get_text(entry)); |
2556 sizeof(user->proto_opt[USEROPT_SOCKSHOST]), | 2776 } else if (entrynum == USEROPT_PROXYPORT) { |
2557 "%s", gtk_entry_get_text(entry)); | 2777 g_snprintf(user->proto_opt[USEROPT_PROXYPORT], |
2558 } else if (entrynum == USEROPT_SOCKSPORT) { | 2778 sizeof(user->proto_opt[USEROPT_PROXYPORT]), "%s", gtk_entry_get_text(entry)); |
2559 g_snprintf(user->proto_opt[USEROPT_SOCKSPORT], | 2779 } else if (entrynum == USEROPT_USER) { |
2560 sizeof(user->proto_opt[USEROPT_SOCKSPORT]), | 2780 g_snprintf(user->proto_opt[USEROPT_USER], |
2561 "%s", gtk_entry_get_text(entry)); | 2781 sizeof(user->proto_opt[USEROPT_USER]), "%s", gtk_entry_get_text(entry)); |
2562 } | 2782 } else if (entrynum == USEROPT_PASS) { |
2563 } | 2783 g_snprintf(user->proto_opt[USEROPT_PASS], |
2564 | 2784 sizeof(user->proto_opt[USEROPT_PASS]), "%s", gtk_entry_get_text(entry)); |
2565 static void oscar_user_opts(GtkWidget *book, struct aim_user *user) { | 2785 } |
2786 } | |
2787 | |
2788 static void oscar_print_optionrad(GtkRadioButton * entry, struct aim_user *user) | |
2789 { | |
2790 int entrynum; | |
2791 | |
2792 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); | |
2793 | |
2794 g_snprintf(user->proto_opt[USEROPT_PROXYTYPE], | |
2795 sizeof(user->proto_opt[USEROPT_PROXYTYPE]), "%d", entrynum); | |
2796 } | |
2797 | |
2798 static void oscar_user_opts(GtkWidget *book, struct aim_user *user) | |
2799 { | |
2566 /* so here, we create the new notebook page */ | 2800 /* so here, we create the new notebook page */ |
2567 GtkWidget *vbox; | 2801 GtkWidget *vbox; |
2568 GtkWidget *hbox; | 2802 GtkWidget *hbox; |
2569 GtkWidget *label; | 2803 GtkWidget *label; |
2570 GtkWidget *entry; | 2804 GtkWidget *entry; |
2805 GtkWidget *first, *opt; | |
2571 | 2806 |
2572 vbox = gtk_vbox_new(FALSE, 5); | 2807 vbox = gtk_vbox_new(FALSE, 5); |
2573 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | 2808 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
2574 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, | 2809 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("Oscar Options")); |
2575 gtk_label_new("OSCAR Options")); | |
2576 gtk_widget_show(vbox); | 2810 gtk_widget_show(vbox); |
2577 | 2811 |
2578 hbox = gtk_hbox_new(FALSE, 5); | 2812 hbox = gtk_hbox_new(FALSE, 5); |
2579 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 2813 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
2580 gtk_widget_show(hbox); | 2814 gtk_widget_show(hbox); |
2581 | 2815 |
2582 label = gtk_label_new("Authorizer:"); | 2816 label = gtk_label_new("Auth Host:"); |
2583 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 2817 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
2584 gtk_widget_show(label); | 2818 gtk_widget_show(label); |
2585 | 2819 |
2586 entry = gtk_entry_new(); | 2820 entry = gtk_entry_new(); |
2587 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | 2821 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
2588 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTH); | 2822 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTH); |
2589 gtk_signal_connect(GTK_OBJECT(entry), "changed", | 2823 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); |
2590 GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2591 if (user->proto_opt[USEROPT_AUTH][0]) { | 2824 if (user->proto_opt[USEROPT_AUTH][0]) { |
2592 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTH]); | 2825 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTH]); |
2593 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTH]); | 2826 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTH]); |
2594 } else | 2827 } else |
2595 gtk_entry_set_text(GTK_ENTRY(entry), "login.oscar.aol.com"); | 2828 gtk_entry_set_text(GTK_ENTRY(entry), "login.oscar.aol.com"); |
2596 gtk_widget_show(entry); | 2829 gtk_widget_show(entry); |
2597 | 2830 |
2598 hbox = gtk_hbox_new(FALSE, 5); | 2831 hbox = gtk_hbox_new(FALSE, 0); |
2599 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 2832 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
2600 gtk_widget_show(hbox); | 2833 gtk_widget_show(hbox); |
2601 | 2834 |
2602 label = gtk_label_new("Authorizer Port:"); | 2835 label = gtk_label_new("Auth Port:"); |
2603 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 2836 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
2604 gtk_widget_show(label); | 2837 gtk_widget_show(label); |
2605 | 2838 |
2606 entry = gtk_entry_new(); | 2839 entry = gtk_entry_new(); |
2607 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | 2840 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
2608 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)1); | 2841 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTHPORT); |
2609 gtk_signal_connect(GTK_OBJECT(entry), "changed", | 2842 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); |
2610 GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2611 if (user->proto_opt[USEROPT_AUTHPORT][0]) { | 2843 if (user->proto_opt[USEROPT_AUTHPORT][0]) { |
2612 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTHPORT]); | 2844 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTHPORT]); |
2613 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHPORT]); | 2845 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHPORT]); |
2614 } else | 2846 } else |
2615 gtk_entry_set_text(GTK_ENTRY(entry), "5190"); | 2847 gtk_entry_set_text(GTK_ENTRY(entry), "9898"); |
2848 | |
2849 gtk_widget_show(entry); | |
2850 | |
2851 hbox = gtk_hbox_new(TRUE, 0); | |
2852 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2853 gtk_widget_show(hbox); | |
2854 | |
2855 first = gtk_radio_button_new_with_label(NULL, "No proxy"); | |
2856 gtk_box_pack_start(GTK_BOX(hbox), first, FALSE, FALSE, 0); | |
2857 gtk_object_set_user_data(GTK_OBJECT(first), (void *)PROXY_NONE); | |
2858 gtk_signal_connect(GTK_OBJECT(first), "clicked", GTK_SIGNAL_FUNC(oscar_print_optionrad), user); | |
2859 gtk_widget_show(first); | |
2860 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_NONE) | |
2861 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(first), TRUE); | |
2862 | |
2863 opt = | |
2864 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 4"); | |
2865 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); | |
2866 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS4); | |
2867 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(oscar_print_optionrad), user); | |
2868 gtk_widget_show(opt); | |
2869 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS4) | |
2870 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
2871 | |
2872 hbox = gtk_hbox_new(TRUE, 0); | |
2873 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2874 gtk_widget_show(hbox); | |
2875 | |
2876 opt = | |
2877 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 5"); | |
2878 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); | |
2879 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS5); | |
2880 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(oscar_print_optionrad), user); | |
2881 gtk_widget_show(opt); | |
2882 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS5) | |
2883 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
2884 | |
2885 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "HTTP"); | |
2886 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); | |
2887 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_HTTP); | |
2888 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(oscar_print_optionrad), user); | |
2889 gtk_widget_show(opt); | |
2890 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_HTTP) | |
2891 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
2892 | |
2893 hbox = gtk_hbox_new(FALSE, 0); | |
2894 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2895 gtk_widget_show(hbox); | |
2896 | |
2897 label = gtk_label_new("Proxy Host:"); | |
2898 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
2899 gtk_widget_show(label); | |
2900 | |
2901 entry = gtk_entry_new(); | |
2902 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
2903 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYHOST); | |
2904 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2905 if (user->proto_opt[USEROPT_PROXYHOST][0]) { | |
2906 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYHOST]); | |
2907 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYHOST]); | |
2908 } | |
2909 gtk_widget_show(entry); | |
2910 | |
2911 hbox = gtk_hbox_new(FALSE, 0); | |
2912 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2913 gtk_widget_show(hbox); | |
2914 | |
2915 label = gtk_label_new("Proxy Port:"); | |
2916 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
2917 gtk_widget_show(label); | |
2918 | |
2919 entry = gtk_entry_new(); | |
2920 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
2921 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYPORT); | |
2922 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2923 if (user->proto_opt[USEROPT_PROXYPORT][0]) { | |
2924 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYPORT]); | |
2925 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYPORT]); | |
2926 } | |
2927 gtk_widget_show(entry); | |
2928 | |
2929 hbox = gtk_hbox_new(FALSE, 0); | |
2930 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2931 gtk_widget_show(hbox); | |
2932 | |
2933 label = gtk_label_new("Proxy User:"); | |
2934 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
2935 gtk_widget_show(label); | |
2936 | |
2937 entry = gtk_entry_new(); | |
2938 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
2939 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_USER); | |
2940 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2941 if (user->proto_opt[USEROPT_USER][0]) { | |
2942 debug_printf("setting text %s\n", user->proto_opt[USEROPT_USER]); | |
2943 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_USER]); | |
2944 } | |
2616 gtk_widget_show(entry); | 2945 gtk_widget_show(entry); |
2617 | 2946 |
2618 hbox = gtk_hbox_new(FALSE, 5); | 2947 hbox = gtk_hbox_new(FALSE, 5); |
2619 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 2948 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
2620 gtk_widget_show(hbox); | 2949 gtk_widget_show(hbox); |
2621 | 2950 |
2622 label = gtk_label_new("SOCKS5 Host:"); | 2951 label = gtk_label_new("Proxy Password:"); |
2623 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 2952 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
2624 gtk_widget_show(label); | 2953 gtk_widget_show(label); |
2625 | 2954 |
2626 entry = gtk_entry_new(); | 2955 entry = gtk_entry_new(); |
2627 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | 2956 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
2628 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SOCKSHOST); | 2957 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
2629 gtk_signal_connect(GTK_OBJECT(entry), "changed", | 2958 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PASS); |
2630 GTK_SIGNAL_FUNC(oscar_print_option), user); | 2959 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(oscar_print_option), user); |
2631 if (user->proto_opt[USEROPT_SOCKSHOST][0]) { | 2960 if (user->proto_opt[USEROPT_PASS][0]) { |
2632 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SOCKSHOST]); | 2961 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PASS]); |
2633 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SOCKSHOST]); | 2962 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PASS]); |
2634 } | |
2635 gtk_widget_show(entry); | |
2636 | |
2637 hbox = gtk_hbox_new(FALSE, 5); | |
2638 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2639 gtk_widget_show(hbox); | |
2640 | |
2641 label = gtk_label_new("SOCKS5 Port:"); | |
2642 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
2643 gtk_widget_show(label); | |
2644 | |
2645 entry = gtk_entry_new(); | |
2646 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
2647 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SOCKSPORT); | |
2648 gtk_signal_connect(GTK_OBJECT(entry), "changed", | |
2649 GTK_SIGNAL_FUNC(oscar_print_option), user); | |
2650 if (user->proto_opt[USEROPT_SOCKSPORT][0]) { | |
2651 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SOCKSPORT]); | |
2652 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SOCKSPORT]); | |
2653 } | 2963 } |
2654 gtk_widget_show(entry); | 2964 gtk_widget_show(entry); |
2655 } | 2965 } |
2656 | 2966 |
2657 static void oscar_set_permit_deny(struct gaim_connection *gc) { | 2967 static void oscar_set_permit_deny(struct gaim_connection *gc) { |