Mercurial > pidgin
comparison src/oscar.c @ 1979:e43c267b1a8a
[gaim-migrate @ 1989]
important oscar fixes. i hadn't considered these. other minor fixes.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 09 Jun 2001 21:19:00 +0000 |
parents | 7b3f1eb1ef7d |
children | 26ff22691f5e |
comparison
equal
deleted
inserted
replaced
1978:a7bfa23e80a1 | 1979:e43c267b1a8a |
---|---|
156 GtkWidget *pix; | 156 GtkWidget *pix; |
157 int curframe; | 157 int curframe; |
158 int timer; | 158 int timer; |
159 }; | 159 }; |
160 #endif | 160 #endif |
161 | |
162 static gpointer memdup(gconstpointer mem, guint size) | |
163 { | |
164 gpointer new_mem; | |
165 | |
166 if (mem) { | |
167 new_mem = malloc(size); | |
168 memcpy(new_mem, mem, size); | |
169 return new_mem; | |
170 } else | |
171 return NULL; | |
172 } | |
161 | 173 |
162 static struct direct_im *find_direct_im(struct oscar_data *od, char *who) { | 174 static struct direct_im *find_direct_im(struct oscar_data *od, char *who) { |
163 GSList *d = od->direct_ims; | 175 GSList *d = od->direct_ims; |
164 char *n = g_strdup(normalize(who)); | 176 char *n = g_strdup(normalize(who)); |
165 struct direct_im *m = NULL; | 177 struct direct_im *m = NULL; |
442 } | 454 } |
443 | 455 |
444 static void oscar_login_connect(gpointer data, gint source, GdkInputCondition cond) | 456 static void oscar_login_connect(gpointer data, gint source, GdkInputCondition cond) |
445 { | 457 { |
446 struct gaim_connection *gc = data; | 458 struct gaim_connection *gc = data; |
447 struct oscar_data *odata = gc->proto_data; | 459 struct oscar_data *odata; |
448 struct aim_session_t *sess = odata->sess; | 460 struct aim_session_t *sess; |
449 struct aim_conn_t *conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | 461 struct aim_conn_t *conn; |
462 | |
463 if (!g_slist_find(connections, gc)) | |
464 return; | |
465 | |
466 odata = gc->proto_data; | |
467 sess = odata->sess; | |
468 conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | |
450 | 469 |
451 if (source < 0) { | 470 if (source < 0) { |
452 hide_login_progress(gc, _("Couldn't connect to host")); | 471 hide_login_progress(gc, _("Couldn't connect to host")); |
453 signoff(gc); | 472 signoff(gc); |
454 return; | 473 return; |
564 debug_printf(_("Signed off.\n")); | 583 debug_printf(_("Signed off.\n")); |
565 } | 584 } |
566 | 585 |
567 static void oscar_bos_connect(gpointer data, gint source, GdkInputCondition cond) { | 586 static void oscar_bos_connect(gpointer data, gint source, GdkInputCondition cond) { |
568 struct gaim_connection *gc = data; | 587 struct gaim_connection *gc = data; |
569 struct oscar_data *odata = gc->proto_data; | 588 struct oscar_data *odata; |
570 struct aim_session_t *sess = odata->sess; | 589 struct aim_session_t *sess; |
571 struct aim_conn_t *bosconn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); | 590 struct aim_conn_t *bosconn; |
591 | |
592 if (!g_slist_find(connections, gc)) | |
593 return; | |
594 | |
595 odata = gc->proto_data; | |
596 sess = odata->sess; | |
597 bosconn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); | |
572 | 598 |
573 if (source < 0) { | 599 if (source < 0) { |
574 if (bosconn->priv) | 600 if (bosconn->priv) |
575 g_free(bosconn->priv); | 601 g_free(bosconn->priv); |
576 bosconn->priv = NULL; | 602 bosconn->priv = NULL; |
581 | 607 |
582 if (bosconn->fd != source) | 608 if (bosconn->fd != source) |
583 bosconn->fd = source; | 609 bosconn->fd = source; |
584 | 610 |
585 aim_auth_sendcookie(sess, bosconn, bosconn->priv); | 611 aim_auth_sendcookie(sess, bosconn, bosconn->priv); |
586 g_free(bosconn->priv); | 612 free(bosconn->priv); |
587 bosconn->priv = NULL; | 613 bosconn->priv = NULL; |
588 gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 614 gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
589 oscar_callback, bosconn); | 615 oscar_callback, bosconn); |
590 set_login_progress(gc, 4, _("Connection established, cookie sent")); | 616 set_login_progress(gc, 4, _("Connection established, cookie sent")); |
591 } | 617 } |
715 port = atoi(&(bosip[i+1])); | 741 port = atoi(&(bosip[i+1])); |
716 break; | 742 break; |
717 } | 743 } |
718 } | 744 } |
719 host = g_strndup(bosip, i); | 745 host = g_strndup(bosip, i); |
720 bosconn->priv = g_memdup(cookie, AIM_COOKIELEN); | 746 bosconn->priv = memdup(cookie, AIM_COOKIELEN); |
721 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc); | 747 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc); |
722 g_free(host); | 748 g_free(host); |
723 if (!user->gc || (bosconn->fd < 0)) { | 749 if (!user->gc || (bosconn->fd < 0)) { |
724 if (bosconn->priv) | 750 if (bosconn->priv) |
725 g_free(bosconn->priv); | 751 g_free(bosconn->priv); |
970 } | 996 } |
971 | 997 |
972 static void oscar_chatnav_connect(gpointer data, gint source, GdkInputCondition cond) | 998 static void oscar_chatnav_connect(gpointer data, gint source, GdkInputCondition cond) |
973 { | 999 { |
974 struct gaim_connection *gc = data; | 1000 struct gaim_connection *gc = data; |
975 struct oscar_data *odata = gc->proto_data; | 1001 struct oscar_data *odata; |
976 struct aim_session_t *sess = odata->sess; | 1002 struct aim_session_t *sess; |
977 struct aim_conn_t *tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV); | 1003 struct aim_conn_t *tstconn; |
1004 | |
1005 if (!g_slist_find(connections, gc)) | |
1006 return; | |
1007 | |
1008 odata = gc->proto_data; | |
1009 sess = odata->sess; | |
1010 tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV); | |
978 | 1011 |
979 if (source < 0) { | 1012 if (source < 0) { |
980 if (tstconn->priv) | 1013 if (tstconn->priv) |
981 g_free(tstconn->priv); | 1014 g_free(tstconn->priv); |
982 tstconn->priv = NULL; | 1015 tstconn->priv = NULL; |
987 | 1020 |
988 if (tstconn->fd != source) | 1021 if (tstconn->fd != source) |
989 tstconn->fd = source; | 1022 tstconn->fd = source; |
990 | 1023 |
991 aim_auth_sendcookie(sess, tstconn, tstconn->priv); | 1024 aim_auth_sendcookie(sess, tstconn, tstconn->priv); |
992 g_free(tstconn->priv); | 1025 free(tstconn->priv); |
993 tstconn->priv = NULL; | 1026 tstconn->priv = NULL; |
994 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 1027 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
995 oscar_callback, tstconn); | 1028 oscar_callback, tstconn); |
996 debug_printf("chatnav: connected\n"); | 1029 debug_printf("chatnav: connected\n"); |
997 } | 1030 } |
998 | 1031 |
999 static void oscar_auth_connect(gpointer data, gint source, GdkInputCondition cond) | 1032 static void oscar_auth_connect(gpointer data, gint source, GdkInputCondition cond) |
1000 { | 1033 { |
1001 struct gaim_connection *gc = data; | 1034 struct gaim_connection *gc = data; |
1002 struct oscar_data *odata = gc->proto_data; | 1035 struct oscar_data *odata; |
1003 struct aim_session_t *sess = odata->sess; | 1036 struct aim_session_t *sess; |
1004 struct aim_conn_t *tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | 1037 struct aim_conn_t *tstconn; |
1038 | |
1039 if (!g_slist_find(connections, gc)) | |
1040 return; | |
1041 | |
1042 odata = gc->proto_data; | |
1043 sess = odata->sess; | |
1044 tstconn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); | |
1005 | 1045 |
1006 if (source < 0) { | 1046 if (source < 0) { |
1007 if (tstconn->priv) | 1047 if (tstconn->priv) |
1008 g_free(tstconn->priv); | 1048 g_free(tstconn->priv); |
1009 tstconn->priv = NULL; | 1049 tstconn->priv = NULL; |
1014 | 1054 |
1015 if (tstconn->fd != source) | 1055 if (tstconn->fd != source) |
1016 tstconn->fd = source; | 1056 tstconn->fd = source; |
1017 | 1057 |
1018 aim_auth_sendcookie(sess, tstconn, tstconn->priv); | 1058 aim_auth_sendcookie(sess, tstconn, tstconn->priv); |
1019 g_free(tstconn->priv); | 1059 free(tstconn->priv); |
1020 tstconn->priv = NULL; | 1060 tstconn->priv = NULL; |
1021 odata->paspa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 1061 odata->paspa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
1022 oscar_callback, tstconn); | 1062 oscar_callback, tstconn); |
1023 debug_printf("chatnav: connected\n"); | 1063 debug_printf("chatnav: connected\n"); |
1024 } | 1064 } |
1025 | 1065 |
1026 static void oscar_chat_connect(gpointer data, gint source, GdkInputCondition cond) | 1066 static void oscar_chat_connect(gpointer data, gint source, GdkInputCondition cond) |
1027 { | 1067 { |
1028 struct chat_connection *ccon = data; | 1068 struct chat_connection *ccon = data; |
1029 struct gaim_connection *gc = ccon->gc; | 1069 struct gaim_connection *gc = ccon->gc; |
1030 struct oscar_data *odata = gc->proto_data; | 1070 struct oscar_data *odata; |
1031 struct aim_session_t *sess = odata->sess; | 1071 struct aim_session_t *sess; |
1032 struct aim_conn_t *tstconn = ccon->conn; | 1072 struct aim_conn_t *tstconn; |
1073 | |
1074 if (!g_slist_find(connections, gc)) { | |
1075 g_free(ccon->priv); | |
1076 g_free(ccon->show); | |
1077 g_free(ccon->name); | |
1078 g_free(ccon); | |
1079 return; | |
1080 } | |
1081 | |
1082 odata = gc->proto_data; | |
1083 sess = odata->sess; | |
1084 tstconn = ccon->conn; | |
1033 | 1085 |
1034 if (source < 0) { | 1086 if (source < 0) { |
1035 aim_conn_kill(sess, &tstconn); | 1087 aim_conn_kill(sess, &tstconn); |
1036 g_free(ccon->priv); | 1088 g_free(ccon->priv); |
1037 g_free(ccon->show); | 1089 g_free(ccon->show); |
1038 g_free(ccon->name); | 1090 g_free(ccon->name); |
1039 g_free(ccon); | 1091 g_free(ccon); |
1092 return; | |
1040 } | 1093 } |
1041 | 1094 |
1042 if (ccon->fd != source) | 1095 if (ccon->fd != source) |
1043 ccon->fd = tstconn->fd = source; | 1096 ccon->fd = tstconn->fd = source; |
1044 | 1097 |
1088 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, gaim_rateresp, 0); | 1141 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, gaim_rateresp, 0); |
1089 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); | 1142 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
1090 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | 1143 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); |
1091 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | 1144 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); |
1092 | 1145 |
1093 tstconn->priv = g_memdup(cookie, AIM_COOKIELEN); | 1146 tstconn->priv = memdup(cookie, AIM_COOKIELEN); |
1094 fd = proxy_connect(host, port, oscar_auth_connect, gc); | 1147 fd = proxy_connect(host, port, oscar_auth_connect, gc); |
1095 if (fd < 0) { | 1148 if (fd < 0) { |
1096 if (tstconn->priv) | 1149 if (tstconn->priv) |
1097 g_free(tstconn->priv); | 1150 g_free(tstconn->priv); |
1098 tstconn->priv = NULL; | 1151 tstconn->priv = NULL; |
1110 g_free(host); | 1163 g_free(host); |
1111 return 1; | 1164 return 1; |
1112 } | 1165 } |
1113 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | 1166 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
1114 | 1167 |
1115 tstconn->priv = g_memdup(cookie, AIM_COOKIELEN); | 1168 tstconn->priv = memdup(cookie, AIM_COOKIELEN); |
1116 fd = proxy_connect(host, port, oscar_chatnav_connect, gc); | 1169 fd = proxy_connect(host, port, oscar_chatnav_connect, gc); |
1117 if (fd < 0) { | 1170 if (fd < 0) { |
1118 if (tstconn->priv) | 1171 if (tstconn->priv) |
1119 g_free(tstconn->priv); | 1172 g_free(tstconn->priv); |
1120 tstconn->priv = NULL; | 1173 tstconn->priv = NULL; |
1144 ccon->fd = -1; | 1197 ccon->fd = -1; |
1145 ccon->name = g_strdup(roomname); | 1198 ccon->name = g_strdup(roomname); |
1146 ccon->exchange = exchange; | 1199 ccon->exchange = exchange; |
1147 ccon->show = extract_name(roomname); | 1200 ccon->show = extract_name(roomname); |
1148 | 1201 |
1149 ccon->priv = g_memdup(cookie, AIM_COOKIELEN); | 1202 ccon->priv = memdup(cookie, AIM_COOKIELEN); |
1150 fd = proxy_connect(host, port, oscar_chat_connect, ccon); | 1203 fd = proxy_connect(host, port, oscar_chat_connect, ccon); |
1151 if (fd < 0) { | 1204 if (fd < 0) { |
1152 aim_conn_kill(sess, &tstconn); | 1205 aim_conn_kill(sess, &tstconn); |
1153 debug_printf("unable to connect to chat server\n"); | 1206 debug_printf("unable to connect to chat server\n"); |
1154 g_free(host); | 1207 g_free(host); |
2527 aim_bos_setidle(odata->sess, odata->conn, time); | 2580 aim_bos_setidle(odata->sess, odata->conn, time); |
2528 } | 2581 } |
2529 | 2582 |
2530 static void oscar_set_info(struct gaim_connection *g, char *info) { | 2583 static void oscar_set_info(struct gaim_connection *g, char *info) { |
2531 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | 2584 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2532 if (awaymessage) | 2585 char inforeal[1025], away[1025]; |
2533 aim_bos_setprofile(odata->sess, odata->conn, info, | 2586 g_snprintf(inforeal, sizeof(inforeal), "%s", info); |
2534 awaymessage->message, gaim_caps); | 2587 if (g->away) |
2535 else | 2588 g_snprintf(away, sizeof(away), "%s", g->away); |
2536 aim_bos_setprofile(odata->sess, odata->conn, info, | 2589 if (strlen(info) > 1024) |
2537 NULL, gaim_caps); | 2590 do_error_dialog("Maximum info length (1024) exceeded, truncating", "Info Too Long"); |
2591 aim_bos_setprofile(odata->sess, odata->conn, inforeal, g->away ? away : NULL, gaim_caps); | |
2538 } | 2592 } |
2539 | 2593 |
2540 static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { | 2594 static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { |
2541 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | 2595 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2542 aim_bos_setprofile(odata->sess, odata->conn, g->user->user_info, message, gaim_caps); | 2596 char info[1025], away[1025]; |
2597 g_snprintf(info, sizeof(info), "%s", g->user->user_info); | |
2598 if (message) | |
2599 g_snprintf(away, sizeof(away), "%s", message); | |
2600 aim_bos_setprofile(odata->sess, odata->conn, info, away, gaim_caps); | |
2543 if (g->away) | 2601 if (g->away) |
2544 g_free (g->away); | 2602 g_free (g->away); |
2545 g->away = NULL; | 2603 g->away = NULL; |
2546 if (message) | 2604 if (message) { |
2605 if (strlen(message) > 1024) | |
2606 do_error_dialog("Maximum away length (1024) exceeded, truncating", | |
2607 "Info Too Long"); | |
2547 g->away = g_strdup (message); | 2608 g->away = g_strdup (message); |
2609 } | |
2548 } | 2610 } |
2549 | 2611 |
2550 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { | 2612 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { |
2551 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | 2613 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2552 aim_send_warning(odata->sess, odata->conn, name, anon); | 2614 aim_send_warning(odata->sess, odata->conn, name, anon); |