src/protocols/toc/toc.c

changeset 4452
1e5d62c19533
parent 4359
cf899ee07d1d
child 4455
f09f1124abc8
equal deleted inserted replaced
4451:5a484f11e395 4452:1e5d62c19533
196 g_snprintf(buf, sizeof buf, "Looking up %s", 196 g_snprintf(buf, sizeof buf, "Looking up %s",
197 user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST); 197 user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST);
198 set_login_progress(gc, 1, buf); 198 set_login_progress(gc, 1, buf);
199 199
200 debug_printf("* Client connects to TOC\n"); 200 debug_printf("* Client connects to TOC\n");
201 tdt->toc_fd = 201 if (proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST,
202 proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST,
203 user->proto_opt[USEROPT_AUTHPORT][0] ? 202 user->proto_opt[USEROPT_AUTHPORT][0] ?
204 atoi(user->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, 203 atoi(user->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT,
205 toc_login_callback, gc); 204 toc_login_callback, gc) != 0 || !user->gc) {
206
207 if (!user->gc || (tdt->toc_fd < 0)) {
208 g_snprintf(buf, sizeof(buf), "Connect to %s failed", user->proto_opt[USEROPT_AUTH]); 205 g_snprintf(buf, sizeof(buf), "Connect to %s failed", user->proto_opt[USEROPT_AUTH]);
209 hide_login_progress(gc, buf); 206 hide_login_progress(gc, buf);
210 signoff(gc); 207 signoff(gc);
211 return; 208 return;
212 } 209 }
229 /* we didn't successfully connect. tdt->toc_fd is valid here */ 226 /* we didn't successfully connect. tdt->toc_fd is valid here */
230 hide_login_progress(gc, "Unable to connect."); 227 hide_login_progress(gc, "Unable to connect.");
231 signoff(gc); 228 signoff(gc);
232 return; 229 return;
233 } 230 }
234 231 tdt->toc_fd = source;
235 if (tdt->toc_fd == 0)
236 tdt->toc_fd = source;
237 232
238 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); 233 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n");
239 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { 234 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) {
240 hide_login_progress(gc, "Disconnected."); 235 hide_login_progress(gc, "Disconnected.");
241 signoff(gc); 236 signoff(gc);
1692 gtk_widget_destroy(old_ft->window); 1687 gtk_widget_destroy(old_ft->window);
1693 1688
1694 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); 1689 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID);
1695 sflap_send(ft->gc, buf, -1, TYPE_DATA); 1690 sflap_send(ft->gc, buf, -1, TYPE_DATA);
1696 1691
1697 fd = 1692 if (proxy_connect(ft->ip, ft->port, toc_send_file_connect, ft) != 0) {
1698 proxy_connect(ft->ip, ft->port, toc_send_file_connect, ft);
1699 if (fd < 0) {
1700 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); 1693 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR);
1701 g_free(ft->filename); 1694 g_free(ft->filename);
1702 g_free(ft->cookie); 1695 g_free(ft->cookie);
1703 g_free(ft->user); 1696 g_free(ft->user);
1704 g_free(ft->ip); 1697 g_free(ft->ip);
1861 1854
1862 static void toc_get_file(gpointer a, struct file_transfer *old_ft) 1855 static void toc_get_file(gpointer a, struct file_transfer *old_ft)
1863 { 1856 {
1864 struct file_transfer *ft; 1857 struct file_transfer *ft;
1865 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); 1858 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window));
1866 int fd;
1867 struct aim_user *user; 1859 struct aim_user *user;
1868 char *buf, buf2[BUF_LEN * 2]; 1860 char *buf, buf2[BUF_LEN * 2];
1869 1861
1870 if (file_is_dir(dirname, old_ft->window)) 1862 if (file_is_dir(dirname, old_ft->window))
1871 return; 1863 return;
1897 gtk_widget_destroy(old_ft->window); 1889 gtk_widget_destroy(old_ft->window);
1898 1890
1899 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); 1891 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID);
1900 sflap_send(ft->gc, buf2, -1, TYPE_DATA); 1892 sflap_send(ft->gc, buf2, -1, TYPE_DATA);
1901 1893
1902 fd = 1894 if (proxy_connect(ft->ip, ft->port, toc_get_file_connect, ft) < 0) {
1903 proxy_connect(ft->ip, ft->port, toc_get_file_connect, ft);
1904 if (fd < 0) {
1905 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); 1895 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR);
1906 fclose(ft->file); 1896 fclose(ft->file);
1907 g_free(ft->filename); 1897 g_free(ft->filename);
1908 g_free(ft->cookie); 1898 g_free(ft->cookie);
1909 g_free(ft->user); 1899 g_free(ft->user);

mercurial