comparison src/protocols/oscar/oscar.c @ 8982:a4fd6666bb83

[gaim-migrate @ 9757] Some Direct IM fixes. 1. Let's send our correct ip. We were usually sending localhost, so the other side would try to connect to localhost and immediately fail and so say, hey! I can't connect to you! Connect to me instead! 2. Add some gaim_conversation_writes to keep the user more informed as to what's going on. This changes the libfaim API. libfaim users take note. I removed the util get local ip function, and made the function that used to use it take an ip as an argument instead, so that oscar.c could just call gaim's function, which works better. I also made it possible to specify a cookie to use, because I think I'll need that later. Probably. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Thu, 20 May 2004 00:14:14 +0000
parents 382bbf503c3d
children 460d02fe03df
comparison
equal deleted inserted replaced
8981:e40f9afd420e 8982:a4fd6666bb83
817 GaimConnection *gc = d->gc; 817 GaimConnection *gc = d->gc;
818 OscarData *od; 818 OscarData *od;
819 struct oscar_direct_im *dim; 819 struct oscar_direct_im *dim;
820 char *host; int port = 5190; 820 char *host; int port = 5190;
821 int i, rc; 821 int i, rc;
822 char *tmp;
823 GaimConversation *conv;
822 824
823 if (!g_list_find(gaim_connections_get_all(), gc)) { 825 if (!g_list_find(gaim_connections_get_all(), gc)) {
824 destroy_direct_im_request(d); 826 destroy_direct_im_request(d);
825 return; 827 return;
826 } 828 }
862 } 864 }
863 host = g_strndup(d->ip, i); 865 host = g_strndup(d->ip, i);
864 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; 866 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS;
865 dim->gpc_pend = TRUE; 867 dim->gpc_pend = TRUE;
866 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); 868 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim);
869
870 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn);
871 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host,
872 port);
873 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
874 g_free(tmp);
875
867 g_free(host); 876 g_free(host);
868 if (rc < 0) { 877 if (rc < 0) {
869 dim->gpc_pend = FALSE; 878 dim->gpc_pend = FALSE;
870 oscar_direct_im_disconnect(od, dim); 879 oscar_direct_im_disconnect(od, dim);
871 destroy_direct_im_request(d); 880 destroy_direct_im_request(d);
1231 static void oscar_direct_im(struct ask_do_dir_im *data) { 1240 static void oscar_direct_im(struct ask_do_dir_im *data) {
1232 GaimConnection *gc = data->gc; 1241 GaimConnection *gc = data->gc;
1233 OscarData *od; 1242 OscarData *od;
1234 struct oscar_direct_im *dim; 1243 struct oscar_direct_im *dim;
1235 int listenfd; 1244 int listenfd;
1245 const char *ip;
1236 1246
1237 if (!g_list_find(gaim_connections_get_all(), gc)) { 1247 if (!g_list_find(gaim_connections_get_all(), gc)) {
1238 g_free(data->who); 1248 g_free(data->who);
1239 g_free(data); 1249 g_free(data);
1240 return; 1250 return;
1258 dim = g_new0(struct oscar_direct_im, 1); 1268 dim = g_new0(struct oscar_direct_im, 1);
1259 dim->gc = gc; 1269 dim->gc = gc;
1260 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); 1270 g_snprintf(dim->name, sizeof dim->name, "%s", data->who);
1261 1271
1262 listenfd = gaim_network_listen_range(5190, 5199); 1272 listenfd = gaim_network_listen_range(5190, 5199);
1263 dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_get_port_from_fd(listenfd)); 1273 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1);
1274 dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), NULL);
1264 if (dim->conn != NULL) { 1275 if (dim->conn != NULL) {
1276 char *tmp;
1277 GaimConversation *conv;
1278
1265 od->direct_ims = g_slist_append(od->direct_ims, dim); 1279 od->direct_ims = g_slist_append(od->direct_ims, dim);
1266 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, 1280 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ,
1267 oscar_callback, dim->conn); 1281 oscar_callback, dim->conn);
1268 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, 1282 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED,
1269 gaim_odc_initiate, 0); 1283 gaim_odc_initiate, 0);
1284
1285 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, data->who);
1286 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), data->who, ip,
1287 gaim_network_get_port_from_fd(listenfd));
1288 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
1289 g_free(tmp);
1270 } else { 1290 } else {
1271 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); 1291 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL);
1272 oscar_direct_im_destroy(od, dim); 1292 oscar_direct_im_destroy(od, dim);
1273 } 1293 }
1274 1294