--- lib/pty.c.orig 2008-11-06 23:40:29 +0300 +++ lib/pty.c 2008-11-06 23:40:41 +0300 @@ -62,7 +62,7 @@ _gftp_ptys_open (int fdm, int fds, char #elif HAVE_GRANTPT #ifndef __FreeBSD__ -#include +//#include #endif char * --- lib/gftp.h 2005-01-19 02:09:58 +0300 +++ lib/gftp.h 2005-09-17 02:08:56 +0400 @@ -902,6 +902,8 @@ int gftp_list_files ( gftp_request * request ); +char * my_convert_charset_func (const char *str, const gchar * to, const gchar * from); + char * gftp_string_to_utf8 ( gftp_request * request, const char *str ); @@ -1101,4 +1103,3 @@ void gftpui_protocol_update_timeout ( gftp_request * request ); #endif - --- lib/options.h 2005-01-19 04:49:17 +0300 +++ lib/options.h 2005-09-17 02:09:06 +0400 @@ -50,7 +50,14 @@ gftp_option_type_text, "", NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK, N_("This is a comma separated list of charsets to try to convert the remote messages to the current locale"), GFTP_PORT_ALL, NULL}, - {"remote_lc_time", N_("Remote LC_TIME:"), + + {"ftp_remote_charset", N_("Character Set for server:"), + gftp_option_type_text, "", NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK, + N_("Character Set for upload to server, don't forget check 'Convert uploaded files to remote code page'"), + GFTP_PORT_ALL, NULL}, + + + {"remote_lc_time", N_("Remote LC_TIME:"), gftp_option_type_text, "", NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK, N_("This is the value of LC_TIME for the remote site. This is so that dates can be parsed properly in the directory listings."), GFTP_PORT_ALL, NULL}, @@ -104,6 +111,12 @@ {"cmd_in_gui", N_("Allow manual commands in GUI"), gftp_option_type_checkbox, GINT_TO_POINTER(0), NULL, 0, N_("Allow entering manual commands in the GUI (functions like the text port)"), GFTP_PORT_GTK, NULL}, + {"convert_to_localcodepage", N_("Convert downloaded from server files to local code page"), + gftp_option_type_checkbox, GINT_TO_POINTER(0), NULL, 0, + N_("Allow convert downloaded files to local code page"), GFTP_PORT_GTK, NULL}, + {"convert_to_remotecodepage", N_("Convert uploaded to server files to remote code page"), + gftp_option_type_checkbox, GINT_TO_POINTER(0), NULL, 0, + N_("Convert Character Set uploaded to server files to remote character set, don't forget fill 'Character Set for server' "), GFTP_PORT_GTK, NULL}, {"", N_("Network"), gftp_option_type_notebook, NULL, NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK, NULL, GFTP_PORT_GTK, NULL}, @@ -274,4 +287,3 @@ FILE * gftp_logfd = NULL; int gftp_configuration_changed = 0; - --- lib/protocols.c.orig 2005-01-25 05:34:18 +0300 +++ lib/protocols.c 2008-01-08 19:52:32 +0300 @@ -178,12 +178,28 @@ gftp_get_file (gftp_request * request, c off_t startsize) { g_return_val_if_fail (request != NULL, GFTP_EFATAL); - + printf(_("geting file= %s ====%s /n"),filename,request->url_prefix); request->cached = 0; if (request->get_file == NULL) return (GFTP_EFATAL); - return (request->get_file (request, filename, fd, startsize)); + //char *newfile_tmp , *FTP_LOCAL_CHARSET, *FTP_REMOTE_CHARSET; + + //newfile_tmp=filename; + /*gftp_lookup_request_option(request,"ftp_local_charset",&FTP_LOCAL_CHARSET); + gftp_lookup_request_option(request,"ftp_remote_charset",&FTP_REMOTE_CHARSET); + printf(_(" ( %s | %s) "),FTP_LOCAL_CHARSET,FTP_REMOTE_CHARSET); + + if(request->url_prefix=="file") + { + if (FTP_LOCAL_CHARSET=="UTF8"){ + newfile_tmp=gftp_string_from_utf8 (request, filename); + }else if (FTP_LOCAL_CHARSET!=NULL){ + newfile_tmp=my_convert_charset_func(filename,FTP_REMOTE_CHARSET,FTP_LOCAL_CHARSET); + } + } +*/ + return (request->get_file (request,filename , fd, startsize));//newfile_tmp } @@ -192,12 +208,50 @@ gftp_put_file (gftp_request * request, c off_t startsize, off_t totalsize) { g_return_val_if_fail (request != NULL, GFTP_EFATAL); - + printf(_("puting file= %s ====%s /n"),filename,request->url_prefix); request->cached = 0; if (request->put_file == NULL) return (GFTP_EFATAL); - - return (request->put_file (request, filename, fd, startsize, totalsize)); + + char *newfile_tmp , *FTP_LOCAL_CHARSET, *FTP_REMOTE_CHARSET; + intptr_t convert_to_localcodepage,convert_to_remotecodepage; + + newfile_tmp=filename; + FTP_LOCAL_CHARSET=""; + //gftp_lookup_request_option(request,"ftp_local_charset",&FTP_LOCAL_CHARSET); + gftp_lookup_request_option(request,"ftp_remote_charset",&FTP_REMOTE_CHARSET); + gftp_lookup_request_option(request,"convert_to_localcodepage",&convert_to_localcodepage); + gftp_lookup_request_option(request,"convert_to_remotecodepage",&convert_to_remotecodepage); + + printf(_(" ( %s | %s) "),FTP_LOCAL_CHARSET,FTP_REMOTE_CHARSET); + + + if(request->url_prefix=="file") + { + if (convert_to_localcodepage) + { + newfile_tmp=gftp_string_to_utf8 (request, filename); + if(newfile_tmp==NULL){newfile_tmp=filename;} + if(!g_get_charset(&FTP_LOCAL_CHARSET)){ + filename=my_convert_charset_func(newfile_tmp,FTP_LOCAL_CHARSET,"UTF8"); + newfile_tmp=filename; + } + printf(_(" Converted file %s to %s for local system "),newfile_tmp,FTP_LOCAL_CHARSET); + } + }else{ //We are not local + if (convert_to_remotecodepage && + (FTP_REMOTE_CHARSET!="")&& + ((g_strup(FTP_REMOTE_CHARSET)!="UTF8")||(g_strup(FTP_REMOTE_CHARSET)!="UTF-8")) + ) + { + newfile_tmp=gftp_string_to_utf8 (request, filename); + if(newfile_tmp==NULL){newfile_tmp=filename;} + filename=my_convert_charset_func(newfile_tmp,FTP_REMOTE_CHARSET,"UTF8"); + newfile_tmp=filename; + printf(_(" Converted file %s to %s for remote system "),newfile_tmp,FTP_REMOTE_CHARSET); + } + } + return (request->put_file (request, newfile_tmp, fd, startsize, totalsize));//filename } @@ -435,6 +489,12 @@ _gftp_get_next_charset (char **curpos) char * +my_convert_charset_func(const char *str, const gchar * to, const gchar * from) +{ + return g_convert_with_fallback(str, -1, to, from, "?", NULL, NULL, NULL); +} + +char * gftp_string_to_utf8 (gftp_request * request, const char *str) { char *ret, *remote_charsets, *stpos, *cur_charset, *tempstr; @@ -443,7 +503,8 @@ gftp_string_to_utf8 (gftp_request * requ if (request == NULL) return (NULL); - + //g_get_charset(&cur_charset); +printf(_("ssfile= %s ###=%s"),str,str); if (g_utf8_validate (str, -1, NULL)) return (NULL); else if (request->iconv_initialized) @@ -458,6 +519,10 @@ gftp_string_to_utf8 (gftp_request * requ } gftp_lookup_request_option (request, "remote_charsets", &tempstr); + if(request->url_prefix=="file") + { + g_get_charset(&tempstr); + } if (*tempstr == '\0') { error = NULL; @@ -510,12 +575,23 @@ gftp_string_from_utf8 (gftp_request * re GError * error = NULL; gsize bread, bwrite; - if (request == NULL) - return (NULL); + if( request == NULL ) + { + ret = g_locale_from_utf8(str,-1,&bread,&bwrite,&error); +/* + if(ret == NULL) + printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"), + str, "UTF-8", _(""), error->message); +*/ + return (ret); + } /* If the string isn't in UTF-8 format, assume it is already in the current locale... */ - if (!g_utf8_validate (str, -1, NULL)) + //if(str==g_convert_with_fallback(str, -1, "UTF8", "UTF8", "?", NULL, NULL, NULL))) + //return (NULL); + + if ((!g_utf8_validate (str, -1, NULL))||(g_get_charset(NULL))) return (NULL); else if (request->iconv_initialized) { @@ -721,7 +797,8 @@ gftp_parse_bookmark (gftp_request * requ if (local_request != NULL && tempentry->local_dir != NULL && *tempentry->local_dir != '\0') { - utf8 = gftp_string_from_utf8 (request, tempentry->local_dir); +// utf8 = gftp_string_from_utf8 (request, tempentry->local_dir); + utf8 = tempentry->local_dir; if (utf8 != NULL) { gftp_set_directory (local_request, utf8); @@ -1038,7 +1115,8 @@ gftp_make_directory (gftp_request * requ if (request->mkdir == NULL) return (GFTP_EFATAL); - utf8 = gftp_string_from_utf8 (request, directory); +// utf8 = gftp_string_from_utf8 (request, directory); + utf8 = directory; if (utf8 != NULL) { ret = request->mkdir (request, utf8); @@ -1063,7 +1141,12 @@ gftp_rename_file (gftp_request * request if (request->rename == NULL) return (GFTP_EFATAL); +printf(_(" rename( %s | %s | %s) "),request->url_prefix,oldname,newname); + + utf8 = gftp_string_from_utf8 (request, newname); +printf(_(" rename2( %s | ut8=%s | %s | %s) "),utf8,request->url_prefix,oldname,newname); + if (utf8 != NULL) { ret = request->rename (request, oldname, utf8); @@ -1085,7 +1168,47 @@ gftp_chmod (gftp_request * request, cons return (GFTP_EFATAL); mode &= S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX; - return (request->chmod (request, file, mode)); + + char *newfile_tmp , *FTP_LOCAL_CHARSET, *FTP_REMOTE_CHARSET; + intptr_t convert_to_localcodepage,convert_to_remotecodepage; + + newfile_tmp=file; + FTP_LOCAL_CHARSET=""; + //gftp_lookup_request_option(request,"ftp_local_charset",&FTP_LOCAL_CHARSET); + gftp_lookup_request_option(request,"ftp_remote_charset",&FTP_REMOTE_CHARSET); + gftp_lookup_request_option(request,"convert_to_localcodepage",&convert_to_localcodepage); + gftp_lookup_request_option(request,"convert_to_remotecodepage",&convert_to_remotecodepage); + + printf(_(" ( %s | %s) "),FTP_LOCAL_CHARSET,FTP_REMOTE_CHARSET); + + + if(request->url_prefix=="file") + { + if (convert_to_localcodepage) + { + newfile_tmp=gftp_string_to_utf8 (request, file); + if(newfile_tmp==NULL){newfile_tmp=file;} + if(!g_get_charset(&FTP_LOCAL_CHARSET)){ + file=my_convert_charset_func(newfile_tmp,FTP_LOCAL_CHARSET,"UTF8"); + newfile_tmp=file; + } + printf(_(" Converted file %s to %s for local system "),newfile_tmp,FTP_LOCAL_CHARSET); + } + }else{ //We are not local + if (convert_to_remotecodepage && + (FTP_REMOTE_CHARSET!="")&& + ((g_strup(FTP_REMOTE_CHARSET)!="UTF8")||(g_strup(FTP_REMOTE_CHARSET)!="UTF-8")) + ) + { + newfile_tmp=gftp_string_to_utf8 (request, file); + if(newfile_tmp==NULL){newfile_tmp=file;} + file=my_convert_charset_func(newfile_tmp,FTP_REMOTE_CHARSET,"UTF8"); + newfile_tmp=file; + printf(_(" Converted file %s to %s for remote system "),newfile_tmp,FTP_REMOTE_CHARSET); + } + } + + return (request->chmod (request, newfile_tmp, mode));//file } @@ -3163,4 +3286,3 @@ gftp_protocol_default_port (gftp_request else return (ntohs (serv_struct.s_port)); } -