bugfix: complete refactoring of session selector in portable mode
This commit is contained in:
+72
-69
@@ -969,6 +969,63 @@ int isSessionExist( struct sessionsaver_data *ssd, char * name ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void sessionlist_add( char** sessionslist, const char* val, int* pos, bool checkfext) {
|
||||
if( !checkfext || !strcmp(FileExtension,"") ) {
|
||||
sessionslist[*pos] = (char*)malloc( strlen(val)+1 ) ;
|
||||
strcpy(sessionslist[*pos],val) ;
|
||||
*pos = *pos + 1 ;
|
||||
} else {
|
||||
if( !strcmp(FileExtension,val+strlen(val)-strlen(FileExtension)) ) {
|
||||
sessionslist[*pos] = (char*)malloc( strlen(val)+1 ) ;
|
||||
strcpy(sessionslist[*pos],val) ;
|
||||
sessionslist[*pos][strlen(sessionslist[*pos])-strlen(FileExtension)]='\0' ; // Remove extension
|
||||
*pos = *pos + 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void filter_session_portable(union control *ctrl, dlgparam *dlg, const int nb, const char** sessionslist, const char * savedsession) {
|
||||
int i, j=0; char **s ; bool * tabb ;
|
||||
// init
|
||||
s = (char**)malloc( nb*sizeof(char*)) ;
|
||||
tabb = (bool*)malloc(nb*sizeof(bool)) ;
|
||||
for( i=0 ; i<nb ; i++ ) { s[i] = NULL ; tabb[i] = true ; }
|
||||
|
||||
// Adding directories
|
||||
if( GetDirectoryBrowseFlag() )
|
||||
for( i=0 ; i<nb ; i++ ) if( tabb[i] ) {
|
||||
if( !strcmp(sessionslist[i]," [..]") ) { sessionlist_add(s,sessionslist[i],&j,false) ; tabb[i] = false ; } // Add directory ..
|
||||
else if( strstr(sessionslist[i]," [")==sessionslist[i] ) { // Add other directories
|
||||
if( !(strstr(sessionslist[i]," [.")==sessionslist[i]) ) sessionlist_add(s,sessionslist[i],&j,false) ; // ... except if start with .
|
||||
tabb[i] = false ;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding Default Settings Session only on Main folder
|
||||
for( i=0 ; i<nb ; i++ ) if( tabb[i] ) {
|
||||
if( strstr(sessionslist[i],"Default Settings")==sessionslist[i] ) {
|
||||
if( !strcmp(CurrentFolder,"Default") ) sessionlist_add(s,sessionslist[i],&j,true) ;
|
||||
tabb[i] = false ;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding other session depending on the filter
|
||||
for( i=0 ; i<nb ; i++ ) if( tabb[i] ) {
|
||||
if( !GetSessionFilterFlag() ) { // On filter disable
|
||||
sessionlist_add(s,sessionslist[i],&j,true) ;
|
||||
} else if( stristr(sessionslist[i],savedsession)!=NULL ) { / If filter match
|
||||
sessionlist_add(s,sessionslist[i],&j,true) ;
|
||||
}
|
||||
tabb[i] = false ;
|
||||
}
|
||||
|
||||
for( i=0 ; i<nb ; i++ ) { if( s[i] != NULL ) { dlg_listbox_add(ctrl, dlg, s[i]) ; } }
|
||||
// cleaning
|
||||
for( i=0 ; i<nb ; i++ ) { if( s[i] != NULL ) { free(s[i]) ; } }
|
||||
free(tabb);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
|
||||
void *data, int event)
|
||||
{
|
||||
@@ -991,7 +1048,11 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
|
||||
|
||||
ctrlSessionList = ctrl ;
|
||||
if(get_param("INIFILE")==SAVEMODE_DIR) CleanFolderName( CurrentFolder ) ;
|
||||
|
||||
|
||||
if( get_param("INIFILE")==SAVEMODE_DIR ) {
|
||||
filter_session_portable(ctrl, dlg, ssd->sesslist.nsessions,ssd->sesslist.sessions, ssd->savedsession ) ;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < ssd->sesslist.nsessions; i++) {
|
||||
char folder[1024] ;
|
||||
strcpy( folder, "" ) ;
|
||||
@@ -1001,69 +1062,7 @@ static void sessionsaver_handler(union control *ctrl, dlgparam *dlg,
|
||||
if( GetPuttyFlag() ) { // In PuTTY mode => all sessions
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
}
|
||||
else if( (get_param("INIFILE")==SAVEMODE_DIR) && GetDirectoryBrowseFlag() ) { // In portable mode
|
||||
CleanFolderName( folder ) ;
|
||||
if( !strcmp( ssd->savedsession, "" ) ) { // If nothing in session name field
|
||||
if( (!strcmp(CurrentFolder,folder))
|
||||
|| (!strcmp("",folder))
|
||||
|| ( strstr(ssd->sesslist.sessions[i]," [")==ssd->sesslist.sessions[i] )
|
||||
) {
|
||||
if ( !strcmp(ssd->sesslist.sessions[i]," [..]") ) {
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
} else if( !strcmp(FileExtension,"") // No file extension defined
|
||||
&& !(strstr(ssd->sesslist.sessions[i]," [.")==ssd->sesslist.sessions[i])
|
||||
) {
|
||||
if( !strcmp(ssd->sesslist.sessions[i], "Default Settings")&&strcmp(CurrentFolder,"Default") ) {
|
||||
//dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
} else {
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
}
|
||||
} else if( strcmp(FileExtension,"") // if file extention defined
|
||||
&& (
|
||||
!strcmp(FileExtension,ssd->sesslist.sessions[i]+strlen(ssd->sesslist.sessions[i])-strlen(FileExtension))
|
||||
||( (strstr(ssd->sesslist.sessions[i]," [")==ssd->sesslist.sessions[i]) && !(strstr(ssd->sesslist.sessions[i]," [.")==ssd->sesslist.sessions[i]) )
|
||||
)
|
||||
) {
|
||||
char *n=(char*)malloc(strlen(ssd->sesslist.sessions[i])+1);
|
||||
strcpy(n,ssd->sesslist.sessions[i]);
|
||||
if( (n[0]!=' ') || (n[1]!='[') )
|
||||
n[strlen(n)-strlen(FileExtension)]='\0'; // On essaie de supprimer l'affichage de l'extention
|
||||
dlg_listbox_add(ctrl, dlg, n);
|
||||
free(n);
|
||||
}
|
||||
}
|
||||
} else { // If something in session name field
|
||||
if( (!strcmp(CurrentFolder,folder))||(!strcmp("",folder)) ) {
|
||||
if( (stristr(ssd->sesslist.sessions[i],ssd->savedsession)!=NULL) || !GetSessionFilterFlag()
|
||||
|| ( strstr(ssd->sesslist.sessions[i]," [")==ssd->sesslist.sessions[i] ) ) {
|
||||
if ( !strcmp(ssd->sesslist.sessions[i]," [..]") ) { // if directory
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
} else if( !strcmp(FileExtension,"") // No file extension defined
|
||||
&& !(strstr(ssd->sesslist.sessions[i]," [.")==ssd->sesslist.sessions[i])
|
||||
) {
|
||||
if( !strcmp(ssd->sesslist.sessions[i], "Default Settings")&&strcmp(CurrentFolder,"Default") ) {
|
||||
//dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
} else {
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
}
|
||||
} else if( strcmp(FileExtension,"") // if file extention defined
|
||||
&& (
|
||||
!strcmp(FileExtension,ssd->sesslist.sessions[i]+strlen(ssd->sesslist.sessions[i])-strlen(FileExtension))
|
||||
|| ( (strstr(ssd->sesslist.sessions[i]," [")==ssd->sesslist.sessions[i]) && !(strstr(ssd->sesslist.sessions[i]," [.")==ssd->sesslist.sessions[i]) )
|
||||
)
|
||||
) {
|
||||
char *n=(char*)malloc(strlen(ssd->sesslist.sessions[i])+1);
|
||||
strcpy(n,ssd->sesslist.sessions[i]);
|
||||
if( (n[0]!=' ') || (n[1]!='[') )
|
||||
n[strlen(n)-strlen(FileExtension)]='\0'; // On essaie de supprimer l'affichage de l'extention
|
||||
dlg_listbox_add(ctrl, dlg, n);
|
||||
free(n);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if( !GetSessionFilterFlag() ) // In registry mode without filter => all sessions
|
||||
dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
|
||||
else { // In registry mode with filter
|
||||
@@ -4019,10 +4018,10 @@ if( !GetPuttyFlag() ) {
|
||||
|
||||
#ifdef MOD_PERSO
|
||||
if( !GetPuttyFlag() ) {
|
||||
ctrl_settitle(b, "Connection/SSH/PSCP&WinSCP",
|
||||
ctrl_settitle(b, "Connection/SSH/PSCP and WinSCP",
|
||||
"PSCP and WinSCP integration");
|
||||
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP&WinSCP", "winSCPproto", "General protocol setting") ;
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP and WinSCP", "winSCPproto", "General protocol setting") ;
|
||||
ctrl_radiobuttons(s, "Prefered protocol:", NO_SHORTCUT, 7,
|
||||
HELPCTX(no_help),
|
||||
conf_radiobutton_handler,
|
||||
@@ -4036,17 +4035,21 @@ if( !GetPuttyFlag() ) {
|
||||
"https", NO_SHORTCUT, I(6),
|
||||
NULL);
|
||||
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP&WinSCP", "pscp", "PSCP integration") ;
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP and WinSCP", "pscp", "PSCP integration") ;
|
||||
ctrl_checkbox(s, "Send file in current directory", NO_SHORTCUT,
|
||||
HELPCTX(no_help),
|
||||
conf_checkbox_handler,
|
||||
I(CONF_scp_auto_pwd));
|
||||
ctrl_editbox(s, "PSCP options", NO_SHORTCUT, 100,
|
||||
ctrl_editbox(s, "Remote directory (exclusive with previous setting)", NO_SHORTCUT, 100,
|
||||
HELPCTX(no_help),
|
||||
conf_editbox_handler, I(CONF_pscpremotedir),
|
||||
I(1));
|
||||
ctrl_editbox(s, "PSCP options", NO_SHORTCUT, 100,
|
||||
HELPCTX(no_help),
|
||||
conf_editbox_handler, I(CONF_pscpoptions),
|
||||
I(1));
|
||||
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP&WinSCP", "WinSCP", "WinSCP integration") ;
|
||||
s = ctrl_getset(b, "Connection/SSH/PSCP and WinSCP", "WinSCP", "WinSCP integration") ;
|
||||
ctrl_editbox(s, "SFTP connect ([user@]hostname[:port])", NO_SHORTCUT, 100,
|
||||
HELPCTX(no_help),
|
||||
conf_editbox_handler, I(CONF_sftpconnect),
|
||||
|
||||
@@ -1558,6 +1558,7 @@ NORETURN void cleanup_exit(int);
|
||||
X(INT, NONE, winscpprot) \
|
||||
X(STR, NONE, sftpconnect) \
|
||||
X(STR, NONE, pscpoptions) \
|
||||
X(STR, NONE, pscpremotedir) \
|
||||
X(STR, NONE, winscpoptions) \
|
||||
X(STR, NONE, winscprawsettings) \
|
||||
X(STR, NONE, folder) \
|
||||
|
||||
@@ -887,6 +887,7 @@ void save_open_settings(settings_w *sesskey, Conf *conf)
|
||||
write_setting_i(sesskey, "WinSCPProtocol", conf_get_int(conf, CONF_winscpprot) );
|
||||
write_setting_s(sesskey, "SFTPConnect", conf_get_str(conf, CONF_sftpconnect) );
|
||||
write_setting_s(sesskey, "PSCPOptions", conf_get_str(conf, CONF_pscpoptions) );
|
||||
write_setting_s(sesskey, "PSCPRemoteDir", conf_get_str(conf, CONF_pscpremotedir) );
|
||||
write_setting_s(sesskey, "WinSCPOptions", conf_get_str(conf, CONF_winscpoptions) );
|
||||
write_setting_s(sesskey, "WinSCPRawSettings", conf_get_str(conf, CONF_winscprawsettings) );
|
||||
Filename * fn = filename_from_str( "" ) ;
|
||||
@@ -1525,6 +1526,7 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
|
||||
gppi(sesskey, "WinSCPProtocol", 1, conf, CONF_winscpprot );
|
||||
gpps(sesskey, "SFTPConnect", "", conf, CONF_sftpconnect );
|
||||
gpps(sesskey, "PSCPOptions", "-r", conf, CONF_pscpoptions );
|
||||
gpps(sesskey, "PSCPRemoteDir", "", conf, CONF_pscpremotedir );
|
||||
gpps(sesskey, "WinSCPOptions", "", conf, CONF_winscpoptions );
|
||||
gpps(sesskey, "WinSCPRawSettings", "", conf, CONF_winscprawsettings );
|
||||
gppfile(sesskey, "Scriptfile", conf, CONF_scriptfile );
|
||||
|
||||
@@ -1300,7 +1300,6 @@ void CreateDefaultIniFile_old( void ) {
|
||||
writeINI( KittyIniFile, INIT_SECTION, "paste", "no" ) ;
|
||||
writeINI( KittyIniFile, INIT_SECTION, "#PlinkPath", "" ) ;
|
||||
writeINI( KittyIniFile, INIT_SECTION, "#PSCPPath", "" ) ;
|
||||
writeINI( KittyIniFile, INIT_SECTION, "#remotedir", "" ) ;
|
||||
#ifdef MOD_PORTABLE
|
||||
writeINI( KittyIniFile, INIT_SECTION, "savemode", "dir" ) ;
|
||||
#else
|
||||
@@ -2015,25 +2014,25 @@ void SendOneFile( HWND hwnd, char * directory, char * filename, char * distantdi
|
||||
if( PSCPPath==NULL ) {
|
||||
if( IniFileFlag == SAVEMODE_REG ) return ;
|
||||
else if( !SearchPSCP() ) return ;
|
||||
}
|
||||
}
|
||||
if( !existfile( PSCPPath ) ) {
|
||||
if( IniFileFlag == SAVEMODE_REG ) return ;
|
||||
else if( !SearchPSCP() ) return ;
|
||||
}
|
||||
}
|
||||
|
||||
if( !GetShortPathName( PSCPPath, pscppath, 4095 ) ) return ;
|
||||
|
||||
if( ReadParameter( INIT_SECTION, "uploaddir", dir ) ) {
|
||||
if( !existdirectory( dir ) )
|
||||
strcpy( dir, InitialDirectory ) ;
|
||||
}
|
||||
}
|
||||
if (strlen( dir ) == 0) strcpy( dir, InitialDirectory ) ;
|
||||
|
||||
if( (distantdir != NULL ) && ( strlen(distantdir)>0 ) ) {
|
||||
strcpy( remotedir, distantdir ) ;
|
||||
} else if( !ReadParameter( INIT_SECTION, "remotedir", remotedir ) ) {
|
||||
strcpy( remotedir, "." ) ;
|
||||
}
|
||||
} else if( strlen(conf_get_str(conf,CONF_pscpremotedir))>0 ) {
|
||||
strcpy( remotedir, conf_get_str(conf,CONF_pscpremotedir) ) ;
|
||||
} else { strcpy( remotedir, "." ) ; }
|
||||
if( strlen( remotedir ) == 0 ) strcpy( remotedir, "." ) ;
|
||||
|
||||
strcpy( buffer, "" ) ;
|
||||
|
||||
@@ -131,9 +131,6 @@ paste=no
|
||||
; ReconnectDelay: the delay before trying to reconnect automatically (in seconds)
|
||||
ReconnectDelay=5
|
||||
|
||||
; remotedir: the default remote directory where files will be uploaded with pscp integration (drag 'n drop in the KiTTY window)
|
||||
;remotedir=.
|
||||
|
||||
; sav: path to the save file of the KiTTY registry
|
||||
;
|
||||
|
||||
@@ -170,9 +167,6 @@ size=no
|
||||
; transparency: enable/disable the transparency feature
|
||||
transparency=yes
|
||||
|
||||
; uploaddir: the default remote directory where files will be uploaded with pscp integration (drag 'n drop in the KiTTY window)
|
||||
;uploaddir=.
|
||||
|
||||
; userpasssshnosave: if yes, SSH password will not be save internaly (and can't be reuse automatically)
|
||||
userpasssshnosave=no
|
||||
|
||||
|
||||
@@ -481,6 +481,7 @@ return 1 ;
|
||||
RegDeleteValue( hSubKey, "WinSCPProtocol" ) ;
|
||||
RegDeleteValue( hSubKey, "SFTPConnect" ) ;
|
||||
RegDeleteValue( hSubKey, "PSCPOptions" ) ;
|
||||
RegDeleteValue( hSubKey, "PSCPRemoteDir" ) ;
|
||||
RegDeleteValue( hSubKey, "WinSCPOptions" ) ;
|
||||
RegDeleteValue( hSubKey, "WinSCPRawSettings" ) ;
|
||||
RegDeleteValue( hSubKey, "InitDelay" ) ;
|
||||
|
||||
@@ -493,6 +493,7 @@ void SaveDumpConfig( FILE *fp, Conf * conf ) {
|
||||
fprintf( fp, "winscpprot=%d\n", conf_get_int(conf,CONF_winscpprot) ) ;
|
||||
fprintf( fp, "sftpconnect=%s\n", conf_get_str(conf,CONF_sftpconnect) ) ;
|
||||
fprintf( fp, "pscpoptions=%s\n", conf_get_str(conf,CONF_pscpoptions) ) ;
|
||||
fprintf( fp, "pscpremotedir=%s\n", conf_get_str(conf,CONF_pscpremotedir) ) ;
|
||||
fprintf( fp, "winscpoptions=%s\n", conf_get_str(conf,CONF_winscpoptions) ) ;
|
||||
fprintf( fp, "winscprawsettings=%s\n", conf_get_str(conf,CONF_winscprawsettings) ) ;
|
||||
fprintf( fp, "folder=%s\n", conf_get_str(conf,CONF_folder) ) ;
|
||||
|
||||
@@ -394,6 +394,7 @@ void save_open_settings_forced(char *filename, Conf *conf) {
|
||||
write_setting_i_forced(sesskey, "WinSCPProtocol", conf_get_int(conf, CONF_winscpprot) );
|
||||
write_setting_s_forced(sesskey, "SFTPConnect", conf_get_str(conf, CONF_sftpconnect) );
|
||||
write_setting_s_forced(sesskey, "PSCPOptions", conf_get_str(conf, CONF_pscpoptions) );
|
||||
write_setting_s_forced(sesskey, "PSCPRemoteDir", conf_get_str(conf, CONF_pscpremotedir) );
|
||||
write_setting_s_forced(sesskey, "WinSCPOptions", conf_get_str(conf, CONF_winscpoptions) );
|
||||
write_setting_s_forced(sesskey, "WinSCPRawSettings", conf_get_str(conf, CONF_winscprawsettings) );
|
||||
Filename * fn = filename_from_str( "" ) ;
|
||||
@@ -1022,6 +1023,10 @@ void load_open_settings_forced(char *filename, Conf *conf) {
|
||||
gppfile_forced(sesskey, "IconeFile", conf, CONF_iconefile );
|
||||
gppi_forced(sesskey, "WinSCPProtocol", 1, conf, CONF_winscpprot );
|
||||
gpps_forced(sesskey, "SFTPConnect", "", conf, CONF_sftpconnect );
|
||||
gpps_forced(sesskey, "PSCPOptions", "-r", conf, CONF_pscpoptions );
|
||||
gpps_forced(sesskey, "PSCPRemoteDir", "", conf, CONF_pscpremotedir );
|
||||
gpps_forced(sesskey, "WinSCPOptions", "", conf, CONF_winscpoptions );
|
||||
gpps_forced(sesskey, "WinSCPRawSettings", "", conf, CONF_winscprawsettings );
|
||||
gppfile_forced(sesskey, "Scriptfile", conf, CONF_scriptfile );
|
||||
Filename * fn = filename_from_str( "" ) ;
|
||||
conf_set_filename(conf,CONF_scriptfile,fn);
|
||||
|
||||
Reference in New Issue
Block a user