Mercurial > pidgin.yaz
comparison src/toc.c @ 1087:56c7ceb986a8
[gaim-migrate @ 1097]
thank god, someone finally redid the proxy stuff. i think most of it works even. isn't that neat? thanks adam.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 12 Nov 2000 23:54:07 +0000 |
parents | 713b0e14e0a9 |
children | 18a14e6dd0af |
comparison
equal
deleted
inserted
replaced
1086:ce201056e7a6 | 1087:56c7ceb986a8 |
---|---|
37 #include <sys/socket.h> | 37 #include <sys/socket.h> |
38 #include "prpl.h" | 38 #include "prpl.h" |
39 #include "multi.h" | 39 #include "multi.h" |
40 #include "gaim.h" | 40 #include "gaim.h" |
41 #include "gnome_applet_mgr.h" | 41 #include "gnome_applet_mgr.h" |
42 #include "proxy.h" | |
42 | 43 |
43 #include "pixmaps/admin_icon.xpm" | 44 #include "pixmaps/admin_icon.xpm" |
44 #include "pixmaps/aol_icon.xpm" | 45 #include "pixmaps/aol_icon.xpm" |
45 #include "pixmaps/away_icon.xpm" | 46 #include "pixmaps/away_icon.xpm" |
46 #include "pixmaps/dt_icon.xpm" | 47 #include "pixmaps/dt_icon.xpm" |
47 #include "pixmaps/free_icon.xpm" | 48 #include "pixmaps/free_icon.xpm" |
48 | 49 |
49 #define REVISION "gaim:$Revision: 1061 $" | 50 #define REVISION "gaim:$Revision: 1097 $" |
50 | 51 |
51 struct toc_data { | 52 struct toc_data { |
52 int toc_fd; | 53 int toc_fd; |
53 int seqno; | 54 int seqno; |
54 int state; | 55 int state; |
60 static int win32_r; | 61 static int win32_r; |
61 #endif | 62 #endif |
62 | 63 |
63 static int toc_signon(struct gaim_connection *); | 64 static int toc_signon(struct gaim_connection *); |
64 | 65 |
65 | 66 /* constants to identify proto_opts */ |
67 #define USEROPT_AUTH 0 | |
68 #define USEROPT_AUTHPORT 1 | |
69 #define USEROPT_SOCKSHOST 2 | |
70 #define USEROPT_SOCKSPORT 3 | |
71 #define USEROPT_PROXYTYPE 4 | |
66 | 72 |
67 /* ok. this function used to take username/password, and return 0 on success. | 73 /* ok. this function used to take username/password, and return 0 on success. |
68 * now, it takes username/password, and returns NULL on error or a new gaim_connection | 74 * now, it takes username/password, and returns NULL on error or a new gaim_connection |
69 * on success. */ | 75 * on success. */ |
70 void toc_login(struct aim_user *user) | 76 void toc_login(struct aim_user *user) |
71 { | 77 { |
72 char *config; | 78 char *config; |
73 struct in_addr *sin; | |
74 struct gaim_connection *gc; | 79 struct gaim_connection *gc; |
75 struct toc_data *tdt; | 80 struct toc_data *tdt; |
76 char buf[80]; | 81 char buf[80]; |
77 char buf2[2048]; | 82 char buf2[2048]; |
78 | 83 |
82 g_snprintf(buf, sizeof(buf), "Looking up %s", aim_host); | 87 g_snprintf(buf, sizeof(buf), "Looking up %s", aim_host); |
83 set_login_progress(gc, 1, buf); | 88 set_login_progress(gc, 1, buf); |
84 while (gtk_events_pending()) | 89 while (gtk_events_pending()) |
85 gtk_main_iteration(); | 90 gtk_main_iteration(); |
86 | 91 |
87 sin = (struct in_addr *)get_address(aim_host); | 92 tdt->toc_fd = proxy_connect( |
88 if (!sin) { | 93 user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST, |
89 g_snprintf(buf, sizeof(buf), "Unable to lookup %s", aim_host); | 94 user->proto_opt[USEROPT_AUTHPORT][0] ? atoi(user->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, |
90 hide_login_progress(gc, buf); | 95 user->proto_opt[USEROPT_SOCKSHOST], atoi(user->proto_opt[USEROPT_SOCKSPORT]), |
91 destroy_gaim_conn(gc); | 96 atoi(user->proto_opt[USEROPT_PROXYTYPE])); |
92 return; | |
93 } | |
94 | |
95 g_snprintf(toc_addy, sizeof(toc_addy), "%s", inet_ntoa(*sin)); | |
96 g_snprintf(buf, sizeof(buf), "Connecting to %s", inet_ntoa(*sin)); | |
97 set_login_progress(gc, 2, buf); | |
98 while (gtk_events_pending()) | |
99 gtk_main_iteration(); | |
100 | |
101 | |
102 | |
103 tdt->toc_fd = connect_address(sin->s_addr, aim_port); | |
104 | 97 |
105 if (tdt->toc_fd < 0) { | 98 if (tdt->toc_fd < 0) { |
106 g_snprintf(buf, sizeof(buf), "Connect to %s failed", | 99 g_snprintf(buf, sizeof(buf), "Connect to %s failed", |
107 inet_ntoa(*sin)); | 100 user->proto_opt[USEROPT_AUTH]); |
108 hide_login_progress(gc, buf); | 101 hide_login_progress(gc, buf); |
109 destroy_gaim_conn(gc); | 102 destroy_gaim_conn(gc); |
110 return; | 103 return; |
111 } | 104 } |
112 | 105 |
113 g_free(sin); | |
114 | |
115 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); | 106 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); |
116 set_login_progress(gc, 3, buf); | 107 set_login_progress(gc, 3, buf); |
117 while (gtk_events_pending()) | 108 while (gtk_events_pending()) |
118 gtk_main_iteration(); | 109 gtk_main_iteration(); |
119 | 110 |
460 name = strtok(NULL, ":"); | 451 name = strtok(NULL, ":"); |
461 url = strtok(NULL, ":"); | 452 url = strtok(NULL, ":"); |
462 | 453 |
463 | 454 |
464 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", toc_addy, aim_port, url); | 455 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", toc_addy, aim_port, url); |
465 /* fprintf(stdout, "Name: %s\n%s\n", name, url); | 456 g_show_info(gc->user, tmp); |
466 printf("%s", grab_url(tmp));*/ | |
467 g_show_info(tmp); | |
468 } else if (!strcasecmp(c, "EVILED")) { | 457 } else if (!strcasecmp(c, "EVILED")) { |
469 int lev; | 458 int lev; |
470 char *name = NULL; | 459 char *name = NULL; |
471 | 460 |
472 sscanf(strtok(NULL, ":"), "%d", &lev); | 461 sscanf(strtok(NULL, ":"), "%d", &lev); |
727 | 716 |
728 sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON); | 717 sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON); |
729 | 718 |
730 g_snprintf(buf, sizeof(buf), | 719 g_snprintf(buf, sizeof(buf), |
731 "toc_signon %s %d %s %s %s \"%s\"", | 720 "toc_signon %s %d %s %s %s \"%s\"", |
732 login_host, login_port, normalize(gc->username), roast_password(gc->password), LANGUAGE, REVISION); | 721 AUTH_HOST, AUTH_PORT, normalize(gc->username), roast_password(gc->password), |
722 LANGUAGE, REVISION); | |
733 | 723 |
734 sprintf(debug_buff,"Send: %s\n", buf); | 724 sprintf(debug_buff,"Send: %s\n", buf); |
735 debug_print(debug_buff); | 725 debug_print(debug_buff); |
736 | 726 |
737 return sflap_send(gc, buf, -1, TYPE_DATA); | 727 return sflap_send(gc, buf, -1, TYPE_DATA); |
1140 gtk_object_set_user_data(GTK_OBJECT(button), gc); | 1130 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
1141 gtk_menu_append(GTK_MENU(menu), button); | 1131 gtk_menu_append(GTK_MENU(menu), button); |
1142 gtk_widget_show(button); | 1132 gtk_widget_show(button); |
1143 } | 1133 } |
1144 | 1134 |
1135 static void toc_print_option(GtkEntry *entry, struct aim_user *user) { | |
1136 int entrynum; | |
1137 | |
1138 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); | |
1139 | |
1140 if (entrynum == USEROPT_AUTH) { | |
1141 g_snprintf(user->proto_opt[USEROPT_AUTH], | |
1142 sizeof(user->proto_opt[USEROPT_AUTH]), | |
1143 "%s", gtk_entry_get_text(entry)); | |
1144 } else if (entrynum == USEROPT_AUTHPORT) { | |
1145 g_snprintf(user->proto_opt[USEROPT_AUTHPORT], | |
1146 sizeof(user->proto_opt[USEROPT_AUTHPORT]), | |
1147 "%s", gtk_entry_get_text(entry)); | |
1148 } else if (entrynum == USEROPT_SOCKSHOST) { | |
1149 g_snprintf(user->proto_opt[USEROPT_SOCKSHOST], | |
1150 sizeof(user->proto_opt[USEROPT_SOCKSHOST]), | |
1151 "%s", gtk_entry_get_text(entry)); | |
1152 } else if (entrynum == USEROPT_SOCKSPORT) { | |
1153 g_snprintf(user->proto_opt[USEROPT_SOCKSPORT], | |
1154 sizeof(user->proto_opt[USEROPT_SOCKSPORT]), | |
1155 "%s", gtk_entry_get_text(entry)); | |
1156 } | |
1157 } | |
1158 | |
1159 static void toc_print_optionrad(GtkRadioButton *entry, struct aim_user *user) { | |
1160 int entrynum; | |
1161 | |
1162 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); | |
1163 | |
1164 g_snprintf(user->proto_opt[USEROPT_PROXYTYPE], | |
1165 sizeof(user->proto_opt[USEROPT_PROXYTYPE]), | |
1166 "%d", entrynum); | |
1167 } | |
1168 | |
1169 static void toc_user_opts(GtkWidget *book, struct aim_user *user) { | |
1170 /* so here, we create the new notebook page */ | |
1171 GtkWidget *vbox; | |
1172 GtkWidget *hbox; | |
1173 GtkWidget *label; | |
1174 GtkWidget *entry; | |
1175 GtkWidget *first, *opt; | |
1176 | |
1177 vbox = gtk_vbox_new(FALSE, 0); | |
1178 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, | |
1179 gtk_label_new("TOC Options")); | |
1180 gtk_widget_show(vbox); | |
1181 | |
1182 | |
1183 hbox = gtk_hbox_new(FALSE, 0); | |
1184 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
1185 gtk_widget_show(hbox); | |
1186 | |
1187 label = gtk_label_new("TOC Host:"); | |
1188 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1189 gtk_widget_show(label); | |
1190 | |
1191 entry = gtk_entry_new(); | |
1192 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
1193 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTH); | |
1194 gtk_signal_connect(GTK_OBJECT(entry), "changed", | |
1195 GTK_SIGNAL_FUNC(toc_print_option), user); | |
1196 if (user->proto_opt[USEROPT_AUTH][0]) { | |
1197 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTH]); | |
1198 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTH]); | |
1199 } else | |
1200 gtk_entry_set_text(GTK_ENTRY(entry), "toc.oscar.aol.com"); | |
1201 gtk_widget_show(entry); | |
1202 | |
1203 hbox = gtk_hbox_new(FALSE, 0); | |
1204 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
1205 gtk_widget_show(hbox); | |
1206 | |
1207 | |
1208 label = gtk_label_new("TOC Port:"); | |
1209 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1210 gtk_widget_show(label); | |
1211 | |
1212 entry = gtk_entry_new(); | |
1213 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
1214 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)1); | |
1215 gtk_signal_connect(GTK_OBJECT(entry), "changed", | |
1216 GTK_SIGNAL_FUNC(toc_print_option), user); | |
1217 if (user->proto_opt[USEROPT_AUTHPORT][0]) { | |
1218 debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTHPORT]); | |
1219 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHPORT]); | |
1220 } else | |
1221 gtk_entry_set_text(GTK_ENTRY(entry), "9898"); | |
1222 | |
1223 gtk_widget_show(entry); | |
1224 | |
1225 | |
1226 hbox = gtk_hbox_new(FALSE, 0); | |
1227 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
1228 gtk_widget_show(hbox); | |
1229 | |
1230 label = gtk_label_new("Proxy Host:"); | |
1231 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1232 gtk_widget_show(label); | |
1233 | |
1234 entry = gtk_entry_new(); | |
1235 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
1236 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SOCKSHOST); | |
1237 gtk_signal_connect(GTK_OBJECT(entry), "changed", | |
1238 GTK_SIGNAL_FUNC(toc_print_option), user); | |
1239 if (user->proto_opt[USEROPT_SOCKSHOST][0]) { | |
1240 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SOCKSHOST]); | |
1241 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SOCKSHOST]); | |
1242 } | |
1243 gtk_widget_show(entry); | |
1244 | |
1245 | |
1246 hbox = gtk_hbox_new(FALSE, 0); | |
1247 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
1248 gtk_widget_show(hbox); | |
1249 | |
1250 label = gtk_label_new("Proxy Port:"); | |
1251 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1252 gtk_widget_show(label); | |
1253 | |
1254 entry = gtk_entry_new(); | |
1255 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
1256 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_SOCKSPORT); | |
1257 gtk_signal_connect(GTK_OBJECT(entry), "changed", | |
1258 GTK_SIGNAL_FUNC(toc_print_option), user); | |
1259 if (user->proto_opt[USEROPT_SOCKSPORT][0]) { | |
1260 debug_printf("setting text %s\n", user->proto_opt[USEROPT_SOCKSPORT]); | |
1261 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_SOCKSPORT]); | |
1262 } | |
1263 gtk_widget_show(entry); | |
1264 | |
1265 | |
1266 first = gtk_radio_button_new_with_label(NULL, "No proxy"); | |
1267 gtk_box_pack_start(GTK_BOX(vbox), first, FALSE, FALSE, 0); | |
1268 gtk_object_set_user_data(GTK_OBJECT(first), (void *)PROXY_NONE); | |
1269 gtk_signal_connect(GTK_OBJECT(first), "clicked", GTK_SIGNAL_FUNC(toc_print_optionrad), user); | |
1270 gtk_widget_show(first); | |
1271 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_NONE) | |
1272 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(first), TRUE); | |
1273 | |
1274 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 4"); | |
1275 gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0); | |
1276 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS4); | |
1277 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(toc_print_optionrad), user); | |
1278 gtk_widget_show(opt); | |
1279 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS4) | |
1280 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
1281 | |
1282 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 5"); | |
1283 gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0); | |
1284 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS5); | |
1285 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(toc_print_optionrad), user); | |
1286 gtk_widget_show(opt); | |
1287 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS5) | |
1288 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
1289 | |
1290 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "HTTP"); | |
1291 gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0); | |
1292 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_HTTP); | |
1293 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(toc_print_optionrad), user); | |
1294 gtk_widget_show(opt); | |
1295 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_HTTP) | |
1296 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); | |
1297 } | |
1298 | |
1145 void toc_init(struct prpl *ret) { | 1299 void toc_init(struct prpl *ret) { |
1146 ret->protocol = PROTO_TOC; | 1300 ret->protocol = PROTO_TOC; |
1147 ret->name = toc_name; | 1301 ret->name = toc_name; |
1148 ret->list_icon = toc_list_icon; | 1302 ret->list_icon = toc_list_icon; |
1149 ret->action_menu = toc_action_menu; | 1303 ret->action_menu = toc_action_menu; |
1304 ret->user_opts = toc_user_opts; | |
1150 ret->login = toc_login; | 1305 ret->login = toc_login; |
1151 ret->close = toc_close; | 1306 ret->close = toc_close; |
1152 ret->send_im = toc_send_im; | 1307 ret->send_im = toc_send_im; |
1153 ret->set_info = toc_set_info; | 1308 ret->set_info = toc_set_info; |
1154 ret->get_info = toc_get_info; | 1309 ret->get_info = toc_get_info; |