changeset 7621:bfe3a796b2c2

[gaim-migrate @ 8245] Reverting the previous patch. Sorry, Juan. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 24 Nov 2003 03:05:16 +0000
parents 4f41c4aa9913
children 072feee65244
files src/gtkconv.c src/protocols/oscar/oscar.c
diffstat 2 files changed, 81 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Mon Nov 24 02:45:53 2003 +0000
+++ b/src/gtkconv.c	Mon Nov 24 03:05:16 2003 +0000
@@ -895,6 +895,20 @@
 }
 
 static void
+menu_sendfile_cb(gpointer data, guint action, GtkWidget *widget)
+{
+	GaimConvWindow *win = (GaimConvWindow *)data;
+	GaimConversation *conv;
+	GaimConnection *gc;
+
+	conv = gaim_conv_window_get_active_conversation(win);
+
+	gc = gaim_conversation_get_gc(conv);
+
+	gaim_prpl_ask_send_file (gc, gaim_conversation_get_name (conv));
+}
+
+static void
 menu_warn_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	GaimConvWindow *win = (GaimConvWindow *)data;
@@ -2102,6 +2116,15 @@
 		gtk_widget_set_sensitive(gtkwin->menu.sendfile, FALSE);
 	}
 
+
+	if (gaim_prpl_has_send_file (gc, gaim_conversation_get_name(conv))) {
+		gtk_widget_show(gtkwin->menu.sendfile);
+		gtk_widget_set_sensitive(gtkwin->menu.sendfile, TRUE);
+	} else {
+		gtk_widget_hide(gtkwin->menu.sendfile);
+		gtk_widget_set_sensitive(gtkwin->menu.sendfile, FALSE);
+	}
+
 	/* Update the menubar */
 	if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
 		gtk_widget_show(gtkwin->menu.view_log);
@@ -2963,6 +2986,9 @@
 	{ N_("/Conversation/Send _File..."), NULL, menu_sendfile_cb, 0,
 	  "<StockItem>", GAIM_STOCK_INVITE },
 
+	{ N_("/Conversation/Send _File..."), NULL, menu_sendfile_cb, 0,
+	  "<StockItem>", GAIM_STOCK_INVITE },
+
 	{ "/Conversation/sep2", NULL, NULL, 0, "<Separator>" },
 
 	{ N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0,
@@ -3055,6 +3081,10 @@
 		gtk_item_factory_get_widget(gtkwin->menu.item_factory,
 									N_("/Conversation/Send File..."));
 
+	gtkwin->menu.sendfile =
+		gtk_item_factory_get_widget(gtkwin->menu.item_factory,
+									N_("/Conversation/Send File..."));
+
 	/* --- */
 
 	gtkwin->menu.insert_link =
--- a/src/protocols/oscar/oscar.c	Mon Nov 24 02:45:53 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Nov 24 03:05:16 2003 +0000
@@ -1025,6 +1025,51 @@
 	gaim_xfer_request(xfer);
 }
 
+static void oscar_sendfile(GaimConnection *gc, const char *destsn, const char *file) {
+	OscarData *od = (OscarData *)gc->proto_data;
+	GaimXfer *xfer;
+	struct aim_oft_info *oft_info;
+
+	/* You want to send a file to someone else, you're so generous */
+
+	/* Build the file transfer handle */
+	xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn);
+	xfer->local_port = 5190;
+
+	/* Create the oscar-specific data */
+	oft_info = aim_oft_createinfo(od->sess, NULL, destsn, xfer->local_ip, xfer->local_port, 0, 0, NULL);
+	xfer->data = oft_info;
+
+	 /* Setup our I/O op functions */
+	gaim_xfer_set_init_fnc(xfer, oscar_xfer_init);
+	gaim_xfer_set_start_fnc(xfer, oscar_xfer_start);
+	gaim_xfer_set_end_fnc(xfer, oscar_xfer_end);
+	gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send);
+	gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv);
+	gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack);
+
+	/* Keep track of this transfer for later */
+	od->file_transfers = g_slist_append(od->file_transfers, xfer);
+
+	/* We don't need to request, since it has already been accepted */
+	gaim_xfer_request_accepted (xfer, g_strdup(file));
+}
+
+static gboolean oscar_has_sendfile (GaimConnection *gc, const char *who)
+{
+	GaimBuddy *b = gaim_find_buddy(gc->account, who);
+	aim_userinfo_t *userinfo;
+        OscarData *od = gc->proto_data;
+	
+	if (b)
+		userinfo = aim_locate_finduserinfo(od->sess, b->name);
+	else
+		return FALSE;
+
+	/* True if we can send files to this dude, false if we can't */
+	return userinfo->capabilities & AIM_CAPS_SENDFILE;
+}
+
 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
 	GaimConnection *gc = sess->aux_data;
 	OscarData *od = gc->proto_data;
@@ -6227,14 +6272,6 @@
 				pbm->gc = gc;
 				m = g_list_append(m, pbm);
 			}
-
-			if (userinfo->capabilities & AIM_CAPS_SENDFILE) {
-				pbm = g_new0(struct proto_buddy_menu, 1);
-				pbm->label = _("Send File");
-				pbm->callback = oscar_ask_sendfile;
-				pbm->gc = gc;
-				m = g_list_append(m, pbm);
-			}
 #if 0
 			if (userinfo->capabilities & AIM_CAPS_GETFILE) {
 				pbm = g_new0(struct proto_buddy_menu, 1);
@@ -6661,7 +6698,12 @@
 	NULL,
 	oscar_convo_closed,
 	NULL,
-	oscar_set_icon
+	oscar_set_icon,
+	NULL,
+	NULL,
+	oscar_ask_sendfile,
+	oscar_sendfile,
+	oscar_has_sendfile
 };
 
 static GaimPluginInfo info =