comparison src/protocols/oscar/oscar.c @ 7282:ad243bc63184

[gaim-migrate @ 7861] Mostly this is my usual blah clean-up/changes. I started merging that icq sms patch, but I'm not comfortable with much of it... I also made AIM have 6 login steps instead of 2. The first few go pretty quickly though. I'll probably work on this more later, but I'm going to sleep now. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 16 Oct 2003 06:12:43 +0000
parents 1930e3d00ecd
children b8fcbff88438
comparison
equal deleted inserted replaced
7281:0f7dd6715a90 7282:ad243bc63184
274 274
275 /* for icons */ 275 /* for icons */
276 static gboolean gaim_icon_timerfunc(gpointer data); 276 static gboolean gaim_icon_timerfunc(gpointer data);
277 277
278 /* prpl actions - remove this at some point */ 278 /* prpl actions - remove this at some point */
279 /* Because I don't like forward declarations? I think that was why... */
279 static void oscar_set_info(GaimConnection *gc, const char *text); 280 static void oscar_set_info(GaimConnection *gc, const char *text);
280 281
281 static void oscar_free_name_data(struct name_data *data) { 282 static void oscar_free_name_data(struct name_data *data) {
282 g_free(data->name); 283 g_free(data->name);
283 g_free(data->nick); 284 g_free(data->nick);
624 } 625 }
625 626
626 od = gc->proto_data; 627 od = gc->proto_data;
627 sess = od->sess; 628 sess = od->sess;
628 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); 629 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH);
629
630 conn->fd = source; 630 conn->fd = source;
631 631
632 if (source < 0) { 632 if (source < 0) {
633 gaim_connection_error(gc, _("Couldn't connect to host")); 633 gaim_connection_error(gc, _("Couldn't connect to host"));
634 return; 634 return;
635 } 635 }
636 636
637 aim_conn_completeconnect(sess, conn); 637 aim_conn_completeconnect(sess, conn);
638 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); 638 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn);
639 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc)));
640
639 gaim_debug(GAIM_DEBUG_INFO, "oscar", 641 gaim_debug(GAIM_DEBUG_INFO, "oscar",
640 "Password sent, waiting for response\n"); 642 "Screen name sent, waiting for response\n");
643 gaim_connection_update_progress(gc, _("Screen name sent"), 1, 6);
641 } 644 }
642 645
643 static void oscar_login(GaimAccount *account) { 646 static void oscar_login(GaimAccount *account) {
644 aim_session_t *sess; 647 aim_session_t *sess;
645 aim_conn_t *conn; 648 aim_conn_t *conn;
646 char buf[256];
647 GaimConnection *gc = gaim_account_get_connection(account); 649 GaimConnection *gc = gaim_account_get_connection(account);
648 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); 650 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1);
649 651
650 gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc); 652 gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc);
651 653
656 gc->flags |= GAIM_CONNECTION_AUTO_RESP; 658 gc->flags |= GAIM_CONNECTION_AUTO_RESP;
657 } 659 }
658 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); 660 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo);
659 661
660 sess = g_new0(aim_session_t, 1); 662 sess = g_new0(aim_session_t, 1);
661
662 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); 663 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
663 aim_setdebuggingcb(sess, oscar_debug); 664 aim_setdebuggingcb(sess, oscar_debug);
664 665 /*
665 /* we need an immediate queue because we don't use a while-loop to 666 * We need an immediate queue because we don't use a while-loop
666 * see if things need to be sent. */ 667 * to see if things need to be sent.
668 */
667 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); 669 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL);
668 od->sess = sess; 670 od->sess = sess;
669 sess->aux_data = gc; 671 sess->aux_data = gc;
670 672
671 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); 673 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
674 "internal connection error\n"); 676 "internal connection error\n");
675 gaim_connection_error(gc, _("Unable to login to AIM")); 677 gaim_connection_error(gc, _("Unable to login to AIM"));
676 return; 678 return;
677 } 679 }
678 680
679 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account));
680 gaim_connection_update_progress(gc, buf, 2, 5);
681
682 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); 681 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0);
683 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); 682 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0);
684 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); 683 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0);
685 684
686 conn->status |= AIM_CONN_STATUS_INPROGRESS; 685 conn->status |= AIM_CONN_STATUS_INPROGRESS;
688 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), 687 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT),
689 oscar_login_connect, gc) < 0) { 688 oscar_login_connect, gc) < 0) {
690 gaim_connection_error(gc, _("Couldn't connect to host")); 689 gaim_connection_error(gc, _("Couldn't connect to host"));
691 return; 690 return;
692 } 691 }
693 aim_request_login(sess, conn, gaim_account_get_username(account)); 692
693 gaim_connection_update_progress(gc, _("Connecting"), 0, 6);
694 } 694 }
695 695
696 static void oscar_close(GaimConnection *gc) { 696 static void oscar_close(GaimConnection *gc) {
697 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 697 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
698 698
780 } 780 }
781 781
782 aim_conn_completeconnect(sess, bosconn); 782 aim_conn_completeconnect(sess, bosconn);
783 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); 783 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn);
784 gaim_connection_update_progress(gc, 784 gaim_connection_update_progress(gc,
785 _("Connection established, cookie sent"), 4, 5); 785 _("Connection established, cookie sent"), 4, 6);
786 } 786 }
787 787
788 /* BBB */ 788 /* BBB */
789 /* 789 /*
790 * This little area in oscar.c is the nexus of file transfer code, 790 * This little area in oscar.c is the nexus of file transfer code,
1167 return 0; 1167 return 0;
1168 } 1168 }
1169 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); 1169 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie);
1170 gaim_input_remove(gc->inpa); 1170 gaim_input_remove(gc->inpa);
1171 1171
1172 gaim_connection_update_progress(gc, _("Received authorization"), 4, 6);
1173
1172 return 1; 1174 return 1;
1173 } 1175 }
1174 1176
1175 struct pieceofcrap { 1177 struct pieceofcrap {
1176 GaimConnection *gc; 1178 GaimConnection *gc;
1329 return 1; 1331 return 1;
1330 } 1332 }
1331 1333
1332 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { 1334 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
1333 GaimConnection *gc = sess->aux_data; 1335 GaimConnection *gc = sess->aux_data;
1336 struct oscar_data *od = gc->proto_data;
1334 GaimAccount *account = gaim_connection_get_account(gc); 1337 GaimAccount *account = gaim_connection_get_account(gc);
1335 GaimAccount *ac = gaim_connection_get_account(gc); 1338 GaimAccount *ac = gaim_connection_get_account(gc);
1336 struct oscar_data *od = gc->proto_data; 1339 #if 0
1340 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b};
1341 #endif
1337 va_list ap; 1342 va_list ap;
1338 char *key; 1343 char *key;
1339 1344
1340 va_start(ap, fr); 1345 va_start(ap, fr);
1341 key = va_arg(ap, char *); 1346 key = va_arg(ap, char *);
1344 if (od->icq) { 1349 if (od->icq) {
1345 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; 1350 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD;
1346 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), 1351 aim_send_login(sess, fr->conn, gaim_account_get_username(ac),
1347 gaim_account_get_password(account), &info, key); 1352 gaim_account_get_password(account), &info, key);
1348 } else { 1353 } else {
1349 #if 0
1350 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b};
1351 #endif
1352 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; 1354 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD;
1353 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), 1355 aim_send_login(sess, fr->conn, gaim_account_get_username(ac),
1354 gaim_account_get_password(account), &info, key); 1356 gaim_account_get_password(account), &info, key);
1355 } 1357 }
1358
1359 gaim_connection_update_progress(gc, _("Password sent"), 3, 6);
1356 1360
1357 return 1; 1361 return 1;
1358 } 1362 }
1359 1363
1360 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { 1364 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
1392 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { 1396 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) {
1393 1397
1394 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); 1398 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0);
1395 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); 1399 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0);
1396 1400
1397 aim_email_sendcookies(sess, fr->conn); 1401 aim_email_sendcookies(sess);
1398 aim_email_activate(sess, fr->conn); 1402 aim_email_activate(sess);
1399 aim_clientready(sess, fr->conn); 1403 aim_clientready(sess, fr->conn);
1400 1404
1401 return 1; 1405 return 1;
1402 } 1406 }
1403 1407