comparison src/oscar.c @ 1002:1d8f05ea6bdf

[gaim-migrate @ 1012] i don't even remember what happened. all good things, i hope committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 18 Oct 2000 02:38:18 +0000
parents 91b7377e7b45
children c3579d03a0c1
comparison
equal deleted inserted replaced
1001:b8a819390499 1002:1d8f05ea6bdf
158 static int gaim_rateresp (struct aim_session_t *, struct command_rx_struct *, ...); 158 static int gaim_rateresp (struct aim_session_t *, struct command_rx_struct *, ...);
159 static int gaim_reportinterval (struct aim_session_t *, struct command_rx_struct *, ...); 159 static int gaim_reportinterval (struct aim_session_t *, struct command_rx_struct *, ...);
160 static int gaim_parse_msgerr (struct aim_session_t *, struct command_rx_struct *, ...); 160 static int gaim_parse_msgerr (struct aim_session_t *, struct command_rx_struct *, ...);
161 static int gaim_parse_buddyrights(struct aim_session_t *, struct command_rx_struct *, ...); 161 static int gaim_parse_buddyrights(struct aim_session_t *, struct command_rx_struct *, ...);
162 static int gaim_parse_locerr (struct aim_session_t *, struct command_rx_struct *, ...); 162 static int gaim_parse_locerr (struct aim_session_t *, struct command_rx_struct *, ...);
163
164 static int gaim_directim_incoming(struct aim_session_t *, struct command_rx_struct *, ...);
165 static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...);
166 static int gaim_directim_initiate(struct aim_session_t *, struct command_rx_struct *, ...);
167 163
168 static char *msgerrreason[] = { 164 static char *msgerrreason[] = {
169 "Invalid error", 165 "Invalid error",
170 "Invalid SNAC", 166 "Invalid SNAC",
171 "Rate to host", 167 "Rate to host",
219 } 215 }
220 } else { 216 } else {
221 if (aim_get_command(odata->sess, conn) >= 0) { 217 if (aim_get_command(odata->sess, conn) >= 0) {
222 aim_rxdispatch(odata->sess); 218 aim_rxdispatch(odata->sess);
223 } else { 219 } else {
224 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS && 220 if ((conn->type == AIM_CONN_TYPE_BOS) ||
225 conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) {
226 struct conversation *cnv =
227 find_conversation(((struct aim_directim_priv *)conn->priv)->sn);
228 debug_print("connection error for directim\n");
229 if (cnv) {
230 make_direct(cnv, FALSE, NULL, 0);
231 }
232 aim_conn_kill(odata->sess, &conn);
233 } else if ((conn->type == AIM_CONN_TYPE_BOS) ||
234 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 221 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
235 debug_print(_("major connection error\n")); 222 debug_print(_("major connection error\n"));
236 hide_login_progress(gc, _("Disconnected.")); 223 hide_login_progress(gc, _("Disconnected."));
237 signoff(gc); 224 signoff(gc);
238 } else if (conn->type == AIM_CONN_TYPE_CHAT) { 225 } else if (conn->type == AIM_CONN_TYPE_CHAT) {
483 aim_bos_ackrateresp(sess, command->conn); 470 aim_bos_ackrateresp(sess, command->conn);
484 aim_chat_clientready(sess, command->conn); 471 aim_chat_clientready(sess, command->conn);
485 serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn)); 472 serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn));
486 break; 473 break;
487 case AIM_CONN_TYPE_RENDEZVOUS: 474 case AIM_CONN_TYPE_RENDEZVOUS:
488 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0);
489 break; 475 break;
490 default: /* huh? */ 476 default: /* huh? */
491 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); 477 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type);
492 debug_print(debug_buff); 478 debug_print(debug_buff);
493 break; 479 break;
624 serv_got_update(sn, 0, 0, 0, 0, 0, 0); 610 serv_got_update(sn, 0, 0, 0, 0, 0, 0);
625 611
626 return 1; 612 return 1;
627 } 613 }
628 614
629 static void accept_directim(GtkWidget *w, GtkWidget *m)
630 {
631 struct aim_conn_t *newconn;
632 struct aim_directim_priv *priv;
633 struct gaim_connection *gc;
634 struct oscar_data *odata;
635 int watcher;
636
637 priv = (struct aim_directim_priv *)gtk_object_get_user_data(GTK_OBJECT(m));
638 gc = (struct gaim_connection *)gtk_object_get_user_data(GTK_OBJECT(w));
639 odata = (struct oscar_data *)gc->proto_data;
640 gtk_widget_destroy(m);
641
642 if (!(newconn = aim_directim_connect(odata->sess, odata->conn, priv))) {
643 debug_print("imimage: could not connect\n");
644 return;
645 }
646
647 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0);
648 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0);
649
650 watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
651 oscar_callback, newconn);
652
653 sprintf(debug_buff, "DirectIM: connected to %s\n", priv->sn);
654 debug_print(debug_buff);
655
656 serv_got_imimage(gc, priv->sn, priv->cookie, priv->ip, newconn, watcher);
657
658 g_free(priv);
659 }
660
661 static void cancel_directim(GtkWidget *w, GtkWidget *m)
662 {
663 gtk_widget_destroy(m);
664 }
665
666 static void directim_dialog(struct gaim_connection *gc, struct aim_directim_priv *priv)
667 {
668 GtkWidget *window;
669 GtkWidget *vbox;
670 GtkWidget *hbox;
671 GtkWidget *label;
672 GtkWidget *yes;
673 GtkWidget *no;
674 char buf[BUF_LONG];
675
676 window = gtk_window_new(GTK_WINDOW_DIALOG);
677 gtk_window_set_title(GTK_WINDOW(window), _("Accept Direct IM?"));
678 gtk_window_set_wmclass(GTK_WINDOW(window), "directim", "Gaim");
679 gtk_widget_realize(window);
680 aol_icon(window->window);
681 gtk_object_set_user_data(GTK_OBJECT(window), (void *)priv);
682
683 vbox = gtk_vbox_new(TRUE, 5);
684 gtk_container_add(GTK_CONTAINER(window), vbox);
685 gtk_widget_show(vbox);
686
687 sprintf(buf, _("%s has requested to directly connect to your computer. "
688 "Do you accept?"), priv->sn);
689 label = gtk_label_new(buf);
690 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
691 gtk_widget_show(label);
692
693 hbox = gtk_hbox_new(TRUE, 10);
694 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
695 gtk_widget_show(hbox);
696
697 yes = picture_button(window, _("Accept"), ok_xpm);
698 gtk_box_pack_start(GTK_BOX(hbox), yes, FALSE, FALSE, 5);
699 gtk_object_set_user_data(GTK_OBJECT(yes), gc);
700
701 no = picture_button(window, _("Cancel"), cancel_xpm);
702 gtk_box_pack_end(GTK_BOX(hbox), no, FALSE, FALSE, 5);
703
704 gtk_signal_connect(GTK_OBJECT(yes), "clicked",
705 GTK_SIGNAL_FUNC(accept_directim), window);
706 gtk_signal_connect(GTK_OBJECT(no), "clicked",
707 GTK_SIGNAL_FUNC(cancel_directim), window);
708
709 gtk_widget_show(window);
710 }
711
712 int gaim_parse_incoming_im(struct aim_session_t *sess, 615 int gaim_parse_incoming_im(struct aim_session_t *sess,
713 struct command_rx_struct *command, ...) { 616 struct command_rx_struct *command, ...) {
714 int channel; 617 int channel;
715 va_list ap; 618 va_list ap;
716 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); 619 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess);
763 /* this one libfaim tells us unuseful info about */ 666 /* this one libfaim tells us unuseful info about */
764 } else if (rendtype & AIM_CAPS_BUDDYICON) { 667 } else if (rendtype & AIM_CAPS_BUDDYICON) {
765 /* bah */ 668 /* bah */
766 } else if (rendtype & AIM_CAPS_IMIMAGE) { 669 } else if (rendtype & AIM_CAPS_IMIMAGE) {
767 /* DirectIM stuff */ 670 /* DirectIM stuff */
768 struct aim_directim_priv *priv, *priv2;
769
770 userinfo = va_arg(ap, struct aim_userinfo_s *);
771 priv = va_arg(ap, struct aim_directim_priv *);
772 va_end(ap);
773
774 sprintf(debug_buff, "DirectIM request from %s (%s)\n", userinfo->sn, priv->ip);
775 debug_print(debug_buff);
776
777 priv2 = g_new0(struct aim_directim_priv, 1);
778 strcpy(priv2->cookie, priv->cookie);
779 strcpy(priv2->sn, priv->sn);
780 strcpy(priv2->ip, priv->ip);
781 directim_dialog(gc, priv2);
782 } else { 671 } else {
783 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); 672 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype);
784 debug_print(debug_buff); 673 debug_print(debug_buff);
785 } 674 }
786 } 675 }
1162 aim_bos_reqpersonalinfo(sess, command->conn); 1051 aim_bos_reqpersonalinfo(sess, command->conn);
1163 aim_bos_reqlocaterights(sess, command->conn); 1052 aim_bos_reqlocaterights(sess, command->conn);
1164 aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps); 1053 aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps);
1165 aim_bos_reqbuddyrights(sess, command->conn); 1054 aim_bos_reqbuddyrights(sess, command->conn);
1166 1055
1167 if (mainwindow)
1168 gtk_widget_hide(mainwindow);
1169 show_buddy_list();
1170
1171 #ifdef USE_APPLET
1172 if (general_options & OPT_GEN_APP_BUDDY_SHOW) {
1173 refresh_buddy_window();
1174 createOnlinePopup();
1175 applet_buddy_show = TRUE;
1176 } else {
1177 gtk_widget_hide(blist);
1178 applet_buddy_show = FALSE;
1179 }
1180 set_user_state(online);
1181 #else
1182 refresh_buddy_window();
1183 #endif
1184
1185 serv_finish_login(gc); 1056 serv_finish_login(gc);
1186 gaim_setup(gc); 1057 account_online(gc);
1187 1058
1188 if (bud_list_cache_exists(gc)) 1059 if (bud_list_cache_exists(gc))
1189 do_import(NULL, gc); 1060 do_import(NULL, gc);
1190 1061
1191 debug_print("buddy list loaded\n"); 1062 debug_print("buddy list loaded\n");
1192
1193 setup_buddy_chats();
1194 1063
1195 aim_addicbmparam(sess, command->conn); 1064 aim_addicbmparam(sess, command->conn);
1196 aim_bos_reqicbmparaminfo(sess, command->conn); 1065 aim_bos_reqicbmparaminfo(sess, command->conn);
1197 1066
1198 aim_bos_reqrights(sess, command->conn); 1067 aim_bos_reqrights(sess, command->conn);
1252 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); 1121 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
1253 1122
1254 return 1; 1123 return 1;
1255 } 1124 }
1256 1125
1257 int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) {
1258 va_list ap;
1259 char *sn = NULL, *msg = NULL;
1260 struct aim_conn_t *conn;
1261 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess);
1262
1263 va_start(ap, command);
1264 conn = va_arg(ap, struct aim_conn_t *);
1265 sn = va_arg(ap, char *);
1266 msg = va_arg(ap, char *);
1267 va_end(ap);
1268
1269 sprintf(debug_buff, "Got DirectIM message from %s\n", sn);
1270 debug_print(debug_buff);
1271
1272 serv_got_im(gc, sn, msg, 0);
1273
1274 return 1;
1275 }
1276
1277 /* this is such a f*cked up function */
1278 int gaim_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...) {
1279 va_list ap;
1280 struct aim_directim_priv *priv;
1281 struct aim_conn_t *newconn;
1282 struct conversation *cnv;
1283 int watcher;
1284
1285 va_start(ap, command);
1286 newconn = va_arg(ap, struct aim_conn_t *);
1287 va_end(ap);
1288
1289 priv = (struct aim_directim_priv *)newconn->priv;
1290
1291 sprintf(debug_buff, "DirectIM: initiate success to %s\n", priv->sn);
1292 debug_print(debug_buff);
1293
1294 cnv = find_conversation(priv->sn);
1295 gdk_input_remove(cnv->watcher);
1296 watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
1297 oscar_callback, newconn);
1298 make_direct(cnv, TRUE, newconn, watcher);
1299
1300 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0);
1301 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0);
1302
1303 return 1;
1304 }
1305
1306 int gaim_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...) {
1307 va_list ap;
1308 char *sn;
1309
1310 va_start(ap, command);
1311 sn = va_arg(ap, char *);
1312 va_end(ap);
1313
1314 /* I had to leave this. It's just too funny. It reminds me of my sister. */
1315 sprintf(debug_buff, "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn);
1316 debug_print(debug_buff);
1317
1318 return 1;
1319 }
1320
1321 void oscar_do_directim(struct gaim_connection *gc, char *name) {
1322 struct oscar_data *odata = (struct oscar_data *)gc->proto_data;
1323 struct aim_conn_t *newconn = aim_directim_initiate(odata->sess, odata->conn, NULL, name);
1324 struct conversation *cnv = find_conversation(name); /* this will never be null because
1325 it just got set up */
1326 cnv->conn = newconn;
1327 cnv->watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn);
1328 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, gaim_directim_initiate, 0);
1329 }
1330
1331 static void oscar_keepalive(struct gaim_connection *gc) { 1126 static void oscar_keepalive(struct gaim_connection *gc) {
1332 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; 1127 struct oscar_data *odata = (struct oscar_data *)gc->proto_data;
1333 aim_flap_nop(odata->sess, odata->conn); 1128 aim_flap_nop(odata->sess, odata->conn);
1334 } 1129 }
1335 1130
1338 } 1133 }
1339 1134
1340 static void oscar_send_im(struct gaim_connection *gc, char *name, char *message, int away) { 1135 static void oscar_send_im(struct gaim_connection *gc, char *name, char *message, int away) {
1341 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; 1136 struct oscar_data *odata = (struct oscar_data *)gc->proto_data;
1342 struct conversation *cnv = find_conversation(name); 1137 struct conversation *cnv = find_conversation(name);
1343 if (cnv && cnv->is_direct) { 1138 if (away)
1344 debug_printf("Sending DirectIM to %s\n", name); 1139 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message);
1345 aim_send_im_direct(odata->sess, cnv->conn, message); 1140 else
1346 } else { 1141 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_ACK, message);
1347 if (away)
1348 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message);
1349 else
1350 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_ACK, message);
1351 }
1352 } 1142 }
1353 1143
1354 static void oscar_get_info(struct gaim_connection *g, char *name) { 1144 static void oscar_get_info(struct gaim_connection *g, char *name) {
1355 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1145 struct oscar_data *odata = (struct oscar_data *)g->proto_data;
1356 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); 1146 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO);