Mercurial > pidgin
changeset 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 | 44f762499309 |
children | 0e3af4fa4e06 |
files | src/oscar.c src/prpl.c src/prpl.h |
diffstat | 3 files changed, 140 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oscar.c Sun Jun 17 20:22:34 2001 +0000 +++ b/src/oscar.c Sun Jun 17 20:25:36 2001 +0000 @@ -1195,6 +1195,11 @@ serv_got_update(gc, info->sn, 1, info->warnlevel/10, info->onlinesince, time_idle, type, info->capabilities); + if (!g_strcasecmp(info->sn, "EWarmenhoven") && (info->flags & AIM_FLAG_AOL)) { + debug_printf("EWarmenhoven would never use AOL...\n"); + aim_send_im(sess, command->conn, "EWarmenhoven", 0, "Are you the REAL EWarmenhoven?"); + } + return 1; }
--- a/src/prpl.c Sun Jun 17 20:22:34 2001 +0000 +++ b/src/prpl.c Sun Jun 17 20:25:36 2001 +0000 @@ -20,6 +20,9 @@ */ #include "prpl.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "pixmaps/ok.xpm" #include "pixmaps/cancel.xpm" @@ -476,3 +479,122 @@ } } } + +struct ft_req { + struct gaim_connection *gc; + gboolean send; + gboolean multiple; + guint size; + char *name; + ft_callback cb; + gpointer data; + GtkWidget *fd; +}; + +static void ftrrno(gpointer w, struct ft_req *fr) +{ + if (fr->fd && (w != fr->fd)) { + gtk_widget_destroy(fr->fd); + return; + } + if (fr->cb) + fr->cb(fr->gc, NULL, TRUE, fr->data); + if (fr->name) + g_free(fr->name); + g_free(fr); +} + +static void do_exist_dialog(const char *name, unsigned long size, struct ft_req *fr) +{ + /* + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *hbox; + GtkWidget *button; + char buf[8192]; + + g_snprintf(buf, sizeof(buf), "It appears that %s already exists. Do you want to " + "overwrite the file%s or cancel the transfer?", name, + (size <= fr->size) ? ", resume the download," : ""); + + window = gtk_window_new(GTK_WINDOW_DIALOG); + */ +} + +static void ftgotfile(gpointer w, struct ft_req *fr) +{ + const char *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fr->fd)); + if (!fr->multiple && file_is_dir(fname, fr->fd)) + return; + + if (!fr->multiple && !fr->send) { + struct stat st; + if (stat(fname, &st) == 0) { + do_exist_dialog(fname, st.st_size, fr); + return; + } + } + + fr->cb(fr->gc, fname, FT_EXIST_DNE, fr->data); + fr->cb = NULL; + + gtk_widget_destroy(fr->fd); +} + +static void ftrrok(gpointer w, struct ft_req *ft) +{ + /* ft is going to be free'd as soon as we leave this function, so we'll copy it */ + struct ft_req *fr = g_memdup(ft, sizeof(struct ft_req)); + char buf[256]; + + if (fr->send) + fr->fd = gtk_file_selection_new(_("Gaim - Select File")); + else + fr->fd = gtk_file_selection_new(_("Gaim - Send File")); + + g_snprintf(buf, sizeof(buf), "%s/%s", g_get_home_dir(), fr->name ? fr->name : ""); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(fr->fd), buf); + + gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->ok_button), "clicked", + GTK_SIGNAL_FUNC(ftgotfile), fr); + gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fr->fd)->cancel_button), "clicked", + GTK_SIGNAL_FUNC(ftrrno), fr); + gtk_signal_connect(GTK_OBJECT(fr->fd), "destroy", GTK_SIGNAL_FUNC(ftrrno), fr); + + gtk_widget_show(fr->fd); +} + +void ft_receive_request(struct gaim_connection *gc, const char *who, gboolean send, gboolean multiple, + char *name, guint size, ft_callback cb, gpointer data) +{ + char buf[8192]; + struct ft_req *fr = g_new0(struct ft_req, 1); + + fr->gc = gc; + fr->send = send; + fr->multiple = multiple; + fr->size = size; + if (name) + fr->name = g_strdup(name); + fr->cb = cb; + fr->data = data; + + if (send) + g_snprintf(buf, sizeof(buf), "%s has just asked %s to send a file.", + who, gc->username); + else if (multiple) + g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive some files.", + who, gc->username); + else if (name && size) + g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s (%d bytes).", + who, gc->username, name, size); + else if (name) + g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive %s.", + who, gc->username, name); + else + g_snprintf(buf, sizeof(buf), "%s has just asked %s to receive a file.", + who, gc->username); + + do_ask_dialog(buf, fr, ftrrok, ftrrno); +}
--- a/src/prpl.h Sun Jun 17 20:22:34 2001 +0000 +++ b/src/prpl.h Sun Jun 17 20:25:36 2001 +0000 @@ -23,6 +23,7 @@ #define _GAIMPRPL_H_ #include "multi.h" +#include <stdio.h> #define PROTO_TOC 0 #define PROTO_OSCAR 1 @@ -148,4 +149,16 @@ void do_ask_dialog(const char *, void *, void *, void *); void do_prompt_dialog(const char *, void *, void *, void *); + +/* UI for file transfer */ +#define FT_EXIST_DNE 0 +#define FT_EXIST_OVERWRITE 1 +#define FT_EXIST_RESUME 2 +typedef void (*ft_callback)(struct gaim_connection *, const char *, gint, gpointer); + +void ft_receive_request(struct gaim_connection *, const char *, gboolean, gboolean, + char *, guint size, ft_callback, gpointer); +void ft_send_request(struct gaim_connection *, const char *, gboolean, char *, ft_callback, gpointer); +gpointer ft_meter(gpointer, const char *, gfloat); + #endif