Mercurial > pidgin
comparison src/prpl.c @ 2189:dca8e00d7de0
[gaim-migrate @ 2199]
I've decided I like Russ Dill's file transfer stuff and will have that go into gaim when i get around to it.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 29 Aug 2001 20:58:08 +0000 |
parents | 0befa2d2e540 |
children | 657dbe515608 |
comparison
equal
deleted
inserted
replaced
2188:98c434792ab7 | 2189:dca8e00d7de0 |
---|---|
547 } | 547 } |
548 gtk_label_set_text(GTK_LABEL(gc->email_label), buf); | 548 gtk_label_set_text(GTK_LABEL(gc->email_label), buf); |
549 } else if (gc->email_win) | 549 } else if (gc->email_win) |
550 gtk_widget_destroy(gc->email_win); | 550 gtk_widget_destroy(gc->email_win); |
551 } | 551 } |
552 | |
553 /* | |
554 struct ft_req { | |
555 struct gaim_connection *gc; | |
556 gboolean send; | |
557 gboolean multiple; | |
558 guint size; | |
559 char *name; | |
560 ft_callback cb; | |
561 gpointer data; | |
562 GtkWidget *fd; | |
563 }; | |
564 | |
565 static void ftrrno(gpointer w, struct ft_req *fr) | |
566 { | |
567 if (fr->fd && (w != fr->fd)) { | |
568 gtk_widget_destroy(fr->fd); | |
569 return; | |
570 } | |
571 if (fr->cb) | |
572 fr->cb(fr->gc, NULL, TRUE, fr->data); | |
573 if (fr->name) | |
574 g_free(fr->name); | |
575 g_free(fr); | |
576 } | |
577 | |
578 static void do_exist_dialog(const char *name, unsigned long size, struct ft_req *fr) | |
579 { | |
580 \* | |
581 GtkWidget *window; | |
582 GtkWidget *vbox; | |
583 GtkWidget *label; | |
584 GtkWidget *hbox; | |
585 GtkWidget *button; | |
586 char buf[8192]; | |
587 | |
588 g_snprintf(buf, sizeof(buf), "It appears that %s already exists. Do you want to " | |
589 "overwrite the file%s or cancel the transfer?", name, | |
590 (size <= fr->size) ? ", resume the download," : ""); | |
591 | |
592 window = gtk_window_new(GTK_WINDOW_DIALOG); | |
593 *\ | |
594 } | |
595 | |
596 static void ftgotfile(gpointer w, struct ft_req *fr) | |
597 { | |
598 const char *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fr->fd)); | |
599 if (!fr->multiple && file_is_dir(fname, fr->fd)) | |
600 return; | |
601 | |
602 if (!fr->multiple && !fr->send) { | |
603 struct stat st; | |
604 if (stat(fname, &st) == 0) { | |
605 do_exist_dialog(fname, st.st_size, fr); | |
606 return; | |
607 } | |
608 } | |
609 | |
610 fr->cb(fr->gc, fname, FT_EXIST_DNE, fr->data); | |
611 fr->cb = NULL; | |
612 | |
613 gtk_widget_destroy(fr->fd); | |
614 } | |
615 | |
616 static void ftrrok(gpointer w, struct ft_req *ft) | |
617 { | |
618 \* ft is going to be free'd as soon as we leave this function, so we'll copy it *\ | |
619 struct ft_req *fr = g_memdup(ft, sizeof(struct ft_req)); | |
620 char buf[256]; | |
621 | |
622 if (fr->send) | |
623 fr->fd = gtk_file_selection_new(_("Gaim - Select File")); | |
624 else | |
625 fr->fd = gtk_file_selection_new(_("Gaim - Send File")); | |
626 | |
627 g_snprintf(buf, sizeof(buf), "%s/%s", g_get_home_dir(), fr->name ? fr->name : ""); | |
628 gtk_file_selection_set_filename(GTK_FILE_SELECTION(fr->fd), buf); | |
629 | |
630 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->ok_button), "clicked", | |
631 GTK_SIGNAL_FUNC(ftgotfile), fr); | |
632 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->cancel_button), "clicked", | |
633 GTK_SIGNAL_FUNC(ftrrno), fr); | |
634 gtk_signal_connect(GTK_OBJECT(fr->fd), "destroy", GTK_SIGNAL_FUNC(ftrrno), fr); | |
635 | |
636 gtk_widget_show(fr->fd); | |
637 } | |
638 | |
639 void ft_receive_request(struct gaim_connection *gc, const char *who, gboolean send, gboolean multiple, | |
640 char *name, guint size, ft_callback cb, gpointer data) | |
641 { | |
642 char buf[8192]; | |
643 struct ft_req *fr = g_new0(struct ft_req, 1); | |
644 | |
645 fr->gc = gc; | |
646 fr->send = send; | |
647 fr->multiple = multiple; | |
648 fr->size = size; | |
649 if (name) | |
650 fr->name = g_strdup(name); | |
651 fr->cb = cb; | |
652 fr->data = data; | |
653 | |
654 if (send) | |
655 g_snprintf(buf, sizeof(buf), "%s has just asked %s to send a file.", | |
656 who, gc->username); | |
657 else if (multiple) | |
658 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive some files.", | |
659 who, gc->username); | |
660 else if (name && size) | |
661 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s (%d bytes).", | |
662 who, gc->username, name, size); | |
663 else if (name) | |
664 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s.", | |
665 who, gc->username, name); | |
666 else | |
667 g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive a file.", | |
668 who, gc->username); | |
669 | |
670 do_ask_dialog(buf, fr, ftrrok, ftrrno); | |
671 } | |
672 */ |