tags 364592 - moreinfo tags 364592 + patch thanks On Mon, Oct 09, 2006 at 10:26:17AM +0200, Aurélien GÉRÔME wrote: > On Mon, Apr 24, 2006 at 08:36:13PM +0800, Hong Jen Yee (PCMan) wrote: > > Here is my patch: > > http://pcman.sayya.org/gftp/gftp-2.0.18-11-pcman.diff.gz > > $ wget http://pcman.sayya.org/gftp/gftp-2.0.18-11-pcman.diff.gz > --10:21:31-- http://pcman.sayya.org/gftp/gftp-2.0.18-11-pcman.diff.gz > => `gftp-2.0.18-11-pcman.diff.gz' > Resolving pcman.sayya.org... 140.113.22.98 > Connecting to pcman.sayya.org[140.113.22.98]:80... failed: Connection timed > out. > > Can you post your patch on the BTS, please? Thanks! ;)
OK, so here is the attached patch... Cheers, -- .''`. Aurélien GÉRÔME : :' : `. `'` Free Software Developer `- Unix Sys & Net Admin
--- gftp-2.0.18.orig/lib/gftp.h
+++ gftp-2.0.18/lib/gftp.h
@@ -497,8 +497,10 @@
#endif
#if GLIB_MAJOR_VERSION > 1
- GIConv iconv;
- unsigned int iconv_initialized : 1;
+ GIConv to_utf8_iconv;
+ GIConv from_utf8_iconv;
+ unsigned int to_utf8_iconv_initialized : 1;
+ unsigned int from_utf8_iconv_initialized : 1;
#endif
};
--- gftp-2.0.18.orig/lib/protocols.c
+++ gftp-2.0.18/lib/protocols.c
@@ -159,10 +159,15 @@
#endif
#if GLIB_MAJOR_VERSION > 1
- if (request->iconv_initialized)
+ if (request->to_utf8_iconv_initialized)
{
- g_iconv_close (request->iconv);
- request->iconv_initialized = 0;
+ g_iconv_close (request->to_utf8_iconv);
+ request->to_utf8_iconv_initialized = 0;
+ }
+ if (request->from_utf8_iconv_initialized)
+ {
+ g_iconv_close (request->from_utf8_iconv);
+ request->from_utf8_iconv_initialized = 0;
}
#endif
@@ -446,9 +451,13 @@
if (g_utf8_validate (str, -1, NULL))
return (NULL);
- else if (request->iconv_initialized)
+ else if( request->protonum == GFTP_LOCAL_NUM ){
+ /* if request represents local file system */
+ return g_filename_to_utf8( str, -1, NULL, NULL, NULL );
+ }
+ else if (request->to_utf8_iconv_initialized)
{
- ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
+ ret = g_convert_with_iconv (str, -1, request->to_utf8_iconv, &bread,
&bwrite,
&error);
if (ret == NULL)
printf (_("Error converting string '%s' from character set %s to
character set %s: %s\n"),
@@ -476,27 +485,26 @@
stpos = remote_charsets;
while ((cur_charset = _gftp_get_next_charset (&stpos)) != NULL)
{
- if ((request->iconv = g_iconv_open ("UTF-8", cur_charset)) == (GIConv)
-1)
+ if ((request->to_utf8_iconv = g_iconv_open ("UTF-8", cur_charset)) ==
(GIConv) -1)
continue;
error = NULL;
- if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread,
&bwrite,
+ if ((ret = g_convert_with_iconv (str, -1, request->to_utf8_iconv,
&bread, &bwrite,
&error)) == NULL)
{
printf (_("Error converting string '%s' from character set %s to
character set %s: %s\n"),
str, cur_charset, "UTF-8", error->message);
- g_iconv_close (request->iconv);
- request->iconv = NULL;
+ g_iconv_close (request->to_utf8_iconv);
+ request->to_utf8_iconv = NULL;
continue;
}
else
{
- request->iconv_initialized = 1;
+ request->to_utf8_iconv_initialized = 1;
break;
}
}
-
g_free (remote_charsets);
return (ret);
@@ -517,9 +525,13 @@
locale... */
if (!g_utf8_validate (str, -1, NULL))
return (NULL);
- else if (request->iconv_initialized)
+ else if( request->protonum == GFTP_LOCAL_NUM ){
+ /* if request represents local file system */
+ return g_filename_from_utf8( str, -1, NULL, NULL, NULL
);
+ }
+ else if (request->from_utf8_iconv_initialized)
{
- ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
+ ret = g_convert_with_iconv (str, -1, request->from_utf8_iconv, &bread,
&bwrite,
&error);
if (ret == NULL)
printf (_("Error converting string '%s' from character set %s to
character set %s: %s\n"),
@@ -547,23 +559,22 @@
stpos = remote_charsets;
while ((cur_charset = _gftp_get_next_charset (&stpos)) != NULL)
{
- if ((request->iconv = g_iconv_open (cur_charset, "UTF-8")) == (GIConv)
-1)
+ if ((request->from_utf8_iconv = g_iconv_open (cur_charset, "UTF-8")) ==
(GIConv) -1)
continue;
-
error = NULL;
- if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread,
&bwrite,
+ if ((ret = g_convert_with_iconv (str, -1, request->from_utf8_iconv,
&bread, &bwrite,
&error)) == NULL)
{
printf (_("Error converting string '%s' from character set %s to
character set %s: %s\n"),
str, "UTF-8", cur_charset, error->message);
- g_iconv_close (request->iconv);
- request->iconv = NULL;
+ g_iconv_close (request->from_utf8_iconv);
+ request->from_utf8_iconv = NULL;
continue;
}
else
{
- request->iconv_initialized = 1;
+ request->from_utf8_iconv_initialized = 1;
break;
}
}
@@ -1915,6 +1926,7 @@
gftp_file * fle;
off_t *newsize;
char *newname;
+ char* destname;
if (getothdir && transfer->toreq)
{
@@ -1944,10 +1956,16 @@
fle->startsize = *newsize;
if (transfer->toreq && fle->destfile == NULL)
+ {
+ destname = (fle->utf8_file ? fle->utf8_file :
fle->file);
+ destname = gftp_string_from_utf8(
transfer->toreq,
+
destname );
fle->destfile = gftp_build_path (transfer->toreq,
transfer->toreq->directory,
- fle->file, NULL);
-
+ destname, NULL);
+ g_free( destname );
+ }
+
if (transfer->fromreq->directory != NULL &&
*transfer->fromreq->directory != '\0' &&
*fle->file != '/')
@@ -1986,6 +2004,8 @@
gftp_file * curfle;
off_t *newsize;
mode_t st_mode;
+ char* utf8;
+ char* destname;
g_return_val_if_fail (transfer != NULL, GFTP_EFATAL);
g_return_val_if_fail (transfer->fromreq != NULL, GFTP_EFATAL);
@@ -2004,15 +2024,23 @@
for (lastlist = transfer->files; ; lastlist = lastlist->next)
{
curfle = lastlist->data;
-
- if ((pos = strrchr (curfle->file, '/')) != NULL)
+ utf8 = curfle->utf8_file ? curfle->utf8_file :
curfle->file;
+ if ((pos = strrchr (utf8, '/')) != NULL)
pos++;
else
- pos = curfle->file;
+ pos = utf8;
- if (dirhash != NULL &&
- (newsize = g_hash_table_lookup (dirhash, pos)) != NULL)
- curfle->startsize = *newsize;
+ destname = gftp_string_from_utf8( transfer->toreq, pos
);
+ if( destname ) {
+ if (dirhash != NULL &&
+ (newsize = g_hash_table_lookup
(dirhash, destname)) != NULL) {
+ curfle->startsize = *newsize;
+ }
+ g_free( destname );
+ }
+ else{
+ curfle->startsize = 0;
+ }
if (curfle->size < 0 && GFTP_IS_CONNECTED (transfer->fromreq))
{
@@ -2022,9 +2050,13 @@
}
if (transfer->toreq && curfle->destfile == NULL)
+ {
+ destname = gftp_string_from_utf8(
transfer->toreq, utf8 );
curfle->destfile = gftp_build_path (transfer->toreq,
transfer->toreq->directory,
- curfle->file, NULL);
+ destname, NULL);
+ g_free( destname );
+ }
if (transfer->fromreq->directory != NULL &&
*transfer->fromreq->directory != '\0' && *curfle->file != '/')
--- gftp-2.0.18.orig/src/gtk/gtkui.c
+++ gftp-2.0.18/src/gtk/gtkui.c
@@ -335,6 +335,7 @@
gftp_window_data * wdata;
gftp_file * curfle;
char *tempstr;
+ char* utf8_name;
int num;
wdata = data;
@@ -352,10 +353,11 @@
templist = get_next_selection (templist, &filelist, &num);
curfle = filelist->data;
cdata->source_string = g_strdup (curfle->file);
+ utf8_name = (curfle->utf8_file ? curfle->utf8_file : curfle->file);
tempstr = g_strdup_printf (_("What would you like to rename %s to?"),
- cdata->source_string);
- MakeEditDialog (_("Rename"), tempstr, cdata->source_string, 1, NULL,
+ utf8_name);
+ MakeEditDialog (_("Rename"), tempstr, utf8_name, 1, NULL,
gftp_dialog_button_rename,
gftpui_run_function_callback, cdata,
gftpui_run_function_cancel_callback, cdata);
signature.asc
Description: Digital signature

