feat: new settings Dynamic WinSCP protocol for WinSCP intgration [#161]

This commit is contained in:
cyd01
2020-04-30 19:29:11 +02:00
parent d70d88423a
commit 3d696f561e
8 changed files with 51 additions and 28 deletions
+20 -8
View File
@@ -3524,12 +3524,28 @@ if( !GetPuttyFlag() ) {
}
#ifdef MOD_PERSO
if (!midsession) {
s = ctrl_getset(b, "Connection/SSH", "pscp", "PSCP integration") ;
ctrl_checkbox(s, "Send file in current directory", NO_SHORTCUT,
if( !midsession && !GetPuttyFlag() ) {
s = ctrl_getset(b, "Connection/SSH", "pscp", "WinSCP and PSCP integration") ;
ctrl_checkbox(s, "Send file in current directory (pscp only)", NO_SHORTCUT,
HELPCTX(no_help),
conf_checkbox_handler,
I(CONF_scp_auto_pwd));
I(CONF_scp_auto_pwd));
ctrl_radiobuttons(s, "WinSCP protocol:", NO_SHORTCUT, 7,
HELPCTX(no_help),
conf_radiobutton_handler,
I(CONF_winscpprot),
"scp", NO_SHORTCUT, I(0),
"sftp", NO_SHORTCUT, I(1),
"ftp", NO_SHORTCUT, I(2),
"ftps", NO_SHORTCUT, I(3),
"ftpes", NO_SHORTCUT, I(4),
"http", NO_SHORTCUT, I(5),
"https", NO_SHORTCUT, I(6),
NULL);
ctrl_editbox(s, "SFTP connect", NO_SHORTCUT, 100,
HELPCTX(no_help),
conf_editbox_handler, I(CONF_sftpconnect),
I(1));
}
#endif
@@ -4081,10 +4097,6 @@ if( !GetPuttyFlag() ) {
HELPCTX(no_help),
conf_editbox_handler, I(CONF_comment),
I(1));
ctrl_editbox(s, "SFTP connect", NO_SHORTCUT, 100,
HELPCTX(no_help),
conf_editbox_handler, I(CONF_sftpconnect),
I(1));
}
#endif
}
+1
View File
@@ -1555,6 +1555,7 @@ NORETURN void cleanup_exit(int);
X(BOOL, NONE, saveonexit) \
X(INT, NONE, icone) \
X(FILENAME, NONE, iconefile) \
X(INT, NONE, winscpprot) \
X(STR, NONE, sftpconnect) \
X(STR, NONE, folder) \
X(STR, NONE, password) \
+2
View File
@@ -884,6 +884,7 @@ void save_open_settings(settings_w *sesskey, Conf *conf)
write_setting_b(sesskey, "SaveOnExit", conf_get_bool(conf, CONF_saveonexit) );
write_setting_i(sesskey, "Icone", conf_get_int(conf, CONF_icone) );
write_setting_filename(sesskey, "IconeFile", conf_get_filename(conf, CONF_iconefile) );
write_setting_i(sesskey, "WinSCPProtocol", conf_get_int(conf, CONF_winscpprot) );
write_setting_s(sesskey, "SFTPConnect", conf_get_str(conf, CONF_sftpconnect) );
Filename * fn = filename_from_str( "" ) ;
conf_set_filename(conf,CONF_scriptfile,fn);
@@ -1518,6 +1519,7 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
gppb(sesskey, "SaveOnExit", false, conf, CONF_saveonexit );
gppi(sesskey, "Icone", 1, conf, CONF_icone );
gppfile(sesskey, "IconeFile", conf, CONF_iconefile );
gppi(sesskey, "WinSCPProtocol", 1, conf, CONF_winscpprot );
gpps(sesskey, "SFTPConnect", "", conf, CONF_sftpconnect );
gppfile(sesskey, "Scriptfile", conf, CONF_scriptfile );
Filename * fn = filename_from_str( "" ) ;
+20 -12
View File
@@ -350,7 +350,7 @@ char * WinSCPPath = NULL ;
char * PSCPPath = NULL ;
// Options pour le programme pscp.exe
char PSCPOptions[1024] = "-scp -r" ;
char PSCPOptions[1024] = "-r" ;
// Chemin vers le programme plink.exe
char * PlinkPath = NULL ;
@@ -1303,7 +1303,7 @@ void CreateDefaultIniFile_old( void ) {
writeINI( KittyIniFile, INIT_SECTION, "paste", "no" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#PlinkPath", "" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#PSCPPath", "" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#PSCPOptions", "-scp -r" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#PSCPOptions", "-r" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#remotedir", "" ) ;
#ifdef MOD_PORTABLE
writeINI( KittyIniFile, INIT_SECTION, "savemode", "dir" ) ;
@@ -1330,7 +1330,6 @@ void CreateDefaultIniFile_old( void ) {
writeINI( KittyIniFile, INIT_SECTION, "#uploaddir", "." ) ;
writeINI( KittyIniFile, INIT_SECTION, "#userpasssshnosave", "no" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#WinSCPPath", "" ) ;
writeINI( KittyIniFile, INIT_SECTION, "#WinSCPProtocol", "sftp" ) ;
#ifdef MOD_ZMODEM
writeINI( KittyIniFile, INIT_SECTION, "zmodem", "yes" ) ;
#endif
@@ -2049,7 +2048,8 @@ void SendOneFile( HWND hwnd, char * directory, char * filename, char * distantdi
if( strlen(PSCPOptions)>0 ) {
strcat( buffer, PSCPOptions ) ; strcat( buffer, " " ) ;
}
//strcat( buffer, "-scp -r " ) ; //strcat( buffer, "-batch " ) ;
if( conf_get_int(conf, CONF_winscpprot)==0 ) { strcat( buffer, "-scp " ) ; }
else { strcat( buffer, "-sftp " ) ; }
//if( GetAutoStoreSSHKeyFlag() ) strcat( buffer, "-auto-store-sshkey " ) ;
@@ -2266,7 +2266,8 @@ void GetOneFile( HWND hwnd, char * directory, const char * filename ) {
if( strlen(PSCPOptions)>0 ) {
strcat( buffer, PSCPOptions ) ; strcat( buffer, " " ) ;
}
//strcat( buffer, "-scp -r " ) ;
if( conf_get_int(conf, CONF_winscpprot)==0 ) { strcat( buffer, "-scp " ) ; }
else { strcat( buffer, "-sftp " ) ; }
//if( GetAutoStoreSSHKeyFlag() ) strcat( buffer, "-auto-store-sshkey " ) ;
@@ -2381,9 +2382,11 @@ void GetFile( HWND hwnd ) {
if( strlen(PSCPOptions)>0 ) {
strcat( buffer, PSCPOptions ) ; strcat( buffer, " " ) ;
}
if( conf_get_int(conf, CONF_winscpprot)==0 ) { strcat( buffer, "-scp " ) ; }
else { strcat( buffer, "-sftp " ) ; }
if( conf_get_int(conf,CONF_sshprot) == 3 ) { // SSH-2 Only (voir putty.h)
strcat( buffer, "-2 " ) ;
}
}
if( ReadParameter( INIT_SECTION, "pscpport", pscpport ) ) {
pscpport[17]='\0';
@@ -3867,12 +3870,17 @@ void StartWinSCP( HWND hwnd, char * directory, char * host, char * user ) {
if( !GetShortPathName( WinSCPPath, shortpath, 4095 ) ) return ;
switch( conf_get_int(conf, CONF_winscpprot) ) {
case 0: strcpy( proto, "scp" ) ; break ;
case 2: strcpy( proto, "ftp" ) ; break ;
case 3: strcpy( proto, "ftps" ) ; break ;
case 4: strcpy( proto, "ftpes" ) ; break ;
case 5: strcpy( proto, "http" ) ; break ;
case 6: strcpy( proto, "https" ) ; break ;
default: strcpy( proto, "sftp" ) ;
}
if( conf_get_int(conf,CONF_protocol) == PROT_SSH ) {
strcpy( proto, "sftp" ) ;
if( ReadParameter( INIT_SECTION, "WinSCPProtocol", buffer ) ) {
if( (!strcmp( buffer, "scp" )) || (!strcmp( buffer, "sftp" )) || (!strcmp( buffer, "ftp" )) )
strcpy( proto, buffer) ;
}
sprintf( cmd, "%s %s://", shortpath, proto ) ;
if( strlen( conf_get_str(conf, CONF_sftpconnect) ) > 0 ) {
@@ -3911,7 +3919,7 @@ void StartWinSCP( HWND hwnd, char * directory, char * host, char * user ) {
}
}
} else {
sprintf( cmd, "%s ftp://%s", shortpath, conf_get_str(conf,CONF_username) ) ;
sprintf( cmd, "%s %s://%s", shortpath, proto, conf_get_str(conf,CONF_username) ) ;
if( strlen( conf_get_str(conf,CONF_password) ) > 0 ) {
char bufpass[1024] ;
strcat( cmd, ":" );
+3 -8
View File
@@ -129,8 +129,8 @@ paste=no
;PSCPPath=
; PSCPOptions: the additionnal options to pass to the pscp command (for download or upload file)
; default settings are -scp -r (force scp mode, and recursive mode)
;PSCPOptions=-scp -r
; default settings are -r (force recursive mode)
;PSCPOptions=-r
; ReconnectDelay: the delay before trying to reconnect automatically (in seconds)
ReconnectDelay=5
@@ -183,14 +183,9 @@ userpasssshnosave=no
; winrol: enable/disable the rolling feature (rolling into the title bar)
winrol=yes
; WinSCPPath: the full path to the winscp.exe binary
; WinSCPPath: the full path to the winscp.exe binary:
;WinSCPPath=
; WinSCPProtocol: force the protocol for WinSCP integration
; Allowed values are: scp, sftp, ftp
; Default value is: sftp
;WinSCPProtocol=sftp
; wintitle: enable/disable the enhanced title feature (for protected mode and window size)
wintitle=yes
+1
View File
@@ -478,6 +478,7 @@ return 1 ;
RegDeleteValue( hSubKey, "Folder" ) ;
RegDeleteValue( hSubKey, "Icone" ) ;
RegDeleteValue( hSubKey, "IconeFile" ) ;
RegDeleteValue( hSubKey, "WinSCPProtocol" ) ;
RegDeleteValue( hSubKey, "SFTPConnect" ) ;
RegDeleteValue( hSubKey, "InitDelay" ) ;
RegDeleteValue( hSubKey, "Password" ) ;
+2
View File
@@ -490,6 +490,7 @@ void SaveDumpConfig( FILE *fp, Conf * conf ) {
fprintf( fp, "saveonexit=%d\n", conf_get_bool(conf,CONF_saveonexit) ) ;
fprintf( fp, "icone=%d\n", conf_get_int(conf,CONF_icone) ) ;
fprintf( fp, "iconefile=%s\n", conf_get_filename(conf,CONF_iconefile)->path ) ;
fprintf( fp, "winscpprot=%d\n", conf_get_int(conf,CONF_winscpprot) ) ;
fprintf( fp, "sftpconnect=%s\n", conf_get_str(conf,CONF_sftpconnect) ) ;
fprintf( fp, "folder=%s\n", conf_get_str(conf,CONF_folder) ) ;
/* On decrypte le password */
@@ -627,6 +628,7 @@ void SaveDumpConfig( FILE *fp, Conf * conf ) {
fprintf( fp, "WinHeight=%d\nWinrolFlag=%d\nAutoSendToTray=%d\nNoKittyFileFlag=%d\nConfigBoxHeight=%d\nConfigBoxWindowHeight=%d\nConfigBoxNoExitFlag=%d\nUserPassSSHNoSave=%d\nPuttyFlag=%d\n",WinHeight,WinrolFlag,AutoSendToTray,NoKittyFileFlag,ConfigBoxHeight,ConfigBoxWindowHeight,ConfigBoxNoExitFlag,GetUserPassSSHNoSave(),PuttyFlag);
fprintf( fp,"BackgroundImageFlag=%d\n",GetBackgroundImageFlag() );
fprintf( fp,"PSCPOptions=%s\n",PSCPOptions );
#ifdef MOD_RECONNECT
fprintf( fp,"AutoreconnectFlag=%d\nReconnectDelay=%d\n",AutoreconnectFlag,ReconnectDelay );
#endif
+2
View File
@@ -391,6 +391,7 @@ void save_open_settings_forced(char *filename, Conf *conf) {
write_setting_b_forced(sesskey, "SaveOnExit", conf_get_bool(conf, CONF_saveonexit) );
write_setting_i_forced(sesskey, "Icone", conf_get_int(conf, CONF_icone) );
write_setting_filename_forced(sesskey, "IconeFile", conf_get_filename(conf, CONF_iconefile) );
write_setting_i_forced(sesskey, "WinSCPProtocol", conf_get_int(conf, CONF_winscpprot) );
write_setting_s_forced(sesskey, "SFTPConnect", conf_get_str(conf, CONF_sftpconnect) );
Filename * fn = filename_from_str( "" ) ;
conf_set_filename(conf,CONF_scriptfile,fn);
@@ -1016,6 +1017,7 @@ void load_open_settings_forced(char *filename, Conf *conf) {
gppb_forced(sesskey, "SaveOnExit", false, conf, CONF_saveonexit );
gppi_forced(sesskey, "Icone", 1, conf, CONF_icone );
gppfile_forced(sesskey, "IconeFile", conf, CONF_iconefile );
gppi_forced(sesskey, "WinSCPProtocol", 1, conf, CONF_winscpprot );
gpps_forced(sesskey, "SFTPConnect", "", conf, CONF_sftpconnect );
gppfile_forced(sesskey, "Scriptfile", conf, CONF_scriptfile );
Filename * fn = filename_from_str( "" ) ;