Mercurial > pidgin.yaz
comparison src/dialogs.c @ 194:d7690984c0f1
[gaim-migrate @ 204]
File Transfer is almost done, it's just the little bugs now.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 29 Apr 2000 12:56:55 +0000 |
parents | f5c3e340c5e4 |
children | a82e9f91a6fc |
comparison
equal
deleted
inserted
replaced
193:6af9b88e4f90 | 194:d7690984c0f1 |
---|---|
39 | 39 |
40 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ | 40 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ |
41 static GList *dialogwindows = NULL; | 41 static GList *dialogwindows = NULL; |
42 static GtkWidget *linkdialog, *colordialog, *exportdialog, *importdialog, *logdialog; | 42 static GtkWidget *linkdialog, *colordialog, *exportdialog, *importdialog, *logdialog; |
43 | 43 |
44 /*static void accept_callback(GtkWidget *widget, struct file_transfer *t);*/ | 44 static void accept_callback(GtkWidget *widget, struct file_transfer *t); |
45 | 45 |
46 struct create_away { | 46 struct create_away { |
47 GtkWidget *window; | 47 GtkWidget *window; |
48 GtkWidget *entry; | 48 GtkWidget *entry; |
49 GtkWidget *text; | 49 GtkWidget *text; |
2191 gtk_widget_show(ca->window); | 2191 gtk_widget_show(ca->window); |
2192 | 2192 |
2193 | 2193 |
2194 } | 2194 } |
2195 | 2195 |
2196 #if 0 | |
2197 | |
2198 /*------------------------------------------------------------------------*/ | 2196 /*------------------------------------------------------------------------*/ |
2199 /* The dialog for file requests */ | 2197 /* The dialog for file requests */ |
2200 /*------------------------------------------------------------------------*/ | 2198 /*------------------------------------------------------------------------*/ |
2201 | 2199 |
2202 | 2200 |
2247 | 2245 |
2248 | 2246 |
2249 static int get_16_int(char *text) | 2247 static int get_16_int(char *text) |
2250 { | 2248 { |
2251 int tmp = 0; | 2249 int tmp = 0; |
2252 tmp = ((*text << 8) & 0xff); | 2250 tmp = ((*text << 8) & 0xff00); |
2253 text++; | 2251 text++; |
2254 tmp |= (*text & 0xff); | 2252 tmp |= (*text & 0xff); |
2255 text++; | 2253 text++; |
2256 return tmp; | 2254 return tmp; |
2257 } | 2255 } |
2258 | 2256 |
2259 static int get_32_int(char *text) | 2257 static int get_32_int(char *text) |
2260 { | 2258 { |
2261 int tmp = 0; | 2259 int tmp = 0; |
2262 tmp = ((*text << 24) & 0xff); | 2260 tmp = ((*text << 24) & 0xff000000); |
2263 text++; | 2261 text++; |
2264 tmp |= ((*text << 16) & 0xff); | 2262 tmp |= ((*text << 16) & 0xff0000); |
2265 text++; | 2263 text++; |
2266 tmp |= ((*text << 8) & 0xff); | 2264 tmp |= ((*text << 8) & 0xff00); |
2267 text++; | 2265 text++; |
2268 tmp |= (*text & 0xff); | 2266 tmp |= (*text & 0xff); |
2269 text++; | 2267 text++; |
2270 return tmp; | 2268 return tmp; |
2271 } | 2269 } |
2274 { | 2272 { |
2275 char *send = g_malloc(256); | 2273 char *send = g_malloc(256); |
2276 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window)); | 2274 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window)); |
2277 char *buf; | 2275 char *buf; |
2278 char *header; | 2276 char *header; |
2279 int hdrlen; | 2277 short hdrlen; |
2280 int read_rv; | 2278 int read_rv; |
2281 char bmagic[5]; | 2279 char bmagic[7]; |
2282 struct sockaddr_in sin; | 2280 struct sockaddr_in sin; |
2283 int rcv; | 2281 guint32 rcv; |
2284 gint hdrtype, encrypt, compress, totfiles, filesleft; | 2282 guint32 size; |
2285 gint totparts, partsleft, totsize, size, modtime, checksum; | |
2286 gint rfrcsum, rfsize, cretime, rfcsum, nrecvd, recvcsum; | |
2287 char *bcookie, *idstring; | |
2288 char flags, lnameoffset, lsizeoffset, dummy; | |
2289 char *macfileinfo; | |
2290 gint nencode, nlanguage; | |
2291 char *name; | |
2292 char *c; | 2283 char *c; |
2293 | 2284 GtkWidget *fw = NULL, *fbar = NULL, *label; |
2294 | 2285 |
2295 if (!(ft->f = fopen(file,"w"))) { | 2286 if (!(ft->f = fopen(file,"w"))) { |
2296 buf = g_malloc(BUF_LONG); | 2287 buf = g_malloc(BUF_LONG); |
2297 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); | 2288 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); |
2298 do_error_dialog(buf, "Error"); | 2289 do_error_dialog(buf, "Error"); |
2316 sin.sin_port = htons(ft->port); | 2307 sin.sin_port = htons(ft->port); |
2317 | 2308 |
2318 ft->fd = socket(AF_INET, SOCK_STREAM, 0); | 2309 ft->fd = socket(AF_INET, SOCK_STREAM, 0); |
2319 | 2310 |
2320 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) { | 2311 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) { |
2321 g_free(buf); | |
2322 return; | 2312 return; |
2323 /*cancel */ | |
2324 } | 2313 } |
2325 | 2314 |
2326 rcv = 0; | 2315 rcv = 0; |
2327 header = g_malloc(6); | 2316 header = g_malloc(6); |
2328 while (rcv != 6) { | 2317 while (rcv != 6) { |
2329 read_rv = read(ft->fd, header + rcv, 6 - rcv); | 2318 read_rv = read(ft->fd, header + rcv, 6 - rcv); |
2330 if(read_rv < 0) { | 2319 if(read_rv < 0) { |
2320 close(ft->fd); | |
2331 g_free(header); | 2321 g_free(header); |
2332 g_free(buf); | |
2333 return; | 2322 return; |
2334 } | 2323 } |
2335 rcv += read_rv; | 2324 rcv += read_rv; |
2336 while(gtk_events_pending()) | 2325 while(gtk_events_pending()) |
2337 gtk_main_iteration(); | 2326 gtk_main_iteration(); |
2338 } | 2327 } |
2339 | 2328 |
2340 strncpy(bmagic, header, 4); | 2329 strncpy(bmagic, header, 6); |
2341 bmagic[4] = 0; | 2330 bmagic[6] = 0; |
2342 | 2331 |
2343 hdrlen = ((header[4] << 8) & 0xff) | (header[5] & 0xff); | 2332 hdrlen = get_16_int(&header[4]); |
2333 hdrlen -= 6; | |
2334 sprintf(debug_buff, "my header is %d\n", hdrlen); | |
2335 debug_print(debug_buff); | |
2336 | |
2337 hdrlen = 0; | |
2338 hdrlen = header[4]; | |
2339 hdrlen <<= 8; | |
2340 hdrlen |= header[5]; | |
2341 hdrlen -= 6; | |
2342 | |
2343 sprintf(debug_buff, "header length %d\n", hdrlen); | |
2344 debug_print(debug_buff); | |
2344 | 2345 |
2345 g_free(header); | 2346 g_free(header); |
2346 header = g_malloc(hdrlen+1); | 2347 header = g_malloc(hdrlen); |
2347 | 2348 |
2348 rcv = 0; | 2349 rcv = 0; |
2349 | 2350 |
2350 while (rcv != hdrlen) { | 2351 while (rcv != hdrlen) { |
2351 read_rv = read(ft->fd, header + rcv, hdrlen - rcv); | 2352 read_rv = read(ft->fd, header + rcv, hdrlen - rcv); |
2352 if(read_rv < 0) { | 2353 if(read_rv < 0) { |
2354 close(ft->fd); | |
2353 g_free(header); | 2355 g_free(header); |
2354 g_free(buf); | |
2355 return; | 2356 return; |
2356 } | 2357 } |
2357 rcv += read_rv; | 2358 rcv += read_rv; |
2358 while(gtk_events_pending()) | 2359 while(gtk_events_pending()) |
2359 gtk_main_iteration(); | 2360 gtk_main_iteration(); |
2360 } | 2361 } |
2361 | 2362 |
2362 header[hdrlen] = 0; | |
2363 | |
2364 c = header; | 2363 c = header; |
2365 | 2364 |
2366 | 2365 header[0] = 2; header[1] = 2; |
2367 hdrtype = get_16_int(c); | 2366 memcpy(header + 2, ft->cookie, 8); |
2368 bcookie = g_malloc(9); | 2367 memset(header + 62, 0, 32); strcpy(header + 62, "Gaim"); |
2369 strncpy(bcookie, c, 8); | 2368 memset(header + 10, 0, 4); |
2370 c+=8; | 2369 header[20] = 1; header[21] = 0; |
2371 bcookie[8] = 0; | 2370 header[22] = header[20]; header[23] = header[21]; |
2372 | 2371 |
2373 encrypt = get_16_int(c); c+=2; | 2372 sprintf(debug_buff, "sending confirmation\n"); |
2374 compress = get_16_int(c); c+=2; | 2373 debug_print(debug_buff); |
2375 totfiles = get_16_int(c); c+=2; | 2374 write(ft->fd, bmagic, 6); |
2376 filesleft = get_16_int(c); c+=2; | 2375 write(ft->fd, header, hdrlen); |
2377 totparts = get_16_int(c); c+=2; | 2376 |
2378 partsleft = get_16_int(c); c+=2; | 2377 buf = g_malloc(1024); |
2379 totsize = get_32_int(c); c+=4; | 2378 rcv = 0; |
2380 size = get_32_int(c); c+=4; | 2379 |
2381 modtime = get_32_int(c); c+=4; | 2380 fw = gtk_dialog_new(); |
2382 checksum = get_32_int(c); c+=4; | 2381 label = gtk_label_new("Receiving file"); |
2383 rfrcsum = get_32_int(c); c+=4; | 2382 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->vbox), label, 0, 0, 5); |
2384 rfsize = get_32_int(c); c+=4; | 2383 gtk_widget_show(label); |
2385 cretime = get_32_int(c); c+=4; | 2384 fbar = gtk_progress_bar_new(); |
2386 rfcsum = get_32_int(c); c+=4; | 2385 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), fbar, 0, 0, 5); |
2387 nrecvd = get_32_int(c); c+=4; | 2386 gtk_widget_show(fbar); |
2388 recvcsum = get_32_int(c); c+=4; | 2387 gtk_window_set_title(GTK_WINDOW(fw), "File Transfer"); |
2389 idstring = g_malloc(33); | 2388 gtk_widget_realize(fw); |
2390 strncpy(idstring, c, 32); | 2389 aol_icon(fw->window); |
2391 c+=32; | 2390 gtk_widget_show(fw); |
2392 idstring[32] = 0; | 2391 |
2393 flags = *c; c++; | 2392 size = get_32_int(header + 22); |
2394 lnameoffset = *c; c++; | 2393 sprintf(debug_buff, "Receiving %d bytes\n", size); |
2395 lsizeoffset = *c; c++; | 2394 debug_print(debug_buff); |
2396 dummy = *c; c++; | 2395 /* |
2397 | 2396 while (rcv != size) { |
2398 macfileinfo = g_malloc(70); | 2397 int i; |
2399 strncpy(macfileinfo, c, 69); | 2398 read_rv = read(ft->fd, buf, 1024); |
2400 c+=69; | 2399 if(read_rv < 0) { |
2401 macfileinfo[69] = 0; | 2400 close(ft->fd); |
2402 nencode = get_16_int(c); c+=2; | 2401 g_free(buf); |
2403 nlanguage = get_16_int(c); c+=2; | 2402 g_free(header); |
2404 | 2403 return; |
2405 name = g_strdup(c); | 2404 } |
2406 | 2405 rcv += read_rv; |
2407 | 2406 for (i = 0; i < read_rv; i++) |
2408 totparts = 1; | 2407 fprintf(ft->f, "%c", buf[i]); |
2409 partsleft = 1; | 2408 gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar), |
2410 rfsize = 0; | 2409 (float)(rcv)/(float)(size)); |
2411 | 2410 while(gtk_events_pending()) |
2412 | 2411 gtk_main_iteration(); |
2413 printf("Header type: %d\n", hdrtype); | 2412 } |
2414 printf("Encryption: %d\n", encrypt); | 2413 */ |
2415 printf("Compress: %d\n", compress); | 2414 gtk_widget_destroy(fw); |
2416 | 2415 fclose(ft->f); |
2417 | 2416 memset(header + 18, 0, 4); |
2418 | 2417 header[94] = 0; |
2419 | 2418 header[1] = 0x04; |
2419 memcpy(header+58, header+34, 4); | |
2420 memcpy(header+54, header+22, 4); | |
2421 write(ft->fd, bmagic, 6); | |
2422 write(ft->fd, header, hdrlen); | |
2423 close(ft->fd); | |
2424 | |
2425 g_free(buf); | |
2426 g_free(header); | |
2420 } | 2427 } |
2421 | 2428 |
2422 | 2429 |
2423 static void accept_callback(GtkWidget *widget, struct file_transfer *ft) | 2430 static void accept_callback(GtkWidget *widget, struct file_transfer *ft) |
2424 { | 2431 { |
2504 label = gtk_label_new(buf); | 2511 label = gtk_label_new(buf); |
2505 gtk_widget_show(label); | 2512 gtk_widget_show(label); |
2506 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); | 2513 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); |
2507 | 2514 |
2508 if (ft->message) { | 2515 if (ft->message) { |
2516 /* we'll do this later | |
2509 text = gaim_new_layout(); | 2517 text = gaim_new_layout(); |
2510 sw = gtk_scrolled_window_new (NULL, NULL); | 2518 sw = gtk_scrolled_window_new (NULL, NULL); |
2511 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | 2519 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), |
2512 GTK_POLICY_NEVER, | 2520 GTK_POLICY_NEVER, |
2513 GTK_POLICY_AUTOMATIC); | 2521 GTK_POLICY_AUTOMATIC); |
2518 gtk_layout_set_size(GTK_LAYOUT(text), 250, 100); | 2526 gtk_layout_set_size(GTK_LAYOUT(text), 250, 100); |
2519 GTK_LAYOUT (text)->vadjustment->step_increment = 10.0; | 2527 GTK_LAYOUT (text)->vadjustment->step_increment = 10.0; |
2520 gtk_widget_set_usize(sw, 250, 100); | 2528 gtk_widget_set_usize(sw, 250, 100); |
2521 | 2529 |
2522 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 10); | 2530 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 10); |
2531 */ | |
2523 } | 2532 } |
2524 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); | 2533 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); |
2525 | 2534 |
2526 gtk_window_set_title(GTK_WINDOW(ft->window), "Gaim - Accept File?"); | 2535 gtk_window_set_title(GTK_WINDOW(ft->window), "Gaim - Accept File?"); |
2527 gtk_window_set_focus(GTK_WINDOW(ft->window), accept); | 2536 gtk_window_set_focus(GTK_WINDOW(ft->window), accept); |
2544 gtk_signal_connect(GTK_OBJECT(info), "clicked", | 2553 gtk_signal_connect(GTK_OBJECT(info), "clicked", |
2545 GTK_SIGNAL_FUNC(info_callback), ft); | 2554 GTK_SIGNAL_FUNC(info_callback), ft); |
2546 | 2555 |
2547 | 2556 |
2548 if (ft->message) { | 2557 if (ft->message) { |
2558 /* we'll do this later | |
2549 while(gtk_events_pending()) | 2559 while(gtk_events_pending()) |
2550 gtk_main_iteration(); | 2560 gtk_main_iteration(); |
2551 html_print(text, ft->message); | 2561 html_print(text, ft->message); |
2562 */ | |
2552 } | 2563 } |
2553 | 2564 |
2554 | 2565 |
2555 | 2566 |
2556 } | 2567 } |
2557 #endif |