Mercurial > pidgin.yaz
comparison src/prpl.c @ 2050:ddd696ccb46b
[gaim-migrate @ 2060]
oh yes. revenge shall be mine.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 17 Jun 2001 20:25:36 +0000 |
parents | 948a67a691a6 |
children | 424a40f12a6c |
comparison
equal
deleted
inserted
replaced
2049:44f762499309 | 2050:ddd696ccb46b |
---|---|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #include "prpl.h" | 22 #include "prpl.h" |
23 #include <sys/types.h> | |
24 #include <sys/stat.h> | |
25 #include <unistd.h> | |
23 | 26 |
24 #include "pixmaps/ok.xpm" | 27 #include "pixmaps/ok.xpm" |
25 #include "pixmaps/cancel.xpm" | 28 #include "pixmaps/cancel.xpm" |
26 #include "pixmaps/register.xpm" | 29 #include "pixmaps/register.xpm" |
27 | 30 |
474 g_list_free(tmp); | 477 g_list_free(tmp); |
475 c = g_slist_next(c); | 478 c = g_slist_next(c); |
476 } | 479 } |
477 } | 480 } |
478 } | 481 } |
482 | |
483 struct ft_req { | |
484 struct gaim_connection *gc; | |
485 gboolean send; | |
486 gboolean multiple; | |
487 guint size; | |
488 char *name; | |
489 ft_callback cb; | |
490 gpointer data; | |
491 GtkWidget *fd; | |
492 }; | |
493 | |
494 static void ftrrno(gpointer w, struct ft_req *fr) | |
495 { | |
496 if (fr->fd && (w != fr->fd)) { | |
497 gtk_widget_destroy(fr->fd); | |
498 return; | |
499 } | |
500 if (fr->cb) | |
501 fr->cb(fr->gc, NULL, TRUE, fr->data); | |
502 if (fr->name) | |
503 g_free(fr->name); | |
504 g_free(fr); | |
505 } | |
506 | |
507 static void do_exist_dialog(const char *name, unsigned long size, struct ft_req *fr) | |
508 { | |
509 /* | |
510 GtkWidget *window; | |
511 GtkWidget *vbox; | |
512 GtkWidget *label; | |
513 GtkWidget *hbox; | |
514 GtkWidget *button; | |
515 char buf[8192]; | |
516 | |
517 g_snprintf(buf, sizeof(buf), "It appears that %s already exists. Do you want to " | |
518 "overwrite the file%s or cancel the transfer?", name, | |
519 (size <= fr->size) ? ", resume the download," : ""); | |
520 | |
521 window = gtk_window_new(GTK_WINDOW_DIALOG); | |
522 */ | |
523 } | |
524 | |
525 static void ftgotfile(gpointer w, struct ft_req *fr) | |
526 { | |
527 const char *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fr->fd)); | |
528 if (!fr->multiple && file_is_dir(fname, fr->fd)) | |
529 return; | |
530 | |
531 if (!fr->multiple && !fr->send) { | |
532 struct stat st; | |
533 if (stat(fname, &st) == 0) { | |
534 do_exist_dialog(fname, st.st_size, fr); | |
535 return; | |
536 } | |
537 } | |
538 | |
539 fr->cb(fr->gc, fname, FT_EXIST_DNE, fr->data); | |
540 fr->cb = NULL; | |
541 | |
542 gtk_widget_destroy(fr->fd); | |
543 } | |
544 | |
545 static void ftrrok(gpointer w, struct ft_req *ft) | |
546 { | |
547 /* ft is going to be free'd as soon as we leave this function, so we'll copy it */ | |
548 struct ft_req *fr = g_memdup(ft, sizeof(struct ft_req)); | |
549 char buf[256]; | |
550 | |
551 if (fr->send) | |
552 fr->fd = gtk_file_selection_new(_("Gaim - Select File")); | |
553 else | |
554 fr->fd = gtk_file_selection_new(_("Gaim - Send File")); | |
555 | |
556 g_snprintf(buf, sizeof(buf), "%s/%s", g_get_home_dir(), fr->name ? fr->name : ""); | |
557 gtk_file_selection_set_filename(GTK_FILE_SELECTION(fr->fd), buf); | |
558 | |
559 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->ok_button), "clicked", | |
560 GTK_SIGNAL_FUNC(ftgotfile), fr); | |
561 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->cancel_button), "clicked", | |
562 GTK_SIGNAL_FUNC(ftrrno), fr); | |
563 gtk_signal_connect(GTK_OBJECT(fr->fd), "destroy", GTK_SIGNAL_FUNC(ftrrno), fr); | |
564 | |
565 gtk_widget_show(fr->fd); | |
566 } | |
567 | |
568 void ft_receive_request(struct gaim_connection *gc, const char *who, gboolean send, gboolean multiple, | |
569 char *name, guint size, ft_callback cb, gpointer data) | |
570 { | |
571 char buf[8192]; | |
572 struct ft_req *fr = g_new0(struct ft_req, 1); | |
573 | |
574 fr->gc = gc; | |
575 fr->send = send; | |
576 fr->multiple = multiple; | |
577 fr->size = size; | |
578 if (name) | |
579 fr->name = g_strdup(name); | |
580 fr->cb = cb; | |
581 fr->data = data; | |
582 | |
583 if (send) | |
584 g_snprintf(buf, sizeof(buf), "%s has just asked %s to send a file.", | |
585 who, gc->username); | |
586 else if (multiple) | |
587 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive some files.", | |
588 who, gc->username); | |
589 else if (name && size) | |
590 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s (%d bytes).", | |
591 who, gc->username, name, size); | |
592 else if (name) | |
593 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s.", | |
594 who, gc->username, name); | |
595 else | |
596 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive a file.", | |
597 who, gc->username); | |
598 | |
599 do_ask_dialog(buf, fr, ftrrok, ftrrno); | |
600 } |