src/protocols/toc/toc.c

changeset 4597
938654764710
parent 4491
715515ab95da
child 4617
35d860860593
equal deleted inserted replaced
4596:64e72bf4ece4 4597:938654764710
121 void *data; 121 void *data;
122 }; 122 };
123 123
124 struct toc_data { 124 struct toc_data {
125 int toc_fd; 125 int toc_fd;
126 char toc_ip[20];
126 int seqno; 127 int seqno;
127 int state; 128 int state;
128 }; 129 };
129 130
130 struct sflap_hdr { 131 struct sflap_hdr {
213 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) 214 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond)
214 { 215 {
215 struct gaim_connection *gc = data; 216 struct gaim_connection *gc = data;
216 struct toc_data *tdt; 217 struct toc_data *tdt;
217 char buf[80]; 218 char buf[80];
219 struct sockaddr_in name;
220 socklen_t namelen;
218 221
219 if (!g_slist_find(connections, data)) { 222 if (!g_slist_find(connections, data)) {
220 toc_soc_close(source); 223 toc_soc_close(source);
221 return; 224 return;
222 } 225 }
228 hide_login_progress(gc, "Unable to connect."); 231 hide_login_progress(gc, "Unable to connect.");
229 signoff(gc); 232 signoff(gc);
230 return; 233 return;
231 } 234 }
232 tdt->toc_fd = source; 235 tdt->toc_fd = source;
236
237 /*
238 * Copy the IP that we're connected to. We need this because "GOTO_URL"'s
239 * should open on the exact server we're connected to. toc.oscar.aol.com
240 * doesn't work because that hostname resolves to multiple IP addresses.
241 */
242 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0)
243 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip));
244 else if (gc->account && gc->account->proto_opt[USEROPT_AUTH][0])
245 strncpy(tdt->toc_ip, gc->account->proto_opt[USEROPT_AUTH], sizeof(tdt->toc_ip));
246 else
247 strncpy(tdt->toc_ip, TOC_HOST, sizeof(tdt->toc_ip));
233 248
234 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); 249 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n");
235 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { 250 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) {
236 hide_login_progress(gc, "Disconnected."); 251 hide_login_progress(gc, "Disconnected.");
237 signoff(gc); 252 signoff(gc);
806 char *name, *url, tmp[256]; 821 char *name, *url, tmp[256];
807 822
808 name = strtok(NULL, ":"); 823 name = strtok(NULL, ":");
809 url = strtok(NULL, ":"); 824 url = strtok(NULL, ":");
810 825
811 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", 826 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip,
812 gc->account->proto_opt[USEROPT_AUTH][0] ?
813 gc->account->proto_opt[USEROPT_AUTH] : TOC_HOST,
814 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? 827 gc->account->proto_opt[USEROPT_AUTHPORT][0] ?
815 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, 828 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT,
816 url); 829 url);
817 grab_url(tmp, FALSE, toc_got_info, NULL); 830 grab_url(tmp, FALSE, toc_got_info, NULL);
818 } else if (!strcasecmp(c, "DIR_STATUS")) { 831 } else if (!strcasecmp(c, "DIR_STATUS")) {

mercurial