Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 2235:5d8b6100a9cc
[gaim-migrate @ 2245]
I'm not sure how good this is.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 07 Sep 2001 09:09:01 +0000 |
parents | 14e8978f86bb |
children | 933346315b9b |
comparison
equal
deleted
inserted
replaced
2234:2abf9cc183a0 | 2235:5d8b6100a9cc |
---|---|
97 }; | 97 }; |
98 | 98 |
99 struct direct_im { | 99 struct direct_im { |
100 struct gaim_connection *gc; | 100 struct gaim_connection *gc; |
101 char name[80]; | 101 char name[80]; |
102 struct conversation *cnv; | |
103 int watcher; | 102 int watcher; |
104 struct aim_conn_t *conn; | 103 struct aim_conn_t *conn; |
105 }; | 104 }; |
106 | 105 |
107 struct ask_direct { | 106 struct ask_direct { |
1139 | 1138 |
1140 g_free(d->sn); | 1139 g_free(d->sn); |
1141 g_free(d); | 1140 g_free(d); |
1142 } | 1141 } |
1143 | 1142 |
1144 static void delete_direct_im(gpointer w, struct direct_im *d) { | |
1145 struct oscar_data *od = (struct oscar_data *)d->gc->proto_data; | |
1146 | |
1147 od->direct_ims = g_slist_remove(od->direct_ims, d); | |
1148 gaim_input_remove(d->watcher); | |
1149 aim_conn_kill(od->sess, &d->conn); | |
1150 g_free(d); | |
1151 } | |
1152 | |
1153 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { | 1143 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { |
1154 struct direct_im *dim = data; | 1144 struct direct_im *dim = data; |
1155 struct gaim_connection *gc = dim->gc; | 1145 struct gaim_connection *gc = dim->gc; |
1156 struct oscar_data *od = gc->proto_data; | 1146 struct oscar_data *od = gc->proto_data; |
1147 struct conversation *cnv; | |
1157 char buf[256]; | 1148 char buf[256]; |
1158 | 1149 |
1159 if (!g_slist_find(connections, gc)) { | 1150 if (!g_slist_find(connections, gc)) { |
1160 g_free(dim); | 1151 g_free(dim); |
1161 return; | 1152 return; |
1165 g_free(dim); | 1156 g_free(dim); |
1166 return; | 1157 return; |
1167 } | 1158 } |
1168 | 1159 |
1169 aim_conn_completeconnect(od->sess, dim->conn); | 1160 aim_conn_completeconnect(od->sess, dim->conn); |
1170 if (!(dim->cnv = find_conversation(dim->name))) dim->cnv = new_conversation(dim->name); | 1161 if (!(cnv = find_conversation(dim->name))) cnv = new_conversation(dim->name); |
1171 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | 1162 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); |
1172 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | 1163 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
1173 | 1164 |
1174 od->direct_ims = g_slist_append(od->direct_ims, dim); | 1165 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1175 | |
1176 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", | |
1177 GTK_SIGNAL_FUNC(delete_direct_im), dim); | |
1178 | 1166 |
1179 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | 1167 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
1180 oscar_callback, dim->conn); | 1168 oscar_callback, dim->conn); |
1181 } | 1169 } |
1182 | 1170 |
2363 va_list ap; | 2351 va_list ap; |
2364 struct gaim_connection *gc = sess->aux_data; | 2352 struct gaim_connection *gc = sess->aux_data; |
2365 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 2353 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2366 struct aim_directim_priv *priv; | 2354 struct aim_directim_priv *priv; |
2367 struct aim_conn_t *newconn; | 2355 struct aim_conn_t *newconn; |
2356 struct conversation *cnv; | |
2368 struct direct_im *dim; | 2357 struct direct_im *dim; |
2369 char buf[256]; | 2358 char buf[256]; |
2370 | 2359 |
2371 va_start(ap, command); | 2360 va_start(ap, command); |
2372 newconn = va_arg(ap, struct aim_conn_t *); | 2361 newconn = va_arg(ap, struct aim_conn_t *); |
2375 priv = (struct aim_directim_priv *)newconn->priv; | 2364 priv = (struct aim_directim_priv *)newconn->priv; |
2376 | 2365 |
2377 debug_printf("DirectIM: initiate success to %s\n", priv->sn); | 2366 debug_printf("DirectIM: initiate success to %s\n", priv->sn); |
2378 dim = find_direct_im(od, priv->sn); | 2367 dim = find_direct_im(od, priv->sn); |
2379 | 2368 |
2380 dim->cnv = find_conversation(priv->sn); | 2369 if (!(cnv = find_conversation(priv->sn))) |
2381 if (!dim->cnv) dim->cnv = new_conversation(priv->sn); | 2370 cnv = new_conversation(priv->sn); |
2382 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", | |
2383 GTK_SIGNAL_FUNC(delete_direct_im), dim); | |
2384 gaim_input_remove(dim->watcher); | 2371 gaim_input_remove(dim->watcher); |
2385 dim->conn = newconn; | 2372 dim->conn = newconn; |
2386 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | 2373 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2387 oscar_callback, dim->conn); | 2374 oscar_callback, dim->conn); |
2388 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), priv->sn); | 2375 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), priv->sn); |
2389 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | 2376 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
2390 | 2377 |
2391 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | 2378 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
2392 gaim_directim_incoming, 0); | 2379 gaim_directim_incoming, 0); |
2393 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, | 2380 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, |
2394 gaim_directim_disconnect, 0); | 2381 gaim_directim_disconnect, 0); |
2425 va_list ap; | 2412 va_list ap; |
2426 struct aim_conn_t *conn; | 2413 struct aim_conn_t *conn; |
2427 char *sn; | 2414 char *sn; |
2428 struct gaim_connection *gc = sess->aux_data; | 2415 struct gaim_connection *gc = sess->aux_data; |
2429 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 2416 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2417 struct conversation *cnv; | |
2430 struct direct_im *dim; | 2418 struct direct_im *dim; |
2431 char buf[256]; | 2419 char buf[256]; |
2432 | 2420 |
2433 va_start(ap, command); | 2421 va_start(ap, command); |
2434 conn = va_arg(ap, struct aim_conn_t *); | 2422 conn = va_arg(ap, struct aim_conn_t *); |
2438 debug_printf("%s disconnected Direct IM.\n", sn); | 2426 debug_printf("%s disconnected Direct IM.\n", sn); |
2439 | 2427 |
2440 dim = find_direct_im(od, sn); | 2428 dim = find_direct_im(od, sn); |
2441 od->direct_ims = g_slist_remove(od->direct_ims, dim); | 2429 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
2442 gaim_input_remove(dim->watcher); | 2430 gaim_input_remove(dim->watcher); |
2443 gtk_signal_disconnect_by_data(GTK_OBJECT(dim->cnv->window), dim); | |
2444 | 2431 |
2445 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | 2432 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); |
2446 if (dim->cnv) | 2433 if ((cnv = find_conversation(sn)) != NULL) |
2447 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | 2434 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); |
2448 | 2435 |
2449 aim_conn_kill(sess, &conn); | 2436 aim_conn_kill(sess, &conn); |
2450 | 2437 |
2451 return 1; | 2438 return 1; |
2452 } | 2439 } |
2473 struct ask_do_dir_im { | 2460 struct ask_do_dir_im { |
2474 char *who; | 2461 char *who; |
2475 struct gaim_connection *gc; | 2462 struct gaim_connection *gc; |
2476 }; | 2463 }; |
2477 | 2464 |
2478 static void oscar_cancel_direct_im(GtkObject *obj, struct ask_do_dir_im *data) { | 2465 static void oscar_cancel_direct_im(gpointer obj, struct ask_do_dir_im *data) { |
2479 g_free(data); | 2466 g_free(data); |
2480 } | 2467 } |
2481 | 2468 |
2482 static void oscar_direct_im(GtkObject *obj, struct ask_do_dir_im *data) { | 2469 static void oscar_direct_im(gpointer obj, struct ask_do_dir_im *data) { |
2483 struct gaim_connection *gc = data->gc; | 2470 struct gaim_connection *gc = data->gc; |
2484 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 2471 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2485 struct direct_im *dim; | 2472 struct direct_im *dim; |
2486 | 2473 |
2487 dim = find_direct_im(od, data->who); | 2474 dim = find_direct_im(od, data->who); |