Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 13226:51dd24fd8290
[gaim-migrate @ 15591]
Whitespace. I remember when this file was ~5000 lines. It's almost
9000 now. I should really do something about that.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 11 Feb 2006 18:12:06 +0000 |
parents | 33bef17125c2 |
children | af3d6c6aee6b |
comparison
equal
deleted
inserted
replaced
13225:b50a8da7a87d | 13226:51dd24fd8290 |
---|---|
328 static fu32_t oscar_charset_check(const char *utf8) | 328 static fu32_t oscar_charset_check(const char *utf8) |
329 { | 329 { |
330 int i = 0; | 330 int i = 0; |
331 int charset = AIM_CHARSET_ASCII; | 331 int charset = AIM_CHARSET_ASCII; |
332 | 332 |
333 /* Determine how we can send this message. Per the warnings elsewhere | 333 /* Determine how we can send this message. Per the warnings elsewhere |
334 * in this file, these little checks determine the simplest encoding | 334 * in this file, these little checks determine the simplest encoding |
335 * we can use for a given message send using it. */ | 335 * we can use for a given message send using it. */ |
336 while (utf8[i]) { | 336 while (utf8[i]) { |
337 if ((unsigned char)utf8[i] > 0x7f) { | 337 if ((unsigned char)utf8[i] > 0x7f) { |
338 /* not ASCII! */ | 338 /* not ASCII! */ |
339 charset = AIM_CHARSET_CUSTOM; | 339 charset = AIM_CHARSET_CUSTOM; |
346 * followed by 0xc0-0xc3 in the second */ | 346 * followed by 0xc0-0xc3 in the second */ |
347 if ((unsigned char)utf8[i] < 0x80) { | 347 if ((unsigned char)utf8[i] < 0x80) { |
348 i++; | 348 i++; |
349 continue; | 349 continue; |
350 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | 350 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && |
351 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | 351 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { |
352 i += 2; | 352 i += 2; |
353 continue; | 353 continue; |
354 } | 354 } |
355 charset = AIM_CHARSET_UNICODE; | 355 charset = AIM_CHARSET_UNICODE; |
356 break; | 356 break; |
359 return charset; | 359 return charset; |
360 } | 360 } |
361 | 361 |
362 /* | 362 /* |
363 * Take a string of the form charset="bleh" where bleh is | 363 * Take a string of the form charset="bleh" where bleh is |
364 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | 364 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
365 * return a newly allocated string containing bleh. | 365 * return a newly allocated string containing bleh. |
366 */ | 366 */ |
367 static gchar *oscar_encoding_extract(const char *encoding) | 367 static gchar *oscar_encoding_extract(const char *encoding) |
368 { | 368 { |
369 gchar *ret = NULL; | 369 gchar *ret = NULL; |
414 * that was specified. So we check if the text is valid utf-8 then | 414 * that was specified. So we check if the text is valid utf-8 then |
415 * just copy it. | 415 * just copy it. |
416 */ | 416 */ |
417 if (utf8 == NULL) { | 417 if (utf8 == NULL) { |
418 if (textlen != 0 && *text != '\0' | 418 if (textlen != 0 && *text != '\0' |
419 && !g_utf8_validate(text, textlen, NULL)) | 419 && !g_utf8_validate(text, textlen, NULL)) |
420 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | 420 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
421 else | 421 else |
422 utf8 = g_strndup(text, textlen); | 422 utf8 = g_strndup(text, textlen); |
423 } | 423 } |
424 | 424 |
526 | 526 |
527 /* | 527 /* |
528 * Figure out what encoding to use when sending a given outgoing message. | 528 * Figure out what encoding to use when sending a given outgoing message. |
529 */ | 529 */ |
530 static void | 530 static void |
531 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | 531 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, |
532 gchar **msg, int *msglen_int, | 532 const char *destsn, const gchar *from, |
533 fu16_t *charset, fu16_t *charsubset) | 533 gchar **msg, int *msglen_int, |
534 fu16_t *charset, fu16_t *charsubset) | |
534 { | 535 { |
535 OscarData *od = gc->proto_data; | 536 OscarData *od = gc->proto_data; |
536 GaimAccount *account = gaim_connection_get_account(gc); | 537 GaimAccount *account = gaim_connection_get_account(gc); |
537 GError *err = NULL; | 538 GError *err = NULL; |
538 aim_userinfo_t *userinfo = NULL; | 539 aim_userinfo_t *userinfo = NULL; |
939 } | 940 } |
940 | 941 |
941 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | 942 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) |
942 { | 943 { |
943 gaim_debug_info("oscar", | 944 gaim_debug_info("oscar", |
944 "destroying Direct IM for %s.\n", dim->name); | 945 "destroying Direct IM for %s.\n", dim->name); |
945 | 946 |
946 od->direct_ims = g_slist_remove(od->direct_ims, dim); | 947 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
947 if (dim->gpc_pend) { | 948 if (dim->gpc_pend) { |
948 dim->killme = TRUE; | 949 dim->killme = TRUE; |
949 return; | 950 return; |
962 { | 963 { |
963 GaimConversation *conv; | 964 GaimConversation *conv; |
964 char buf[256]; | 965 char buf[256]; |
965 | 966 |
966 gaim_debug_info("oscar", | 967 gaim_debug_info("oscar", |
967 "%s disconnected Direct IM.\n", dim->name); | 968 "%s disconnected Direct IM.\n", dim->name); |
968 | 969 |
969 if (dim->connected) | 970 if (dim->connected) |
970 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | 971 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); |
971 else | 972 else |
972 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); | 973 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
973 | 974 |
974 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, | 975 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, |
975 gaim_connection_get_account(dim->gc)); | 976 gaim_connection_get_account(dim->gc)); |
976 | 977 |
977 if (conv) { | 978 if (conv) { |
978 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | 979 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
979 } else { | 980 } else { |
980 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | 981 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); |
981 } | 982 } |
1116 oscar_direct_im_disconnect(od, dim); | 1117 oscar_direct_im_disconnect(od, dim); |
1117 destroy_direct_im_request(d); | 1118 destroy_direct_im_request(d); |
1118 return; | 1119 return; |
1119 } | 1120 } |
1120 | 1121 |
1121 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | 1122 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
1122 gaim_odc_incoming, 0); | 1123 AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
1123 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | 1124 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
1124 gaim_odc_typing, 0); | 1125 AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); |
1125 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | 1126 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, |
1126 gaim_odc_update_ui, 0); | 1127 AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
1127 | 1128 |
1128 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | 1129 gaim_debug_info("oscar", "ip is %s.\n", d->ip); |
1129 for (i = 0; i < (int)strlen(d->ip); i++) { | 1130 for (i = 0; i < (int)strlen(d->ip); i++) { |
1130 if (d->ip[i] == ':') { | 1131 if (d->ip[i] == ':') { |
1131 port = atoi(&(d->ip[i+1])); | 1132 port = atoi(&(d->ip[i+1])); |
1136 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | 1137 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
1137 dim->gpc_pend = TRUE; | 1138 dim->gpc_pend = TRUE; |
1138 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); | 1139 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
1139 | 1140 |
1140 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); | 1141 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); |
1141 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | 1142 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), |
1142 port); | 1143 d->sn, host, port); |
1143 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | 1144 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
1144 g_free(tmp); | 1145 g_free(tmp); |
1145 | 1146 |
1146 g_free(host); | 1147 g_free(host); |
1147 if (rc < 0) { | 1148 if (rc < 0) { |
1177 aim_conn_close(listenerconn); | 1178 aim_conn_close(listenerconn); |
1178 aim_conn_kill(sess, &listenerconn); | 1179 aim_conn_kill(sess, &listenerconn); |
1179 | 1180 |
1180 sn = g_strdup(aim_odc_getsn(newconn)); | 1181 sn = g_strdup(aim_odc_getsn(newconn)); |
1181 | 1182 |
1182 gaim_debug_info("oscar", | 1183 gaim_debug_info("oscar", "DirectIM: initiate success to %s\n", sn); |
1183 "DirectIM: initiate success to %s\n", sn); | |
1184 dim = oscar_direct_im_find(od, sn); | 1184 dim = oscar_direct_im_find(od, sn); |
1185 | 1185 |
1186 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); | 1186 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); |
1187 gaim_input_remove(dim->watcher); | 1187 gaim_input_remove(dim->watcher); |
1188 dim->conn = newconn; | 1188 dim->conn = newconn; |
1218 va_end(ap); | 1218 va_end(ap); |
1219 | 1219 |
1220 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | 1220 if (!sn || !(dim = oscar_direct_im_find(od, sn))) |
1221 return 1; | 1221 return 1; |
1222 if (dim->watcher) { | 1222 if (dim->watcher) { |
1223 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | 1223 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ |
1224 /* The callback will callback? I don't get how that would happen here. */ | 1224 /* The callback will callback? I don't get how that would happen here. */ |
1225 dim->watcher = 0; | 1225 dim->watcher = 0; |
1226 } | 1226 } |
1227 | 1227 |
1228 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | 1228 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
1229 oscar_callback, dim->conn); | 1229 oscar_callback, dim->conn); |
1230 | 1230 |
1231 return 1; | 1231 return 1; |
1232 } | 1232 } |
1233 | 1233 |
1234 /* | 1234 /* |
1278 encoding = va_arg(ap, int); | 1278 encoding = va_arg(ap, int); |
1279 isawaymsg = va_arg(ap, int); | 1279 isawaymsg = va_arg(ap, int); |
1280 va_end(ap); | 1280 va_end(ap); |
1281 msgend = msg + len; | 1281 msgend = msg + len; |
1282 | 1282 |
1283 gaim_debug_info("oscar", | 1283 gaim_debug_info("oscar", "Got DirectIM message from %s\n", sn); |
1284 "Got DirectIM message from %s\n", sn); | |
1285 | 1284 |
1286 if (isawaymsg) | 1285 if (isawaymsg) |
1287 imflags |= GAIM_MESSAGE_AUTO_RESP; | 1286 imflags |= GAIM_MESSAGE_AUTO_RESP; |
1288 | 1287 |
1289 /* message has a binary trailer */ | 1288 /* message has a binary trailer */ |
1542 oscar_callback, dim->conn); | 1541 oscar_callback, dim->conn); |
1543 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | 1542 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
1544 gaim_odc_initiate, 0); | 1543 gaim_odc_initiate, 0); |
1545 | 1544 |
1546 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); | 1545 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
1547 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), dim->name, ip, | 1546 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), |
1548 gaim_network_get_port_from_fd(listenfd)); | 1547 dim->name, ip, gaim_network_get_port_from_fd(listenfd)); |
1549 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | 1548 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
1550 g_free(tmp); | 1549 g_free(tmp); |
1551 } else { | 1550 } else { |
1552 gaim_notify_error(dim->gc, NULL, _("Unable to open Direct IM"), NULL); | 1551 gaim_notify_error(dim->gc, NULL, _("Unable to open Direct IM"), NULL); |
1553 oscar_direct_im_destroy(od, dim); | 1552 oscar_direct_im_destroy(od, dim); |
1658 if (!gc) { | 1657 if (!gc) { |
1659 gaim_debug_info("oscar", | 1658 gaim_debug_info("oscar", |
1660 "oscar callback for closed connection (1).\n"); | 1659 "oscar callback for closed connection (1).\n"); |
1661 return; | 1660 return; |
1662 } | 1661 } |
1663 | 1662 |
1664 if( !(od = (OscarData *)gc->proto_data) ) { | 1663 if( !(od = (OscarData *)gc->proto_data) ) { |
1665 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); | 1664 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); |
1666 return; | 1665 return; |
1667 } | 1666 } |
1668 | 1667 |
1669 if (!g_list_find(gaim_connections_get_all(), gc)) { | 1668 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1670 /* oh boy. this is probably bad. i guess the only thing we | 1669 /* oh boy. this is probably bad. i guess the only thing we |
1671 * can really do is return? */ | 1670 * can really do is return? */ |
1672 gaim_debug_info("oscar", | 1671 gaim_debug_info("oscar", |
1673 "oscar callback for closed connection (2).\n"); | 1672 "oscar callback for closed connection (2).\n"); |
1674 gaim_debug_misc("oscar", "gc = %p\n", gc); | 1673 gaim_debug_misc("oscar", "gc = %p\n", gc); |
1675 return; | 1674 return; |
2625 oft_info->port = xfer->local_port; | 2624 oft_info->port = xfer->local_port; |
2626 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | 2625 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { |
2627 gaim_xfer_cancel_local(xfer); | 2626 gaim_xfer_cancel_local(xfer); |
2628 return; | 2627 return; |
2629 } | 2628 } |
2630 gaim_debug_misc("oscar", | 2629 gaim_debug_misc("oscar", "port is %hu, ip is %s\n", |
2631 "port is %hu, ip is %s\n", | 2630 xfer->local_port, oft_info->clientip); |
2632 xfer->local_port, oft_info->clientip); | |
2633 | 2631 |
2634 if(oft_info->conn) | 2632 if(oft_info->conn) |
2635 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, | 2633 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, |
2636 oft_info->conn); | 2634 oft_info->conn); |
2637 else | 2635 else |
2857 break; | 2855 break; |
2858 default: | 2856 default: |
2859 gaim_connection_error(gc, _("Authentication failed")); | 2857 gaim_connection_error(gc, _("Authentication failed")); |
2860 break; | 2858 break; |
2861 } | 2859 } |
2862 gaim_debug_error("oscar", | 2860 gaim_debug_error("oscar", "Login Error Code 0x%04hx\n", info->errorcode); |
2863 "Login Error Code 0x%04hx\n", info->errorcode); | 2861 gaim_debug_error("oscar", "Error URL: %s\n", info->errorurl); |
2864 gaim_debug_error("oscar", | |
2865 "Error URL: %s\n", info->errorurl); | |
2866 od->killme = TRUE; | 2862 od->killme = TRUE; |
2867 return 1; | 2863 return 1; |
2868 } | 2864 } |
2869 | 2865 |
2870 | 2866 |
2873 if (info->email) { | 2869 if (info->email) { |
2874 gaim_debug_misc("oscar", "Email: %s\n", info->email); | 2870 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2875 } else { | 2871 } else { |
2876 gaim_debug_misc("oscar", "Email is NULL\n"); | 2872 gaim_debug_misc("oscar", "Email is NULL\n"); |
2877 } | 2873 } |
2878 | 2874 |
2879 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); | 2875 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2880 gaim_debug_info("oscar", | 2876 gaim_debug_info("oscar", "Closing auth connection...\n"); |
2881 "Closing auth connection...\n"); | |
2882 aim_conn_kill(sess, &fr->conn); | 2877 aim_conn_kill(sess, &fr->conn); |
2883 | 2878 |
2884 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); | 2879 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
2885 if (bosconn == NULL) { | 2880 if (bosconn == NULL) { |
2886 gaim_connection_error(gc, _("Internal Error")); | 2881 gaim_connection_error(gc, _("Internal Error")); |
3101 offset = va_arg(ap, fu32_t); | 3096 offset = va_arg(ap, fu32_t); |
3102 len = va_arg(ap, fu32_t); | 3097 len = va_arg(ap, fu32_t); |
3103 modname = va_arg(ap, char *); | 3098 modname = va_arg(ap, char *); |
3104 va_end(ap); | 3099 va_end(ap); |
3105 | 3100 |
3106 gaim_debug_misc("oscar", | 3101 gaim_debug_misc("oscar", "offset: %u, len: %u, file: %s\n", |
3107 "offset: %u, len: %u, file: %s\n", | 3102 offset, len, (modname ? modname : "aim.exe")); |
3108 offset, len, (modname ? modname : "aim.exe")); | |
3109 | 3103 |
3110 if (len == 0) { | 3104 if (len == 0) { |
3111 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); | 3105 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
3112 aim_sendmemblock(sess, fr->conn, offset, len, NULL, | 3106 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
3113 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | 3107 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
3264 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); | 3258 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
3265 tstconn->fd = source; | 3259 tstconn->fd = source; |
3266 | 3260 |
3267 if (source < 0) { | 3261 if (source < 0) { |
3268 aim_conn_kill(sess, &tstconn); | 3262 aim_conn_kill(sess, &tstconn); |
3269 gaim_debug_error("oscar", | 3263 gaim_debug_error("oscar", "unable to connect to chatnav server\n"); |
3270 "unable to connect to chatnav server\n"); | |
3271 return; | 3264 return; |
3272 } | 3265 } |
3273 | 3266 |
3274 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ | 3267 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
3275 fcntl(source, F_SETFL, 0); | 3268 fcntl(source, F_SETFL, 0); |
3296 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | 3289 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
3297 tstconn->fd = source; | 3290 tstconn->fd = source; |
3298 | 3291 |
3299 if (source < 0) { | 3292 if (source < 0) { |
3300 aim_conn_kill(sess, &tstconn); | 3293 aim_conn_kill(sess, &tstconn); |
3301 gaim_debug_error("oscar", | 3294 gaim_debug_error("oscar", "unable to connect to authorizer\n"); |
3302 "unable to connect to authorizer\n"); | |
3303 return; | 3295 return; |
3304 } | 3296 } |
3305 | 3297 |
3306 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ | 3298 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
3307 fcntl(source, F_SETFL, 0); | 3299 fcntl(source, F_SETFL, 0); |
3364 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); | 3356 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
3365 tstconn->fd = source; | 3357 tstconn->fd = source; |
3366 | 3358 |
3367 if (source < 0) { | 3359 if (source < 0) { |
3368 aim_conn_kill(sess, &tstconn); | 3360 aim_conn_kill(sess, &tstconn); |
3369 gaim_debug_error("oscar", | 3361 gaim_debug_error("oscar", "unable to connect to email server\n"); |
3370 "unable to connect to email server\n"); | |
3371 return; | 3362 return; |
3372 } | 3363 } |
3373 | 3364 |
3374 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ | 3365 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
3375 fcntl(source, F_SETFL, 0); | 3366 fcntl(source, F_SETFL, 0); |
3376 | 3367 |
3377 aim_conn_completeconnect(sess, tstconn); | 3368 aim_conn_completeconnect(sess, tstconn); |
3378 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | 3369 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
3379 gaim_debug_info("oscar", | 3370 gaim_debug_info("oscar", "email: connected\n"); |
3380 "email: connected\n"); | |
3381 } | 3371 } |
3382 | 3372 |
3383 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { | 3373 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
3384 GaimConnection *gc = data; | 3374 GaimConnection *gc = data; |
3385 OscarData *od; | 3375 OscarData *od; |
3396 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | 3386 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); |
3397 tstconn->fd = source; | 3387 tstconn->fd = source; |
3398 | 3388 |
3399 if (source < 0) { | 3389 if (source < 0) { |
3400 aim_conn_kill(sess, &tstconn); | 3390 aim_conn_kill(sess, &tstconn); |
3401 gaim_debug_error("oscar", | 3391 gaim_debug_error("oscar", "unable to connect to icon server\n"); |
3402 "unable to connect to icon server\n"); | |
3403 return; | 3392 return; |
3404 } | 3393 } |
3405 | 3394 |
3406 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ | 3395 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
3407 fcntl(source, F_SETFL, 0); | 3396 fcntl(source, F_SETFL, 0); |
3436 } | 3425 } |
3437 host = g_strndup(redir->ip, i); | 3426 host = g_strndup(redir->ip, i); |
3438 | 3427 |
3439 switch(redir->group) { | 3428 switch(redir->group) { |
3440 case 0x7: /* Authorizer */ | 3429 case 0x7: /* Authorizer */ |
3441 gaim_debug_info("oscar", | 3430 gaim_debug_info("oscar", "Reconnecting with authorizor...\n"); |
3442 "Reconnecting with authorizor...\n"); | |
3443 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); | 3431 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
3444 if (tstconn == NULL) { | 3432 if (tstconn == NULL) { |
3445 gaim_debug_error("oscar", | 3433 gaim_debug_error("oscar", |
3446 "unable to reconnect with authorizer\n"); | 3434 "unable to reconnect with authorizer\n"); |
3447 g_free(host); | 3435 g_free(host); |
3775 struct aim_oft_info *oft_info; | 3763 struct aim_oft_info *oft_info; |
3776 va_list ap; | 3764 va_list ap; |
3777 aim_conn_t *conn, *listenerconn; | 3765 aim_conn_t *conn, *listenerconn; |
3778 | 3766 |
3779 gaim_debug_info("oscar", "AAA - in oscar_sendfile_estblsh\n"); | 3767 gaim_debug_info("oscar", "AAA - in oscar_sendfile_estblsh\n"); |
3780 | 3768 |
3781 va_start(ap, fr); | 3769 va_start(ap, fr); |
3782 conn = va_arg(ap, aim_conn_t *); | 3770 conn = va_arg(ap, aim_conn_t *); |
3783 listenerconn = va_arg(ap, aim_conn_t *); | 3771 listenerconn = va_arg(ap, aim_conn_t *); |
3784 va_end(ap); | 3772 va_end(ap); |
3785 | 3773 |
3793 } | 3781 } |
3794 if (!(oft_info = xfer->data)) { | 3782 if (!(oft_info = xfer->data)) { |
3795 gaim_debug_warning("oscar","NULL data\n"); | 3783 gaim_debug_warning("oscar","NULL data\n"); |
3796 return 1; | 3784 return 1; |
3797 } | 3785 } |
3798 | 3786 |
3799 /* Mark connection as success so further connections aren't attempted | 3787 /* Mark connection as success so further connections aren't attempted |
3800 * This is important here since some receive file code paths pass through here */ | 3788 * This is important here since some receive file code paths pass through here */ |
3801 oft_info->success = TRUE; | 3789 oft_info->success = TRUE; |
3802 | 3790 |
3803 if(oft_info->method != AIM_XFER_PROXY) { | 3791 if(oft_info->method != AIM_XFER_PROXY) { |
3804 /* Stop watching listener conn; watch transfer conn instead */ | 3792 /* Stop watching listener conn; watch transfer conn instead */ |
3805 gaim_input_remove(xfer->watcher); | 3793 gaim_input_remove(xfer->watcher); |
3806 | 3794 |
3807 aim_conn_kill(sess, &listenerconn); | 3795 aim_conn_kill(sess, &listenerconn); |
3808 | 3796 |
3809 oft_info->conn = conn; | 3797 oft_info->conn = conn; |
3810 xfer->fd = oft_info->conn->fd; | 3798 xfer->fd = oft_info->conn->fd; |
3811 } | 3799 } |
3812 | 3800 |
3813 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | 3801 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
3814 | 3802 |
3815 if(oft_info->send_or_recv == AIM_XFER_SEND) { | 3803 if(oft_info->send_or_recv == AIM_XFER_SEND) { |
3816 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, | 3804 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, |
3817 oscar_sendfile_ack, 0); | 3805 oscar_sendfile_ack, 0); |
3818 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, | 3806 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, |
3819 oscar_sendfile_done, 0); | 3807 oscar_sendfile_done, 0); |
3820 | 3808 |
3821 /* Inform the other user that we are connected and ready to transfer */ | 3809 /* Inform the other user that we are connected and ready to transfer */ |
3822 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); | 3810 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3823 } | 3811 } |
3824 | 3812 |
3825 /* For a file send, we'll hopefully end up in oscar_sendfile_ack next | 3813 /* For a file send, we'll hopefully end up in oscar_sendfile_ack next |
3826 * For a file receive, oscar_sendfile_prompt */ | 3814 * For a file receive, oscar_sendfile_prompt */ |
3827 | 3815 |
3828 return 0; | 3816 return 0; |
3829 } | 3817 } |
3830 | 3818 |
3831 /* | 3819 /* |
3832 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM | 3820 * This is the gaim callback passed to gaim_proxy_connect when |
3833 * user in order to transfer a file | 3821 * connecting to another AIM user in order to transfer a file |
3834 * Takes xfer as data and fd as source | 3822 * Takes xfer as data and fd as source |
3835 * BBB | 3823 * BBB |
3836 */ | 3824 */ |
3837 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { | 3825 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
3838 GaimXfer *xfer; | 3826 GaimXfer *xfer; |
3839 struct aim_oft_info *oft_info; | 3827 struct aim_oft_info *oft_info; |
3840 | 3828 |
3841 gaim_debug_info("oscar", | 3829 gaim_debug_info("oscar", "AAA - in oscar_sendfile_connected\n"); |
3842 "AAA - in oscar_sendfile_connected\n"); | |
3843 if (!(xfer = data)) | 3830 if (!(xfer = data)) |
3844 return; | 3831 return; |
3845 if (!(oft_info = xfer->data)) | 3832 if (!(oft_info = xfer->data)) |
3846 return; | 3833 return; |
3847 if(oft_info->success) { | 3834 if(oft_info->success) { |
3861 | 3848 |
3862 /* We might have already set these in oscar_sendfile_proxylogin, but it won't | 3849 /* We might have already set these in oscar_sendfile_proxylogin, but it won't |
3863 * hurt to do it again since it is rather necessary */ | 3850 * hurt to do it again since it is rather necessary */ |
3864 xfer->fd = source; | 3851 xfer->fd = source; |
3865 oft_info->conn->fd = source; | 3852 oft_info->conn->fd = source; |
3866 | 3853 |
3867 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | 3854 aim_conn_completeconnect(oft_info->sess, oft_info->conn); |
3868 | 3855 |
3869 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | 3856 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
3870 | 3857 |
3871 /* Inform the other user that we are connected and accept the transfer | 3858 /* Inform the other user that we are connected and accept the transfer |
3872 * Except for a stage 2 receive, then we'll be the ones receiving this accept message */ | 3859 * Except for a stage 2 receive, then we'll be the ones receiving this accept message */ |
3873 if(oft_info->stage != AIM_XFER_PROXY_STG2) | 3860 if(oft_info->stage != AIM_XFER_PROXY_STG2) |
3874 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); | 3861 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
3875 | 3862 |
3876 /* Don't wait around if this is a redirected send */ | 3863 /* Don't wait around if this is a redirected send */ |
3877 if(oft_info->send_or_recv == AIM_XFER_SEND) { | 3864 if(oft_info->send_or_recv == AIM_XFER_SEND) { |
3878 /* We should only get here if this is a redirected file send */ | 3865 /* We should only get here if this is a redirected file send */ |
3879 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, | 3866 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, |
3880 oscar_sendfile_ack, 0); | 3867 oscar_sendfile_ack, 0); |
3881 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, | 3868 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, |
3882 oscar_sendfile_done, 0); | 3869 oscar_sendfile_done, 0); |
3883 | 3870 |
3884 /* Inform the other user that we are ready to transfer */ | 3871 /* Inform the other user that we are ready to transfer */ |
3885 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_PROMPT, oft_info); | 3872 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_PROMPT, oft_info); |
3886 } | 3873 } |
3887 } | 3874 } |
3888 | 3875 |
3889 /* | 3876 /* |
3890 * This is called when a buddy sends us some file info. This happens when they | 3877 * This is called when a buddy sends us some file info. This happens when they |
3891 * are sending a file to you, and you have just established a connection to them. | 3878 * are sending a file to you, and you have just established a connection to them. |
3892 * You should send them the exact same info except use the real cookie. We also | 3879 * You should send them the exact same info except use the real cookie. We also |
3893 * get like totally ready to like, receive the file, kay? | 3880 * get like totally ready to like, receive the file, kay? |
3894 */ | 3881 */ |
3895 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { | 3882 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
3896 GaimConnection *gc = sess->aux_data; | 3883 GaimConnection *gc = sess->aux_data; |
3897 OscarData *od = gc->proto_data; | 3884 OscarData *od = gc->proto_data; |
3899 struct aim_oft_info *oft_info; | 3886 struct aim_oft_info *oft_info; |
3900 va_list ap; | 3887 va_list ap; |
3901 aim_conn_t *conn; | 3888 aim_conn_t *conn; |
3902 fu8_t *cookie; | 3889 fu8_t *cookie; |
3903 struct aim_fileheader_t *fh; | 3890 struct aim_fileheader_t *fh; |
3904 | 3891 |
3905 gaim_debug_info("oscar", | 3892 gaim_debug_info("oscar", "AAA - in oscar_sendfile_prompt\n"); |
3906 "AAA - in oscar_sendfile_prompt\n"); | 3893 |
3907 | |
3908 va_start(ap, fr); | 3894 va_start(ap, fr); |
3909 conn = va_arg(ap, aim_conn_t *); | 3895 conn = va_arg(ap, aim_conn_t *); |
3910 cookie = va_arg(ap, fu8_t *); | 3896 cookie = va_arg(ap, fu8_t *); |
3911 fh = va_arg(ap, struct aim_fileheader_t *); | 3897 fh = va_arg(ap, struct aim_fileheader_t *); |
3912 va_end(ap); | 3898 va_end(ap); |
3933 | 3919 |
3934 return 0; | 3920 return 0; |
3935 } | 3921 } |
3936 | 3922 |
3937 /* | 3923 /* |
3938 * We are sending a file to someone else. They have just acknowledged our | 3924 * We are sending a file to someone else. They have just acknowledged our |
3939 * prompt, so we want to start sending data like there's no tomorrow. | 3925 * prompt, so we want to start sending data like there's no tomorrow. |
3940 */ | 3926 */ |
3941 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { | 3927 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
3942 GaimConnection *gc = sess->aux_data; | 3928 GaimConnection *gc = sess->aux_data; |
3943 OscarData *od = gc->proto_data; | 3929 OscarData *od = gc->proto_data; |
3965 | 3951 |
3966 return 0; | 3952 return 0; |
3967 } | 3953 } |
3968 | 3954 |
3969 /* | 3955 /* |
3970 * We just sent a file to someone. They said they got it and everything, | 3956 * We just sent a file to someone. They said they got it and everything, |
3971 * so we can close our direct connection and what not. | 3957 * so we can close our direct connection and what not. |
3972 */ | 3958 */ |
3973 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | 3959 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { |
3974 GaimConnection *gc = sess->aux_data; | 3960 GaimConnection *gc = sess->aux_data; |
3975 OscarData *od = gc->proto_data; | 3961 OscarData *od = gc->proto_data; |
4037 bi->typingnot = TRUE; | 4023 bi->typingnot = TRUE; |
4038 else | 4024 else |
4039 bi->typingnot = FALSE; | 4025 bi->typingnot = FALSE; |
4040 | 4026 |
4041 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { | 4027 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
4042 gaim_debug_misc("oscar", | 4028 gaim_debug_misc("oscar", "%s has an icon\n", userinfo->sn); |
4043 "%s has an icon\n", userinfo->sn); | |
4044 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { | 4029 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
4045 bi->ico_need = TRUE; | 4030 bi->ico_need = TRUE; |
4046 bi->ico_len = args->iconlen; | 4031 bi->ico_len = args->iconlen; |
4047 bi->ico_csum = args->iconsum; | 4032 bi->ico_csum = args->iconsum; |
4048 bi->ico_time = args->iconstamp; | 4033 bi->ico_time = args->iconstamp; |
4067 userinfo->sn, len, st.st_size); | 4052 userinfo->sn, len, st.st_size); |
4068 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, | 4053 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
4069 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | 4054 st.st_mtime, aimutil_iconsum(buf, st.st_size)); |
4070 fclose(file); | 4055 fclose(file); |
4071 } else | 4056 } else |
4072 gaim_debug_error("oscar", | 4057 gaim_debug_error("oscar", "Can't open buddy icon file!\n"); |
4073 "Can't open buddy icon file!\n"); | |
4074 g_free(buf); | 4058 g_free(buf); |
4075 } else | 4059 } else |
4076 gaim_debug_error("oscar", | 4060 gaim_debug_error("oscar", "Can't stat buddy icon file!\n"); |
4077 "Can't stat buddy icon file!\n"); | |
4078 } | 4061 } |
4079 g_free(iconfile); | 4062 g_free(iconfile); |
4080 | 4063 |
4081 message = g_string_new(""); | 4064 message = g_string_new(""); |
4082 curpart = args->mpmsg.parts; | 4065 curpart = args->mpmsg.parts; |
4267 xfer_method = AIM_XFER_DIRECT; | 4250 xfer_method = AIM_XFER_DIRECT; |
4268 proxy_stage = AIM_XFER_PROXY_NONE; | 4251 proxy_stage = AIM_XFER_PROXY_NONE; |
4269 xfer->remote_ip = g_strdup(args->clientip); | 4252 xfer->remote_ip = g_strdup(args->clientip); |
4270 xfer->remote_port = args->port; | 4253 xfer->remote_port = args->port; |
4271 } | 4254 } |
4272 | 4255 |
4273 /* Use UTF8 so that the world will be a happier place */ | 4256 /* Use UTF8 so that the world will be a happier place */ |
4274 if (g_utf8_validate(args->info.sendfile.filename, -1, | 4257 if (g_utf8_validate(args->info.sendfile.filename, -1, |
4275 NULL)) { | 4258 NULL)) { |
4276 gaim_xfer_set_filename(xfer, | 4259 gaim_xfer_set_filename(xfer, |
4277 args->info.sendfile.filename); | 4260 args->info.sendfile.filename); |
4281 gaim_xfer_set_filename(xfer, utf8_filename); | 4264 gaim_xfer_set_filename(xfer, utf8_filename); |
4282 g_free(utf8_filename); | 4265 g_free(utf8_filename); |
4283 } | 4266 } |
4284 | 4267 |
4285 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | 4268 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
4286 | 4269 |
4287 /* Ignore messages that start with <ICQ_COOL_FT> (XML that is sent along | 4270 /* Ignore messages that start with <ICQ_COOL_FT> (XML that is sent along |
4288 * with ICQ sendfile requests) & <HTML> message that is sent with AOL file | 4271 * with ICQ sendfile requests) & <HTML> message that is sent with AOL file |
4289 * transfers (Note: this latter message is ignored only if whole message | 4272 * transfers (Note: this latter message is ignored only if whole message |
4290 * is <HTML>, but not if it starts with <HTML> */ | 4273 * is <HTML>, but not if it starts with <HTML> */ |
4291 if(message && ( g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13) < 0 | 4274 if(message && ( g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13) < 0 |
4317 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); | 4300 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4318 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); | 4301 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4319 | 4302 |
4320 /* Keep track of this transfer for later */ | 4303 /* Keep track of this transfer for later */ |
4321 od->file_transfers = g_slist_append(od->file_transfers, xfer); | 4304 od->file_transfers = g_slist_append(od->file_transfers, xfer); |
4322 | 4305 |
4323 /* Now perform the request */ | 4306 /* Now perform the request */ |
4324 gaim_xfer_request(xfer); | 4307 gaim_xfer_request(xfer); |
4325 /* A secondary request has been sent to negotiate the connection method */ | 4308 /* A secondary request has been sent to negotiate the connection method */ |
4326 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0002) { | 4309 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0002) { |
4327 /* We have asked to send a file to someone else, but they sent us a reply request | 4310 /* We have asked to send a file to someone else, but they sent us a reply request |
4328 * asking us to use an alternative method of connecting */ | 4311 * asking us to use an alternative method of connecting */ |
4329 GaimXfer *xfer; | 4312 GaimXfer *xfer; |
4330 struct aim_oft_info *oft_info; | 4313 struct aim_oft_info *oft_info; |
4331 | 4314 |
4332 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { | 4315 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
4333 oft_info = xfer->data; | 4316 oft_info = xfer->data; |
4334 | 4317 |
4335 /* Stop the listener connection */ | 4318 /* Stop the listener connection */ |
4336 gaim_input_remove(xfer->watcher); | 4319 gaim_input_remove(xfer->watcher); |
4337 aim_conn_kill(sess, &oft_info->conn); /* This is currently the listener */ | 4320 aim_conn_kill(sess, &oft_info->conn); /* This is currently the listener */ |
4338 | 4321 |
4339 if(args->info.sendfile.use_proxy) { | 4322 if(args->info.sendfile.use_proxy) { |
4340 gaim_debug_info("oscar", | 4323 gaim_debug_info("oscar", |
4341 "received request for stage 2 rv proxy with ip: %s\n", | 4324 "received request for stage 2 rv proxy with ip: %s\n", |
4342 args->proxyip); | 4325 args->proxyip); |
4343 oft_info->method = AIM_XFER_PROXY; | 4326 oft_info->method = AIM_XFER_PROXY; |
4344 oft_info->stage = AIM_XFER_PROXY_STG2; | 4327 oft_info->stage = AIM_XFER_PROXY_STG2; |
4345 | 4328 |
4346 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, | 4329 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, |
4347 args->cookie, args->port); | 4330 args->cookie, args->port); |
4348 if(args->proxyip) { | 4331 if(args->proxyip) { |
4349 if(xfer->remote_ip) | 4332 if(xfer->remote_ip) |
4350 g_free(xfer->remote_ip); | 4333 g_free(xfer->remote_ip); |
4360 { | 4343 { |
4361 gaim_debug_warning("oscar", | 4344 gaim_debug_warning("oscar", |
4362 "other client wants us to send stage 3 proxy info\n"); | 4345 "other client wants us to send stage 3 proxy info\n"); |
4363 oft_info->method = AIM_XFER_PROXY; | 4346 oft_info->method = AIM_XFER_PROXY; |
4364 oft_info->stage = AIM_XFER_PROXY_STG3; | 4347 oft_info->stage = AIM_XFER_PROXY_STG3; |
4365 | 4348 |
4366 /* Clean useless data from oft_info */ | 4349 /* Clean useless data from oft_info */ |
4367 oft_info->clientip = NULL; | 4350 oft_info->clientip = NULL; |
4368 oft_info->verifiedip = NULL; | 4351 oft_info->verifiedip = NULL; |
4369 | 4352 |
4370 /* This hostname will be resolved in gaim_proxy_connect */ | 4353 /* This hostname will be resolved in gaim_proxy_connect */ |
4371 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | 4354 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); |
4372 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | 4355 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; |
4373 | 4356 |
4374 oft_info->proxy_info | 4357 oft_info->proxy_info |
4375 = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); | 4358 = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); |
4376 oscar_xfer_init_recv(xfer); | 4359 oscar_xfer_init_recv(xfer); |
4377 } else { | 4360 } else { |
4378 gaim_debug_info("oscar","received request to redirect transfer; clientip/verifiedip: %s / %s\n", | 4361 gaim_debug_info("oscar","received request to redirect transfer; clientip/verifiedip: %s / %s\n", |
4383 if (args->clientip) { | 4366 if (args->clientip) { |
4384 oft_info->clientip = g_strdup(args->clientip); | 4367 oft_info->clientip = g_strdup(args->clientip); |
4385 xfer->remote_ip = g_strdup(args->clientip); | 4368 xfer->remote_ip = g_strdup(args->clientip); |
4386 } | 4369 } |
4387 xfer->remote_port = args->port; | 4370 xfer->remote_port = args->port; |
4388 | 4371 |
4389 /* This file send will briefly follow file receive codepaths */ | 4372 /* This file send will briefly follow file receive codepaths */ |
4390 oscar_xfer_init_recv(xfer); | 4373 oscar_xfer_init_recv(xfer); |
4391 } | 4374 } |
4392 } else { | 4375 } else { |
4393 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | 4376 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); |
4398 /* We are receiving a file from someone. We sent a request to use a stage 3 | 4381 /* We are receiving a file from someone. We sent a request to use a stage 3 |
4399 * proxy. They did the initial proxy login and have sent us the info in a | 4382 * proxy. They did the initial proxy login and have sent us the info in a |
4400 * third file transfer request. */ | 4383 * third file transfer request. */ |
4401 GaimXfer *xfer; | 4384 GaimXfer *xfer; |
4402 struct aim_oft_info *oft_info; | 4385 struct aim_oft_info *oft_info; |
4403 | 4386 |
4404 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { | 4387 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
4405 oft_info = xfer->data; | 4388 oft_info = xfer->data; |
4406 | 4389 |
4407 /* We are receiving a file */ | 4390 /* We are receiving a file */ |
4408 gaim_debug_info("oscar", | 4391 gaim_debug_info("oscar", |
4409 "other client sent us stage 3 proxy info\n"); | 4392 "other client sent us stage 3 proxy info\n"); |
4410 | 4393 |
4411 /* The following pieces of information should already have | 4394 /* The following pieces of information should already have |
4412 * been set in oscar_xfer_ip_timeout, but we'll list them | 4395 * been set in oscar_xfer_ip_timeout, but we'll list them |
4413 * again just for clarity. */ | 4396 * again just for clarity. */ |
4414 oft_info->method = AIM_XFER_PROXY; | 4397 oft_info->method = AIM_XFER_PROXY; |
4415 oft_info->stage = AIM_XFER_PROXY_STG3; | 4398 oft_info->stage = AIM_XFER_PROXY_STG3; |
4416 | 4399 |
4417 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, | 4400 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, |
4418 args->cookie, args->port); | 4401 args->cookie, args->port); |
4419 if(args->proxyip) { | 4402 if(args->proxyip) { |
4420 if(xfer->remote_ip) | 4403 if(xfer->remote_ip) |
4421 g_free(xfer->remote_ip); | 4404 g_free(xfer->remote_ip); |
4436 "AAA - File transfer canceled by remote user\n"); | 4419 "AAA - File transfer canceled by remote user\n"); |
4437 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) | 4420 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) |
4438 gaim_xfer_cancel_remote(xfer); | 4421 gaim_xfer_cancel_remote(xfer); |
4439 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { | 4422 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
4440 /* | 4423 /* |
4441 * This gets sent by the receiver of a file | 4424 * This gets sent by the receiver of a file |
4442 * as they connect directly to us. If we don't | 4425 * as they connect directly to us. If we don't |
4443 * get this, then maybe a third party connected | 4426 * get this, then maybe a third party connected |
4444 * to us, and we shouldn't send them anything. | 4427 * to us, and we shouldn't send them anything. |
4445 */ | 4428 */ |
4446 gaim_debug_info("oscar", | 4429 gaim_debug_info("oscar", |
4447 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); | 4430 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); |
4448 } else { | 4431 } else { |
4449 gaim_debug_error("oscar", | 4432 gaim_debug_error("oscar", |
4450 "unknown rendezvous status!\n"); | 4433 "unknown rendezvous status!\n"); |
4451 } | 4434 } |
4452 } else if (args->reqclass & AIM_CAPS_GETFILE) { | 4435 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
4487 * other person using. | 4470 * other person using. |
4488 */ | 4471 */ |
4489 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); | 4472 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); |
4490 memcpy(d->cookie, args->cookie, 8); | 4473 memcpy(d->cookie, args->cookie, 8); |
4491 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && | 4474 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
4492 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | 4475 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { |
4493 | 4476 |
4494 oscar_direct_im_destroy(od, dim); | 4477 oscar_direct_im_destroy(od, dim); |
4495 d->donttryagain = TRUE; | 4478 d->donttryagain = TRUE; |
4496 accept_direct_im_request(d); | 4479 accept_direct_im_request(d); |
4497 } else { | 4480 } else { |
4498 if (dim && !dim->connected) | 4481 if (dim && !dim->connected) |
4499 gaim_debug_warning("oscar", "DirectIM: received direct im request while " | 4482 gaim_debug_warning("oscar", "DirectIM: received direct im request " |
4500 "already connected to that buddy!"); | 4483 "while already connected to that buddy!"); |
4501 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, username); | 4484 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, username); |
4502 | 4485 |
4503 gaim_request_action(gc, NULL, buf, | 4486 gaim_request_action(gc, NULL, buf, |
4504 _("This requires a direct connection between " | 4487 _("This requires a direct connection between " |
4505 "the two computers and is necessary for IM " | 4488 "the two computers and is necessary for IM " |
4506 "Images. Because your IP address will be " | 4489 "Images. Because your IP address will be " |
4507 "revealed, this may be considered a privacy " | 4490 "revealed, this may be considered a privacy " |
4508 "risk."), | 4491 "risk."), |
4509 GAIM_DEFAULT_ACTION_NONE, d, 2, | 4492 GAIM_DEFAULT_ACTION_NONE, d, 2, |
4510 _("_Connect"), G_CALLBACK(accept_direct_im_request), | 4493 _("_Connect"), G_CALLBACK(accept_direct_im_request), |
4511 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | 4494 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); |
4512 /* FIXME: we should actually send a packet on cancel */ | 4495 /* FIXME: we should actually send a packet on cancel */ |
4513 } | 4496 } |
4523 return 1; | 4506 return 1; |
4524 } | 4507 } |
4525 | 4508 |
4526 /* | 4509 /* |
4527 * Authorization Functions | 4510 * Authorization Functions |
4528 * Most of these are callbacks from dialogs. They're used by both | 4511 * Most of these are callbacks from dialogs. They're used by both |
4529 * methods of authorization (SSI and old-school channel 4 ICBM) | 4512 * methods of authorization (SSI and old-school channel 4 ICBM) |
4530 */ | 4513 */ |
4531 /* When you ask other people for authorization */ | 4514 /* When you ask other people for authorization */ |
4532 static void gaim_auth_request(struct name_data *data, char *msg) { | 4515 static void gaim_auth_request(struct name_data *data, char *msg) { |
4533 GaimConnection *gc = data->gc; | 4516 GaimConnection *gc = data->gc; |
5558 emailinfo->domain ? emailinfo->domain : ""); | 5541 emailinfo->domain ? emailinfo->domain : ""); |
5559 if (emailinfo->unread && havenewmail) | 5542 if (emailinfo->unread && havenewmail) |
5560 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | 5543 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); |
5561 g_free(to); | 5544 g_free(to); |
5562 } | 5545 } |
5563 | 5546 |
5564 if (alertitle) | 5547 if (alertitle) |
5565 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); | 5548 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
5566 | 5549 |
5567 return 1; | 5550 return 1; |
5568 } | 5551 } |
5726 }; | 5709 }; |
5727 va_list ap; | 5710 va_list ap; |
5728 fu16_t code, rateclass; | 5711 fu16_t code, rateclass; |
5729 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; | 5712 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
5730 | 5713 |
5731 va_start(ap, fr); | 5714 va_start(ap, fr); |
5732 code = (fu16_t)va_arg(ap, unsigned int); | 5715 code = (fu16_t)va_arg(ap, unsigned int); |
5733 rateclass= (fu16_t)va_arg(ap, unsigned int); | 5716 rateclass= (fu16_t)va_arg(ap, unsigned int); |
5734 windowsize = va_arg(ap, fu32_t); | 5717 windowsize = va_arg(ap, fu32_t); |
5735 clear = va_arg(ap, fu32_t); | 5718 clear = va_arg(ap, fu32_t); |
5736 alert = va_arg(ap, fu32_t); | 5719 alert = va_arg(ap, fu32_t); |
6406 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); | 6389 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
6407 g_free(dialog_msg); | 6390 g_free(dialog_msg); |
6408 } | 6391 } |
6409 | 6392 |
6410 if (email != NULL) { | 6393 if (email != NULL) { |
6411 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), | 6394 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
6412 gaim_account_get_username(gaim_connection_get_account(gc)), email); | 6395 gaim_account_get_username(gaim_connection_get_account(gc)), email); |
6413 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); | 6396 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
6414 g_free(dialog_msg); | 6397 g_free(dialog_msg); |
6415 } | 6398 } |
6416 | 6399 |
6557 | 6540 |
6558 args.destsn = name; | 6541 args.destsn = name; |
6559 | 6542 |
6560 /* | 6543 /* |
6561 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML. | 6544 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML. |
6562 */ | 6545 */ |
6563 if (aim_sn_is_sms(name)) { | 6546 if (aim_sn_is_sms(name)) { |
6564 /* Messaging an SMS (mobile) user */ | 6547 /* Messaging an SMS (mobile) user */ |
6565 tmp2 = gaim_unescape_html(tmp1); | 6548 tmp2 = gaim_unescape_html(tmp1); |
6566 } else if (aim_sn_is_icq(gaim_account_get_username(account))) { | 6549 } else if (aim_sn_is_icq(gaim_account_get_username(account))) { |
6567 if (aim_sn_is_icq(name)) | 6550 if (aim_sn_is_icq(name)) |
6568 /* From ICQ to ICQ */ | 6551 /* From ICQ to ICQ */ |
6569 tmp2 = gaim_unescape_html(tmp1); | 6552 tmp2 = gaim_unescape_html(tmp1); |
6570 else | 6553 else |
7601 buf = gaim_strdup_withhtml(message); | 7584 buf = gaim_strdup_withhtml(message); |
7602 len = strlen(buf); | 7585 len = strlen(buf); |
7603 | 7586 |
7604 if (strstr(buf, "<IMG ")) | 7587 if (strstr(buf, "<IMG ")) |
7605 gaim_conversation_write(conv, "", | 7588 gaim_conversation_write(conv, "", |
7606 _("Your IM Image was not sent. " | 7589 _("Your IM Image was not sent. " |
7607 "You cannot send IM Images in AIM chats."), | 7590 "You cannot send IM Images in AIM chats."), |
7608 GAIM_MESSAGE_ERROR, time(NULL)); | 7591 GAIM_MESSAGE_ERROR, time(NULL)); |
7609 | 7592 |
7610 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); | 7593 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
7611 if ((len > c->maxlen) || (len > c->maxvis)) { | 7594 if ((len > c->maxlen) || (len > c->maxvis)) { |
7612 g_free(buf2); | 7595 g_free(buf2); |
7613 return -E2BIG; | 7596 return -E2BIG; |
7664 status = gaim_presence_get_active_status(presence); | 7647 status = gaim_presence_get_active_status(presence); |
7665 status_id = gaim_status_get_id(status); | 7648 status_id = gaim_status_get_id(status); |
7666 | 7649 |
7667 if (gaim_presence_is_online(presence) == FALSE) { | 7650 if (gaim_presence_is_online(presence) == FALSE) { |
7668 char *gname; | 7651 char *gname; |
7669 if ((b->name) && (od) && (od->sess->ssi.received_data) && | 7652 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
7670 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | 7653 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
7671 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | 7654 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { |
7672 emblems[i++] = "notauthorized"; | 7655 emblems[i++] = "notauthorized"; |
7673 } else { | 7656 } else { |
7674 emblems[i++] = "offline"; | 7657 emblems[i++] = "offline"; |
7675 } | 7658 } |