| 860 struct aim_oft_info *oft_info = xfer->data; |
860 struct aim_oft_info *oft_info = xfer->data; |
| 861 GaimConnection *gc = oft_info->sess->aux_data; |
861 GaimConnection *gc = oft_info->sess->aux_data; |
| 862 OscarData *od = gc->proto_data; |
862 OscarData *od = gc->proto_data; |
| 863 |
863 |
| 864 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { |
864 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { |
| 865 int i; |
865 int listenfd; |
| 866 |
866 |
| 867 xfer->filename = g_path_get_basename(xfer->local_filename); |
867 xfer->filename = g_path_get_basename(xfer->local_filename); |
| 868 strncpy(oft_info->fh.name, xfer->filename, 64); |
868 strncpy(oft_info->fh.name, xfer->filename, 64); |
| 869 oft_info->fh.totsize = gaim_xfer_get_size(xfer); |
869 oft_info->fh.totsize = gaim_xfer_get_size(xfer); |
| 870 oft_info->fh.size = gaim_xfer_get_size(xfer); |
870 oft_info->fh.size = gaim_xfer_get_size(xfer); |
| 871 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
871 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
| 872 |
872 |
| 873 /* |
873 /* Create a listening socket and an associated libfaim conn */ |
| 874 * First try the port specified earlier (5190). If that fails, |
874 if ((listenfd = gaim_network_listen(5190, 5199)) < 0) |
| 875 * increment by 1 and try again. |
875 return; |
| 876 */ |
876 xfer->local_port = gaim_network_get_port_from_fd(listenfd); |
| 877 aim_sendfile_listen(od->sess, oft_info); |
877 oft_info->port = xfer->local_port; |
| 878 for (i=0; (i<5 && !oft_info->conn); i++) { |
878 aim_sendfile_listen(od->sess, oft_info, listenfd); |
| 879 xfer->local_port = oft_info->port = oft_info->port + 1; |
|
| 880 aim_sendfile_listen(od->sess, oft_info); |
|
| 881 } |
|
| 882 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
879 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
| 883 "port is %d, ip is %s\n", |
880 "port is %d, ip is %s\n", |
| 884 xfer->local_port, oft_info->clientip); |
881 xfer->local_port, oft_info->clientip); |
| 885 if (oft_info->conn) { |
882 if (oft_info->conn) { |
| 886 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
883 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
| 1040 |
1037 |
| 1041 /* You want to send a file to someone else, you're so generous */ |
1038 /* You want to send a file to someone else, you're so generous */ |
| 1042 |
1039 |
| 1043 /* Build the file transfer handle */ |
1040 /* Build the file transfer handle */ |
| 1044 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); |
1041 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); |
| 1045 xfer->local_port = 5190; |
|
| 1046 |
1042 |
| 1047 /* Create the oscar-specific data */ |
1043 /* Create the oscar-specific data */ |
| 1048 ip = gaim_network_get_ip_for_account(account, od->conn?od->conn->fd:-1); |
1044 ip = gaim_network_get_ip_for_account(account, od->conn ? od->conn->fd : -1); |
| 1049 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, ip, xfer->local_port, 0, 0, NULL); |
1045 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, ip, 0, 0, 0, NULL); |
| 1050 xfer->data = oft_info; |
1046 xfer->data = oft_info; |
| 1051 |
1047 |
| 1052 /* Setup our I/O op functions */ |
1048 /* Setup our I/O op functions */ |
| 1053 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); |
1049 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); |
| 1054 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); |
1050 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); |
| 2133 |
2129 |
| 2134 static void accept_direct_im(struct ask_direct *d) { |
2130 static void accept_direct_im(struct ask_direct *d) { |
| 2135 GaimConnection *gc = d->gc; |
2131 GaimConnection *gc = d->gc; |
| 2136 OscarData *od; |
2132 OscarData *od; |
| 2137 struct direct_im *dim; |
2133 struct direct_im *dim; |
| 2138 char *host; int port = 4443; |
2134 char *host; int port = 5190; |
| 2139 int i, rc; |
2135 int i, rc; |
| 2140 |
2136 |
| 2141 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2137 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2142 cancel_direct_im(d); |
2138 cancel_direct_im(d); |
| 2143 return; |
2139 return; |
| 6150 } |
6147 } |
| 6151 dim = g_new0(struct direct_im, 1); |
6148 dim = g_new0(struct direct_im, 1); |
| 6152 dim->gc = gc; |
6149 dim->gc = gc; |
| 6153 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); |
6150 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); |
| 6154 |
6151 |
| 6155 dim->conn = aim_odc_initiate(od->sess, data->who); |
6152 listenfd = gaim_network_listen(5190, 5199); |
| |
6153 dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_get_port_from_fd(listenfd)); |
| 6156 if (dim->conn != NULL) { |
6154 if (dim->conn != NULL) { |
| 6157 od->direct_ims = g_slist_append(od->direct_ims, dim); |
6155 od->direct_ims = g_slist_append(od->direct_ims, dim); |
| 6158 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
6156 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
| 6159 oscar_callback, dim->conn); |
6157 oscar_callback, dim->conn); |
| 6160 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
6158 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |