Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 2821:9467e4ee81be
[gaim-migrate @ 2834]
new libfaim stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 01 Dec 2001 00:56:31 +0000 |
parents | b917845dad3c |
children | 744df95bf123 |
comparison
equal
deleted
inserted
replaced
2820:b917845dad3c | 2821:9467e4ee81be |
---|---|
103 }; | 103 }; |
104 | 104 |
105 struct chat_connection { | 105 struct chat_connection { |
106 char *name; | 106 char *name; |
107 char *show; /* AOL did something funny to us */ | 107 char *show; /* AOL did something funny to us */ |
108 fu16_t exchange; /* XXX should have instance here too */ | 108 fu16_t exchange; |
109 fu16_t instance; | |
109 int fd; /* this is redundant since we have the conn below */ | 110 int fd; /* this is redundant since we have the conn below */ |
110 aim_conn_t *conn; | 111 aim_conn_t *conn; |
111 int inpa; | 112 int inpa; |
112 int id; | 113 int id; |
113 struct gaim_connection *gc; /* i hate this. */ | 114 struct gaim_connection *gc; /* i hate this. */ |
153 | 154 |
154 g_free(n); | 155 g_free(n); |
155 return m; | 156 return m; |
156 } | 157 } |
157 | 158 |
158 static char *extract_name(char *name) { | 159 static char *extract_name(const char *name) { |
159 char *tmp; | 160 char *tmp; |
160 int i, j; | 161 int i, j; |
161 char *x = strchr(name, '-'); | 162 char *x = strchr(name, '-'); |
162 if (!x) return NULL; | 163 if (!x) return NULL; |
163 x = strchr(++x, '-'); | 164 x = strchr(++x, '-'); |
856 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { | 857 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
857 struct gaim_connection *gc = sess->aux_data; | 858 struct gaim_connection *gc = sess->aux_data; |
858 struct chat_connection *chatcon; | 859 struct chat_connection *chatcon; |
859 static int id = 1; | 860 static int id = 1; |
860 | 861 |
862 aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); | |
861 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | 863 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
862 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | 864 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); |
863 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | 865 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); |
864 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | 866 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); |
865 | 867 |
872 return 1; | 874 return 1; |
873 } | 875 } |
874 | 876 |
875 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { | 877 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
876 | 878 |
879 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); | |
877 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); | 880 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
878 | 881 |
879 aim_clientready(sess, fr->conn); | 882 aim_clientready(sess, fr->conn); |
880 | 883 |
881 aim_chatnav_reqrights(sess, fr->conn); | 884 aim_chatnav_reqrights(sess, fr->conn); |
969 aim_conn_completeconnect(sess, ccon->conn); | 972 aim_conn_completeconnect(sess, ccon->conn); |
970 ccon->inpa = gaim_input_add(tstconn->fd, | 973 ccon->inpa = gaim_input_add(tstconn->fd, |
971 GAIM_INPUT_READ, | 974 GAIM_INPUT_READ, |
972 oscar_callback, tstconn); | 975 oscar_callback, tstconn); |
973 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | 976 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); |
974 aim_chat_attachname(tstconn, ccon->name); | |
975 } | 977 } |
976 | 978 |
977 /* Hrmph. I don't know how to make this look better. --mid */ | 979 /* Hrmph. I don't know how to make this look better. --mid */ |
978 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { | 980 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
979 va_list ap; | 981 va_list ap; |
980 fu16_t serviceid; | 982 struct aim_redirect_data *redir; |
981 char *ip; | |
982 fu8_t *cookie; | |
983 struct gaim_connection *gc = sess->aux_data; | 983 struct gaim_connection *gc = sess->aux_data; |
984 struct aim_user *user = gc->user; | 984 struct aim_user *user = gc->user; |
985 aim_conn_t *tstconn; | 985 aim_conn_t *tstconn; |
986 int i; | 986 int i; |
987 char *host; | 987 char *host; |
989 | 989 |
990 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | 990 port = user->proto_opt[USEROPT_AUTHPORT][0] ? |
991 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | 991 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, |
992 | 992 |
993 va_start(ap, fr); | 993 va_start(ap, fr); |
994 serviceid = (fu16_t)va_arg(ap, unsigned int); | 994 redir = va_arg(ap, struct aim_redirect_data *); |
995 ip = va_arg(ap, char *); | 995 va_end(ap); |
996 cookie = (fu8_t *)va_arg(ap, unsigned char *); | 996 |
997 | 997 for (i = 0; i < (int)strlen(redir->ip); i++) { |
998 for (i = 0; i < (int)strlen(ip); i++) { | 998 if (redir->ip[i] == ':') { |
999 if (ip[i] == ':') { | 999 port = atoi(&(redir->ip[i+1])); |
1000 port = atoi(&(ip[i+1])); | |
1001 break; | 1000 break; |
1002 } | 1001 } |
1003 } | 1002 } |
1004 host = g_strndup(ip, i); | 1003 host = g_strndup(redir->ip, i); |
1005 | 1004 |
1006 switch(serviceid) { | 1005 switch(redir->group) { |
1007 case 0x7: /* Authorizer */ | 1006 case 0x7: /* Authorizer */ |
1008 debug_printf("Reconnecting with authorizor...\n"); | 1007 debug_printf("Reconnecting with authorizor...\n"); |
1009 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | 1008 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1010 if (tstconn == NULL) { | 1009 if (tstconn == NULL) { |
1011 debug_printf("unable to reconnect with authorizer\n"); | 1010 debug_printf("unable to reconnect with authorizer\n"); |
1023 aim_conn_kill(sess, &tstconn); | 1022 aim_conn_kill(sess, &tstconn); |
1024 debug_printf("unable to reconnect with authorizer\n"); | 1023 debug_printf("unable to reconnect with authorizer\n"); |
1025 g_free(host); | 1024 g_free(host); |
1026 return 1; | 1025 return 1; |
1027 } | 1026 } |
1028 aim_sendcookie(sess, tstconn, cookie); | 1027 aim_sendcookie(sess, tstconn, redir->cookie); |
1029 break; | 1028 break; |
1030 case 0xd: /* ChatNav */ | 1029 case 0xd: /* ChatNav */ |
1031 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | 1030 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); |
1032 if (tstconn == NULL) { | 1031 if (tstconn == NULL) { |
1033 debug_printf("unable to connect to chatnav server\n"); | 1032 debug_printf("unable to connect to chatnav server\n"); |
1042 aim_conn_kill(sess, &tstconn); | 1041 aim_conn_kill(sess, &tstconn); |
1043 debug_printf("unable to connect to chatnav server\n"); | 1042 debug_printf("unable to connect to chatnav server\n"); |
1044 g_free(host); | 1043 g_free(host); |
1045 return 1; | 1044 return 1; |
1046 } | 1045 } |
1047 aim_sendcookie(sess, tstconn, cookie); | 1046 aim_sendcookie(sess, tstconn, redir->cookie); |
1048 break; | 1047 break; |
1049 case 0xe: /* Chat */ | 1048 case 0xe: /* Chat */ |
1050 { | 1049 { |
1051 char *roomname; | |
1052 fu16_t exchange; | |
1053 struct chat_connection *ccon; | 1050 struct chat_connection *ccon; |
1054 | |
1055 roomname = va_arg(ap, char *); | |
1056 exchange = (fu16_t)va_arg(ap, unsigned int); | |
1057 | 1051 |
1058 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); | 1052 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1059 if (tstconn == NULL) { | 1053 if (tstconn == NULL) { |
1060 debug_printf("unable to connect to chat server\n"); | 1054 debug_printf("unable to connect to chat server\n"); |
1061 g_free(host); | 1055 g_free(host); |
1066 | 1060 |
1067 ccon = g_new0(struct chat_connection, 1); | 1061 ccon = g_new0(struct chat_connection, 1); |
1068 ccon->conn = tstconn; | 1062 ccon->conn = tstconn; |
1069 ccon->gc = gc; | 1063 ccon->gc = gc; |
1070 ccon->fd = -1; | 1064 ccon->fd = -1; |
1071 ccon->name = g_strdup(roomname); | 1065 ccon->name = g_strdup(redir->chat.room); |
1072 ccon->exchange = exchange; | 1066 ccon->exchange = redir->chat.exchange; |
1073 ccon->show = extract_name(roomname); | 1067 ccon->instance = redir->chat.instance; |
1068 ccon->show = extract_name(redir->chat.room); | |
1074 | 1069 |
1075 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; | 1070 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
1076 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); | 1071 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); |
1077 if (ccon->conn->fd < 0) { | 1072 if (ccon->conn->fd < 0) { |
1078 aim_conn_kill(sess, &tstconn); | 1073 aim_conn_kill(sess, &tstconn); |
1081 g_free(ccon->show); | 1076 g_free(ccon->show); |
1082 g_free(ccon->name); | 1077 g_free(ccon->name); |
1083 g_free(ccon); | 1078 g_free(ccon); |
1084 return 1; | 1079 return 1; |
1085 } | 1080 } |
1086 aim_sendcookie(sess, tstconn, cookie); | 1081 aim_sendcookie(sess, tstconn, redir->cookie); |
1087 debug_printf("Connected to chat room %s exchange %d\n", roomname, exchange); | 1082 debug_printf("Connected to chat room %s exchange %d\n", ccon->name, ccon->exchange); |
1088 } | 1083 } |
1089 break; | 1084 break; |
1090 default: /* huh? */ | 1085 default: /* huh? */ |
1091 debug_printf("got redirect for unknown service 0x%04x\n", serviceid); | 1086 debug_printf("got redirect for unknown service 0x%04x\n", redir->group); |
1092 break; | 1087 break; |
1093 } | 1088 } |
1094 | |
1095 va_end(ap); | |
1096 | 1089 |
1097 g_free(host); | 1090 g_free(host); |
1098 return 1; | 1091 return 1; |
1099 } | 1092 } |
1100 | 1093 |