annotate src/gtk/dnd.c @ 677:8990a8a26ccf

2005-1-24 Brian Masney <masneyb@gftp.org> * lib/protocols.c lib/rfc959.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/transfer.c src/gtk/view-dialog.c src/uicommon/gftpui.c - make sure the logging level gftp_logging_error is used for all error messages
author masneyb
date Tue, 25 Jan 2005 02:34:19 +0000
parents 3bf77096052c
children 49cfbe02926b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* dnd.c - drag and drop functions */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp-gtk.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
23
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
24 static int
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
25 dnd_remote_file (gftp_window_data * wdata, GList ** trans_list, char *url)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
26 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
27 gftp_request * current_ftpdata;
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
28 gftp_window_data * fromwdata;
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
29 gftp_transfer * tdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
30 gftp_file * newfle;
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
31 GList * templist;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
32 char *pos;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
33
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
34 if (wdata == &window1)
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
35 fromwdata = &window2;
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
36 else if (wdata == &window2)
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
37 fromwdata = &window1;
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
38 else
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
39 fromwdata = NULL;
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
40
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
41 newfle = g_malloc0 (sizeof (*newfle));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
42 newfle->shown = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
43 if (url[strlen (url) - 1] == '/')
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
44 {
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 472
diff changeset
45 newfle->st_mode |= S_IFDIR;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
46 url[strlen (url) - 1] = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
47 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
49 current_ftpdata = gftp_request_new ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
50 current_ftpdata->logging_function = ftp_log;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
51
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
52 if (gftp_parse_url (current_ftpdata, url) != 0 ||
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
53 current_ftpdata->directory == NULL ||
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
54 (pos = strrchr (current_ftpdata->directory, '/')) == NULL)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
55 {
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
56 gftp_request_destroy (current_ftpdata, 1);
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
57 gftp_file_destroy (newfle, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
58 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
59 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
60
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
61 *pos++ = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
62 if (compare_request (current_ftpdata, wdata->request, 1))
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
63 {
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
64 gftp_request_destroy (current_ftpdata, 1);
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
65 gftp_file_destroy (newfle, 1);
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
66 return (0);
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
67 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
68
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
69 if (fromwdata != NULL &&
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
70 compare_request (current_ftpdata, fromwdata->request, 0))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
71 {
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
72 if (fromwdata->request->password != NULL)
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
73 gftp_set_password (current_ftpdata, fromwdata->request->password);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
74 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
75 else
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
76 fromwdata = NULL;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
77
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
78 *(pos - 1) = '/';
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
79 newfle->file = g_strdup (current_ftpdata->directory);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
80 *(pos - 1) = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
81
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
82 newfle->destfile = gftp_build_path (wdata->request,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
83 wdata->request->directory, pos, NULL);
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
84
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
85 tdata = NULL;
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
86 for (templist = *trans_list; templist != NULL; templist = templist->next)
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
87 {
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
88 tdata = templist->data;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
89 if (compare_request (current_ftpdata, tdata->fromreq, 0))
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
90 break;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
91 }
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
92
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
93 if (templist == NULL || tdata == NULL)
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
94 {
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
95 tdata = gftp_tdata_new ();
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
96
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
97 tdata->fromreq = current_ftpdata;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
98 tdata->fromwdata = fromwdata;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
99
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
100 tdata->toreq = wdata->request;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
101 tdata->towdata = wdata;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
102
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
103 *trans_list = g_list_append (*trans_list, tdata);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
104 }
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
105 else
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
106 gftp_request_destroy (current_ftpdata, 1);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
107
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
108 tdata->files = g_list_append (tdata->files, newfle);
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
109
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
110 return (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
111 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
112
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 openurl_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 {
660
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
119 if (current_wdata->request->stopable)
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
120 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 660
diff changeset
121 ftp_log (gftp_logging_error, NULL,
660
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
122 _("%s: Please hit the stop button first to do anything else\n"),
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
123 _("Connect"));
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
124 return;
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
125 }
3bf77096052c 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
126
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 {
329
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
129 if (GFTP_IS_CONNECTED (current_wdata->request))
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
130 gftpui_disconnect (current_wdata);
329
df4c91bf4adf 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
131
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 if (gftp_parse_url (current_wdata->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 (char *) selection_data->data) == 0)
472
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
134 {
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
135 ftp_log (gftp_logging_misc, NULL,
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
136 _("Received URL %s\n"), (char *) selection_data->data);
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
137
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
138 ftp_connect (current_wdata, current_wdata->request, 1);
5100b89c44e1 2004-5-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 382
diff changeset
139 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145 listbox_drag (GtkWidget * widget, GdkDragContext * context,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146 GtkSelectionData * selection_data, guint info, guint32 clk_time,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149 GList * templist, * filelist;
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
150 char *tempstr, *str, *df;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 size_t totlen, oldlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 totlen = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 str = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 filelist = wdata->files;
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
163 templist = gftp_gtk_get_list_selection (wdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 if (strcmp (tempfle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 oldlen = totlen;
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
174 df = gftp_build_path (wdata->request, wdata->request->directory,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
175 tempfle->file, NULL);
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
176
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
177 if (wdata->request->hostname == NULL ||
65
4b5fec7711e9 2002-11-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
178 wdata->request->protonum == GFTP_LOCAL_NUM)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
180 tempstr = g_strdup_printf ("%s://%s ",
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
181 wdata->request->url_prefix, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 }
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
183 else if (wdata->request->username == NULL ||
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
184 *wdata->request->username == '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
186 tempstr = g_strdup_printf ("%s://%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
187 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
188 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
189 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
193 tempstr = g_strdup_printf ("%s://%s@%s:%d%s ",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
194 wdata->request->url_prefix,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
195 wdata->request->username,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 74
diff changeset
196 wdata->request->hostname,
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
197 wdata->request->port, df);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 }
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
199
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 296
diff changeset
200 g_free (df);
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
201
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
202 /* Note, I am allocating memory for this byte above. Note the extra space
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
203 at the end of the g_strdup_printf() format argument */
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 472
diff changeset
204 if (S_ISDIR (tempfle->st_mode))
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
205 tempstr[strlen (tempstr) - 1] = '/';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
206 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
207 tempstr[strlen (tempstr) - 1] = '\0';
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 50
diff changeset
208
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 totlen += strlen (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 totlen++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 str = g_realloc (str, totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 strcpy (str + oldlen, "\n");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 strcpy (str + oldlen + 1, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 str = g_malloc (totlen + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 strcpy (str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 if (str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 gtk_selection_data_set (selection_data, selection_data->target, 8,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 (unsigned char *) str, strlen (str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 listbox_get_drag_data (GtkWidget * widget, GdkDragContext * context, gint x,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 gint y, GtkSelectionData * selection_data, guint info,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 guint32 clk_time, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
239 char *newpos, *oldpos, *tempstr;
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
240 GList * trans_list, * templist;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 gftp_window_data * wdata;
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
242 gftp_transfer * tdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 int finish_drag;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
244 size_t len;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
250 trans_list = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 finish_drag = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 if ((selection_data->length >= 0) && (selection_data->format == 8))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 oldpos = (char *) selection_data->data;
50
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
255 while ((newpos = strchr (oldpos, '\n')) ||
d433c1417d7d 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
256 (newpos = strchr (oldpos, '\0')))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
258 len = newpos - oldpos;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
259 if (oldpos[len - 1] == '\r')
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
260 len--;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
261
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
262 if (len == 0)
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
263 break;
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
264
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
265 tempstr = g_malloc (len + 1);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
266 memcpy (tempstr, oldpos, len);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
267 tempstr[len] = '\0';
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
268
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
269 ftp_log (gftp_logging_misc, NULL, _("Received URL %s\n"), tempstr);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
270
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
271 if (dnd_remote_file (wdata, &trans_list, tempstr))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 finish_drag = 1;
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
273
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
274 g_free (tempstr);
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
275
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 if (*newpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 break;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
278
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 oldpos = newpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283 gtk_drag_finish (context, finish_drag, FALSE, clk_time);
382
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
284
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
285 for (templist = trans_list; templist != NULL; templist = templist->next)
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
286 {
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
287 tdata = templist->data;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
288
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
289 if (tdata->files == NULL || gftp_get_all_subdirs (tdata, NULL) != 0)
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
290 {
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
291 g_free (tdata);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
292 continue;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
293 }
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
294
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
295 if (tdata->files == NULL)
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
296 {
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
297 g_free (tdata);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
298 continue;
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
299 }
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
300
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
301 gftpui_common_add_file_transfer (tdata->fromreq, tdata->toreq,
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
302 tdata->fromwdata, tdata->towdata,
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
303 tdata->files);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
304 g_free (tdata);
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
305 }
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
306
c5acf744ad79 2003-2-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
307 g_list_free (trans_list);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308 }