diff --git a/dotnet/Session.cs b/dotnet/Session.cs index 78b0f4af..14e9285a 100644 --- a/dotnet/Session.cs +++ b/dotnet/Session.cs @@ -961,20 +961,20 @@ private string SessionOptionsToOpenSwitches(SessionOptions sessionOptions) } } - if (!string.IsNullOrEmpty(sessionOptions.SslHostCertificateFingerprint) || - sessionOptions.GiveUpSecurityAndAcceptAnySslHostCertificate) + if (!string.IsNullOrEmpty(sessionOptions.TlsHostCertificateFingerprint) || + sessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate) { if (sessionOptions.FtpSecure == FtpSecure.None) { - throw new ArgumentException("SessionOptions.SslHostCertificateFingerprint or SessionOptions.GiveUpSecurityAndAcceptAnySslHostCertificate is set, but SessionOptions.FtpSecure is FtpSecure.None."); + throw new ArgumentException("SessionOptions.TlsHostCertificateFingerprint or SessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate is set, but SessionOptions.FtpSecure is FtpSecure.None."); } - string sslHostCertificateFingerprint = sessionOptions.SslHostCertificateFingerprint; - if (sessionOptions.GiveUpSecurityAndAcceptAnySslHostCertificate) + string tlsHostCertificateFingerprint = sessionOptions.TlsHostCertificateFingerprint; + if (sessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate) { Logger.WriteLine("WARNING! Giving up security and accepting any certificate as configured"); - sslHostCertificateFingerprint = AddStarToList(sslHostCertificateFingerprint); + tlsHostCertificateFingerprint = AddStarToList(tlsHostCertificateFingerprint); } - switches.Add(FormatSwitch("certificate", sslHostCertificateFingerprint)); + switches.Add(FormatSwitch("certificate", tlsHostCertificateFingerprint)); } if (sessionOptions.Protocol == Protocol.Ftp) diff --git a/dotnet/SessionOptions.cs b/dotnet/SessionOptions.cs index e4dbf299..b95fcfdd 100644 --- a/dotnet/SessionOptions.cs +++ b/dotnet/SessionOptions.cs @@ -29,8 +29,8 @@ public enum FtpSecure { None = 0, Implicit = 1, - ExplicitSsl = 2, ExplicitTls = 3, + ExplicitSsl = 2, } [Guid("2D4EF368-EE80-4C15-AE77-D12AEAF4B00A")] @@ -59,8 +59,12 @@ public SessionOptions() // FTP public FtpMode FtpMode { get; set; } public FtpSecure FtpSecure { get; set; } - public string SslHostCertificateFingerprint { get { return _sslHostCertificateFingerprint; } set { SetHostSslCertificateFingerprint(value); } } - public bool GiveUpSecurityAndAcceptAnySslHostCertificate { get; set; } + public string TlsHostCertificateFingerprint { get { return _tlsHostCertificateFingerprint; } set { SetHostTlsCertificateFingerprint(value); } } + [Obsolete("Use TlsHostCertificateFingerprint")] + public string SslHostCertificateFingerprint { get { return TlsHostCertificateFingerprint; } set { TlsHostCertificateFingerprint = value; } } + public bool GiveUpSecurityAndAcceptAnyTlsHostCertificate { get; set; } + [Obsolete("Use GiveUpSecurityAndAcceptAnyTlsHostCertificate")] + public bool GiveUpSecurityAndAcceptAnySslHostCertificate { get { return GiveUpSecurityAndAcceptAnyTlsHostCertificate; } set { GiveUpSecurityAndAcceptAnyTlsHostCertificate = value; } } public void AddRawSettings(string setting, string value) { @@ -85,19 +89,19 @@ private void SetSshHostKeyFingerprint(string s) _sshHostKeyFingerprint = s; } - private void SetHostSslCertificateFingerprint(string s) + private void SetHostTlsCertificateFingerprint(string s) { if (s != null) { - Match match = _sslCertificateRegex.Match(s); + Match match = _tlsCertificateRegex.Match(s); if (!match.Success || (match.Length != s.Length)) { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "SSL host certificate fingerprint \"{0}\" does not match pattern /{1}/", s, _sslCertificateRegex)); + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "TLS host certificate fingerprint \"{0}\" does not match pattern /{1}/", s, _tlsCertificateRegex)); } } - _sslHostCertificateFingerprint = s; + _tlsHostCertificateFingerprint = s; } private void SetTimeout(TimeSpan value) @@ -121,7 +125,7 @@ private void SetPortNumber(int value) } private string _sshHostKeyFingerprint; - private string _sslHostCertificateFingerprint; + private string _tlsHostCertificateFingerprint; private TimeSpan _timeout; private int _portNumber; @@ -129,8 +133,8 @@ private void SetPortNumber(int value) private const string _sshHostKeyPattern = @"(ssh-rsa |ssh-dss )?\d+ ([0-9a-f]{2}:){15}[0-9a-f]{2}"; private static readonly Regex _sshHostKeyRegex = new Regex(string.Format(CultureInfo.InvariantCulture, _listPattern, _sshHostKeyPattern)); - private const string _sslCertificatePattern = @"([0-9a-f]{2}:){19}[0-9a-f]{2}"; - private static readonly Regex _sslCertificateRegex = - new Regex(string.Format(CultureInfo.InvariantCulture, _listPattern, _sslCertificatePattern)); + private const string _tlsCertificatePattern = @"([0-9a-f]{2}:){19}[0-9a-f]{2}"; + private static readonly Regex _tlsCertificateRegex = + new Regex(string.Format(CultureInfo.InvariantCulture, _listPattern, _tlsCertificatePattern)); } } diff --git a/dotnet/internal/Logger.cs b/dotnet/internal/Logger.cs index 453a70d3..5ee2a27a 100644 --- a/dotnet/internal/Logger.cs +++ b/dotnet/internal/Logger.cs @@ -80,7 +80,7 @@ private void CreateCounters() private void AddCounter(PerformanceCounter counter) { counter.NextValue(); - _processorCounters.Add(counter); + _performanceCounters.Add(counter); } public void WriteLine(string message) @@ -144,6 +144,11 @@ public void Dispose() _writter.Dispose(); _writter = null; } + + foreach (PerformanceCounter counter in _performanceCounters) + { + counter.Dispose(); + } } } @@ -153,7 +158,7 @@ public void WriteCounters() { try { - foreach (PerformanceCounter counter in _processorCounters) + foreach (PerformanceCounter counter in _performanceCounters) { WriteLine("{0}{1}{2} = [{3}]", counter.CounterName, @@ -282,6 +287,6 @@ private void WriteEnvironmentInfo() private readonly Dictionary _indents = new Dictionary(); private readonly object _logLock = new object(); private readonly Lock _lock = new Lock(); - private List _processorCounters = new List(); + private List _performanceCounters = new List(); } } diff --git a/dotnet/properties/AssemblyInfo.cs b/dotnet/properties/AssemblyInfo.cs index 30def7cc..8c77add8 100644 --- a/dotnet/properties/AssemblyInfo.cs +++ b/dotnet/properties/AssemblyInfo.cs @@ -19,9 +19,9 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a0b93468-d98a-4845-a234-8076229ad93f")] -[assembly: AssemblyVersion("1.1.2.0")] -[assembly: AssemblyFileVersion("1.1.2.0")] -[assembly: AssemblyInformationalVersionAttribute("5.2.2.0")] +[assembly: AssemblyVersion("1.1.3.0")] +[assembly: AssemblyFileVersion("1.1.3.0")] +[assembly: AssemblyInformationalVersionAttribute("5.2.3.0")] [assembly: CLSCompliant(true)] diff --git a/libs/apr/docs/pool-design.html b/libs/apr/docs/pool-design.html index 5e794f64..96180638 100644 --- a/libs/apr/docs/pool-design.html +++ b/libs/apr/docs/pool-design.html @@ -4,7 +4,7 @@
- Last modified at [$Date: 2013/04/07 20:33:12 $] + Last modified at [$Date: 2013/08/12 09:54:01 $]

Using APR Pools

diff --git a/libs/expat/conftools/ac_c_bigendian_cross.m4 b/libs/expat/conftools/ac_c_bigendian_cross.m4 index 4a332a14..3f1d3186 100644 --- a/libs/expat/conftools/ac_c_bigendian_cross.m4 +++ b/libs/expat/conftools/ac_c_bigendian_cross.m4 @@ -7,7 +7,7 @@ dnl The implementation will create a binary, and instead of running dnl the binary it will be grep'ed for some symbols that will look dnl different for different endianess of the binary. dnl -dnl @version $Id: ac_c_bigendian_cross.m4,v 1.1 2013/04/07 20:33:22 martinprikryl Exp $ +dnl @version $Id: ac_c_bigendian_cross.m4,v 1.2 2013/08/12 09:54:02 martinprikryl Exp $ dnl @author Guido Draheim dnl AC_DEFUN([AC_C_BIGENDIAN_CROSS], diff --git a/libs/expat/conftools/mkinstalldirs b/libs/expat/conftools/mkinstalldirs index 02ece671..7dbbe54f 100644 --- a/libs/expat/conftools/mkinstalldirs +++ b/libs/expat/conftools/mkinstalldirs @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1 2013/04/07 20:33:22 martinprikryl Exp $ +# $Id: mkinstalldirs,v 1.2 2013/08/12 09:54:02 martinprikryl Exp $ errstatus=0 diff --git a/libs/install/openssl/readme_debug b/libs/install/openssl/readme_debug index e4175ef0..29389fd7 100644 --- a/libs/install/openssl/readme_debug +++ b/libs/install/openssl/readme_debug @@ -1,7 +1,6 @@ Debug build: - do CFLAG pridat - -v -y + -v -y -k -r- -vi- pro CodeGuard pridat -vG - a ubrat - -O2 + nahradit -O2 za -Od diff --git a/libs/mfc/source/borland.mak2 b/libs/mfc/source/borland.mak2 deleted file mode 100644 index 8db268e2..00000000 --- a/libs/mfc/source/borland.mak2 +++ /dev/null @@ -1,525 +0,0 @@ -# BORLAND.MAK: Borland makefile for MFC variants -# -# Usage: MAKE -F BORLAND.MAK CLEAN (removes all intermediary files) -# or: MAKE -F BORLAND.MAK options (builds library variant (see below)) -# Note that an MAKE CLEAN should be performed before building a new variant. -# -# 'Options' are one of each of: -# "DLL" (defaults to 0) -# If this item is 0, then a normal library is generated. -# DLL=1 is obsolete and not supported by this release. -# If this item is 2, objects suitable for the shared DLL version -# of MFC are created. Note: DLL=2 is to be used only from -# MFCDLL.MAK, MFCOLE.MAK, or MFCDB.MAK -# -# "DEBUG" (defaults to 1) -# If this item is 1, diagnostic support is compiled into -# the library. If this item is 0, then diagnostic support -# is disabled. Diagnostic support does not include debug info -# information. -# -# "OBJ=.\obj" (defaults to '$$(MODEL)$(BASE)$(DEBUG)') -# This optional specification specifies where temporary OBJ files -# are stored during the build process. The directory is created or -# removed as necessary. -# -# "OPT=" (no default value) -# This allows additional compiler options to be added to the build. -# If more than one switch is desired, put double-quotes around the -# whole OPT= argument, e.g., "OPT=/J /W3". -# -# "NO_PCH=1" -# Set this item to override the default use of precompiled headers. -# -# "BROWSE=1" (defaults to 0) -# Set this option to build browse info -# -# "MT=0" (defaults to 1) -# To build a non-multithreaded library instead of the default -# (which enables multitheading and uses the multithread -# C-runtimes) you can use MT=0. -# -#============================================================================= -# Borland Additional flags -#============================================================================= -# -# "NO_CLEAN_PCH" (defaults to off) -# To prevent deleting an existing PCH (.csm) file -# -# "DBGINFO" (defaults to 0) -# If this item is 1, Turbo Debugger debug info is compiled into -# the library. If it's 0, then no debugger info is added. -# -# "LIBDIR=..\..\lib" -# Directory for libraries that are created -# -# "MFCINCL=..\..\include\mfc" -# MFC Include directory base -# -# "BCINCL=..\..\include" -# BC++ Include directory -# -############################################################################# -# Define defaults if not defined -UNICODE=1 -# Default to DEBUG mode -!ifndef DEBUG -DEBUG=0 -!endif - -# Default to No Debug Info mode -!ifndef DBGINFO -DBGINFO=0 -!endif - -# Check for MS syntax -!ifdef CODEVIEW -DBGINFO=$(CODEVIEW) -!endif - -# Default to NOT DLL -!ifndef DLL -DLL=0 -!endif - -# Default to no BROWSE info -!ifndef BROWSE -BROWSE=0 -!endif - -# Default to no precompiled headers -#!ifndef NO_PCH -#NO_PCH=1 -#!endif - -# Default to _MBCS build -MBCS=1 - -# Default to multithreading support -!ifndef MT -MT=1 -!endif - -# Default to not enable Borland CodeGuard -!ifndef CG -CG=0 -!endif - -# Lib directory -!ifndef LIBDIR -LIBDIR=..\..\LIB -!endif - -# Lib Path -!ifndef LPATH -LPATH=..\..\LIB;..\..\LIB\PSDK -!endif - -# MFC Include directory base -!ifndef MFCINCL -MFCINCL=..\..\include\mfc -!endif - -# BC Include directory -!ifndef BCINCL -BCINCL=..\..\include;..\..\include\atl -!endif - -# Disable Warnings -!ifndef NO_WARNINGS -NO_WARNINGS=0 -!endif - - -# Clean up PCH file -!ifndef NO_CLEAN_PCH -NO_CLEAN_PCH=0 -!endif - -BASE=W -MODEL=U -TARGDEFS=/D_UNICODE /DUNICODE /D_AFX_NO_OLEDB_SUPPORT /D_AFX_NO_OCC_SUPPORT -!if "$(MBCS)" != "0" -TARGDEFS=$(TARGDEFS) /D_MBCS -!endif -PLATFORM=INTEL - -LFLAGS=$(LFLAGS) /j$(LPATH) /L$(LPATH) -!if "$(NO_WARNINGS)" == "1" -LFLAGS=$(LFLAGS) /w- -!endif - -# -# DEBUG OPTIONS -# -!if "$(DEBUG)" != "0" - -DEBUGSUF=D -DEBDEFS=/D_DEBUG -DEBOPTS= - -!endif - -# -# NON-DEBUG OPTIONS -# -!if "$(DEBUG)" == "0" - -DEBUGSUF= -DEBDEFS= -DEBOPTS=/O1 - -!endif - -!if "$(DBGINFO)" == "1" -DEBOPTS=/Od /v /vi -!endif - -!if "$(CG)" == "1" -DEBOPTS=$(DEBOPTS) -vG -!endif - -# -# PLATFORM options -# -CC=bcc32 -LIB32=tlib -!ifndef LINK32 -LINK32=ilink32 /Gn -!endif -CL_MODEL=/D_X86_ -GENDEFS=perl -w $(MAKEDIR)\gendefs.pl - -# TYPE = Library Type Designator -# c = normal C library -# d = DLL library -TYPE=c - -!if "$(DEXT)" == "" -DEXT= -!endif - -# -# Object File Directory -# -!if "$(OBJ)" == "" -D=$$$(MODEL)$(BASE)$(DEBUGSUF)$(DEXT) # subdirectory specific to variant -!else -D=$(OBJ) # User specified directory -!endif - -# -# _AFXDLL DLL Variant -# -!if "$(DLL)" == "2" -!if "$(TARG)" == "" -!error DLL=2 is used only from BFCDLL.MAK, BFCOLE.MAK, or BFCDB.MAK -!endif -GOAL=$(TARG) -TYPE=e -!if "$(OBJ)" == "" -D=DLL$(DEBUGSUF).$(BASE) -!if "$(UNICODE)" == "1" -D=$(MODEL)$(D) -!endif -D=$$$(D) -!endif -TARGDEFS=$(TARGDEFS) /D_WINDLL /D_AFXDLL -!else -GOAL=$(MODEL)afx$(TYPE)$(BASE)$(DEBUGSUF) -!endif - -# -# Threaded-ness -# -!if "$(MT)" != "0" -TARGOPTS=$(TARGOPTS) /WM /D_MT=1 -!else -!error This makefile only builds multi-threaded libraries, not single threaded. -!endif - -# -# Import libraries for the DLL builds -# -IMPORT_LIBS=import32.lib inet.lib odbc32.lib - -# -# COMPILER OPTIONS -# - -DEFS=$(DEFS) -D_declspec=__declspec /D_WCHAR_T_DEFINED /D__MSC /D_ANONYMOUS_STRUCT -D_MSC_VER=1200 -D_WINDOWS -!if "$(DLL)" == "2" -DEFS=$(DEFS) /D_RTLDLL /D_DLL -!endif -CL_OPT= -a8 -g0 -j2 -jb -VF4 $(INCROPTS) $(DEBOPTS) $(CVOPTS) $(TARGOPTS) - -# -# Internal debugging switch for the compiler (-=xx) -# -!ifdef COMPILER_DIAG -CL_OPT= $(CL_OPT) -=o -!endif - -!if "$(BROWSE)" != "0" -CL_OPT=-R $(CL_OPT) -!endif - -CL_OPT=-n$(D) $(CL_OPT) - -!if "$(NO_WARNINGS)" == "1" -CL_OPT=$(CL_OPT) -w- -!endif - -!if "$(DEVBUILD)" != "0" -CL_OPT=$(CL_OPT) /D_AFX_DEVBUILD -!endif - -DEFS=$(DEFS) $(DEBDEFS) $(TARGDEFS) - -############################################################################# -# Library Components - -OBJECT=objcore.obj except.obj \ - validadd.obj dumpcont.obj dumpflt.obj \ - arccore.obj arcobj.obj arcex.obj arcstrm.obj - -# non-shared diagnostics -OBJDIAG=dumpinit.obj dumpout.obj \ - afxasert.obj afxmem.obj afxabort.obj - -FILES=filecore.obj filetxt.obj filemem.obj fileshrd.obj \ - filex.obj filest.obj - -COLL1=array_b.obj array_d.obj array_p.obj array_o.obj \ - array_s.obj array_u.obj array_w.obj \ - list_o.obj list_p.obj list_s.obj - -COLL2=map_pp.obj map_pw.obj map_so.obj \ - map_sp.obj map_ss.obj map_wo.obj map_wp.obj plex.obj - -MISC=\ - strcore.obj strex.obj timecore.obj \ - afxdbcs.obj afxstate.obj afxtls.obj fixalloc.obj \ - mtcore.obj mtex.obj - -WINDOWS=winhand.obj - -DIALOG= - -WINMISC=afxcrit.obj winstr.obj winutil.obj auxdata.obj wingdi.obj - -DOCVIEW= - -INTERNET=inet.obj filefind.obj -!if "$(UNICODE)" == "1" -#INTERNET=$(INTERNET) isapimix.obj -!endif - -APPLICATION=appterm.obj appui1.obj appinit.obj apphelp.obj thrdcore.obj - -!if "$(DLL)" != "2" -#APPLICATION=$(APPLICATION) app3ds.obj \ -# nolib.obj appmodul.obj dllmodul.obj oleexp.obj dumpstak.obj -!endif - -# ODBC components: -DB=\ - dbcore.obj dbrfx.obj dbview.obj dbflt.obj \ - dblong.obj dbvar.obj - -# -# DAO is not supported under Borland C++ -# -#DB= $(DB) daocore.obj daodfx.obj daoview.obj viewoled.obj -# - -SOCKETS=sockcore.obj - -OLEREQ=olelock.obj - -OLE=\ - oleinit.obj olecli1.obj olecli2.obj \ - olecli3.obj olecnvrt.obj oledobj1.obj oledobj2.obj \ - oledisp1.obj oledisp2.obj oledlgs1.obj oledlgs2.obj \ - oledlgs3.obj oledata.obj olevar.obj olevar1.obj \ - oledoc1.obj oledoc2.obj oledrop1.obj oledrop2.obj \ - olemsgf.obj oleenum.obj olefact.obj oleipfrm.obj \ - olelink.obj olemisc.obj olestrm.obj olesvr1.obj \ - olesvr2.obj olereg.obj oletsvr.obj oleui1.obj \ - oleui2.obj oleunk.obj oleverb.obj olecall.obj \ - viewrich.obj oledll.obj oletyplb.obj \ - olemon.obj winctrl5.obj viewhtml.obj \ - occmgr.obj occevent.obj occcont.obj occsite.obj \ - occlock.obj occddx.obj occddxf.obj occdlg.obj \ - oledocvw.obj oledocob.obj oledoctg.obj oledocip.obj \ - oledoccl.obj oleasmon.obj olebar.obj - -OLECTL= - -!if "$(DEBUG)" == "1" -OLECTL=$(OLECTL) ctlinl.obj -!endif - -# Borland enhancement: -!if "$(DEBUG)" == "1" && "$(MONOLITHIC)" == "1" -OLE=$(OLE) dllole.obj -!endif - -OLEDLL=$(OLE) $(OLECTL) $(OLEASM) - -!if "$(DEBUG)" == "1" -INLINES = afxinl1.obj afxinl2.obj afxinl3.obj -!else -INLINES = -!endif - -CPP_OBJS=$(OBJECT) $(OBJDIAG) $(INLINES) $(FILES) $(COLL1) $(COLL2) $(MISC) \ - $(WINDOWS) $(DIALOG) $(WINMISC) $(DOCVIEW) $(APPLICATION) \ - $(SOCKETS) $(OLEREQ) $(OLE) $(DAO) $(DB) $(INTERNET) $(OLECTL) - - -OBJS=$(CPP_OBJS) $(OLEASM) - - -############################################################################# -# Standard tools - -############################################################################# -# Set CPPFLAGS for use with .cpp.obj and .c.obj rules -# Define rule for use with OBJ directory -# C++ uses a PCH file - -CPPFLAGS=$(CPPFLAGS) $(CL_MODEL) $(CL_OPT) $(PDBOPTS) $(DEFS) $(OPT) -BORRSP=bor.rsp - -!ifndef NO_PCH -!ifndef PCH_FILE -# put the PCH file in the OBJ directory for easy cleanup later -PCH_FILE=$(D)\stdafx -!if "$(BROWSE)" != "0" -PCH_FILE=$(PCH_FILE)b -!endif -PCH_FILE=$(PCH_FILE).csm -!endif -!ifndef PCH_CPP -PCH_CPP=objcore -!endif -PCH_CMD=-Hc -H=$(PCH_FILE) -!else -PCH_CMD=-H- -PCH_FILE= -!endif -CPPFLAGS=$(CPPFLAGS) $(PCH_CMD) - -!ifdef JOHNS_CPP32 -PREPROCFLAGS=-Sd -Sk -Sr -P- -!else -PREPROCFLAGS=-Sd -Sk -Ss -P -!endif - -.SUFFIXES: .cpp - -.path.obj = $(D) - - -.cpp.i: - cpp32 @$(BORRSP) $(PREPROCFLAGS) $< - -.cpp.obj: -!if $d(FORCE_CPP32) - cpp32 @$(BORRSP) $(PREPROCFLAGS) $< -!else - $(CC) @$(BORRSP) /c { $< } -!endif - -!ifndef NO_PCH -PCH_TARGETS=$(PCH_FILE) $(D)\$(PCH_CPP).obj -!endif - -############################################################################# -# Goals to build - -GOALS=log.mode create.dir create.rsp -!ifndef NO_PCH -GOALS=$(GOALS) $(PCH_TARGETS) -!endif -GOALS=$(GOALS) $(LIBDIR)\$(GOAL).lib - -goal: $(GOALS) - -log.mode: - @-echo BORLAND.MAK: - @-echo GOAL=$(GOAL), DLL=$(DLL), DEBUG=$(DEBUG), - @-echo DBGINFO=$(DBGINFO), RCDEFINES=$(RCDEFINES), - @-echo CL_OPT=$(CL_OPT), DEFS=$(DEFS), - @-echo CPPFLAGS=$(CPPFLAGS) - @-echo D=$(D) - @-echo STATICLINK_OBJS=$(STATICLINK_OBJS) - -create.rsp: -!ifndef NO_PCH -!if "$(NO_CLEAN_PCH)" == "0" - @-if exist $(PCH_FILE) echo Erasing PCH file: $(PCH_FILE) for a fresh build - @-if exist $(PCH_FILE) erase $(PCH_FILE) > nul -!endif -!endif - @-if exist $(BORRSP) erase $(BORRSP) > nul - copy &&| -$(CPPFLAGS) -I$(BCINCL);$(MFCINCL) -| $(BORRSP) - -create.dir: - @-if not exist $(D) mkdir $(D) - @-if not exist $(LIBDIR) mkdir $(LIBDIR) - -clean: - @-if exist *.map erase *.map - @-if exist *.dll erase *.dll - @-if exist *.cfg erase *.cfg - @-if exist *.rsp erase *.rsp - @-if exist *.tds erase *.tds -!if $d(INTEGRATION_BUILD) - @-if exist $(PLATFORM)\*.def erase $(PLATFORM)\*.def -!endif - @-if exist $$DLLD.W rmdir $$DLLD.W /s - @-if exist $$DLL.W rmdir $$DLL.W /s - @-if exist $$NW rmdir $$NW /s - @-if exist $$NWD rmdir $$NWD /s - - -############################################################################# -# Precompiled header file - -!ifndef NO_PCH - -!if "$(DEBUG)" == "1" -HDRS =$(MFCINCL)\*.h -!else -HDRS =$(MFCINCL)\*.h $(MFCINCL)\*.inl -!endif - -!if "$(DLL)" != "2" -$(PCH_TARGETS): $(PCH_CPP).cpp - $(CC) @&&! -$(CPPFLAGS) -I$(BCINCL);$(MFCINCL) /c $(PCH_CPP).cpp -! - -!endif # DLL != 2 -!endif # NO_PCH - - -############################################################################# -# Build the library from the up-to-date objs - -!if "$(DLL)" != "2" -# Build final library -$(LIBDIR)\$(GOAL).lib: $(OBJS) - @-if exist $@ erase $@ - @$(LIB32) $@ /P2048 @&&! -+-$(**: = &^ -+-) -! - -!endif #DLL!=2 - -############################################################################# diff --git a/libs/mfc/source/bormem.cpp b/libs/mfc/source/bormem.cpp index 5f973072..6a05a585 100644 --- a/libs/mfc/source/bormem.cpp +++ b/libs/mfc/source/bormem.cpp @@ -14,6 +14,6 @@ * All Rights Reserved. * */ -/* $Revision: 1.2 $ */ +/* $Revision: 1.3 $ */ diff --git a/libs/zlib/src/README b/libs/zlib/src/README index 6f1255ff..5ca9d127 100644 --- a/libs/zlib/src/README +++ b/libs/zlib/src/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.7 is a general purpose data compression library. All the code is +zlib 1.2.8 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -31,7 +31,7 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at http://marknelson.us/1997/01/01/zlib-engine/ . -The changes made in version 1.2.7 are documented in the file ChangeLog. +The changes made in version 1.2.8 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -84,7 +84,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2012 Jean-loup Gailly and Mark Adler + (C) 1995-2013 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/zlib/src/adler32.c b/libs/zlib/src/adler32.c index c5391fe7..674ec76b 100644 --- a/libs/zlib/src/adler32.c +++ b/libs/zlib/src/adler32.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: adler32.c,v 1.1 2013/04/07 20:33:47 martinprikryl Exp $ */ +/* @(#) $Id: adler32.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #include "zutil.h" diff --git a/libs/zlib/src/compress.c b/libs/zlib/src/compress.c index 990d3453..2bcd1e1b 100644 --- a/libs/zlib/src/compress.c +++ b/libs/zlib/src/compress.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: compress.c,v 1.1 2013/04/07 20:33:47 martinprikryl Exp $ */ +/* @(#) $Id: compress.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #define ZLIB_INTERNAL #include "zlib.h" @@ -29,7 +29,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) z_stream stream; int err; - stream.next_in = (Bytef*)source; + stream.next_in = (z_const Bytef *)source; stream.avail_in = (uInt)sourceLen; #ifdef MAXSEG_64K /* Check for source > 64K on 16-bit machine: */ diff --git a/libs/zlib/src/crc32.c b/libs/zlib/src/crc32.c index 18950351..7690b3a7 100644 --- a/libs/zlib/src/crc32.c +++ b/libs/zlib/src/crc32.c @@ -9,7 +9,7 @@ * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. */ -/* @(#) $Id: crc32.c,v 1.1 2013/04/07 20:33:47 martinprikryl Exp $ */ +/* @(#) $Id: crc32.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ /* Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore diff --git a/libs/zlib/src/deflate.c b/libs/zlib/src/deflate.c index a2018d61..f9cfeb5d 100644 --- a/libs/zlib/src/deflate.c +++ b/libs/zlib/src/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -47,12 +47,12 @@ * */ -/* @(#) $Id: deflate.c,v 1.1 2013/04/07 20:33:47 martinprikryl Exp $ */ +/* @(#) $Id: deflate.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -305,7 +305,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + strm->msg = ERR_MSG(Z_MEM_ERROR); deflateEnd (strm); return Z_MEM_ERROR; } @@ -329,7 +329,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) uInt str, n; int wrap; unsigned avail; - unsigned char *next; + z_const unsigned char *next; if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) return Z_STREAM_ERROR; @@ -359,7 +359,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) avail = strm->avail_in; next = strm->next_in; strm->avail_in = dictLength; - strm->next_in = (Bytef *)dictionary; + strm->next_in = (z_const Bytef *)dictionary; fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; @@ -513,6 +513,8 @@ int ZEXPORT deflateParams(strm, level, strategy) strm->total_in != 0) { /* Flush the last buffer: */ err = deflate(strm, Z_BLOCK); + if (err == Z_BUF_ERROR && s->pending == 0) + err = Z_OK; } if (s->level != level) { s->level = level; diff --git a/libs/zlib/src/deflate.h b/libs/zlib/src/deflate.h index acde1b10..57a8d376 100644 --- a/libs/zlib/src/deflate.h +++ b/libs/zlib/src/deflate.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id: deflate.h,v 1.1 2013/04/07 20:33:47 martinprikryl Exp $ */ +/* @(#) $Id: deflate.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #ifndef DEFLATE_H #define DEFLATE_H @@ -104,7 +104,7 @@ typedef struct internal_state { int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ gz_headerp gzhead; /* gzip header information to write */ uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ + Byte method; /* can only be DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ /* used by deflate.c: */ diff --git a/libs/zlib/src/gzguts.h b/libs/zlib/src/gzguts.h index ee3f281a..d87659d0 100644 --- a/libs/zlib/src/gzguts.h +++ b/libs/zlib/src/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -35,6 +35,13 @@ # include #endif +#ifdef WINAPI_FAMILY +# define open _open +# define read _read +# define write _write +# define close _close +#endif + #ifdef NO_DEFLATE /* for compatibility with old definition */ # define NO_GZCOMPRESS #endif @@ -60,7 +67,7 @@ #ifndef HAVE_VSNPRINTF # ifdef MSDOS /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ + but for now we just assume it doesn't. */ # define NO_vsnprintf # endif # ifdef __TURBOC__ @@ -88,6 +95,14 @@ # endif #endif +/* unlike snprintf (which is required in C99, yet still not supported by + Microsoft more than a decade later!), _snprintf does not guarantee null + termination of the result -- however this is only used in gzlib.c where + the result is assured to fit in the space provided */ +#ifdef _MSC_VER +# define snprintf _snprintf +#endif + #ifndef local # define local static #endif @@ -127,7 +142,8 @@ # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif -/* default i/o buffer size -- double this for output when reading */ +/* default i/o buffer size -- double this for output when reading (this and + twice this must be able to fit in an unsigned type) */ #define GZBUFSIZE 8192 /* gzip modes, also provide a little integrity check on the passed structure */ diff --git a/libs/zlib/src/gzlib.c b/libs/zlib/src/gzlib.c index ca55c6ea..fae202ef 100644 --- a/libs/zlib/src/gzlib.c +++ b/libs/zlib/src/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -108,7 +108,7 @@ local gzFile gz_open(path, fd, mode) return NULL; /* allocate gzFile structure to return */ - state = malloc(sizeof(gz_state)); + state = (gz_statep)malloc(sizeof(gz_state)); if (state == NULL) return NULL; state->size = 0; /* no buffers allocated yet */ @@ -162,8 +162,10 @@ local gzFile gz_open(path, fd, mode) break; case 'F': state->strategy = Z_FIXED; + break; case 'T': state->direct = 1; + break; default: /* could consider as an error, but just ignore */ ; } @@ -194,8 +196,8 @@ local gzFile gz_open(path, fd, mode) } else #endif - len = strlen(path); - state->path = malloc(len + 1); + len = strlen((const char *)path); + state->path = (char *)malloc(len + 1); if (state->path == NULL) { free(state); return NULL; @@ -208,7 +210,11 @@ local gzFile gz_open(path, fd, mode) *(state->path) = 0; else #endif +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(state->path, len + 1, "%s", (const char *)path); +#else strcpy(state->path, path); +#endif /* compute the flags for open() */ oflag = @@ -236,7 +242,7 @@ local gzFile gz_open(path, fd, mode) #ifdef _WIN32 fd == -2 ? _wopen(path, oflag, 0666) : #endif - open(path, oflag, 0666)); + open((const char *)path, oflag, 0666)); if (state->fd == -1) { free(state->path); free(state); @@ -282,9 +288,13 @@ gzFile ZEXPORT gzdopen(fd, mode) char *path; /* identifier for error messages */ gzFile gz; - if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL) + if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) return NULL; +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(path, 7 + 3 * sizeof(int), "", fd); /* for debugging */ +#else sprintf(path, "", fd); /* for debugging */ +#endif gz = gz_open(path, fd, mode); free(path); return gz; @@ -531,7 +541,8 @@ const char * ZEXPORT gzerror(file, errnum) /* return error information */ if (errnum != NULL) *errnum = state->err; - return state->msg == NULL ? "" : state->msg; + return state->err == Z_MEM_ERROR ? "out of memory" : + (state->msg == NULL ? "" : state->msg); } /* -- see zlib.h -- */ @@ -582,21 +593,24 @@ void ZLIB_INTERNAL gz_error(state, err, msg) if (msg == NULL) return; - /* for an out of memory error, save as static string */ - if (err == Z_MEM_ERROR) { - state->msg = (char *)msg; + /* for an out of memory error, return literal string when requested */ + if (err == Z_MEM_ERROR) return; - } /* construct error message with path */ - if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { + if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == + NULL) { state->err = Z_MEM_ERROR; - state->msg = (char *)"out of memory"; return; } +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, + "%s%s%s", state->path, ": ", msg); +#else strcpy(state->msg, state->path); strcat(state->msg, ": "); strcat(state->msg, msg); +#endif return; } diff --git a/libs/zlib/src/gzread.c b/libs/zlib/src/gzread.c index 3493d34d..bf4538eb 100644 --- a/libs/zlib/src/gzread.c +++ b/libs/zlib/src/gzread.c @@ -1,5 +1,5 @@ /* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -58,7 +58,8 @@ local int gz_avail(state) return -1; if (state->eof == 0) { if (strm->avail_in) { /* copy what's there to the start */ - unsigned char *p = state->in, *q = strm->next_in; + unsigned char *p = state->in; + unsigned const char *q = strm->next_in; unsigned n = strm->avail_in; do { *p++ = *q++; @@ -90,8 +91,8 @@ local int gz_look(state) /* allocate read buffers and inflate memory */ if (state->size == 0) { /* allocate buffers */ - state->in = malloc(state->want); - state->out = malloc(state->want << 1); + state->in = (unsigned char *)malloc(state->want); + state->out = (unsigned char *)malloc(state->want << 1); if (state->in == NULL || state->out == NULL) { if (state->out != NULL) free(state->out); @@ -352,14 +353,14 @@ int ZEXPORT gzread(file, buf, len) /* large len -- read directly into user buffer */ else if (state->how == COPY) { /* read directly */ - if (gz_load(state, buf, len, &n) == -1) + if (gz_load(state, (unsigned char *)buf, len, &n) == -1) return -1; } /* large len -- decompress directly into user buffer */ else { /* state->how == GZIP */ strm->avail_out = len; - strm->next_out = buf; + strm->next_out = (unsigned char *)buf; if (gz_decomp(state) == -1) return -1; n = state->x.have; @@ -378,7 +379,11 @@ int ZEXPORT gzread(file, buf, len) } /* -- see zlib.h -- */ -#undef gzgetc +#ifdef Z_PREFIX_SET +# undef z_gzgetc +#else +# undef gzgetc +#endif int ZEXPORT gzgetc(file) gzFile file; { @@ -518,7 +523,7 @@ char * ZEXPORT gzgets(file, buf, len) /* look for end-of-line in current output buffer */ n = state->x.have > left ? left : state->x.have; - eol = memchr(state->x.next, '\n', n); + eol = (unsigned char *)memchr(state->x.next, '\n', n); if (eol != NULL) n = (unsigned)(eol - state->x.next) + 1; diff --git a/libs/zlib/src/gzwrite.c b/libs/zlib/src/gzwrite.c index 27cb3428..aa767fbf 100644 --- a/libs/zlib/src/gzwrite.c +++ b/libs/zlib/src/gzwrite.c @@ -1,5 +1,5 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -19,7 +19,7 @@ local int gz_init(state) z_streamp strm = &(state->strm); /* allocate input buffer */ - state->in = malloc(state->want); + state->in = (unsigned char *)malloc(state->want); if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; @@ -28,7 +28,7 @@ local int gz_init(state) /* only need output buffer and deflate state if compressing */ if (!state->direct) { /* allocate output buffer */ - state->out = malloc(state->want); + state->out = (unsigned char *)malloc(state->want); if (state->out == NULL) { free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); @@ -168,7 +168,6 @@ int ZEXPORT gzwrite(file, buf, len) unsigned len; { unsigned put = len; - unsigned n; gz_statep state; z_streamp strm; @@ -208,16 +207,19 @@ int ZEXPORT gzwrite(file, buf, len) if (len < state->size) { /* copy to input buffer, compress when full */ do { + unsigned have, copy; + if (strm->avail_in == 0) strm->next_in = state->in; - n = state->size - strm->avail_in; - if (n > len) - n = len; - memcpy(strm->next_in + strm->avail_in, buf, n); - strm->avail_in += n; - state->x.pos += n; - buf = (char *)buf + n; - len -= n; + have = (unsigned)((strm->next_in + strm->avail_in) - state->in); + copy = state->size - have; + if (copy > len) + copy = len; + memcpy(state->in + have, buf, copy); + strm->avail_in += copy; + state->x.pos += copy; + buf = (const char *)buf + copy; + len -= copy; if (len && gz_comp(state, Z_NO_FLUSH) == -1) return 0; } while (len); @@ -229,7 +231,7 @@ int ZEXPORT gzwrite(file, buf, len) /* directly compress user buffer to file */ strm->avail_in = len; - strm->next_in = (voidp)buf; + strm->next_in = (z_const Bytef *)buf; state->x.pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; @@ -244,6 +246,7 @@ int ZEXPORT gzputc(file, c) gzFile file; int c; { + unsigned have; unsigned char buf[1]; gz_statep state; z_streamp strm; @@ -267,12 +270,16 @@ int ZEXPORT gzputc(file, c) /* try writing to input buffer for speed (state->size == 0 if buffer not initialized) */ - if (strm->avail_in < state->size) { + if (state->size) { if (strm->avail_in == 0) strm->next_in = state->in; - strm->next_in[strm->avail_in++] = c; - state->x.pos++; - return c & 0xff; + have = (unsigned)((strm->next_in + strm->avail_in) - state->in); + if (have < state->size) { + state->in[have] = c; + strm->avail_in++; + state->x.pos++; + return c & 0xff; + } } /* no room in buffer or not initialized, use gz_write() */ @@ -300,12 +307,11 @@ int ZEXPORT gzputs(file, str) #include /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int size, len; gz_statep state; z_streamp strm; - va_list va; /* get internal structure */ if (file == NULL) @@ -335,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) /* do the printf() into the input buffer, put length in len */ size = (int)(state->size); state->in[size - 1] = 0; - va_start(va, format); #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void (void)vsprintf((char *)(state->in), format, va); - va_end(va); for (len = 0; len < size; len++) if (state->in[len] == 0) break; # else len = vsprintf((char *)(state->in), format, va); - va_end(va); # endif #else # ifdef HAS_vsnprintf_void (void)vsnprintf((char *)(state->in), size, format, va); - va_end(va); len = strlen((char *)(state->in)); # else len = vsnprintf((char *)(state->in), size, format, va); - va_end(va); # endif #endif @@ -368,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) return len; } +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) +{ + va_list va; + int ret; + + va_start(va, format); + ret = gzvprintf(file, format, va); + va_end(va); + return ret; +} + #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ @@ -547,9 +559,9 @@ int ZEXPORT gzclose_w(file) } /* flush, free memory, and close file */ + if (gz_comp(state, Z_FINISH) == -1) + ret = state->err; if (state->size) { - if (gz_comp(state, Z_FINISH) == -1) - ret = state->err; if (!state->direct) { (void)deflateEnd(&(state->strm)); free(state->out); diff --git a/libs/zlib/src/infback.c b/libs/zlib/src/infback.c index 981aff17..f3833c2e 100644 --- a/libs/zlib/src/infback.c +++ b/libs/zlib/src/infback.c @@ -255,7 +255,7 @@ out_func out; void FAR *out_desc; { struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ + z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ diff --git a/libs/zlib/src/inffast.c b/libs/zlib/src/inffast.c index 2f1d60b4..bda59ceb 100644 --- a/libs/zlib/src/inffast.c +++ b/libs/zlib/src/inffast.c @@ -1,5 +1,5 @@ /* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010 Mark Adler + * Copyright (C) 1995-2008, 2010, 2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -69,8 +69,8 @@ z_streamp strm; unsigned start; /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ + z_const unsigned char FAR *in; /* local strm->next_in */ + z_const unsigned char FAR *last; /* have enough input while in < last */ unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ diff --git a/libs/zlib/src/inflate.c b/libs/zlib/src/inflate.c index 47418a1e..870f89bb 100644 --- a/libs/zlib/src/inflate.c +++ b/libs/zlib/src/inflate.c @@ -93,11 +93,12 @@ /* function prototypes */ local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); +local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, + unsigned copy)); #ifdef BUILDFIXED void makefixed OF((void)); #endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, +local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, unsigned len)); int ZEXPORT inflateResetKeep(strm) @@ -375,12 +376,13 @@ void makefixed() output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, out) +local int updatewindow(strm, end, copy) z_streamp strm; -unsigned out; +const Bytef *end; +unsigned copy; { struct inflate_state FAR *state; - unsigned copy, dist; + unsigned dist; state = (struct inflate_state FAR *)strm->state; @@ -400,19 +402,18 @@ unsigned out; } /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + zmemcpy(state->window, end - state->wsize, state->wsize); state->wnext = 0; state->whave = state->wsize; } else { dist = state->wsize - state->wnext; if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, strm->next_out - copy, dist); + zmemcpy(state->window + state->wnext, end - copy, dist); copy -= dist; if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); + zmemcpy(state->window, end - copy, copy); state->wnext = copy; state->whave = state->wsize; } @@ -606,7 +607,7 @@ z_streamp strm; int flush; { struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ + z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ @@ -920,7 +921,7 @@ int flush; while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; - state->lencode = (code const FAR *)(state->next); + state->lencode = (const code FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); @@ -994,7 +995,7 @@ int flush; values here (9 and 6) without reading the comments in inftrees.h concerning the ENOUGH constants, which depend on those values */ state->next = state->codes; - state->lencode = (code const FAR *)(state->next); + state->lencode = (const code FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); @@ -1003,7 +1004,7 @@ int flush; state->mode = BAD; break; } - state->distcode = (code const FAR *)(state->next); + state->distcode = (const code FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); @@ -1230,7 +1231,7 @@ int flush; RESTORE(); if (state->wsize || (out != strm->avail_out && state->mode < BAD && (state->mode < CHECK || flush != Z_FINISH))) - if (updatewindow(strm, out)) { + if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { state->mode = MEM; return Z_MEM_ERROR; } @@ -1264,6 +1265,29 @@ z_streamp strm; return Z_OK; } +int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) +z_streamp strm; +Bytef *dictionary; +uInt *dictLength; +{ + struct inflate_state FAR *state; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* copy dictionary */ + if (state->whave && dictionary != Z_NULL) { + zmemcpy(dictionary, state->window + state->wnext, + state->whave - state->wnext); + zmemcpy(dictionary + state->whave - state->wnext, + state->window, state->wnext); + } + if (dictLength != Z_NULL) + *dictLength = state->whave; + return Z_OK; +} + int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) z_streamp strm; const Bytef *dictionary; @@ -1271,8 +1295,6 @@ uInt dictLength; { struct inflate_state FAR *state; unsigned long dictid; - unsigned char *next; - unsigned avail; int ret; /* check state */ @@ -1291,13 +1313,7 @@ uInt dictLength; /* copy dictionary to window using updatewindow(), which will amend the existing dictionary if appropriate */ - next = strm->next_out; - avail = strm->avail_out; - strm->next_out = (Bytef *)dictionary + dictLength; - strm->avail_out = 0; - ret = updatewindow(strm, dictLength); - strm->avail_out = avail; - strm->next_out = next; + ret = updatewindow(strm, dictionary + dictLength, dictLength); if (ret) { state->mode = MEM; return Z_MEM_ERROR; @@ -1337,7 +1353,7 @@ gz_headerp head; */ local unsigned syncsearch(have, buf, len) unsigned FAR *have; -unsigned char FAR *buf; +const unsigned char FAR *buf; unsigned len; { unsigned got; diff --git a/libs/zlib/src/inftrees.c b/libs/zlib/src/inftrees.c index abcd7c45..44d89cf2 100644 --- a/libs/zlib/src/inftrees.c +++ b/libs/zlib/src/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2012 Mark Adler + * Copyright (C) 1995-2013 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.7 Copyright 1995-2012 Mark Adler "; + " inflate 1.2.8 Copyright 1995-2013 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -62,7 +62,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, @@ -208,8 +208,8 @@ unsigned short FAR *work; mask = used - 1; /* mask for comparing low */ /* check available table space */ - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) return 1; /* process all codes and make table entries */ @@ -277,8 +277,8 @@ unsigned short FAR *work; /* check for enough space */ used += 1U << curr; - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) return 1; /* point entry in root table to sub-table */ diff --git a/libs/zlib/src/trees.c b/libs/zlib/src/trees.c index 16f8723f..4805e34a 100644 --- a/libs/zlib/src/trees.c +++ b/libs/zlib/src/trees.c @@ -30,7 +30,7 @@ * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ -/* @(#) $Id: trees.c,v 1.1 2013/04/07 20:33:48 martinprikryl Exp $ */ +/* @(#) $Id: trees.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ /* #define GEN_TREES_H */ @@ -146,8 +146,8 @@ local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); local int build_bl_tree OF((deflate_state *s)); local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); +local void compress_block OF((deflate_state *s, const ct_data *ltree, + const ct_data *dtree)); local int detect_data_type OF((deflate_state *s)); local unsigned bi_reverse OF((unsigned value, int length)); local void bi_windup OF((deflate_state *s)); @@ -972,7 +972,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { #endif send_bits(s, (STATIC_TREES<<1)+last, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); + compress_block(s, (const ct_data *)static_ltree, + (const ct_data *)static_dtree); #ifdef DEBUG s->compressed_len += 3 + s->static_len; #endif @@ -980,7 +981,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) send_bits(s, (DYN_TREES<<1)+last, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); + compress_block(s, (const ct_data *)s->dyn_ltree, + (const ct_data *)s->dyn_dtree); #ifdef DEBUG s->compressed_len += 3 + s->opt_len; #endif @@ -1057,8 +1059,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) */ local void compress_block(s, ltree, dtree) deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ + const ct_data *ltree; /* literal tree */ + const ct_data *dtree; /* distance tree */ { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ diff --git a/libs/zlib/src/uncompr.c b/libs/zlib/src/uncompr.c index 6f39860b..cd28f67d 100644 --- a/libs/zlib/src/uncompr.c +++ b/libs/zlib/src/uncompr.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: uncompr.c,v 1.1 2013/04/07 20:33:48 martinprikryl Exp $ */ +/* @(#) $Id: uncompr.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #define ZLIB_INTERNAL #include "zlib.h" @@ -30,7 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen) z_stream stream; int err; - stream.next_in = (Bytef*)source; + stream.next_in = (z_const Bytef *)source; stream.avail_in = (uInt)sourceLen; /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; diff --git a/libs/zlib/src/zconf.h b/libs/zlib/src/zconf.h index 83d89e86..e91dda01 100644 --- a/libs/zlib/src/zconf.h +++ b/libs/zlib/src/zconf.h @@ -1,9 +1,9 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2012 Jean-loup Gailly. + * Copyright (C) 1995-2013 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: zconf.h,v 1.1 2013/04/07 20:33:48 martinprikryl Exp $ */ +/* @(#) $Id: zconf.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #ifndef ZCONF_H #define ZCONF_H @@ -21,6 +21,7 @@ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits # define _tr_flush_block z__tr_flush_block # define _tr_init z__tr_init # define _tr_stored_block z__tr_stored_block @@ -77,6 +78,7 @@ # define gzopen_w z_gzopen_w # endif # define gzprintf z_gzprintf +# define gzvprintf z_gzvprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread @@ -103,6 +105,7 @@ # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 # define inflateSetDictionary z_inflateSetDictionary +# define inflateGetDictionary z_inflateGetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine @@ -388,20 +391,14 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif -/* ./configure may #define Z_U4 here */ - #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) # include # if (UINT_MAX == 0xffffffffUL) # define Z_U4 unsigned -# else -# if (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# else -# if (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -# endif +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short # endif #endif @@ -425,8 +422,16 @@ typedef uLong FAR uLongf; # endif #endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + #ifdef _WIN32 -# include /* for wchar_t */ +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and @@ -435,7 +440,7 @@ typedef uLong FAR uLongf; * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ -#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif @@ -443,7 +448,7 @@ typedef uLong FAR uLongf; # define Z_HAVE_UNISTD_H #endif #ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE) +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ # ifdef VMS # include /* for off_t */ diff --git a/libs/zlib/src/zlib.h b/libs/zlib/src/zlib.h index 3edf3acd..3e0c7672 100644 --- a/libs/zlib/src/zlib.h +++ b/libs/zlib/src/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.7, May 2nd, 2012 + version 1.2.8, April 28th, 2013 - Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.7" -#define ZLIB_VERNUM 0x1270 +#define ZLIB_VERSION "1.2.8" +#define ZLIB_VERNUM 0x1280 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 7 +#define ZLIB_VER_REVISION 8 #define ZLIB_VER_SUBREVISION 0 /* @@ -839,6 +839,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ +ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* Skips invalid compressed data until a possible full flush point (see above @@ -846,7 +861,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); available input is skipped. No output is provided. inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurences of this + All full flush points have this pattern, but not all occurrences of this pattern are full flush points. inflateSync returns Z_OK if a possible full flush point has been found, @@ -1007,7 +1022,8 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, the version of the header file. */ -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef unsigned (*in_func) OF((void FAR *, + z_const unsigned char FAR * FAR *)); typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, @@ -1015,11 +1031,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, out_func out, void FAR *out_desc)); /* inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. @@ -1736,6 +1753,13 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, const char *mode)); #endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, + const char *format, + va_list va)); +# endif +#endif #ifdef __cplusplus } diff --git a/libs/zlib/src/zutil.c b/libs/zlib/src/zutil.c index b36d0792..b00497df 100644 --- a/libs/zlib/src/zutil.c +++ b/libs/zlib/src/zutil.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: zutil.c,v 1.1 2013/04/07 20:33:48 martinprikryl Exp $ */ +/* @(#) $Id: zutil.c,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #include "zutil.h" #ifndef Z_SOLO @@ -14,7 +14,7 @@ struct internal_state {int dummy;}; /* for buggy compilers */ #endif -const char * const z_errmsg[10] = { +z_const char * const z_errmsg[10] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ diff --git a/libs/zlib/src/zutil.h b/libs/zlib/src/zutil.h index 0d419c80..af606c5a 100644 --- a/libs/zlib/src/zutil.h +++ b/libs/zlib/src/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2012 Jean-loup Gailly. + * Copyright (C) 1995-2013 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id: zutil.h,v 1.1 2013/04/07 20:33:48 martinprikryl Exp $ */ +/* @(#) $Id: zutil.h,v 1.2 2013/08/12 09:54:03 martinprikryl Exp $ */ #ifndef ZUTIL_H #define ZUTIL_H @@ -44,13 +44,13 @@ typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) + return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ @@ -168,7 +168,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif /* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) +#if !defined(_WIN32) && \ + (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); #endif diff --git a/source/Console.cbproj b/source/Console.cbproj index ed2e3513..3fcab5a8 100644 --- a/source/Console.cbproj +++ b/source/Console.cbproj @@ -41,7 +41,7 @@ rtl.bpi;$(PackageImports) CppConsoleApplication true - CompanyName=Martin Prikryl;FileDescription=Console interface for WinSCP;FileVersion=4.0.1.0;InternalName=console;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.com;ProductName=WinSCP;ProductVersion=5.2.2.0;ReleaseType=beta;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=Console interface for WinSCP;FileVersion=4.0.1.0;InternalName=console;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.com;ProductName=WinSCP;ProductVersion=5.2.3.0;ReleaseType=beta;WWW=http://winscp.net/ 1033 4 1 diff --git a/source/DragExt.cbproj b/source/DragExt.cbproj index 605fa374..837264c8 100644 --- a/source/DragExt.cbproj +++ b/source/DragExt.cbproj @@ -42,7 +42,7 @@ CppDynamicLibrary true true - CompanyName=Martin Prikryl;FileDescription=Drag&Drop shell extension for WinSCP (32-bit);FileVersion=1.2.1.0;InternalName=dragext32;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.2.2.0;ReleaseType=beta;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=Drag&Drop shell extension for WinSCP (32-bit);FileVersion=1.2.1.0;InternalName=dragext32;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.2.3.0;ReleaseType=beta;WWW=http://winscp.net/ 1033 2 1 diff --git a/source/DragExt64.rc b/source/DragExt64.rc index 798571ce..ac6066f4 100644 --- a/source/DragExt64.rc +++ b/source/DragExt64.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO FILEVERSION 1,2,1,0 -PRODUCTVERSION 5,2,2,0 +PRODUCTVERSION 5,2,3,0 FILEOS 0x4 FILETYPE 0x2 { @@ -16,7 +16,7 @@ FILETYPE 0x2 VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "dragext64.dll\0" VALUE "ProductName", "WinSCP\0" - VALUE "ProductVersion", "5.2.2.0\0" + VALUE "ProductVersion", "5.2.3.0\0" VALUE "ReleaseType", "beta\0" VALUE "WWW", "http://winscp.net/\0" } diff --git a/source/PngComponents.cbproj b/source/PngComponents.cbproj index 75a83026..591dcc5c 100644 --- a/source/PngComponents.cbproj +++ b/source/PngComponents.cbproj @@ -42,14 +42,14 @@ -LUDesignIDE JPHNE System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) - packages\png;$(DCC_UnitSearchPath) + packages\png;packages\my;$(DCC_UnitSearchPath) true Png Components true true - packages\png\;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(BDS)\source\toolsapi\;$(ILINK_LibraryPath) + packages\png\;packages\my;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(BDS)\source\toolsapi\;$(ILINK_LibraryPath) $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) - packages\png\;$(IncludePath) + packages\png\;packages\my;$(IncludePath) true CppPackage true diff --git a/source/WinSCP.cbproj b/source/WinSCP.cbproj index 02458fc5..daf75853 100644 --- a/source/WinSCP.cbproj +++ b/source/WinSCP.cbproj @@ -51,11 +51,11 @@ CppVCLApplication true true - CompanyName=Martin Prikryl;FileDescription=WinSCP: SFTP, FTP and SCP client;FileVersion=5.2.2.0;InternalName=winscp;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.exe;ProductName=WinSCP;ProductVersion=5.2.2.0;ReleaseType=beta;WWW=http://winscp.net/ + CompanyName=Martin Prikryl;FileDescription=WinSCP: SFTP, FTP and SCP client;FileVersion=5.2.3.0;InternalName=winscp;LegalCopyright=(c) 2000-2013 Martin Prikryl;LegalTrademarks=;OriginalFilename=winscp.exe;ProductName=WinSCP;ProductVersion=5.2.3.0;ReleaseType=beta;WWW=http://winscp.net/ 1033 5 2 - 2 + 3 true diff --git a/source/components/UnixDriveView.h b/source/components/UnixDriveView.h index 472c4d7d..e54e2f93 100644 --- a/source/components/UnixDriveView.h +++ b/source/components/UnixDriveView.h @@ -110,8 +110,6 @@ class TUnixDriveView : public TCustomUnixDriveView __property OnDDDragFileName; __property OnDDEnd; - __property UseDragImages; - __property TargetPopUpMenu; __property UseSystemContextMenu; diff --git a/source/core/Common.cpp b/source/core/Common.cpp index db409008..410ffeb4 100644 --- a/source/core/Common.cpp +++ b/source/core/Common.cpp @@ -1775,16 +1775,9 @@ void __fastcall AddToList(UnicodeString & List, const UnicodeString & Value, con } } //--------------------------------------------------------------------------- -bool __fastcall Is2000() -{ - return (Win32MajorVersion >= 5); -} -//--------------------------------------------------------------------------- bool __fastcall IsWin7() { - return - (Win32MajorVersion > 6) || - ((Win32MajorVersion == 6) && (Win32MinorVersion >= 1)); + return CheckWin32Version(6, 1); } //--------------------------------------------------------------------------- bool __fastcall IsExactly2008R2() @@ -1845,7 +1838,7 @@ bool __fastcall IsExactly2008R2() //--------------------------------------------------------------------------- LCID __fastcall GetDefaultLCID() { - return Is2000() ? GetUserDefaultLCID() : GetThreadLocale(); + return GetUserDefaultLCID(); } //--------------------------------------------------------------------------- static UnicodeString ADefaultEncodingName; @@ -1908,5 +1901,10 @@ UnicodeString __fastcall FormatSize(__int64 Size) return FormatNumber(Size); } //--------------------------------------------------------------------------- +UnicodeString __fastcall ExtractFileBaseName(const UnicodeString & Path) +{ + return ChangeFileExt(ExtractFileName(Path), L""); +} +//--------------------------------------------------------------------------- // Suppress warning about unused constants in DateUtils.hpp #pragma warn -8080 diff --git a/source/core/Common.h b/source/core/Common.h index b938b5d1..9513cc26 100644 --- a/source/core/Common.h +++ b/source/core/Common.h @@ -87,7 +87,6 @@ UnicodeString __fastcall EscapeHotkey(const UnicodeString & Caption); bool __fastcall CutToken(UnicodeString & Str, UnicodeString & Token, UnicodeString * RawToken = NULL); void __fastcall AddToList(UnicodeString & List, const UnicodeString & Value, const UnicodeString & Delimiter); -bool __fastcall Is2000(); bool __fastcall IsWin7(); bool __fastcall IsExactly2008R2(); TLibModule * __fastcall FindModule(void * Instance); @@ -99,6 +98,7 @@ UnicodeString __fastcall WindowsProductName(); bool __fastcall IsDirectoryWriteable(const UnicodeString & Path); UnicodeString __fastcall FormatNumber(__int64 Size); UnicodeString __fastcall FormatSize(__int64 Size); +UnicodeString __fastcall ExtractFileBaseName(const UnicodeString & Path); //--------------------------------------------------------------------------- typedef void __fastcall (__closure* TProcessLocalFileEvent) (const UnicodeString FileName, const TSearchRec Rec, void * Param); diff --git a/source/core/Configuration.cpp b/source/core/Configuration.cpp index 12e4efb0..b976447b 100644 --- a/source/core/Configuration.cpp +++ b/source/core/Configuration.cpp @@ -178,7 +178,13 @@ void __fastcall TConfiguration::SaveData(THierarchicalStorage * Storage, bool /* } } //--------------------------------------------------------------------------- -void __fastcall TConfiguration::Save(bool All, bool Explicit) +void __fastcall TConfiguration::Save() +{ + // only modified, implicit + DoSave(false, false); +} +//--------------------------------------------------------------------------- +void __fastcall TConfiguration::DoSave(bool All, bool Explicit) { if (FDontSave) return; @@ -272,7 +278,7 @@ void __fastcall TConfiguration::Import(const UnicodeString & FileName) } // save all and explicit - Save(true, true); + DoSave(true, true); } //--------------------------------------------------------------------------- void __fastcall TConfiguration::LoadData(THierarchicalStorage * Storage) @@ -977,7 +983,7 @@ void __fastcall TConfiguration::SetStorage(TStorage value) } // save all and explicit - Save(true, true); + DoSave(true, true); } } //--------------------------------------------------------------------------- diff --git a/source/core/Configuration.h b/source/core/Configuration.h index 7bb7cfa6..05e3c104 100644 --- a/source/core/Configuration.h +++ b/source/core/Configuration.h @@ -132,6 +132,7 @@ class TConfiguration : public TObject void __fastcall CleanupRegistry(UnicodeString CleanupSubKey); UnicodeString __fastcall BannerHash(const UnicodeString & Banner); static UnicodeString __fastcall PropertyToKey(const UnicodeString & Property); + virtual void __fastcall DoSave(bool All, bool Explicit); virtual bool __fastcall GetConfirmOverwriting(); virtual void __fastcall SetConfirmOverwriting(bool value); @@ -160,7 +161,7 @@ class TConfiguration : public TObject virtual __fastcall ~TConfiguration(); virtual void __fastcall Default(); virtual void __fastcall Load(); - virtual void __fastcall Save(bool All, bool Explicit); + virtual void __fastcall Save(); void __fastcall SetNulStorage(); void __fastcall SetDefaultStorage(); void __fastcall Export(const UnicodeString & FileName); diff --git a/source/core/CoreMain.cpp b/source/core/CoreMain.cpp index a1c241ac..70cf48cc 100644 --- a/source/core/CoreMain.cpp +++ b/source/core/CoreMain.cpp @@ -96,8 +96,7 @@ void CoreFinalize() { try { - // only modified, implicit - Configuration->Save(false, false); + Configuration->Save(); } catch(Exception & E) { diff --git a/source/core/Cryptography.cpp b/source/core/Cryptography.cpp index 84ddec37..83bd2a10 100644 --- a/source/core/Cryptography.cpp +++ b/source/core/Cryptography.cpp @@ -508,7 +508,7 @@ RawByteString __fastcall ScramblePassword(UnicodeString Password) for (int Index = 0; Index < Padding; Index++) { int P = 0; - while ((P <= 0) || (P > 255) || IsDigit(P >= '0')) + while ((P <= 0) || (P > 255) || IsDigit(static_cast(P))) { P = (int)((double)rand() / ((double)RAND_MAX / 256.0)); } diff --git a/source/core/FtpFileSystem.cpp b/source/core/FtpFileSystem.cpp index 89d7958d..81c83a38 100644 --- a/source/core/FtpFileSystem.cpp +++ b/source/core/FtpFileSystem.cpp @@ -298,11 +298,13 @@ void __fastcall TFTPFileSystem::Open() TSessionData * Data = FTerminal->SessionData; FSessionInfo.LoginTime = Now(); - FSessionInfo.ProtocolBaseName = L"FTP"; - FSessionInfo.ProtocolName = FSessionInfo.ProtocolBaseName; switch (Data->Ftps) { + case ftpsNone: + // noop; + break; + case ftpsImplicit: FSessionInfo.SecurityProtocolName = LoadStr(FTPS_IMPLICIT); break; @@ -314,6 +316,10 @@ void __fastcall TFTPFileSystem::Open() case ftpsExplicitTls: FSessionInfo.SecurityProtocolName = LoadStr(FTPS_EXPLICIT_TLS); break; + + default: + FAIL; + break; } FLastDataSent = Now(); @@ -484,6 +490,11 @@ void __fastcall TFTPFileSystem::Open() } } while (FPasswordFailed); + + FSessionInfo.CSCipher = FFileZillaIntf->GetCipherName().c_str(); + FSessionInfo.SCCipher = FSessionInfo.CSCipher; + UnicodeString TlsVersionStr = FFileZillaIntf->GetTlsVersionStr().c_str(); + AddToList(FSessionInfo.SecurityProtocolName, TlsVersionStr, L", "); } //--------------------------------------------------------------------------- void __fastcall TFTPFileSystem::Close() @@ -935,8 +946,7 @@ void __fastcall TFTPFileSystem::DoFileTransferProgress(__int64 TransferSize, } __int64 Diff = Bytes - OperationProgress->TransferedSize; - assert(Diff >= 0); - if (Diff >= 0) + if (ALWAYS_TRUE(Diff >= 0)) { OperationProgress->AddTransfered(Diff); } @@ -2274,6 +2284,14 @@ int __fastcall TFTPFileSystem::GetOptionVal(int OptionID) const Result = (Data->SslSessionReuse ? TRUE : FALSE); break; + case OPTION_MPEXT_MIN_TLS_VERSION: + Result = Data->MinTlsVersion; + break; + + case OPTION_MPEXT_MAX_TLS_VERSION: + Result = Data->MaxTlsVersion; + break; + case OPTION_MPEXT_SNDBUF: Result = Data->SendBuf; break; diff --git a/source/core/Queue.cpp b/source/core/Queue.cpp index 207806cb..b07f13c8 100644 --- a/source/core/Queue.cpp +++ b/source/core/Queue.cpp @@ -1819,6 +1819,11 @@ int __fastcall TTerminalQueueStatus::GetDoneAndActiveCount() return DoneCount + ActiveCount; } //--------------------------------------------------------------------------- +int __fastcall TTerminalQueueStatus::GetActiveAndPendingCount() +{ + return Count - DoneCount; +} +//--------------------------------------------------------------------------- void __fastcall TTerminalQueueStatus::Add(TQueueItemProxy * ItemProxy) { ItemProxy->FQueueStatus = this; diff --git a/source/core/Queue.h b/source/core/Queue.h index e976aa6f..e9b444de 100644 --- a/source/core/Queue.h +++ b/source/core/Queue.h @@ -254,6 +254,7 @@ friend class TQueueItemProxy; __property int DoneCount = { read = FDoneCount }; __property int ActiveCount = { read = GetActiveCount }; __property int DoneAndActiveCount = { read = GetDoneAndActiveCount }; + __property int ActiveAndPendingCount = { read = GetActiveAndPendingCount }; __property TQueueItemProxy * Items[int Index] = { read = GetItem }; protected: @@ -271,6 +272,7 @@ friend class TQueueItemProxy; int __fastcall GetCount(); int __fastcall GetActiveCount(); int __fastcall GetDoneAndActiveCount(); + int __fastcall GetActiveAndPendingCount(); void __fastcall SetDoneCount(int Value); TQueueItemProxy * __fastcall GetItem(int Index); }; diff --git a/source/core/RemoteFiles.cpp b/source/core/RemoteFiles.cpp index e7ca26f5..2da7525d 100644 --- a/source/core/RemoteFiles.cpp +++ b/source/core/RemoteFiles.cpp @@ -391,6 +391,34 @@ UnicodeString __fastcall UserModificationStr(TDateTime DateTime, } } //--------------------------------------------------------------------------- +UnicodeString __fastcall ModificationStr(TDateTime DateTime, + TModificationFmt Precision) +{ + Word Year, Month, Day, Hour, Min, Sec, MSec; + DateTime.DecodeDate(&Year, &Month, &Day); + DateTime.DecodeTime(&Hour, &Min, &Sec, &MSec); + switch (Precision) + { + case mfNone: + return L""; + + case mfMDY: + return FORMAT(L"%3s %2d %2d", (EngShortMonthNames[Month-1], Day, Year)); + + case mfMDHM: + return FORMAT(L"%3s %2d %2d:%2.2d", + (EngShortMonthNames[Month-1], Day, Hour, Min)); + + default: + assert(false); + // fall thru + + case mfFull: + return FORMAT(L"%3s %2d %2d:%2.2d:%2.2d %4d", + (EngShortMonthNames[Month-1], Day, Hour, Min, Sec, Year)); + } +} +//--------------------------------------------------------------------------- int __fastcall FakeFileImageIndex(UnicodeString FileName, unsigned long Attrs, UnicodeString * TypeName) { @@ -920,29 +948,7 @@ UnicodeString __fastcall TRemoteFile::GetUserModificationStr() //--------------------------------------------------------------------------- UnicodeString __fastcall TRemoteFile::GetModificationStr() { - Word Year, Month, Day, Hour, Min, Sec, MSec; - Modification.DecodeDate(&Year, &Month, &Day); - Modification.DecodeTime(&Hour, &Min, &Sec, &MSec); - switch (FModificationFmt) - { - case mfNone: - return L""; - - case mfMDY: - return FORMAT(L"%3s %2d %2d", (EngShortMonthNames[Month-1], Day, Year)); - - case mfMDHM: - return FORMAT(L"%3s %2d %2d:%2.2d", - (EngShortMonthNames[Month-1], Day, Hour, Min)); - - default: - assert(false); - // fall thru - - case mfFull: - return FORMAT(L"%3s %2d %2d:%2.2d:%2.2d %4d", - (EngShortMonthNames[Month-1], Day, Hour, Min, Sec, Year)); - } + return ::ModificationStr(Modification, FModificationFmt); } //--------------------------------------------------------------------------- UnicodeString __fastcall TRemoteFile::GetExtension() diff --git a/source/core/RemoteFiles.h b/source/core/RemoteFiles.h index aec46c6e..f8be2334 100644 --- a/source/core/RemoteFiles.h +++ b/source/core/RemoteFiles.h @@ -449,6 +449,8 @@ TModificationFmt __fastcall LessDateTimePrecision( TModificationFmt Precision1, TModificationFmt Precision2); UnicodeString __fastcall UserModificationStr(TDateTime DateTime, TModificationFmt Precision); +UnicodeString __fastcall ModificationStr(TDateTime DateTime, + TModificationFmt Precision); int __fastcall FakeFileImageIndex(UnicodeString FileName, unsigned long Attrs = 0, UnicodeString * TypeName = NULL); //--------------------------------------------------------------------------- diff --git a/source/core/ScpFileSystem.cpp b/source/core/ScpFileSystem.cpp index bce34601..6185232b 100644 --- a/source/core/ScpFileSystem.cpp +++ b/source/core/ScpFileSystem.cpp @@ -691,10 +691,17 @@ void __fastcall TSCPFileSystem::DoStartup() { // SkipStartupMessage and DetectReturnVar must succeed, // otherwise session is to be closed. - FTerminal->ExceptionOnFail = true; - SkipStartupMessage(); - if (FTerminal->SessionData->DetectReturnVar) DetectReturnVar(); - FTerminal->ExceptionOnFail = false; + try + { + FTerminal->ExceptionOnFail = true; + SkipStartupMessage(); + if (FTerminal->SessionData->DetectReturnVar) DetectReturnVar(); + FTerminal->ExceptionOnFail = false; + } + catch (Exception & E) + { + FTerminal->FatalError(&E, L""); + } #define COND_OPER(OPER) if (FTerminal->SessionData->OPER) OPER() COND_OPER(ClearAliases); @@ -754,7 +761,7 @@ void __fastcall TSCPFileSystem::DetectReturnVar() if ((Output->Count != 1) || (StrToIntDef(Output->Strings[0], 256) > 255)) { FTerminal->LogEvent(L"The response is not numerical exit code"); - Abort(); + EXCEPTION; } } catch (EFatal &E) @@ -777,7 +784,7 @@ void __fastcall TSCPFileSystem::DetectReturnVar() if (NewReturnVar.IsEmpty()) { - Abort(); + EXCEPTION; } else { diff --git a/source/core/Script.cpp b/source/core/Script.cpp index bb989cf5..aee200a8 100644 --- a/source/core/Script.cpp +++ b/source/core/Script.cpp @@ -366,7 +366,7 @@ void __fastcall TScript::Init() FCommands->Register(L"option", SCRIPT_OPTION_DESC, SCRIPT_OPTION_HELP6, &OptionProc, -1, 2, false); FCommands->Register(L"ascii", 0, SCRIPT_OPTION_HELP6, &AsciiProc, 0, 0, false); FCommands->Register(L"binary", 0, SCRIPT_OPTION_HELP6, &BinaryProc, 0, 0, false); - FCommands->Register(L"synchronize", SCRIPT_SYNCHRONIZE_DESC, SCRIPT_SYNCHRONIZE_HELP6, &SynchronizeProc, 1, 3, true); + FCommands->Register(L"synchronize", SCRIPT_SYNCHRONIZE_DESC, SCRIPT_SYNCHRONIZE_HELP7, &SynchronizeProc, 1, 3, true); FCommands->Register(L"keepuptodate", SCRIPT_KEEPUPTODATE_DESC, SCRIPT_KEEPUPTODATE_HELP4, &KeepUpToDateProc, 0, 2, true); // the echo command does not have switches actually, but it must handle dashes in its arguments FCommands->Register(L"echo", SCRIPT_ECHO_DESC, SCRIPT_ECHO_HELP, &EchoProc, -1, -1, true); @@ -1412,6 +1412,108 @@ void __fastcall TScript::SynchronizeDirectories(TScriptProcParams * Parameters, } } //--------------------------------------------------------------------------- +UnicodeString __fastcall TScript::SynchronizeFileRecord( + const UnicodeString & RootDirectory, const TSynchronizeChecklist::TItem * Item, bool Local) +{ + const TSynchronizeChecklist::TItem::TFileInfo & FileInfo = + Local ? Item->Local : Item->Remote; + UnicodeString Path; + if (Local) + { + Path = IncludeTrailingBackslash(FileInfo.Directory) + FileInfo.FileName; + } + else + { + Path = UnixIncludeTrailingBackslash(FileInfo.Directory) + FileInfo.FileName; + } + + if (SameText(RootDirectory, Path.SubString(1, RootDirectory.Length()))) + { + Path[1] = L'.'; + Path.Delete(2, RootDirectory.Length() - 2); + } + + UnicodeString Result; + if (Item->IsDirectory) + { + if (Local) + { + Result = IncludeTrailingBackslash(Path); + } + else + { + Result = UnixIncludeTrailingBackslash(Path); + } + } + else + { + UnicodeString SizeStr = IntToStr(FileInfo.Size); + UnicodeString ModificationStr = + ::ModificationStr(FileInfo.Modification, FileInfo.ModificationFmt); + Result = FORMAT("%s [%s, %s]", (Path, SizeStr, ModificationStr)); + } + return Result; +} +//--------------------------------------------------------------------------- +void __fastcall TScript::SynchronizePreview( + UnicodeString LocalDirectory, UnicodeString RemoteDirectory, + TSynchronizeChecklist * Checklist) +{ + + LocalDirectory = IncludeTrailingBackslash(LocalDirectory); + RemoteDirectory = UnixIncludeTrailingBackslash(RemoteDirectory); + + for (int Index = 0; (Index < Checklist->Count); Index++) + { + const TSynchronizeChecklist::TItem * Item = Checklist->Item[Index]; + if (Item->Checked) + { + UnicodeString Message; + UnicodeString LocalRecord = SynchronizeFileRecord(LocalDirectory, Item, true); + UnicodeString RemoteRecord = SynchronizeFileRecord(RemoteDirectory, Item, false); + + switch (Item->Action) + { + case TSynchronizeChecklist::saUploadNew: + Message = + FMTLOAD(SCRIPT_SYNC_UPLOAD_NEW, (LocalRecord)); + break; + + case TSynchronizeChecklist::saDownloadNew: + Message = + FMTLOAD(SCRIPT_SYNC_DOWNLOAD_NEW, (RemoteRecord)); + break; + + case TSynchronizeChecklist::saUploadUpdate: + Message = + FMTLOAD(SCRIPT_SYNC_UPLOAD_UPDATE, + (LocalRecord, RemoteRecord)); + break; + + case TSynchronizeChecklist::saDownloadUpdate: + Message = + FMTLOAD(SCRIPT_SYNC_DOWNLOAD_UPDATE, + (RemoteRecord, LocalRecord)); + break; + + case TSynchronizeChecklist::saDeleteRemote: + Message = + FMTLOAD(SCRIPT_SYNC_DELETE_REMOTE, (RemoteRecord)); + break; + + case TSynchronizeChecklist::saDeleteLocal: + Message = + FMTLOAD(SCRIPT_SYNC_DELETE_LOCAL, (LocalRecord)); + break; + + default: + FAIL; + } + PrintLine(Message); + } + } +} +//--------------------------------------------------------------------------- void __fastcall TScript::SynchronizeProc(TScriptProcParams * Parameters) { CheckSession(); @@ -1477,6 +1579,7 @@ void __fastcall TScript::SynchronizeProc(TScriptProcParams * Parameters) break; } } + bool Preview = Parameters->FindSwitch(L"preview"); // enforce rules if (FSynchronizeMode == TTerminal::smBoth) @@ -1502,9 +1605,17 @@ void __fastcall TScript::SynchronizeProc(TScriptProcParams * Parameters) if (AnyChecked) { - PrintLine(LoadStr(SCRIPT_SYNCHRONIZE_SYNCHRONIZING)); - FTerminal->SynchronizeApply(Checklist, LocalDirectory, RemoteDirectory, - &CopyParam, SynchronizeParams, OnTerminalSynchronizeDirectory); + if (Preview) + { + PrintLine(LoadStr(SCRIPT_SYNCHRONIZE_CHECKLIST)); + SynchronizePreview(LocalDirectory, RemoteDirectory, Checklist); + } + else + { + PrintLine(LoadStr(SCRIPT_SYNCHRONIZE_SYNCHRONIZING)); + FTerminal->SynchronizeApply(Checklist, LocalDirectory, RemoteDirectory, + &CopyParam, SynchronizeParams, OnTerminalSynchronizeDirectory); + } } else { @@ -1515,7 +1626,6 @@ void __fastcall TScript::SynchronizeProc(TScriptProcParams * Parameters) { delete Checklist; } - } __finally { diff --git a/source/core/Script.h b/source/core/Script.h index 6752e776..02a71779 100644 --- a/source/core/Script.h +++ b/source/core/Script.h @@ -147,6 +147,12 @@ class TScript void __fastcall TerminalCaptureLog(const UnicodeString & AddedLine, bool StdError); virtual UnicodeString __fastcall GetLogCmd(const UnicodeString & FullCommand, const UnicodeString & Command, const UnicodeString & Params); + void __fastcall SynchronizePreview( + UnicodeString LocalDirectory, UnicodeString RemoteDirectory, + TSynchronizeChecklist * Checklist); + UnicodeString __fastcall SynchronizeFileRecord( + const UnicodeString & RootDirectory, const TSynchronizeChecklist::TItem * Item, + bool Local); private: void __fastcall Init(); diff --git a/source/core/SessionData.cpp b/source/core/SessionData.cpp index 06a56e06..6b1871a4 100644 --- a/source/core/SessionData.cpp +++ b/source/core/SessionData.cpp @@ -178,6 +178,8 @@ void __fastcall TSessionData::Default() FtpPingInterval = 30; FtpPingType = ptDummyCommand; Ftps = ftpsNone; + MinTlsVersion = ssl2; + MaxTlsVersion = tls12; FtpListAll = asAuto; SslSessionReuse = true; @@ -319,6 +321,9 @@ void __fastcall TSessionData::NonPersistant() \ PROPERTY(FtpProxyLogonType); \ \ + PROPERTY(MinTlsVersion); \ + PROPERTY(MaxTlsVersion); \ + \ PROPERTY(IsWorkspace); \ PROPERTY(Link); \ \ @@ -586,6 +591,9 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool & Rewr FtpProxyLogonType = Storage->ReadInteger(L"FtpProxyLogonType", FtpProxyLogonType); + MinTlsVersion = static_cast(Storage->ReadInteger(L"MinTlsVersion", MinTlsVersion)); + MaxTlsVersion = static_cast(Storage->ReadInteger(L"MaxTlsVersion", MaxTlsVersion)); + IsWorkspace = Storage->ReadBool(L"IsWorkspace", IsWorkspace); Link = Storage->ReadString(L"Link", Link); @@ -860,6 +868,9 @@ void __fastcall TSessionData::Save(THierarchicalStorage * Storage, WRITE_DATA(Integer, FtpProxyLogonType); + WRITE_DATA(Integer, MinTlsVersion); + WRITE_DATA(Integer, MaxTlsVersion); + WRITE_DATA(Bool, IsWorkspace); WRITE_DATA(String, Link); @@ -1049,9 +1060,14 @@ void __fastcall TSessionData::RecryptPasswords() TunnelPassword = TunnelPassword; } //--------------------------------------------------------------------- +bool __fastcall TSessionData::HasPassword() +{ + return !FPassword.IsEmpty(); +} +//--------------------------------------------------------------------- bool __fastcall TSessionData::HasAnyPassword() { - return !FPassword.IsEmpty() || !FProxyPassword.IsEmpty() || !FTunnelPassword.IsEmpty(); + return HasPassword() || !FProxyPassword.IsEmpty() || !FTunnelPassword.IsEmpty(); } //--------------------------------------------------------------------- void __fastcall TSessionData::Modify() @@ -1086,11 +1102,16 @@ void __fastcall TSessionData::SaveRecryptedPasswords(THierarchicalStorage * Stor { if (Storage->OpenSubKey(InternalStorageKey, true)) { - RecryptPasswords(); - - SavePasswords(Storage, false); + try + { + RecryptPasswords(); - Storage->CloseSubKey(); + SavePasswords(Storage, false); + } + __finally + { + Storage->CloseSubKey(); + } } } //--------------------------------------------------------------------- @@ -2306,6 +2327,16 @@ void __fastcall TSessionData::SetFtps(TFtps value) { SET_SESSION_PROPERTY(Ftps); } +//--------------------------------------------------------------------------- +void __fastcall TSessionData::SetMinTlsVersion(TTlsVersion value) +{ + SET_SESSION_PROPERTY(MinTlsVersion); +} +//--------------------------------------------------------------------------- +void __fastcall TSessionData::SetMaxTlsVersion(TTlsVersion value) +{ + SET_SESSION_PROPERTY(MaxTlsVersion); +} //--------------------------------------------------------------------- void __fastcall TSessionData::SetFtpListAll(TAutoSwitch value) { @@ -2517,7 +2548,7 @@ void __fastcall TStoredSessionList::DoSave(THierarchicalStorage * Storage, } //--------------------------------------------------------------------- void __fastcall TStoredSessionList::DoSave(THierarchicalStorage * Storage, - bool All, bool RecryptPasswordOnly) + bool All, bool RecryptPasswordOnly, TStrings * RecryptPasswordErrors) { TSessionData * FactoryDefaults = new TSessionData(L""); try @@ -2526,7 +2557,23 @@ void __fastcall TStoredSessionList::DoSave(THierarchicalStorage * Storage, for (int Index = 0; Index < Count+HiddenCount; Index++) { TSessionData * SessionData = (TSessionData *)Items[Index]; - DoSave(Storage, SessionData, All, RecryptPasswordOnly, FactoryDefaults); + try + { + DoSave(Storage, SessionData, All, RecryptPasswordOnly, FactoryDefaults); + } + catch (Exception & E) + { + UnicodeString Message; + if (RecryptPasswordOnly && ALWAYS_TRUE(RecryptPasswordErrors != NULL) && + ExceptionMessage(&E, Message)) + { + RecryptPasswordErrors->Add(FORMAT("%s: %s", (SessionData->SessionName, Message))); + } + else + { + throw; + } + } } } __finally @@ -2537,10 +2584,11 @@ void __fastcall TStoredSessionList::DoSave(THierarchicalStorage * Storage, //--------------------------------------------------------------------- void __fastcall TStoredSessionList::Save(THierarchicalStorage * Storage, bool All) { - DoSave(Storage, All, false); + DoSave(Storage, All, false, NULL); } //--------------------------------------------------------------------- -void __fastcall TStoredSessionList::DoSave(bool All, bool Explicit, bool RecryptPasswordOnly) +void __fastcall TStoredSessionList::DoSave(bool All, bool Explicit, + bool RecryptPasswordOnly, TStrings * RecryptPasswordErrors) { THierarchicalStorage * Storage = Configuration->CreateScpStorage(true); try @@ -2549,7 +2597,7 @@ void __fastcall TStoredSessionList::DoSave(bool All, bool Explicit, bool Recrypt Storage->Explicit = Explicit; if (Storage->OpenSubKey(Configuration->StoredSessionsSubKey, true)) { - DoSave(Storage, All, RecryptPasswordOnly); + DoSave(Storage, All, RecryptPasswordOnly, RecryptPasswordErrors); } } __finally @@ -2562,12 +2610,12 @@ void __fastcall TStoredSessionList::DoSave(bool All, bool Explicit, bool Recrypt //--------------------------------------------------------------------- void __fastcall TStoredSessionList::Save(bool All, bool Explicit) { - DoSave(All, Explicit, false); + DoSave(All, Explicit, false, NULL); } //--------------------------------------------------------------------- -void __fastcall TStoredSessionList::RecryptPasswords() +void __fastcall TStoredSessionList::RecryptPasswords(TStrings * RecryptPasswordErrors) { - DoSave(true, true, true); + DoSave(true, true, true, RecryptPasswordErrors); } //--------------------------------------------------------------------- void __fastcall TStoredSessionList::Saved() @@ -2786,8 +2834,21 @@ void __fastcall TStoredSessionList::UpdateStaticUsage() Configuration->Usage->Set(L"StoredSessionsCountColor", Color); Configuration->Usage->Set(L"StoredSessionsCountAdvanced", Advanced); - bool CustomDefaultStoredSession = !FDefaultSettings->IsSame(FactoryDefaults.get(), false); + // actually default might be true, see below for when the default is actually used + bool CustomDefaultStoredSession = false; + try + { + // this can throw, when the default session settings have password set + // (and no other basic property, like hostname/username), + // and master password is enabled as we are called before master password + // handler is set + CustomDefaultStoredSession = !FDefaultSettings->IsSame(FactoryDefaults.get(), false); + } + catch (...) + { + } Configuration->Usage->Set(L"UsingDefaultStoredSession", CustomDefaultStoredSession); + Configuration->Usage->Set(L"UsingStoredSessionsFolders", Folders); Configuration->Usage->Set(L"UsingWorkspaces", Workspaces); } diff --git a/source/core/SessionData.h b/source/core/SessionData.h index 66661009..e03a02ca 100644 --- a/source/core/SessionData.h +++ b/source/core/SessionData.h @@ -30,6 +30,8 @@ enum TSftpBug { sbSymlink, sbSignedTS }; enum TPingType { ptOff, ptNullPacket, ptDummyCommand }; enum TAddressFamily { afAuto, afIPv4, afIPv6 }; enum TFtps { ftpsNone, ftpsImplicit, ftpsExplicitSsl, ftpsExplicitTls }; +// has to match SSL_VERSION_XXX constants in AsyncSslSocketLayer.h +enum TTlsVersion { ssl2 = 2, ssl3 = 3, tls10 = 10, tls11 = 11, tls12 = 12 }; enum TSessionSource { ssNone, ssStored, ssStoredModified }; //--------------------------------------------------------------------------- extern const wchar_t CipherNames[CIPHER_COUNT][10]; @@ -156,6 +158,8 @@ friend class TStoredSessionList; int FFtpPingInterval; TPingType FFtpPingType; TFtps FFtps; + TTlsVersion FMinTlsVersion; + TTlsVersion FMaxTlsVersion; TAutoSwitch FNotUtf; bool FIsWorkspace; UnicodeString FLink; @@ -297,6 +301,8 @@ friend class TStoredSessionList; void __fastcall SetFtpPingInterval(int value); void __fastcall SetFtpPingType(TPingType value); void __fastcall SetFtps(TFtps value); + void __fastcall SetMinTlsVersion(TTlsVersion value); + void __fastcall SetMaxTlsVersion(TTlsVersion value); void __fastcall SetNotUtf(TAutoSwitch value); void __fastcall SetIsWorkspace(bool value); void __fastcall SetLink(UnicodeString value); @@ -327,6 +333,7 @@ friend class TStoredSessionList; const TSessionData * Default = NULL); void __fastcall SaveRecryptedPasswords(THierarchicalStorage * Storage); void __fastcall RecryptPasswords(); + bool __fastcall HasPassword(); bool __fastcall HasAnyPassword(); void __fastcall Remove(); virtual void __fastcall Assign(TPersistent * Source); @@ -462,6 +469,8 @@ friend class TStoredSessionList; __property TDateTime FtpPingIntervalDT = { read=GetFtpPingIntervalDT }; __property TPingType FtpPingType = { read = FFtpPingType, write = SetFtpPingType }; __property TFtps Ftps = { read = FFtps, write = SetFtps }; + __property TTlsVersion MinTlsVersion = { read = FMinTlsVersion, write = SetMinTlsVersion }; + __property TTlsVersion MaxTlsVersion = { read = FMaxTlsVersion, write = SetMaxTlsVersion }; __property TAutoSwitch NotUtf = { read = FNotUtf, write = SetNotUtf }; __property bool IsWorkspace = { read = FIsWorkspace, write = SetIsWorkspace }; __property UnicodeString Link = { read = FLink, write = SetLink }; @@ -488,7 +497,7 @@ class TStoredSessionList : public TNamedObjectList void __fastcall Save(THierarchicalStorage * Storage, bool All = false); void __fastcall SelectAll(bool Select); void __fastcall Import(TStoredSessionList * From, bool OnlySelected); - void __fastcall RecryptPasswords(); + void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors); TSessionData * __fastcall AtSession(int Index) { return (TSessionData*)AtObject(Index); } void __fastcall SelectSessionsToImport(TStoredSessionList * Dest, bool SSHOnly); @@ -519,8 +528,10 @@ class TStoredSessionList : public TNamedObjectList TSessionData * FDefaultSettings; bool FReadOnly; void __fastcall SetDefaultSettings(TSessionData * value); - void __fastcall DoSave(THierarchicalStorage * Storage, bool All, bool RecryptPasswordOnly); - void __fastcall DoSave(bool All, bool Explicit, bool RecryptPasswordOnly); + void __fastcall DoSave(THierarchicalStorage * Storage, bool All, + bool RecryptPasswordOnly, TStrings * RecryptPasswordErrors); + void __fastcall DoSave(bool All, bool Explicit, bool RecryptPasswordOnly, + TStrings * RecryptPasswordErrors); void __fastcall DoSave(THierarchicalStorage * Storage, TSessionData * Data, bool All, bool RecryptPasswordOnly, TSessionData * FactoryDefaults); diff --git a/source/core/SessionInfo.cpp b/source/core/SessionInfo.cpp index a96369b2..b2675a54 100644 --- a/source/core/SessionInfo.cpp +++ b/source/core/SessionInfo.cpp @@ -867,6 +867,25 @@ void __fastcall TSessionLog::AddStartupInfo(bool System) } } //--------------------------------------------------------------------------- +UnicodeString __fastcall TSessionLog::GetTlsVersionName(TTlsVersion TlsVersion) +{ + switch (TlsVersion) + { + default: + FAIL; + case ssl2: + return "SSLv2"; + case ssl3: + return "SSLv3"; + case tls10: + return "TLSv1.0"; + case tls11: + return "TLSv1.1"; + case tls12: + return "TLSv1.2"; + } +} +//--------------------------------------------------------------------------- void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) { TGuard Guard(FCriticalSection); @@ -1006,7 +1025,7 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) switch (Data->Ftps) { case ftpsImplicit: - Ftps = L"Implicit SSL/TLS"; + Ftps = L"Implicit TLS/SSL"; break; case ftpsExplicitSsl: @@ -1030,6 +1049,7 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data) if (Data->Ftps != ftpsNone) { ADF(L"Session reuse: %s", (BooleanToEngStr(Data->SslSessionReuse))); + ADF(L"TLS/SSL versions: %s-%s", (GetTlsVersionName(Data->MinTlsVersion), GetTlsVersionName(Data->MaxTlsVersion))); } } ADF(L"Local directory: %s, Remote directory: %s, Update: %s, Cache: %s", diff --git a/source/core/SessionInfo.h b/source/core/SessionInfo.h index 3c437527..66903738 100644 --- a/source/core/SessionInfo.h +++ b/source/core/SessionInfo.h @@ -258,6 +258,7 @@ class TSessionLog : protected TStringList void __fastcall DoAddToSelf(TLogLineType aType, const UnicodeString & aLine); void __fastcall AddStartupInfo(bool System); void __fastcall DoAddStartupInfo(TSessionData * Data); + UnicodeString __fastcall GetTlsVersionName(TTlsVersion TlsVersion); }; //--------------------------------------------------------------------------- class TActionLog diff --git a/source/core/Terminal.cpp b/source/core/Terminal.cpp index 8d687410..a1c71f43 100644 --- a/source/core/Terminal.cpp +++ b/source/core/Terminal.cpp @@ -4144,6 +4144,7 @@ UnicodeString __fastcall TTerminal::SynchronizeParamsStr(int Params) AddFlagName(ParamsStr, Params, spUseCache, L"UseCache"); AddFlagName(ParamsStr, Params, spDelayProgress, L"DelayProgress"); AddFlagName(ParamsStr, Params, spPreviewChanges, L"*PreviewChanges"); // GUI only + AddFlagName(ParamsStr, Params, spSubDirs, L"SubDirs"); AddFlagName(ParamsStr, Params, spTimestamp, L"Timestamp"); AddFlagName(ParamsStr, Params, spNotByTime, L"NotByTime"); AddFlagName(ParamsStr, Params, spBySize, L"BySize"); diff --git a/source/core/WebDAVFileSystem.cpp b/source/core/WebDAVFileSystem.cpp index a4833868..5fb0cee2 100644 --- a/source/core/WebDAVFileSystem.cpp +++ b/source/core/WebDAVFileSystem.cpp @@ -11545,7 +11545,7 @@ neon_open( { if (ne_has_support(NE_FEATURE_SSL) == 0) return error_create(WEBDAV_ERR_DAV_SOCK_INIT, NULL, - "SSL is not supported"); + "TLS is not supported"); } ne_session * sess = ne_session_create(uri->scheme, uri->host, uri->port); @@ -12195,8 +12195,6 @@ void __fastcall TWebDAVFileSystem::Open() TSessionData * Data = FTerminal->SessionData; FSessionInfo.LoginTime = Now(); - FSessionInfo.ProtocolBaseName = CONST_WEBDAV_PROTOCOL_BASE_NAME; - FSessionInfo.ProtocolName = FSessionInfo.ProtocolBaseName; bool Ssl = (FTerminal->SessionData->Ftps != ftpsNone); if (Ssl) diff --git a/source/filezilla/AsyncSocketEx.cpp b/source/filezilla/AsyncSocketEx.cpp index 49e79542..15a134fe 100644 --- a/source/filezilla/AsyncSocketEx.cpp +++ b/source/filezilla/AsyncSocketEx.cpp @@ -1783,6 +1783,36 @@ void CAsyncSocketEx::SetState(int nState) m_nState = nState; } +const TCHAR * CAsyncSocketEx::GetStateDesc(int nState) +{ + switch (nState) + { + case notsock: + return _T("none"); + case unconnected: + return _T("unconnected"); + case connecting: + return _T("connecting"); + case listening: + return _T("listening"); + case connected: + return _T("connected"); + case closed: + return _T("closed"); + case aborted: + return _T("aborted"); + case attached: + return _T("attached"); + default: + return _T("unknown"); + } +} + +bool CAsyncSocketEx::LogStateChange(int nState1, int nState2) +{ + return (nState2 != notsock) || (nState1 != unconnected); +} + #endif //NOSOCKETSTATES int CAsyncSocketEx::GetFamily() const diff --git a/source/filezilla/AsyncSocketEx.h b/source/filezilla/AsyncSocketEx.h index 71dfea20..725067fe 100644 --- a/source/filezilla/AsyncSocketEx.h +++ b/source/filezilla/AsyncSocketEx.h @@ -296,6 +296,8 @@ class CAsyncSocketEx int GetState() const; void SetState(int nState); + static const TCHAR * GetStateDesc(int nState); + static bool LogStateChange(int nState1, int nState2); int m_nState; #endif //NOSOCKETSTATES diff --git a/source/filezilla/AsyncSslSocketLayer.cpp b/source/filezilla/AsyncSslSocketLayer.cpp index 954d1446..753a093f 100644 --- a/source/filezilla/AsyncSslSocketLayer.cpp +++ b/source/filezilla/AsyncSslSocketLayer.cpp @@ -1025,6 +1025,7 @@ BOOL CAsyncSslSocketLayer::Connect(LPCTSTR lpszHostAddress, UINT nHostPort) int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, CAsyncSslSocketLayer* main, bool sessionreuse, + int minTlsVersion, int maxTlsVersion, void* pSslContext /*=0*/) { if (m_bUseSSL) @@ -1104,7 +1105,14 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, } long options = pSSL_ctrl(m_ssl, SSL_CTRL_OPTIONS, 0, NULL); - options |= SSL_OP_ALL; + #define MASK_TLS_VERSION(VERSION, FLAG) ((minTlsVersion > VERSION) || (maxTlsVersion < VERSION) ? FLAG : 0) + options |= + SSL_OP_ALL | + MASK_TLS_VERSION(SSL_VERSION_SSL2, SSL_OP_NO_SSLv2) | + MASK_TLS_VERSION(SSL_VERSION_SSL3, SSL_OP_NO_SSLv3) | + MASK_TLS_VERSION(SSL_VERSION_TLS10, SSL_OP_NO_TLSv1) | + MASK_TLS_VERSION(SSL_VERSION_TLS11, SSL_OP_NO_TLSv1_1) | + MASK_TLS_VERSION(SSL_VERSION_TLS12, SSL_OP_NO_TLSv1_2); pSSL_ctrl(m_ssl, SSL_CTRL_OPTIONS, options, NULL); //Init SSL connection @@ -1123,11 +1131,11 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode, LogSocketMessage(FZ_LOG_INFO, _T("SSL_set_session failed")); return SSL_FAILURE_INITSSL; } - LogSocketMessage(FZ_LOG_INFO, _T("Trying reuse main SSL session ID")); + LogSocketMessage(FZ_LOG_INFO, _T("Trying reuse main TLS session ID")); } else { - LogSocketMessage(FZ_LOG_INFO, _T("Main SSL session ID was not reused previously, not trying again")); + LogSocketMessage(FZ_LOG_INFO, _T("Main TLS session ID was not reused previously, not trying again")); pSSL_set_session(m_ssl, NULL); } } @@ -1398,7 +1406,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r if (!cur) { m_sCriticalSection.Unlock(); - MessageBox(0, _T("Can't lookup SSL session!"), _T("Critical error"), MB_ICONEXCLAMATION); + MessageBox(0, _T("Can't lookup TLS session!"), _T("Critical error"), MB_ICONEXCLAMATION); return; } else @@ -1416,7 +1424,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r if (w & SSL_ST_CONNECT) { - str = "SSL_connect"; + str = "TLS connect"; if (pLayer->m_sessionreuse) { SSL_SESSION * sessionid = SSL_get1_session(pLayer->m_ssl); @@ -1432,7 +1440,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r { if ((pLayer->m_Main != NULL) && (pLayer->m_Main->m_sessionid != NULL)) { - pLayer->LogSocketMessage(FZ_LOG_INFO, _T("Main SSL session ID not reused, will not try again")); + pLayer->LogSocketMessage(FZ_LOG_INFO, _T("Main TLS session ID not reused, will not try again")); SSL_SESSION_free(pLayer->m_Main->m_sessionid); pLayer->m_Main->m_sessionid = NULL; } @@ -1453,9 +1461,9 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r } } else if (w & SSL_ST_ACCEPT) - str = "SSL_accept"; + str = "TLS accept"; else - str = "undefined"; + str = "Undefined"; if (where & SSL_CB_LOOP) { @@ -1919,6 +1927,16 @@ BOOL CAsyncSslSocketLayer::GetPeerCertificateData(t_SslCertData &SslCertData) return TRUE; } +std::string CAsyncSslSocketLayer::GetTlsVersionStr() +{ + return m_TlsVersionStr; +} + +std::string CAsyncSslSocketLayer::GetCipherName() +{ + return m_CipherName; +} + void CAsyncSslSocketLayer::SetNotifyReply(int nID, int nCode, int result) { if (!m_bBlocking) @@ -1986,12 +2004,16 @@ void CAsyncSslSocketLayer::PrintSessionInfo() } char *buffer = new char[4096]; - sprintf(buffer, "Using %s, cipher %s: %s, %s", - pSSL_get_version(m_ssl), + m_TlsVersionStr = pSSL_get_version(m_ssl); + sprintf(buffer, "%s: %s, %s", pSSL_CIPHER_get_version(ciph), pSSL_CIPHER_get_name(ciph), enc); - DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_INFO, 0, buffer); + m_CipherName = buffer; + sprintf(buffer, "Using %s, cipher %s", + m_TlsVersionStr.c_str(), + m_CipherName.c_str()); + DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, SSL_VERBOSE_WARNING, 0, buffer); } void CAsyncSslSocketLayer::OnConnect(int nErrorCode) @@ -2030,7 +2052,7 @@ int CAsyncSslSocketLayer::verify_callback(int preverify_ok, X509_STORE_CTX *ctx) if (!cur) { m_sCriticalSection.Unlock(); - MessageBox(0, _T("Can't lookup SSL session!"), _T("Critical error"), MB_ICONEXCLAMATION); + MessageBox(0, _T("Can't lookup TLS session!"), _T("Critical error"), MB_ICONEXCLAMATION); return 1; } else @@ -2106,7 +2128,7 @@ bool CAsyncSslSocketLayer::CreateSslCertificate(LPCTSTR filename, int bits, unsi CAsyncSslSocketLayer layer; if (layer.InitSSL()) { - err = _T("Failed to initialize SSL library"); + err = _T("Failed to initialize TLS library"); return false; } diff --git a/source/filezilla/AsyncSslSocketLayer.h b/source/filezilla/AsyncSslSocketLayer.h index 275970a0..4f559a59 100644 --- a/source/filezilla/AsyncSslSocketLayer.h +++ b/source/filezilla/AsyncSslSocketLayer.h @@ -144,11 +144,13 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer void SetNotifyReply(int nID, int nCode, int result); BOOL GetPeerCertificateData(t_SslCertData &SslCertData); + std::string GetTlsVersionStr(); + std::string GetCipherName(); bool IsUsingSSL(); int InitSSLConnection(bool clientMode, CAsyncSslSocketLayer* main, - bool sessionreuse, + bool sessionreuse, int minTlsVersion, int maxTlsVersion, void* pContext = 0); static bool CreateSslCertificate(LPCTSTR filename, int bits, unsigned char* country, unsigned char* state, @@ -248,6 +250,9 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer bool m_onCloseCalled; char* m_pKeyPassword; + + std::string m_TlsVersionStr; + std::string m_CipherName; }; #define SSL_INFO 0 @@ -268,4 +273,10 @@ class CAsyncSslSocketLayer : public CAsyncSocketExLayer #define SSL_FAILURE_VERIFYCERT 8 #define SSL_FAILURE_CERTREJECTED 0x10 +#define SSL_VERSION_SSL2 2 +#define SSL_VERSION_SSL3 3 +#define SSL_VERSION_TLS10 10 +#define SSL_VERSION_TLS11 11 +#define SSL_VERSION_TLS12 12 + #endif // ASYNCSSLSOCKETLEAYER_INCLUDED diff --git a/source/filezilla/ControlSocket.cpp b/source/filezilla/ControlSocket.cpp index 5dcaef06..9b259075 100644 --- a/source/filezilla/ControlSocket.cpp +++ b/source/filezilla/ControlSocket.cpp @@ -211,14 +211,19 @@ int CControlSocket::OnLayerCallback(std::list& callbacks) { if (iter->nType == LAYERCALLBACK_STATECHANGE) { - if (iter->pLayer == m_pProxyLayer) - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pProxyLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); + if (CAsyncSocketEx::LogStateChange(iter->nParam1, iter->nParam2)) + { + const TCHAR * state2Desc = CAsyncSocketEx::GetStateDesc(iter->nParam2); + const TCHAR * state1Desc = CAsyncSocketEx::GetStateDesc(iter->nParam1); + if (iter->pLayer == m_pProxyLayer) + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Proxy layer changed state from %s to %s"), state2Desc, state1Desc); #ifndef MPEXT_NO_GSS - else if (iter->pLayer == m_pGssLayer) - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pGssLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); + else if (iter->pLayer == m_pGssLayer) + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pGssLayer changed state from %s to %s"), state2Desc, state1Desc); #endif - else - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Layer @ %d changed state from %d to %d"), iter->pLayer, iter->nParam2, iter->nParam1); + else + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Layer @ %d changed state from %s to %s"), iter->pLayer, state2Desc, state1Desc); + } } else if (iter->nType == LAYERCALLBACK_LAYERSPECIFIC) { @@ -227,24 +232,24 @@ int CControlSocket::OnLayerCallback(std::list& callbacks) switch (iter->nParam1) { case PROXYERROR_NOCONN: - ShowStatus(IDS_ERRORMSG_PROXY_NOCONN, 1); + ShowStatus(IDS_ERRORMSG_PROXY_NOCONN, FZ_LOG_ERROR); break; case PROXYERROR_REQUESTFAILED: - ShowStatus(IDS_ERRORMSG_PROXY_REQUESTFAILED, 1); + ShowStatus(IDS_ERRORMSG_PROXY_REQUESTFAILED, FZ_LOG_ERROR); if (iter->str) - ShowStatus(A2T(iter->str), 1); + ShowStatus(A2T(iter->str), FZ_LOG_ERROR); break; case PROXYERROR_AUTHTYPEUNKNOWN: - ShowStatus(IDS_ERRORMSG_PROXY_AUTHTYPEUNKNOWN, 1); + ShowStatus(IDS_ERRORMSG_PROXY_AUTHTYPEUNKNOWN, FZ_LOG_ERROR); break; case PROXYERROR_AUTHFAILED: - ShowStatus(IDS_ERRORMSG_PROXY_AUTHFAILED, 1); + ShowStatus(IDS_ERRORMSG_PROXY_AUTHFAILED, FZ_LOG_ERROR); break; case PROXYERROR_AUTHNOLOGON: - ShowStatus(IDS_ERRORMSG_PROXY_AUTHNOLOGON, 1); + ShowStatus(IDS_ERRORMSG_PROXY_AUTHNOLOGON, FZ_LOG_ERROR); break; case PROXYERROR_CANTRESOLVEHOST: - ShowStatus(IDS_ERRORMSG_PROXY_CANTRESOLVEHOST, 1); + ShowStatus(IDS_ERRORMSG_PROXY_CANTRESOLVEHOST, FZ_LOG_ERROR); break; default: LogMessage(__FILE__, __LINE__, this, FZ_LOG_WARNING, _T("Unknown proxy error") ); @@ -262,10 +267,10 @@ int CControlSocket::OnLayerCallback(std::list& callbacks) LogMessageRaw(FZ_LOG_APIERROR, A2CT(iter->str)); break; case GSS_COMMAND: - ShowStatus(A2CT(iter->str), 2); + ShowStatus(A2CT(iter->str), FZ_LOG_COMMAND); break; case GSS_REPLY: - ShowStatus(A2CT(iter->str), 3); + ShowStatus(A2CT(iter->str), FZ_LOG_REPLY); break; } } diff --git a/source/filezilla/ControlSocket.h b/source/filezilla/ControlSocket.h index b9bc3c9f..3c2d1efb 100644 --- a/source/filezilla/ControlSocket.h +++ b/source/filezilla/ControlSocket.h @@ -114,7 +114,9 @@ class CControlSocket : public CAsyncSocketEx, public CApiLog void ShowStatus(CString status,int type) const; #ifdef MPEXT - virtual bool __fastcall UsingMlsd() = 0; + virtual bool UsingMlsd() = 0; + virtual std::string GetTlsVersionStr() = 0; + virtual std::string GetCipherName() = 0; #endif virtual int OnLayerCallback(std::list& callbacks); diff --git a/source/filezilla/FileZillaApi.cpp b/source/filezilla/FileZillaApi.cpp index 12485deb..30c625af 100644 --- a/source/filezilla/FileZillaApi.cpp +++ b/source/filezilla/FileZillaApi.cpp @@ -555,7 +555,7 @@ int CFileZillaApi::GetCurrentPath(CServerPath & path) return (m_pMainThread->GetCurrentPath(path) ? FZ_REPLY_OK : FZ_REPLY_NOTCONNECTED); } -bool __fastcall CFileZillaApi::UsingMlsd() +bool CFileZillaApi::UsingMlsd() { //Check if call allowed if (!m_bInitialized) @@ -564,6 +564,26 @@ bool __fastcall CFileZillaApi::UsingMlsd() return false; return m_pMainThread->UsingMlsd(); } + +std::string CFileZillaApi::GetTlsVersionStr() +{ + //Check if call allowed + if (!m_bInitialized) + return std::string(); + if (IsConnected()==FZ_REPLY_NOTCONNECTED) + return std::string(); + return m_pMainThread->GetTlsVersionStr(); +} + +std::string CFileZillaApi::GetCipherName() +{ + //Check if call allowed + if (!m_bInitialized) + return std::string(); + if (IsConnected()==FZ_REPLY_NOTCONNECTED) + return std::string(); + return m_pMainThread->GetCipherName(); +} #endif int CFileZillaApi::CustomCommand(CString CustomCommand) diff --git a/source/filezilla/FileZillaApi.h b/source/filezilla/FileZillaApi.h index 3eb51b70..7c9d8e3d 100644 --- a/source/filezilla/FileZillaApi.h +++ b/source/filezilla/FileZillaApi.h @@ -350,7 +350,9 @@ class CFileZillaApi #ifdef MPEXT int SetCurrentPath(CServerPath path); int GetCurrentPath(CServerPath & path); - bool __fastcall UsingMlsd(); + bool UsingMlsd(); + std::string GetTlsVersionStr(); + std::string GetCipherName(); #endif #ifndef MPEXT_NO_CACHE diff --git a/source/filezilla/FileZillaIntf.cpp b/source/filezilla/FileZillaIntf.cpp index 94780d37..f4e9bce0 100644 --- a/source/filezilla/FileZillaIntf.cpp +++ b/source/filezilla/FileZillaIntf.cpp @@ -523,3 +523,14 @@ bool __fastcall TFileZillaIntf::UsingMlsd() { return FFileZillaApi->UsingMlsd(); } +//--------------------------------------------------------------------------- +std::string __fastcall TFileZillaIntf::GetTlsVersionStr() +{ + return FFileZillaApi->GetTlsVersionStr(); +} +//--------------------------------------------------------------------------- +std::string __fastcall TFileZillaIntf::GetCipherName() +{ + return FFileZillaApi->GetCipherName(); +} + diff --git a/source/filezilla/FileZillaIntf.h b/source/filezilla/FileZillaIntf.h index 5d8b8e1c..70889ca1 100644 --- a/source/filezilla/FileZillaIntf.h +++ b/source/filezilla/FileZillaIntf.h @@ -157,7 +157,10 @@ friend class TFileZillaIntern; bool __fastcall SetCurrentPath(const wchar_t * Path); bool __fastcall GetCurrentPath(wchar_t * Path, size_t MaxLen); + bool __fastcall UsingMlsd(); + std::string __fastcall GetTlsVersionStr(); + std::string __fastcall GetCipherName(); bool __fastcall Cancel(); diff --git a/source/filezilla/FileZillaOpt.h b/source/filezilla/FileZillaOpt.h index 8763913a..a691670b 100644 --- a/source/filezilla/FileZillaOpt.h +++ b/source/filezilla/FileZillaOpt.h @@ -162,5 +162,7 @@ #define OPTION_MPEXT_PRESERVEUPLOADFILETIME 1001 #define OPTION_MPEXT_SSLSESSIONREUSE 1002 #define OPTION_MPEXT_SNDBUF 1003 +#define OPTION_MPEXT_MIN_TLS_VERSION 1004 +#define OPTION_MPEXT_MAX_TLS_VERSION 1005 //--------------------------------------------------------------------------- #endif // FileZillaOptH diff --git a/source/filezilla/FtpControlSocket.cpp b/source/filezilla/FtpControlSocket.cpp index cca7678a..cfe1c964 100644 --- a/source/filezilla/FtpControlSocket.cpp +++ b/source/filezilla/FtpControlSocket.cpp @@ -263,7 +263,7 @@ bool CFtpControlSocket::InitConnect() // Some sanity checks if (m_pOwner->IsConnected()) { - ShowStatus(_T("Internal error: Connect called while still connected"), 1); + ShowStatus(_T("Internal error: Connect called while still connected"), FZ_LOG_ERROR); if (!m_Operation.nOpMode) m_Operation.nOpMode = CSMODE_CONNECT; DoClose(FZ_REPLY_CRITICALERROR); @@ -273,14 +273,14 @@ bool CFtpControlSocket::InitConnect() #ifndef MPEXT_NO_SSL if (m_pSslLayer) { - ShowStatus(_T("Internal error: m_pSslLayer not zero in Connect"), 1); + ShowStatus(_T("Internal error: m_pSslLayer not zero in Connect"), FZ_LOG_ERROR); DoClose(FZ_REPLY_CRITICALERROR); return false; } #endif if (m_pProxyLayer) { - ShowStatus(_T("Internal error: m_pProxyLayer not zero in Connect"), 1); + ShowStatus(_T("Internal error: m_pProxyLayer not zero in Connect"), FZ_LOG_ERROR); DoClose(FZ_REPLY_CRITICALERROR); return false; } @@ -374,7 +374,7 @@ bool CFtpControlSocket::InitConnect() AddLayer(m_pGssLayer); if (!m_pGssLayer->InitGSS()) { - ShowStatus(_T("Unable to initialize GSS api"), 1); + ShowStatus(_T("Unable to initialize GSS api"), FZ_LOG_ERROR); DoClose(FZ_REPLY_CRITICALERROR); return false; } @@ -390,7 +390,7 @@ void CFtpControlSocket::Connect(t_server &server) if (m_Operation.nOpMode) { - ShowStatus(_T("Internal error: m_Operation.nOpMode not zero in Connect"), 1); + ShowStatus(_T("Internal error: m_Operation.nOpMode not zero in Connect"), FZ_LOG_ERROR); m_Operation.nOpMode = CSMODE_CONNECT; DoClose(FZ_REPLY_CRITICALERROR); return; @@ -420,18 +420,21 @@ void CFtpControlSocket::Connect(t_server &server) { if (!m_pSslLayer) { - ShowStatus(_T("Internal error: m_pSslLayer not initialized"), 1); + ShowStatus(_T("Internal error: m_pSslLayer not initialized"), FZ_LOG_ERROR); DoClose(FZ_REPLY_CRITICALERROR); return; } - int res = m_pSslLayer->InitSSLConnection(true, NULL, COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE)); + int res = m_pSslLayer->InitSSLConnection(true, NULL, + COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), + COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), + COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); #ifndef MPEXT_NO_SSLDLL if (res == SSL_FAILURE_LOADDLLS) - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); else #endif if (res == SSL_FAILURE_INITSSL) - ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (!res) PostMessage(m_pOwner->m_hOwnerWnd, m_pOwner->m_nReplyMessageID, FZ_MSG_MAKEMSG(FZ_MSG_SECURESERVER, 1), 0); else @@ -471,7 +474,7 @@ void CFtpControlSocket::Connect(t_server &server) hostname.Format( _T("%s:%d"), hostname, server.port); // add port to hostname (only if port is not 21) CString str; str.Format(IDS_STATUSMSG_CONNECTING, hostname); - ShowStatus(str, 0); + ShowStatus(str, FZ_LOG_STATUS); #ifndef MPEXT_NO_SSL if ((server.nServerType & FZ_SERVERTYPE_LAYERMASK) & (FZ_SERVERTYPE_LAYER_SSL_EXPLICIT | FZ_SERVERTYPE_LAYER_TLS_EXPLICIT)) @@ -548,18 +551,21 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) { if (!m_pSslLayer) { - ShowStatus(_T("Internal error: m_pSslLayer not initialized"), 1); + ShowStatus(_T("Internal error: m_pSslLayer not initialized"), FZ_LOG_ERROR); DoClose(FZ_REPLY_CRITICALERROR); return; } - int res = m_pSslLayer->InitSSLConnection(true, NULL, COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE)); + int res = m_pSslLayer->InitSSLConnection(true, NULL, + COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), + COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), + COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); #ifndef MPEXT_NO_SSLDLL if (res == SSL_FAILURE_LOADDLLS) - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); else #endif if (res == SSL_FAILURE_INITSSL) - ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (res) { DoClose(); @@ -586,7 +592,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) if (code == 2 || code == 3) m_bProtP = true; - ShowStatus(IDS_STATUSMSG_CONNECTED, 0); + ShowStatus(IDS_STATUSMSG_CONNECTED, FZ_LOG_STATUS); m_pOwner->SetConnected(TRUE); ResetOperation(FZ_REPLY_OK); return; @@ -613,7 +619,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) int code = GetReplyCode(); if (code != 2 && code != 3) m_serverCapabilities.SetCapability(mlsd_command, no); - ShowStatus(IDS_STATUSMSG_CONNECTED, 0); + ShowStatus(IDS_STATUSMSG_CONNECTED, FZ_LOG_STATUS); m_pOwner->SetConnected(TRUE); ResetOperation(FZ_REPLY_OK); return; @@ -740,7 +746,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) } } - ShowStatus(IDS_STATUSMSG_CONNECTED, 0); + ShowStatus(IDS_STATUSMSG_CONNECTED, FZ_LOG_STATUS); m_pOwner->SetConnected(TRUE); ResetOperation(FZ_REPLY_OK); return; @@ -763,7 +769,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) } #endif - ShowStatus(IDS_STATUSMSG_CONNECTED, 0); + ShowStatus(IDS_STATUSMSG_CONNECTED, FZ_LOG_STATUS); m_pOwner->SetConnected(TRUE); ResetOperation(FZ_REPLY_OK); return; @@ -808,7 +814,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) asciiOnly = false; if (!asciiOnly) { - ShowStatus(_T("Login data contains non-ascii characters and server might not be UTF-8 aware. Trying local charset."), 0); + ShowStatus(_T("Login data contains non-ascii characters and server might not be UTF-8 aware. Trying local charset."), FZ_LOG_STATUS); m_bUTF8 = false; m_Operation.nOpState = CONNECT_INIT; } @@ -858,7 +864,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) else { // we got authentication, we need to check whether we have forwardable tickets - //ShowStatus(IDS_STATUSMSG_GSSAUTH, 0); + //ShowStatus(IDS_STATUSMSG_GSSAUTH, FZ_LOG_STATUS); PostMessage(m_pOwner->m_hOwnerWnd,m_pOwner->m_nReplyMessageID, FZ_MSG_MAKEMSG(FZ_MSG_SECURESERVER, TRUE), 0); if (Send(_MPT("CWD ."))) m_Operation.nOpState = CONNECT_GSS_CWD; @@ -886,7 +892,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) else { // we got authentication, we need to check whether we have forwardable tickets - //ShowStatus(IDS_STATUSMSG_GSSAUTH, 0); + //ShowStatus(IDS_STATUSMSG_GSSAUTH, FZ_LOG_STATUS); PostMessage(m_pOwner->m_hOwnerWnd,m_pOwner->m_nReplyMessageID, FZ_MSG_MAKEMSG(FZ_MSG_SECURESERVER, TRUE), 0); if (Send(_MPT("CWD ."))) m_Operation.nOpState = CONNECT_GSS_CWD; @@ -914,7 +920,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/) CString str; str.Format(IDS_STATUSMSG_FWCONNECT,hostname); - ShowStatus(str,0); + ShowStatus(str,FZ_LOG_STATUS); } m_Operation.nOpState++; } @@ -1100,7 +1106,7 @@ void CFtpControlSocket::OnReceive(int nErrorCode) m_MultiLine = ""; CString str; str.Format(IDS_STATUSMSG_CONNECTEDWITH, m_ServerName); - ShowStatus(str, 0); + ShowStatus(str, FZ_LOG_STATUS); m_pOwner->SetConnected(TRUE); } char *buffer = new char[BUFFERSIZE]; @@ -1112,7 +1118,7 @@ void CFtpControlSocket::OnReceive(int nErrorCode) buffer = NULL; if (GetLastError() != WSAEWOULDBLOCK) { - ShowStatus(IDS_STATUSMSG_DISCONNECTED, 1); + ShowStatus(IDS_STATUSMSG_DISCONNECTED, FZ_LOG_ERROR); DoClose(); } return; @@ -1121,7 +1127,7 @@ void CFtpControlSocket::OnReceive(int nErrorCode) { delete [] buffer; buffer = NULL; - ShowStatus(IDS_STATUSMSG_DISCONNECTED, 1); + ShowStatus(IDS_STATUSMSG_DISCONNECTED, FZ_LOG_ERROR); DoClose(); } @@ -1143,7 +1149,7 @@ void CFtpControlSocket::OnReceive(int nErrorCode) LogMessage(__FILE__, __LINE__, this, FZ_LOG_WARNING, _T("Server does not send proper UTF-8, falling back to local charset")); m_bUTF8 = false; } - ShowStatus(A2CT(utf8), 3); + ShowStatus(A2CT(utf8), FZ_LOG_REPLY); } else { @@ -1154,13 +1160,13 @@ void CFtpControlSocket::OnReceive(int nErrorCode) { LPWSTR p1 = new WCHAR[len + 1]; MultiByteToWideChar(CP_UTF8, 0, utf8, -1 , (LPWSTR)p1, len + 1); - ShowStatus(W2CT(p1), 3); + ShowStatus(W2CT(p1), FZ_LOG_REPLY); delete [] p1; } } } else - ShowStatus(A2CT(m_RecvBuffer.back()), 3); + ShowStatus(A2CT(m_RecvBuffer.back()), FZ_LOG_REPLY); //Check for multi-line responses if (m_RecvBuffer.back().GetLength() > 3) { @@ -1287,13 +1293,13 @@ void CFtpControlSocket::OnConnect(int nErrorCode) m_pSslLayer ? IDS_STATUSMSG_CONNECTEDWITHSSL : #endif IDS_STATUSMSG_CONNECTEDWITH, m_ServerName); - ShowStatus(str,0); + ShowStatus(str,FZ_LOG_STATUS); } } else { if (nErrorCode == WSAHOST_NOT_FOUND) - ShowStatus(IDS_ERRORMSG_CANTRESOLVEHOST, 1); + ShowStatus(IDS_ERRORMSG_CANTRESOLVEHOST, FZ_LOG_ERROR); #ifdef MPEXT else { @@ -1305,7 +1311,7 @@ void CFtpControlSocket::OnConnect(int nErrorCode) { --Len; } - ShowStatus(CString(Buffer, Len), 1); + ShowStatus(CString(Buffer, Len), FZ_LOG_ERROR); } #endif DoClose(); @@ -1316,7 +1322,7 @@ BOOL CFtpControlSocket::Send(CString str) { USES_CONVERSION; - ShowStatus(str, 2); + ShowStatus(str, FZ_LOG_COMMAND); str += _MPT("\r\n"); int res = 0; if (m_bUTF8) @@ -1325,7 +1331,7 @@ BOOL CFtpControlSocket::Send(CString str) int len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, 0, 0, 0, 0); if (!len) { - ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, 1); + ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, FZ_LOG_ERROR); DoClose(); return FALSE; } @@ -1340,7 +1346,7 @@ BOOL CFtpControlSocket::Send(CString str) if ((res == SOCKET_ERROR && GetLastError() != WSAEWOULDBLOCK) || !res) { delete [] utf8; - ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, 1); + ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, FZ_LOG_ERROR); DoClose(); return FALSE; } @@ -1377,7 +1383,7 @@ BOOL CFtpControlSocket::Send(CString str) res = -2; if ((res == SOCKET_ERROR && GetLastError() != WSAEWOULDBLOCK) || !res) { - ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, 1); + ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, FZ_LOG_ERROR); DoClose(); return FALSE; } @@ -1476,7 +1482,7 @@ void CFtpControlSocket::Disconnect() ASSERT(!m_Operation.nOpMode); m_Operation.nOpMode=CSMODE_DISCONNECT; DoClose(); - ShowStatus(IDS_STATUSMSG_DISCONNECTED,0); //Send the disconnected message to the message log + ShowStatus(IDS_STATUSMSG_DISCONNECTED,FZ_LOG_STATUS); //Send the disconnected message to the message log } void CFtpControlSocket::CheckForTimeout() @@ -1495,7 +1501,7 @@ void CFtpControlSocket::CheckForTimeout() CTimeSpan span=CTime::GetCurrentTime()-m_LastRecvTime; if (span.GetTotalSeconds()>=delay) { - ShowStatus(IDS_ERRORMSG_TIMEOUT, 1); + ShowStatus(IDS_ERRORMSG_TIMEOUT, FZ_LOG_ERROR); DoClose(); } } @@ -1508,7 +1514,7 @@ void CFtpControlSocket::FtpCommand(LPCTSTR pCommand) } #ifdef MPEXT -bool __fastcall CFtpControlSocket::UsingMlsd() +bool CFtpControlSocket::UsingMlsd() { return // 0 = on, 1 = off, 2 = auto @@ -1516,6 +1522,30 @@ bool __fastcall CFtpControlSocket::UsingMlsd() ((m_CurrentServer.iUseMlsd != 1) && (m_serverCapabilities.GetCapability(mlsd_command) == yes)); } + +std::string CFtpControlSocket::GetTlsVersionStr() +{ + if (m_pSslLayer != NULL) + { + return m_pSslLayer->GetTlsVersionStr(); + } + else + { + return std::string(); + } +} + +std::string CFtpControlSocket::GetCipherName() +{ + if (m_pSslLayer != NULL) + { + return m_pSslLayer->GetCipherName(); + } + else + { + return std::string(); + } +} #endif CString CFtpControlSocket::GetListingCmd() @@ -1659,7 +1689,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa } else if (pData->pDirectoryListing && pData->nFinish==1) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL,0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL,FZ_LOG_STATUS); #ifndef MPEXT_NO_CACHE CDirectoryCache cache; cache.Lock(); @@ -1734,7 +1764,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa } if (bExact) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, FZ_LOG_STATUS); SetDirectoryListing(&dir); ResetOperation(FZ_REPLY_OK); return; @@ -1790,7 +1820,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa } if (bExact) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, FZ_LOG_STATUS); SetDirectoryListing(&dir); ResetOperation(FZ_REPLY_OK); return; @@ -1840,7 +1870,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa } if (bExact) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, FZ_LOG_STATUS); SetDirectoryListing(&dir); ResetOperation(FZ_REPLY_OK); return; @@ -1961,7 +1991,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa case LIST_LIST: if (IsMisleadingListResponse()) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, FZ_LOG_STATUS); t_directory listing; listing.server = m_CurrentServer; @@ -2011,7 +2041,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa pData->path=path; pData->subdir=subdir; m_Operation.pData=pData; - ShowStatus(IDS_STATUSMSG_RETRIEVINGDIRLIST, 0); + ShowStatus(IDS_STATUSMSG_RETRIEVINGDIRLIST, FZ_LOG_STATUS); pData->nFinish=-1; if (m_pDirectoryListing) { @@ -2065,7 +2095,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa } if (bExact) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL,0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL,FZ_LOG_STATUS); SetDirectoryListing(&dir); ResetOperation(FZ_REPLY_OK); return; @@ -2151,7 +2181,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa { if (!m_pTransferSocket->InitZlib(m_zlibLevel)) { - ShowStatus(_T("Failed to initialize zlib"), 1); + ShowStatus(_T("Failed to initialize zlib"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -2170,7 +2200,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa ) || !m_pTransferSocket->AsyncSelect()) { - ShowStatus(_T("Failed to create socket"), 1); + ShowStatus(_T("Failed to create socket"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -2216,7 +2246,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa !m_pTransferSocket->Listen() || !m_pTransferSocket->GetSockName(tempHostname, nPort)) { - ShowStatus(_T("Failed to create listen socket"), 1); + ShowStatus(_T("Failed to create listen socket"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -2253,7 +2283,7 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa if (!GetSockName(host, temp)) { - ShowStatus(_T("Failed to get socket address "), 1); + ShowStatus(_T("Failed to get socket address "), FZ_LOG_ERROR); bError = true; } @@ -2384,7 +2414,7 @@ void CFtpControlSocket::ListFile(CServerPath path /*=CServerPath()*/, CString fi pData->path=path; pData->fileName=fileName; m_Operation.pData=pData; - ShowStatus(IDS_STATUSMSG_RETRIEVINGLISTFILE, 0); + ShowStatus(IDS_STATUSMSG_RETRIEVINGLISTFILE, FZ_LOG_STATUS); pData->nFinish=-1; if (m_pDirectoryListing) { @@ -2402,7 +2432,7 @@ void CFtpControlSocket::ListFile(CServerPath path /*=CServerPath()*/, CString fi code = GetReplyCode(); if (IsMisleadingListResponse()) { - ShowStatus(IDS_STATUSMSG_LISTFILESUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_LISTFILESUCCESSFUL, FZ_LOG_STATUS); t_directory listing; listing.server = m_CurrentServer; @@ -2436,7 +2466,7 @@ void CFtpControlSocket::ListFile(CServerPath path /*=CServerPath()*/, CString fi pData->pDirectoryListing->path = m_pOwner->GetCurrentPath(); delete pListResult; - ShowStatus(IDS_STATUSMSG_LISTFILESUCCESSFUL,0); + ShowStatus(IDS_STATUSMSG_LISTFILESUCCESSFUL,FZ_LOG_STATUS); SetDirectoryListing(pData->pDirectoryListing); ResetOperation(FZ_REPLY_OK); return; @@ -2473,7 +2503,7 @@ void CFtpControlSocket::TransferEnd(int nMode) void CFtpControlSocket::OnClose(int nErrorCode) { LogMessage(__FILE__, __LINE__, this,FZ_LOG_DEBUG, _T("OnClose(%d) OpMode=%d OpState=%d"), nErrorCode, m_Operation.nOpMode, m_Operation.nOpState); - ShowStatus(IDS_STATUSMSG_DISCONNECTED, 1); + ShowStatus(IDS_STATUSMSG_DISCONNECTED, FZ_LOG_ERROR); if (m_pTransferSocket) { m_pTransferSocket->OnClose(0); @@ -2481,7 +2511,7 @@ void CFtpControlSocket::OnClose(int nErrorCode) delete m_pTransferSocket; m_pTransferSocket=0; DoClose(); - ShowStatus(IDS_ERRORMSG_TIMEOUT,1); + ShowStatus(IDS_ERRORMSG_TIMEOUT,FZ_LOG_ERROR); return; } #ifndef MPEXT_NO_SSL @@ -2739,7 +2769,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi CString str; str.Format(transferfile->get?IDS_STATUSMSG_DOWNLOADSTART:IDS_STATUSMSG_UPLOADSTART, transferfile->get ? transferfile->remotepath.FormatFilename(transferfile->remotefile) : transferfile->localfile); - ShowStatus(str,0); + ShowStatus(str,FZ_LOG_STATUS); m_Operation.nOpMode=CSMODE_TRANSFER|(transferfile->get?CSMODE_DOWNLOAD:CSMODE_UPLOAD); @@ -3355,7 +3385,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi { if (!m_pTransferSocket->InitZlib(m_zlibLevel)) { - ShowStatus(_MPT("Failed to initialize zlib"), 1); + ShowStatus(_MPT("Failed to initialize zlib"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -3384,7 +3414,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi case FILETRANSFER_LIST_LIST: if (IsMisleadingListResponse()) { - ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, 0); + ShowStatus(IDS_STATUSMSG_DIRLISTSUCCESSFUL, FZ_LOG_STATUS); t_directory listing; listing.server = m_CurrentServer; @@ -3703,7 +3733,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi { if (!m_pTransferSocket->InitZlib(m_zlibLevel)) { - ShowStatus(_MPT("Failed to initialize zlib"), 1); + ShowStatus(_MPT("Failed to initialize zlib"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -3753,7 +3783,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi //Error opening the file CString str; str.Format(IDS_ERRORMSG_FILEOPENFAILED,pData->transferfile.localfile); - ShowStatus(str,1); + ShowStatus(str,FZ_LOG_ERROR); nReplyError = FZ_REPLY_ERROR; break; } @@ -3786,7 +3816,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi LONG high = static_cast(size>>32); if (SetFilePointer((HANDLE)m_pDataFile->m_hFile, low, &high, FILE_BEGIN)==0xFFFFFFFF && GetLastError()!=NO_ERROR) { - ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, 1); + ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, FZ_LOG_ERROR); nReplyError = FZ_REPLY_ERROR; } } @@ -3827,7 +3857,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi pData->transferdata.transferleft = pData->transferdata.transfersize - GetLength64(*m_pDataFile); if (SetFilePointer((HANDLE)m_pDataFile->m_hFile, 0, &high, FILE_END)==0xFFFFFFFF && GetLastError()!=NO_ERROR) { - ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, 1); + ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, FZ_LOG_ERROR); nReplyError = FZ_REPLY_ERROR; } else @@ -3842,13 +3872,13 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi ASSERT(m_pDataFile); if (GetLength64(*m_pDataFile) == pData->transferdata.transfersize) { - ShowStatus(IDS_ERRORMSG_CANTRESUME_FINISH, 0); + ShowStatus(IDS_ERRORMSG_CANTRESUME_FINISH, FZ_LOG_STATUS); ResetOperation(FZ_REPLY_OK); return; } } - ShowStatus(IDS_ERRORMSG_CANTRESUME, 1); + ShowStatus(IDS_ERRORMSG_CANTRESUME, FZ_LOG_ERROR); pData->transferdata.transferleft=pData->transferdata.transfersize; pData->transferdata.bResume=FALSE; m_Operation.nOpState=FILETRANSFER_RETRSTOR; @@ -3921,7 +3951,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi { if (SetFilePointer((HANDLE)m_pDataFile->m_hFile, 0, &high, FILE_END)==0xFFFFFFFF && GetLastError()!=NO_ERROR) { - ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, 1); + ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, FZ_LOG_ERROR); nReplyError = FZ_REPLY_ERROR; } } @@ -3931,7 +3961,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi high=static_cast(nOffset>>32); if (SetFilePointer((HANDLE)m_pDataFile->m_hFile, low, &high, FILE_BEGIN)==0xFFFFFFFF && GetLastError()!=NO_ERROR) { - ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, 1); + ShowStatus(IDS_ERRORMSG_SETFILEPOINTER, FZ_LOG_ERROR); nReplyError = FZ_REPLY_ERROR; } } @@ -4068,7 +4098,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi { if (!m_pTransferSocket->InitZlib(m_zlibLevel)) { - ShowStatus(_MPT("Failed to initialize zlib"), 1); + ShowStatus(_MPT("Failed to initialize zlib"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -4093,12 +4123,12 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi int len=sizeof(addr); if (!m_pProxyLayer->GetPeerName((SOCKADDR *)&addr,&len)) { - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); bError=TRUE; } else if (!m_pTransferSocket->Listen(addr.sin_addr.S_un.S_addr)) { - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); bError=TRUE; } //Don't send PORT command yet, params are unknown. @@ -4231,7 +4261,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi if (GetLastError()!=WSAEWOULDBLOCK) { bError=TRUE; - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); } } } @@ -4311,7 +4341,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi { if (!m_pTransferSocket->InitZlib(m_zlibLevel)) { - ShowStatus(_MPT("Failed to initialize zlib"), 1); + ShowStatus(_MPT("Failed to initialize zlib"), FZ_LOG_ERROR); ResetOperation(FZ_REPLY_ERROR); return; } @@ -4336,12 +4366,12 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi int len=sizeof(addr); if (!m_pProxyLayer->GetPeerName((SOCKADDR *)&addr,&len)) { - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); bError=TRUE; } else if (!m_pTransferSocket->Listen(addr.sin_addr.S_un.S_addr)) { - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); bError=TRUE; } //Don't send PORT command yet, params are unknown. @@ -4566,7 +4596,7 @@ void CFtpControlSocket::Cancel(BOOL bQuit/*=FALSE*/) ResetOperation(FZ_REPLY_ERROR | FZ_REPLY_CANCEL); if (nOpMode != CSMODE_NONE && !bQuit) - ShowStatus(IDS_ERRORMSG_INTERRUPTED, 1); + ShowStatus(IDS_ERRORMSG_INTERRUPTED, FZ_LOG_ERROR); if (m_awaitsReply) m_skipReply = true; @@ -4601,7 +4631,7 @@ BOOL CFtpControlSocket::Create() int max=COptions::GetOptionVal(OPTION_PORTRANGEHIGH); if (min>=max) { - ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,1); + ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,FZ_LOG_ERROR); return FALSE; } int startport = static_cast(min+((double)rand()*(max-min))/(RAND_MAX+1)); @@ -4614,7 +4644,7 @@ BOOL CFtpControlSocket::Create() port=min; if (port==startport) { - ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,1); + ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,FZ_LOG_ERROR); return FALSE; } @@ -4658,7 +4688,7 @@ void CFtpControlSocket::ResetOperation(int nSuccessful /*=FALSE*/) if (m_Operation.nOpMode&CSMODE_CONNECT && nSuccessful&FZ_REPLY_ERROR) { nSuccessful|=FZ_REPLY_DISCONNECTED; - ShowStatus(IDS_ERRORMSG_CANTCONNECT, 1); + ShowStatus(IDS_ERRORMSG_CANTCONNECT, FZ_LOG_ERROR); } if (m_Operation.nOpMode & (CSMODE_LIST|CSMODE_LISTFILE|CSMODE_TRANSFER) && nSuccessful==FZ_REPLY_OK) @@ -4766,16 +4796,16 @@ void CFtpControlSocket::ResetOperation(int nSuccessful /*=FALSE*/) if (m_Operation.nOpMode&CSMODE_TRANSFER) if (nSuccessful&FZ_REPLY_ABORTED) //Transfer aborted by user - ShowStatus((m_Operation.nOpMode&CSMODE_DOWNLOAD)?IDS_ERRORMSG_DOWNLOADABORTED:IDS_ERRORMSG_UPLOADABORTED,1); + ShowStatus((m_Operation.nOpMode&CSMODE_DOWNLOAD)?IDS_ERRORMSG_DOWNLOADABORTED:IDS_ERRORMSG_UPLOADABORTED,FZ_LOG_ERROR); else - ShowStatus(((CFileTransferData*)m_Operation.pData)->transferfile.get?IDS_ERRORMSG_DOWNLOADFAILED:IDS_ERRORMSG_UPLOADFAILED,1); + ShowStatus(((CFileTransferData*)m_Operation.pData)->transferfile.get?IDS_ERRORMSG_DOWNLOADFAILED:IDS_ERRORMSG_UPLOADFAILED,FZ_LOG_ERROR); else if (m_Operation.nOpMode&CSMODE_LIST) - ShowStatus(IDS_ERRORMSG_CANTGETLIST,1); + ShowStatus(IDS_ERRORMSG_CANTGETLIST,FZ_LOG_ERROR); else if (m_Operation.nOpMode&CSMODE_LISTFILE) - ShowStatus(IDS_ERRORMSG_CANTGETLISTFILE,1); + ShowStatus(IDS_ERRORMSG_CANTGETLISTFILE,FZ_LOG_ERROR); } else if (m_Operation.pData && m_Operation.nOpMode&CSMODE_TRANSFER && nSuccessful==FZ_REPLY_OK) - ShowStatus(((CFileTransferData*)m_Operation.pData)->transferfile.get?IDS_STATUSMSG_DOWNLOADSUCCESSFUL:IDS_STATUSMSG_UPLOADSUCCESSFUL,0); + ShowStatus(((CFileTransferData*)m_Operation.pData)->transferfile.get?IDS_STATUSMSG_DOWNLOADSUCCESSFUL:IDS_STATUSMSG_UPLOADSUCCESSFUL,FZ_LOG_STATUS); } else { @@ -4951,7 +4981,7 @@ void CFtpControlSocket::RemoveDir(CString dirname, const CServerPath &path) CServerPath newPath = path; if (!newPath.AddSubdir(dirname)) { - ShowStatus(_T("Unable to concatenate path"), 1); + ShowStatus(_T("Unable to concatenate path"), FZ_LOG_ERROR); return; } if (!Send(_MPT("RMD ")+ newPath.GetPath())) @@ -5219,7 +5249,7 @@ void CFtpControlSocket::SetFileExistsAction(int nAction, COverwriteRequestData * CFileStatus64 status; if (GetStatus64(pData->FileName1, status)) { - ShowStatus(IDS_ERRORMSG_NAMEINUSE, 1); + ShowStatus(IDS_ERRORMSG_NAMEINUSE, FZ_LOG_ERROR); nReplyError= FZ_REPLY_CRITICALERROR; } else @@ -5242,7 +5272,7 @@ void CFtpControlSocket::SetFileExistsAction(int nAction, COverwriteRequestData * { if (m_pDirectoryListing->direntry[i].name == pData->FileName1) { - ShowStatus(IDS_ERRORMSG_NAMEINUSE, 1); + ShowStatus(IDS_ERRORMSG_NAMEINUSE, FZ_LOG_ERROR); nReplyError = FZ_REPLY_CRITICALERROR; break; } @@ -5781,7 +5811,7 @@ void CFtpControlSocket::SetAsyncRequestResult(int nAction, CAsyncRequestData *pD if (!nAction) { DoClose(FZ_REPLY_CRITICALERROR|FZ_REPLY_CANCEL); - ShowStatus(IDS_ERRORMSG_INTERRUPTED,1); + ShowStatus(IDS_ERRORMSG_INTERRUPTED,FZ_LOG_ERROR); break; } else @@ -5807,7 +5837,7 @@ void CFtpControlSocket::SetAsyncRequestResult(int nAction, CAsyncRequestData *pD if (!nAction) { DoClose(FZ_REPLY_CRITICALERROR|FZ_REPLY_CANCEL); - ShowStatus(IDS_ERRORMSG_INTERRUPTED,1); + ShowStatus(IDS_ERRORMSG_INTERRUPTED,FZ_LOG_ERROR); break; } m_bCheckForTimeout = TRUE; @@ -5826,7 +5856,7 @@ void CFtpControlSocket::SetAsyncRequestResult(int nAction, CAsyncRequestData *pD if (!nAction) { DoClose(FZ_REPLY_CRITICALERROR|FZ_REPLY_CANCEL); - ShowStatus(IDS_ERRORMSG_INTERRUPTED,1); + ShowStatus(IDS_ERRORMSG_INTERRUPTED,FZ_LOG_ERROR); break; } else @@ -5849,7 +5879,7 @@ void CFtpControlSocket::SetAsyncRequestResult(int nAction, CAsyncRequestData *pD if (!nAction) { DoClose(FZ_REPLY_CRITICALERROR | FZ_REPLY_CANCEL); - ShowStatus(IDS_ERRORMSG_INTERRUPTED, 1); + ShowStatus(IDS_ERRORMSG_INTERRUPTED, FZ_LOG_ERROR); break; } else @@ -5873,12 +5903,15 @@ int CFtpControlSocket::OnLayerCallback(std::list& callbacks) { if (iter->nType == LAYERCALLBACK_STATECHANGE) { + if (CAsyncSocketEx::LogStateChange(iter->nParam1, iter->nParam2)) + { #ifndef MPEXT_NO_SSL - if (iter->pLayer == m_pSslLayer) - { - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pSslLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); - delete [] iter->str; - continue; + if (iter->pLayer == m_pSslLayer) + { + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("TLS layer changed state from %s to %s"), CAsyncSocketEx::GetStateDesc(iter->nParam2), CAsyncSocketEx::GetStateDesc(iter->nParam1)); + delete [] iter->str; + continue; + } } #endif } @@ -5895,7 +5928,7 @@ int CFtpControlSocket::OnLayerCallback(std::list& callbacks) switch (iter->nParam2) { case SSL_INFO_ESTABLISHED: - ShowStatus(IDS_STATUSMSG_SSLESTABLISHED, 0); + ShowStatus(IDS_STATUSMSG_SSLESTABLISHED, FZ_LOG_STATUS); PostMessage(m_pOwner->m_hOwnerWnd, m_pOwner->m_nReplyMessageID, FZ_MSG_MAKEMSG(FZ_MSG_SECURESERVER, 1), 0); if (m_Operation.nOpState == CONNECT_SSL_WAITDONE) { @@ -5908,24 +5941,24 @@ int CFtpControlSocket::OnLayerCallback(std::list& callbacks) switch (iter->nParam2) { case SSL_FAILURE_UNKNOWN: - ShowStatus(IDS_ERRORMSG_UNKNOWNSSLERROR, 1); + ShowStatus(IDS_ERRORMSG_UNKNOWNSSLERROR, FZ_LOG_ERROR); break; case SSL_FAILURE_ESTABLISH: - ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, 1); + ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, FZ_LOG_ERROR); break; #ifndef MPEXT_NO_SSLDLL case SSL_FAILURE_LOADDLLS: - ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); break; #endif case SSL_FAILURE_INITSSL: - ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); break; case SSL_FAILURE_VERIFYCERT: - ShowStatus(IDS_ERRORMSG_SSLCERTIFICATEERROR, 1); + ShowStatus(IDS_ERRORMSG_SSLCERTIFICATEERROR, FZ_LOG_ERROR); break; case SSL_FAILURE_CERTREJECTED: - ShowStatus(IDS_ERRORMSG_CERTREJECTED, 1); + ShowStatus(IDS_ERRORMSG_CERTREJECTED, FZ_LOG_ERROR); m_bDidRejectCertificate = TRUE; break; } @@ -6162,14 +6195,14 @@ void CFtpControlSocket::OnSend(int nErrorCode) { if (GetLastError() != WSAEWOULDBLOCK) { - ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, 1); + ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, FZ_LOG_ERROR); DoClose(); } return; } if (!res) { - ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, 1); + ShowStatus(IDS_ERRORMSG_CANTSENDCOMMAND, FZ_LOG_ERROR); DoClose(); } diff --git a/source/filezilla/FtpControlSocket.h b/source/filezilla/FtpControlSocket.h index 2a9817c7..4ce60329 100644 --- a/source/filezilla/FtpControlSocket.h +++ b/source/filezilla/FtpControlSocket.h @@ -87,7 +87,9 @@ class CFtpControlSocket : public CControlSocket bool IsMisleadingListResponse(); #ifdef MPEXT - virtual bool __fastcall UsingMlsd(); + virtual bool UsingMlsd(); + virtual std::string GetTlsVersionStr(); + virtual std::string GetCipherName(); #endif // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen diff --git a/source/filezilla/FtpListResult.cpp b/source/filezilla/FtpListResult.cpp index 94452977..790d9099 100644 --- a/source/filezilla/FtpListResult.cpp +++ b/source/filezilla/FtpListResult.cpp @@ -1028,6 +1028,8 @@ BOOL CFtpListResult::parseAsVMS(const char *line, const int linelen, t_directory std::map::const_iterator iter; t_directory::t_direntry dir; + dir.bUnsure = FALSE; + const char *str = GetNextToken(line, linelen, tokenlen, pos, 0); if (!str) return FALSE; @@ -1301,6 +1303,7 @@ BOOL CFtpListResult::parseAsMlsd(const char *line, const int linelen, t_director CString facts(str, tokenlen); if (facts.IsEmpty()) return FALSE; + direntry.bUnsure = FALSE; direntry.dir = FALSE; direntry.bLink = FALSE; direntry.size = -1; @@ -2556,6 +2559,8 @@ BOOL CFtpListResult::parseAsIBM(const char *line, const int linelen, t_directory copyStr(direntry.name, 0, str, tokenlen, true); + direntry.bUnsure = FALSE; + return true; } @@ -2660,6 +2665,9 @@ BOOL CFtpListResult::parseAsIBMMVS(const char *line, const int linelen, t_direct if (!str) return FALSE; copyStr(direntry.name, 0, str, tokenlen, true); + + direntry.bUnsure = FALSE; + return true; } @@ -2726,6 +2734,7 @@ BOOL CFtpListResult::parseAsIBMMVSPDS(const char *line, const int linelen, t_dir return FALSE; direntry.dir = FALSE; + direntry.bUnsure = FALSE; return true; } @@ -2742,6 +2751,7 @@ BOOL CFtpListResult::parseAsIBMMVSPDS2(const char *line, const int linelen, t_di int pos = 0; int tokenlen = 0; + direntry.bUnsure = FALSE; direntry.dir = FALSE; direntry.bLink = FALSE; direntry.ownergroup = _MPT(""); @@ -2969,6 +2979,7 @@ BOOL CFtpListResult::parseAsWfFtp(const char *line, const int linelen, t_directo if (!parseTime(str, tokenlen, direntry.date)) return FALSE; + direntry.bUnsure = FALSE; direntry.dir = false; direntry.bLink = false; direntry.permissionstr = _T(""); diff --git a/source/filezilla/MainThread.cpp b/source/filezilla/MainThread.cpp index e0d0ceb7..f437eadf 100644 --- a/source/filezilla/MainThread.cpp +++ b/source/filezilla/MainThread.cpp @@ -411,12 +411,26 @@ void CMainThread::SetOption(int nOption, int nValue) LCS; } #else -bool __fastcall CMainThread::UsingMlsd() +bool CMainThread::UsingMlsd() { if (!IsConnected()) return false; return m_pControlSocket->UsingMlsd(); } + +std::string CMainThread::GetTlsVersionStr() +{ + if (!IsConnected()) + return std::string(); + return m_pControlSocket->GetTlsVersionStr(); +} + +std::string CMainThread::GetCipherName() +{ + if (!IsConnected()) + return std::string(); + return m_pControlSocket->GetCipherName(); +} #endif BOOL CMainThread::GetWorkingDir(t_directory *pWorkingDir) diff --git a/source/filezilla/MainThread.h b/source/filezilla/MainThread.h index cc3f33bd..6d94b445 100644 --- a/source/filezilla/MainThread.h +++ b/source/filezilla/MainThread.h @@ -68,7 +68,9 @@ class CMainThread : public CApiLog void SetOption(int nOption, int nValue); int GetOption(int nOption); #else - bool __fastcall UsingMlsd(); + bool UsingMlsd(); + std::string GetTlsVersionStr(); + std::string GetCipherName(); #endif t_command m_LastCommand; #ifndef MPEXT_NO_CACHE diff --git a/source/filezilla/TransferSocket.cpp b/source/filezilla/TransferSocket.cpp index a3d44f6a..bfb6b614 100644 --- a/source/filezilla/TransferSocket.cpp +++ b/source/filezilla/TransferSocket.cpp @@ -386,7 +386,7 @@ void CTransferSocket::OnReceive(int nErrorCode) { LPTSTR msg = new TCHAR[BUFSIZE]; if (e->GetErrorMessage(msg, BUFSIZE)) - m_pOwner->ShowStatus(msg, 1); + m_pOwner->ShowStatus(msg, FZ_LOG_ERROR); delete [] msg; Close(); if (!m_bSentClose) @@ -437,14 +437,17 @@ void CTransferSocket::OnAccept(int nErrorCode) if (m_pSslLayer) { AddLayer(m_pSslLayer); - int res = m_pSslLayer->InitSSLConnection(true, m_pOwner->m_pSslLayer, COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE)); + int res = m_pSslLayer->InitSSLConnection(true, m_pOwner->m_pSslLayer, + COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), + COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), + COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); #ifndef MPEXT_NO_SSLDLL if (res == SSL_FAILURE_LOADDLLS) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); else #endif if (res == SSL_FAILURE_INITSSL) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (res) { @@ -484,7 +487,7 @@ void CTransferSocket::OnConnect(int nErrorCode) str.Format(IDS_ERRORMSG_CANTOPENTRANSFERCHANNEL,buffer); str.Replace( _T("\n"), _T("\0") ); str.Replace( _T("\r"), _T("\0") ); - m_pOwner->ShowStatus(str, 1); + m_pOwner->ShowStatus(str, FZ_LOG_ERROR); Close(); if (!m_bSentClose) { @@ -520,14 +523,17 @@ void CTransferSocket::OnConnect(int nErrorCode) if (m_pSslLayer) { AddLayer(m_pSslLayer); - int res = m_pSslLayer->InitSSLConnection(true, m_pOwner->m_pSslLayer, COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE)); + int res = m_pSslLayer->InitSSLConnection(true, m_pOwner->m_pSslLayer, + COptions::GetOptionVal(OPTION_MPEXT_SSLSESSIONREUSE), + COptions::GetOptionVal(OPTION_MPEXT_MIN_TLS_VERSION), + COptions::GetOptionVal(OPTION_MPEXT_MAX_TLS_VERSION)); #ifndef MPEXT_NO_SSLDLL if (res == SSL_FAILURE_LOADDLLS) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); else #endif if (res == SSL_FAILURE_INITSSL) - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); if (res) { @@ -584,7 +590,7 @@ int CTransferSocket::CheckForTimeout(int delay) CTimeSpan span = CTime::GetCurrentTime()-m_LastActiveTime; if (span.GetTotalSeconds()>=delay) { - m_pOwner->ShowStatus(IDS_ERRORMSG_TIMEOUT, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_TIMEOUT, FZ_LOG_ERROR); Close(); if (!m_bSentClose) { @@ -698,7 +704,7 @@ void CTransferSocket::OnSend(int nErrorCode) res = deflate(&m_zlibStream, m_pFile ? 0 : Z_FINISH); if (res != Z_OK && (!m_pFile && res != Z_STREAM_END)) { - m_pOwner->ShowStatus("ZLib error", 1); + m_pOwner->ShowStatus("ZLib error", FZ_LOG_ERROR); Close(); if (!m_bSentClose) { @@ -1176,7 +1182,7 @@ BOOL CTransferSocket::Create( int max=COptions::GetOptionVal(OPTION_PORTRANGEHIGH); if (min>=max) { - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,FZ_LOG_ERROR); return FALSE; } int startport=static_cast(min+((double)rand()*(max-min))/(RAND_MAX+1)); @@ -1188,7 +1194,7 @@ BOOL CTransferSocket::Create( port=min; if (port==startport) { - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE,FZ_LOG_ERROR); return FALSE; } } @@ -1210,18 +1216,23 @@ int CTransferSocket::OnLayerCallback(std::list& callbacks) { if (iter->nType == LAYERCALLBACK_STATECHANGE) { - if (iter->pLayer == m_pProxyLayer) - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pProxyLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); + if (CAsyncSocketEx::LogStateChange(iter->nParam1, iter->nParam2)) + { + const TCHAR * state2Desc = CAsyncSocketEx::GetStateDesc(iter->nParam2); + const TCHAR * state1Desc = CAsyncSocketEx::GetStateDesc(iter->nParam1); + if (iter->pLayer == m_pProxyLayer) + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Proxy layer changed state from %s to %s"), state2Desc, state1Desc); #ifndef MPEXT_NO_SSL - else if (iter->pLayer == m_pSslLayer) - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pSslLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); + else if (iter->pLayer == m_pSslLayer) + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("TLS layer changed state from %s to %s"), state2Desc, state1Desc); #endif #ifndef MPEXT_NO_GSS - else if (iter->pLayer == m_pGssLayer) - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("m_pGssLayer changed state from %d to %d"), iter->nParam2, iter->nParam1); + else if (iter->pLayer == m_pGssLayer) + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("GSS layer changed state from %s to %s"), state2Desc, state1Desc); #endif - else - LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Layer @ %d changed state from %d to %d"), iter->pLayer, iter->nParam2, iter->nParam1); + else + LogMessage(__FILE__, __LINE__, this, FZ_LOG_INFO, _T("Layer @ %d changed state from %s to %s"), iter->pLayer, state2Desc, state1Desc); + } } else if (iter->nType == LAYERCALLBACK_LAYERSPECIFIC) { @@ -1230,22 +1241,22 @@ int CTransferSocket::OnLayerCallback(std::list& callbacks) switch (iter->nParam1) { case PROXYERROR_NOCONN: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_NOCONN, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_NOCONN, FZ_LOG_ERROR); break; case PROXYERROR_REQUESTFAILED: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_REQUESTFAILED, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_REQUESTFAILED, FZ_LOG_ERROR); break; case PROXYERROR_AUTHTYPEUNKNOWN: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHTYPEUNKNOWN, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHTYPEUNKNOWN, FZ_LOG_ERROR); break; case PROXYERROR_AUTHFAILED: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHFAILED, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHFAILED, FZ_LOG_ERROR); break; case PROXYERROR_AUTHNOLOGON: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHNOLOGON, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_AUTHNOLOGON, FZ_LOG_ERROR); break; case PROXYERROR_CANTRESOLVEHOST: - m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_CANTRESOLVEHOST, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_PROXY_CANTRESOLVEHOST, FZ_LOG_ERROR); break; default: LogMessage(__FILE__, __LINE__, this, FZ_LOG_WARNING, _T("Unknown proxy error")); @@ -1268,7 +1279,7 @@ int CTransferSocket::OnLayerCallback(std::list& callbacks) } break; case SSL_INFO_ESTABLISHED: - m_pOwner->ShowStatus(IDS_STATUSMSG_SSLESTABLISHEDTRANSFER, 0); + m_pOwner->ShowStatus(IDS_STATUSMSG_SSLESTABLISHEDTRANSFER, FZ_LOG_STATUS); TriggerEvent(FD_FORCEREAD); break; } @@ -1277,15 +1288,15 @@ int CTransferSocket::OnLayerCallback(std::list& callbacks) switch (iter->nParam2) { case SSL_FAILURE_ESTABLISH: - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, FZ_LOG_ERROR); break; #ifndef MPEXT_NO_SSLDLL case SSL_FAILURE_LOADDLLS: - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTLOADSSLDLLS, FZ_LOG_ERROR); break; #endif case SSL_FAILURE_INITSSL: - m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, 1); + m_pOwner->ShowStatus(IDS_ERRORMSG_CANTINITSSL, FZ_LOG_ERROR); break; } if (!m_bSentClose) @@ -1438,7 +1449,7 @@ int CTransferSocket::ReadDataFromFile(char *buffer, int len) { TCHAR error[BUFSIZE]; if (e->GetErrorMessage(error, BUFSIZE)) - m_pOwner->ShowStatus(error, 1); + m_pOwner->ShowStatus(error, FZ_LOG_ERROR); if (ShutDown() || GetLastError() != WSAEWOULDBLOCK) { Close(); diff --git a/source/forms/Custom.cpp b/source/forms/Custom.cpp index 8805b2a8..ca4c7a5f 100644 --- a/source/forms/Custom.cpp +++ b/source/forms/Custom.cpp @@ -335,6 +335,7 @@ TSessionData * __fastcall DoSaveSession(TSessionData * SessionData, bool Result; if (!ForceDialog && ((PSavePassword == NULL) || SavePassword)) { + CustomWinConfiguration->AskForMasterPasswordIfNotSetAndNeededToPersistSessionData(SessionData); Result = true; } else diff --git a/source/forms/CustomScpExplorer.cpp b/source/forms/CustomScpExplorer.cpp index 014cd5c0..f6130189 100644 --- a/source/forms/CustomScpExplorer.cpp +++ b/source/forms/CustomScpExplorer.cpp @@ -260,7 +260,7 @@ __fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner): AddNewSessionImage(); SessionsPageControl->Images = FSessionColors; QueueLabel->FocusControl = QueueView3; - QueueLabel->Caption = LoadStr(QUEUE_CAPTION); + UpdateQueueLabel(); CreateHiddenWindow(); StartUpdates(); @@ -550,8 +550,8 @@ void __fastcall TCustomScpExplorerForm::UpdateQueueStatus(bool QueueChanging) Configuration->Usage->SetMax(L"MaxQueueLength", FMaxQueueLength); } - SetQueueTaskbarProgress(); FQueueController->UpdateQueueStatus(FQueueStatus); + SetQueueProgress(); UpdateQueueView(); @@ -580,8 +580,8 @@ UnicodeString __fastcall TCustomScpExplorerForm::GetQueueProgressTitle() UnicodeString Result; if (FQueueStatus != NULL) { - int ActiveCount = FQueueStatus->ActiveCount; - if (ActiveCount == 1) + int ActiveAndPendingCount = FQueueStatus->ActiveAndPendingCount; + if ((ActiveAndPendingCount == 1) && (FQueueStatus->ActiveCount == 1)) { TFileOperationProgressType * ProgressData = FQueueStatus->Items[FQueueStatus->DoneCount]->ProgressData; @@ -590,9 +590,9 @@ UnicodeString __fastcall TCustomScpExplorerForm::GetQueueProgressTitle() Result = TTerminalManager::ProgressTitle(ProgressData); } } - else if (ActiveCount > 1) + else if (ActiveAndPendingCount > 1) { - Result = FMTLOAD(PROGRESS_IN_QUEUE, (ActiveCount)); + Result = FMTLOAD(PROGRESS_IN_QUEUE, (ActiveAndPendingCount)); } } return Result; @@ -699,12 +699,12 @@ void __fastcall TCustomScpExplorerForm::RefreshQueueItems() if (Updated) { NonVisualDataModule->UpdateNonVisibleActions(); - SetQueueTaskbarProgress(); + SetQueueProgress(); } } } //--------------------------------------------------------------------------- -void __fastcall TCustomScpExplorerForm::SetQueueTaskbarProgress() +void __fastcall TCustomScpExplorerForm::SetQueueProgress() { TTerminalManager::Instance()->QueueStatusUpdated(); @@ -744,6 +744,22 @@ void __fastcall TCustomScpExplorerForm::SetQueueTaskbarProgress() FTaskbarList->SetProgressState(Handle, TBPF_NOPROGRESS); } } + + UpdateQueueLabel(); +} +//--------------------------------------------------------------------------- +void __fastcall TCustomScpExplorerForm::UpdateQueueLabel() +{ + UnicodeString Caption = LoadStr(QUEUE_CAPTION); + if (FQueueStatus != NULL) + { + int ActiveAndPendingCount = FQueueStatus->ActiveAndPendingCount; + if (ActiveAndPendingCount > 0) + { + Caption = FORMAT("%s (%d)", (Caption, ActiveAndPendingCount)); + } + } + QueueLabel->Caption = Caption; } //--------------------------------------------------------------------------- void __fastcall TCustomScpExplorerForm::UpdateTransferList() @@ -1139,7 +1155,7 @@ void __fastcall TCustomScpExplorerForm::FileOperationProgress( { SAFE_DESTROY(FProgressForm); - SetQueueTaskbarProgress(); + SetQueueProgress(); if ((ProgressData.Operation != foCalculateSize) && (ProgressData.Cancel == csContinue) && @@ -7419,6 +7435,18 @@ void __fastcall TCustomScpExplorerForm::SessionsPageControlMouseDown( { SessionsPageControl->ActivePageIndex = Index; SessionsPageControlChange(NULL); + + // copied from TControl.WMContextMenu + SendCancelMode(SessionsPageControl); + + // explicit popup instead of using PopupMenu property + // to avoid menu to popup somewhere within SessionsPageControlChange above, + // while connecting yet not-connected session and hence + // allowing an access to commands over not-completelly connected session + TPoint Point = SessionsPageControl->ClientToScreen(TPoint(X, Y)); + TPopupMenu * PopupMenu = NonVisualDataModule->SessionsPopup; + PopupMenu->PopupComponent = SessionsPageControl; + PopupMenu->Popup(Point.x, Point.y); } else if (Button == mbLeft) { diff --git a/source/forms/CustomScpExplorer.dfm b/source/forms/CustomScpExplorer.dfm index 96a8abac..4e3bf82a 100644 --- a/source/forms/CustomScpExplorer.dfm +++ b/source/forms/CustomScpExplorer.dfm @@ -296,7 +296,6 @@ object CustomScpExplorerForm: TCustomScpExplorerForm Align = alTop DoubleBuffered = True ParentDoubleBuffered = False - PopupMenu = NonVisualDataModule.SessionsPopup TabOrder = 3 TabStop = False OnChange = SessionsPageControlChange diff --git a/source/forms/CustomScpExplorer.h b/source/forms/CustomScpExplorer.h index f2011a4d..ed2023fe 100644 --- a/source/forms/CustomScpExplorer.h +++ b/source/forms/CustomScpExplorer.h @@ -493,7 +493,8 @@ class TCustomScpExplorerForm : public TForm void __fastcall DirViewContextPopup( TOperationSide Side, Byte PopupComponent, const TPoint & MousePos); bool __fastcall CommandLineFromAnotherInstance(const UnicodeString & CommandLine); - void __fastcall SetQueueTaskbarProgress(); + void __fastcall SetQueueProgress(); + void __fastcall UpdateQueueLabel(); public: virtual __fastcall ~TCustomScpExplorerForm(); diff --git a/source/forms/FileSystemInfo.cpp b/source/forms/FileSystemInfo.cpp index b014ba18..44523834 100644 --- a/source/forms/FileSystemInfo.cpp +++ b/source/forms/FileSystemInfo.cpp @@ -92,7 +92,8 @@ UnicodeString __fastcall TFileSystemInfoDialog::SpaceStr(__int64 Bytes) void __fastcall TFileSystemInfoDialog::Feed(TFeedFileSystemData AddItem) { AddItem(ServerView, FSINFO_REMOTE_SYSTEM, FFileSystemInfo.RemoteSystem); - AddItem(ServerView, FSINFO_SESSION_PROTOCOL, FSessionInfo.ProtocolName); + AddItem(ServerView, FSINFO_FS_PROTOCOL, FFileSystemInfo.ProtocolName); + AddItem(ServerView, FSINFO_CRYPTOGRAPHIC_PROTOCOL, FSessionInfo.SecurityProtocolName); AddItem(ServerView, FSINFO_SSH_IMPLEMENTATION, FSessionInfo.SshImplementation); UnicodeString Str = FSessionInfo.CSCipher; @@ -108,10 +109,6 @@ void __fastcall TFileSystemInfoDialog::Feed(TFeedFileSystemData AddItem) Str += FORMAT(L"/%s", (DefaultStr(FSessionInfo.SCCompression, LoadStr(NO_STR)))); } AddItem(ServerView, FSINFO_COMPRESSION, Str); - if (FSessionInfo.ProtocolName != FFileSystemInfo.ProtocolName) - { - AddItem(ServerView, FSINFO_FS_PROTOCOL, FFileSystemInfo.ProtocolName); - } AddItem(HostKeyFingerprintEdit, 0, FSessionInfo.HostKeyFingerprint); AddItem(CertificateFingerprintEdit, 0, FSessionInfo.CertificateFingerprint); diff --git a/source/forms/Login.cpp b/source/forms/Login.cpp index f1514bf1..a16e8c0b 100644 --- a/source/forms/Login.cpp +++ b/source/forms/Login.cpp @@ -54,9 +54,7 @@ __fastcall TLoginDialog::TLoginDialog(TComponent* AOwner) : TForm(AOwner) { FNewSiteData = new TSessionData(L""); - FSessionData = new TSessionData(L""); FInitialized = false; - FSavedSession = -1; FOptions = loStartup; FLocaleChanging = false; FHintNode = NULL; @@ -71,6 +69,9 @@ __fastcall TLoginDialog::TLoginDialog(TComponent* AOwner) // we need to make sure that window procedure is set asap // (so that CM_SHOWINGCHANGED handling is applied) UseSystemSettingsPre(this, &FSystemSettings); + + FOriginalSize = BoundsRect.GetSize(); + FBasicGroupBaseHeight = BasicGroup->Height - BasicSshPanel->Height - BasicFtpPanel->Height; InitControls(); } //--------------------------------------------------------------------- @@ -81,7 +82,13 @@ __fastcall TLoginDialog::~TLoginDialog() DeleteSystemSettings(this, FSystemSettings); FSystemSettings = NULL; delete FNewSiteData; + InvalidateSessionData(); +} +//--------------------------------------------------------------------- +void __fastcall TLoginDialog::InvalidateSessionData() +{ delete FSessionData; + FSessionData = NULL; } //--------------------------------------------------------------------- void __fastcall TLoginDialog::Init(TStoredSessionList *SessionList, @@ -104,14 +111,15 @@ void __fastcall TLoginDialog::InitControls() SessionTree->WindowProc = SessionTreeProc; } - FtpsCombo->Items->Strings[1] = LoadStr(FTPS_IMPLICIT); - FtpsCombo->Items->Strings[2] = LoadStr(FTPS_EXPLICIT_SSL); - FtpsCombo->Items->Strings[3] = LoadStr(FTPS_EXPLICIT_TLS); - WebDavsCombo->Items->Strings[0] = FtpsCombo->Items->Strings[0]; - WebDavsCombo->Items->Strings[1] = FtpsCombo->Items->Strings[1]; + int FtpsNoneIndex = FtpsToIndex(ftpsNone); + int FtpsImplicitIndex = FtpsToIndex(ftpsImplicit); + FtpsCombo->Items->Strings[FtpsImplicitIndex] = LoadStr(FTPS_IMPLICIT); + FtpsCombo->Items->Strings[FtpsToIndex(ftpsExplicitTls)] = LoadStr(FTPS_EXPLICIT_TLS); + FtpsCombo->Items->Strings[FtpsToIndex(ftpsExplicitSsl)] = LoadStr(FTPS_EXPLICIT_SSL); + WebDavsCombo->Items->Strings[FtpsNoneIndex] = FtpsCombo->Items->Strings[FtpsNoneIndex]; + WebDavsCombo->Items->Strings[FtpsImplicitIndex] = FtpsCombo->Items->Strings[FtpsImplicitIndex]; BasicSshPanel->Top = BasicFtpPanel->Top; - FBasicGroupBaseHeight = BasicGroup->Height - BasicSshPanel->Height - BasicFtpPanel->Height; SitesIncrementalSearchLabel->AutoSize = false; SitesIncrementalSearchLabel->Left = SessionTree->Left; @@ -353,25 +361,53 @@ void __fastcall TLoginDialog::LoadContents() //--------------------------------------------------------------------- void __fastcall TLoginDialog::LoadSession(TSessionData * SessionData) { - UserNameEdit->Text = SessionData->UserName; - PortNumberEdit->AsInteger = SessionData->PortNumber; - HostNameEdit->Text = SessionData->HostName; - PasswordEdit->Text = SessionData->Password; - FtpsCombo->ItemIndex = SessionData->Ftps; - WebDavsCombo->ItemIndex = SessionData->Ftps; - EncryptionView->Text = - ALWAYS_TRUE(FtpsCombo->ItemIndex >= WebDavsCombo->ItemIndex) ? FtpsCombo->Text : WebDavsCombo->Text; - - bool AllowScpFallback; - TransferProtocolCombo->ItemIndex = FSProtocolToIndex(SessionData->FSProtocol, AllowScpFallback); - TransferProtocolView->Text = TransferProtocolCombo->Text; - - // just in case TransferProtocolComboChange is not triggered - FDefaultPort = DefaultPort(); - FUpdatePortWithProtocol = true; + WinConfiguration->BeginMasterPasswordSession(); + try + { + UserNameEdit->Text = SessionData->UserName; + PortNumberEdit->AsInteger = SessionData->PortNumber; + HostNameEdit->Text = SessionData->HostName; - // advanced - FSessionData->Assign(SessionData); + bool Editable = FEditing || (SessionData == FNewSiteData); + if (Editable) + { + PasswordEdit->Text = SessionData->Password; + } + else + { + PasswordEdit->Text = + SessionData->HasPassword() ? + UnicodeString::StringOfChar(L'?', 16) : UnicodeString(); + } + + int FtpsIndex = FtpsToIndex(SessionData->Ftps); + FtpsCombo->ItemIndex = FtpsIndex; + WebDavsCombo->ItemIndex = FtpsIndex; + EncryptionView->Text = + ALWAYS_TRUE(FtpsCombo->ItemIndex >= WebDavsCombo->ItemIndex) ? FtpsCombo->Text : WebDavsCombo->Text; + + bool AllowScpFallback; + TransferProtocolCombo->ItemIndex = FSProtocolToIndex(SessionData->FSProtocol, AllowScpFallback); + TransferProtocolView->Text = TransferProtocolCombo->Text; + + // just in case TransferProtocolComboChange is not triggered + FDefaultPort = DefaultPort(); + FUpdatePortWithProtocol = true; + + // advanced + InvalidateSessionData(); + // close advanced settings only when really needed, + // see also note in SessionAdvancedActionExecute + if (Editable) + { + FSessionData = new TSessionData(L""); + FSessionData->Assign(SessionData); + } + } + __finally + { + WinConfiguration->EndMasterPasswordSession(); + } UpdateControls(); } @@ -379,7 +415,10 @@ void __fastcall TLoginDialog::LoadSession(TSessionData * SessionData) void __fastcall TLoginDialog::SaveSession(TSessionData * SessionData) { // advanced - SessionData->Assign(FSessionData); + if (ALWAYS_TRUE(FSessionData != NULL)) + { + SessionData->Assign(FSessionData); + } // Basic page SessionData->UserName = UserNameEdit->Text.Trim(); @@ -389,7 +428,9 @@ void __fastcall TLoginDialog::SaveSession(TSessionData * SessionData) SessionData->Password = PasswordEdit->Text; SessionData->Ftps = GetFtps(); - SessionData->FSProtocol = GetFSProtocol(); + SessionData->FSProtocol = + // requiring SCP fallback distinction + GetFSProtocol(true); TSessionData * EditingSessionData = GetEditingSessionData(); SessionData->Name = @@ -398,13 +439,14 @@ void __fastcall TLoginDialog::SaveSession(TSessionData * SessionData) //--------------------------------------------------------------------- void __fastcall TLoginDialog::UpdateControls() { - if (Visible && FInitialized) + // without FLocaleChanging test, some button controls get lost, when changing language + if (Visible && FInitialized && !FLocaleChanging) { bool NewSiteSelected = IsNewSiteNode(SessionTree->Selected); bool Editable = NewSiteSelected || FEditing; - TFSProtocol FSProtocol = GetFSProtocol(); + TFSProtocol FSProtocol = GetFSProtocol(false); bool SshProtocol = IsSshProtocol(FSProtocol); bool FtpProtocol = (FSProtocol == fsFTP); bool WebDavProtocol = (FSProtocol == fsWebDAV); @@ -517,14 +559,6 @@ void __fastcall TLoginDialog::FormShow(TObject * /*Sender*/) LoadContents(); } - if (FLocaleChanging) - { - if (FSavedSession >= 0) - { - SessionTree->Selected = SessionTree->Items->Item[FSavedSession]; - SessionTree->Selected->MakeVisible(); - } - } // among other this makes the expanded nodes look like expanded, // because the LoadState call in Execute is too early, // and some stray call to collapsed event during showing process, @@ -668,6 +702,8 @@ void __fastcall TLoginDialog::EditSessionActionExecute(TObject * /*Sender*/) { FEditing = true; EditSession(); + // reload session, to make sure we load decrypted password + LoadContents(); UpdateControls(); } } @@ -718,6 +754,7 @@ void __fastcall TLoginDialog::SaveAsSession(bool ForceDialog) // this // - updates TransferProtocolView and EncryptionView // - clears the password box, if user has not opted to save password + // - reloads fake password LoadContents(); UpdateControls(); @@ -1086,6 +1123,9 @@ void __fastcall TLoginDialog::SaveState() WinConfiguration->LastStoredSession = SessionNodePath(SessionTree->Selected); + // used only when changing locale + FSavedBounds = BoundsRect; + TLoginDialogConfiguration DialogConfiguration = CustomWinConfiguration->LoginDialog; DialogConfiguration.WindowSize = StoreFormSize(this); CustomWinConfiguration->LoginDialog = DialogConfiguration; @@ -1168,7 +1208,14 @@ void __fastcall TLoginDialog::LoadState() } } - RestoreFormSize(CustomWinConfiguration->LoginDialog.WindowSize, this); + if (FLocaleChanging) + { + BoundsRect = FSavedBounds; + } + else + { + RestoreFormSize(CustomWinConfiguration->LoginDialog.WindowSize, this); + } } //--------------------------------------------------------------------------- void __fastcall TLoginDialog::SaveConfiguration() @@ -1261,8 +1308,11 @@ void __fastcall TLoginDialog::Dispatch(void * Message) SaveConfiguration(); SaveState(); PersistNewSiteIfNeeded(); - FSavedSession = ((SessionTree->Selected != NULL) ? - SessionTree->Selected->AbsoluteIndex : -1); + + // restore sizes to design-time state, + // otherwise layout is lost while reloading the form + BasicGroup->Height = FBasicGroupBaseHeight + BasicSshPanel->Height + BasicFtpPanel->Height; + SetBounds(Left, Top, FOriginalSize.cx, FOriginalSize.cy); assert(FSystemSettings); RevokeSystemSettings(this, FSystemSettings); @@ -1297,12 +1347,7 @@ void __fastcall TLoginDialog::SetDefaultSessionActionExecute( { std::auto_ptr SessionData(new TSessionData(L"")); SaveSession(SessionData.get()); - if (!Configuration->DisablePasswordStoring && - SessionData->HasAnyPassword() && - CustomWinConfiguration->UseMasterPassword) - { - CustomWinConfiguration->AskForMasterPasswordIfNotSet(); - } + CustomWinConfiguration->AskForMasterPasswordIfNotSetAndNeededToPersistSessionData(SessionData.get()); StoredSessions->DefaultSettings = SessionData.get(); Default(); @@ -1632,21 +1677,66 @@ TFSProtocol __fastcall TLoginDialog::IndexToFSProtocol(int Index, bool AllowScpF return Result; } //--------------------------------------------------------------------------- +int __fastcall TLoginDialog::FtpsToIndex(TFtps Ftps) +{ + switch (Ftps) + { + default: + FAIL; + case ftpsNone: + return 0; + + case ftpsImplicit: + return 1; + + case ftpsExplicitSsl: + return 3; + + case ftpsExplicitTls: + return 2; + } +} +//--------------------------------------------------------------------------- TFtps __fastcall TLoginDialog::GetFtps() { - return (TFtps)((GetFSProtocol() == fsWebDAV) ? WebDavsCombo->ItemIndex : FtpsCombo->ItemIndex); + int Index = ((GetFSProtocol(false) == fsWebDAV) ? WebDavsCombo->ItemIndex : FtpsCombo->ItemIndex); + TFtps Ftps; + switch (Index) + { + default: + FAIL; + case 0: + Ftps = ftpsNone; + break; + + case 1: + Ftps = ftpsImplicit; + break; + + case 2: + Ftps = ftpsExplicitTls; + break; + + case 3: + Ftps = ftpsExplicitSsl; + break; + } + return Ftps; } //--------------------------------------------------------------------------- -TFSProtocol __fastcall TLoginDialog::GetFSProtocol() +TFSProtocol __fastcall TLoginDialog::GetFSProtocol(bool RequireScpFallbackDistinction) { bool AllowScpFallback = false; - FSProtocolToIndex(FSessionData->FSProtocol, AllowScpFallback); + if (RequireScpFallbackDistinction && ALWAYS_TRUE(FSessionData != NULL)) + { + FSProtocolToIndex(FSessionData->FSProtocol, AllowScpFallback); + } return IndexToFSProtocol(TransferProtocolCombo->ItemIndex, AllowScpFallback); } //--------------------------------------------------------------------------- int __fastcall TLoginDialog::DefaultPort() { - TFSProtocol FSProtocol = GetFSProtocol(); + TFSProtocol FSProtocol = GetFSProtocol(false); TFtps Ftps = GetFtps(); int Result; switch (FSProtocol) @@ -2130,8 +2220,9 @@ void __fastcall TLoginDialog::PortNumberEditChange(TObject * Sender) { TransferProtocolCombo->ItemIndex = ProtocolIndex; - FtpsCombo->ItemIndex = Ftps; - WebDavsCombo->ItemIndex = Ftps; + int FtpsIndex = FtpsToIndex(Ftps); + FtpsCombo->ItemIndex = FtpsIndex; + WebDavsCombo->ItemIndex = FtpsIndex; } __finally { @@ -2358,8 +2449,17 @@ void __fastcall TLoginDialog::PersistNewSiteIfNeeded() //--------------------------------------------------------------------------- void __fastcall TLoginDialog::SessionAdvancedActionExecute(TObject * /*Sender*/) { - SaveSession(FSessionData); - DoSiteAdvancedDialog(FSessionData, FOptions); + // If we ever allow showing advanced settings, while read-only, + // we must make sure that FSessionData actually holds the advanced settings, + // what is currently does not, in order to avoid master password prompt, + // while cloning the session data in LoadSession. + // To implement this, we may delegate the cloning to TWinConfiguration and + // make use of FDontDecryptPasswords + if (ALWAYS_TRUE(FSessionData != NULL)) + { + SaveSession(FSessionData); + DoSiteAdvancedDialog(FSessionData, FOptions); + } } //--------------------------------------------------------------------------- TPopupMenu * __fastcall TLoginDialog::GetSelectedNodePopupMenu() @@ -2396,7 +2496,7 @@ void __fastcall TLoginDialog::SessionTreeMouseDown(TObject * /*Sender*/, TMouseButton Button, TShiftState /*Shift*/, int X, int Y) { TTreeNode * Node = SessionTree->GetNodeAt(X, Y); - if (Button == mbRight) + if ((Button == mbRight) && (Node != NULL)) { SessionTree->Selected = Node; } @@ -2415,8 +2515,14 @@ void __fastcall TLoginDialog::SessionTreeContextPopup(TObject * /*Sender*/, } else { - SessionTree->PopupMenu = GetSelectedNodePopupMenu(); - MenuPopup(SessionTree, MousePos, Handled); + if (SessionTree->Selected != NULL) + { + SessionTree->PopupMenu = GetSelectedNodePopupMenu(); + if (NOT_NULL(SessionTree->PopupMenu)) + { + MenuPopup(SessionTree, MousePos, Handled); + } + } } } //--------------------------------------------------------------------------- diff --git a/source/forms/Login.dfm b/source/forms/Login.dfm index 1286dddf..34ea0449 100644 --- a/source/forms/Login.dfm +++ b/source/forms/Login.dfm @@ -241,9 +241,9 @@ object LoginDialog: TLoginDialog OnChange = TransferProtocolComboChange Items.Strings = ( 'No encryption' - 'SSL/TLS Implicit encryptionX' - 'SSL Explicit encryptionX' - 'TLS Explicit encryptionX') + 'TLS/SSL Implicit encryptionX' + 'TLS Explicit encryptionX' + 'SSL Explicit encryptionX') end object WebDavsCombo: TComboBox Left = 163 @@ -255,7 +255,7 @@ object LoginDialog: TLoginDialog OnChange = TransferProtocolComboChange Items.Strings = ( 'No encryptionX' - 'SSL/TLS Implicit encryptionX') + 'TLS/SSL Implicit encryptionX') end object BasicFtpPanel: TPanel Left = 12 diff --git a/source/forms/Login.h b/source/forms/Login.h index 4d552350..31d3a541 100644 --- a/source/forms/Login.h +++ b/source/forms/Login.h @@ -221,7 +221,6 @@ class TLoginDialog : public TForm TStoredSessionList * FStoredSessions; int FOptions; bool FInitialized; - int FSavedSession; bool FLocaleChanging; void * FSystemSettings; TWndMethod FOldSessionTreeProc; @@ -234,8 +233,10 @@ class TLoginDialog : public TForm int FIncrementalSearching; bool FSitesIncrementalSearchHaveNext; int FBasicGroupBaseHeight; + TRect FSavedBounds; bool FEditing; bool FRenaming; + TSize FOriginalSize; void __fastcall LoadSession(TSessionData * SessionData); void __fastcall LoadContents(); @@ -248,8 +249,9 @@ class TLoginDialog : public TForm void __fastcall CMDialogKey(TWMKeyDown & Message); int __fastcall FSProtocolToIndex(TFSProtocol FSProtocol, bool & AllowScpFallback); TFSProtocol __fastcall IndexToFSProtocol(int Index, bool AllowScpFallback); + int __fastcall FtpsToIndex(TFtps Ftps); TFtps __fastcall GetFtps(); - TFSProtocol __fastcall GetFSProtocol(); + TFSProtocol __fastcall GetFSProtocol(bool RequireScpFallbackDistinction); void __fastcall UpdateFolderNode(TTreeNode * Node); TTreeNode * __fastcall AddSession(TSessionData * Data); TTreeNode * __fastcall AddSessionPath(UnicodeString Path, @@ -299,6 +301,7 @@ class TLoginDialog : public TForm void __fastcall DefaultButton(TButton * Button, bool Default); TSessionData * __fastcall GetEditingSessionData(); void __fastcall SaveAsSession(bool ForceDialog); + void __fastcall InvalidateSessionData(); protected: void __fastcall Default(); diff --git a/source/forms/NonVisual.dfm b/source/forms/NonVisual.dfm index d5c26ac6..1b409f0b 100644 --- a/source/forms/NonVisual.dfm +++ b/source/forms/NonVisual.dfm @@ -604,6 +604,8 @@ object NonVisualDataModule: TNonVisualDataModule Hint = 'Close session|Terminate current session' ImageIndex = 26 ShortCut = 24644 + SecondaryShortCuts.Strings = ( + 'Ctrl+W') end object SavedSessionsAction2: TAction Tag = 15 diff --git a/source/forms/Preferences.cpp b/source/forms/Preferences.cpp index fb8379f1..dc18ab3f 100644 --- a/source/forms/Preferences.cpp +++ b/source/forms/Preferences.cpp @@ -78,7 +78,7 @@ __fastcall TPreferencesDialog::TPreferencesDialog( HintLabel(LogFileNameHintText, LoadStr(LOG_FILE_HINT3)); HintLabel(ActionsLogFileNameHintText, LoadStr(LOG_FILE_HINT3)); - HintLabel(ShellIconsText); + HintLabel(ShellIconsText2); HotTrackLabel(CopyParamLabel); HintLabel(PuttyPathHintText, LoadStr(PUTTY_PATTERNS_HINT)); @@ -1053,7 +1053,7 @@ void __fastcall TPreferencesDialog::UpdateControls() // integration // There's no quick launch in Windows 7 - EnableControl(QuickLaunchIconButton, !IsWin7()); + EnableControl(QuickLaunchIconButton, !::IsWin7()); // languages LanguageChangeLabel->Visible = @@ -1859,6 +1859,68 @@ void __fastcall TPreferencesDialog::SessionReopenTimeoutEditGetValue( } } //--------------------------------------------------------------------------- +bool __fastcall TPreferencesDialog::CanSetMasterPassword() +{ + bool Result; + bool Retry; + do + { + Retry = false; + Result = !AnyOtherInstanceOfSelf(); + + if (!Result) + { + unsigned int Answer = + MessageDialog( + LoadStr(MASTER_PASSWORD_OTHER_INSTANCE), + qtConfirmation, qaRetry | qaIgnore | qaCancel, + HELP_MASTER_PASSWORD); + + switch (Answer) + { + case qaRetry: + Retry = true; + break; + + case qaIgnore: + Result = true; + break; + + case qaCancel: + default: + // noop + break; + } + } + } + while (Retry && !Result); + + return Result; +} +//--------------------------------------------------------------------------- +void __fastcall TPreferencesDialog::MasterPasswordChanged( + UnicodeString Message, TStrings * RecryptPasswordErrors) +{ + Configuration->Save(); + if (RecryptPasswordErrors->Count > 0) + { + Message = FMTLOAD(MASTER_PASSWORD_RECRYPT_ERRORS, (Message)); + } + MoreMessageDialog( + Message, RecryptPasswordErrors, qtInformation, qaOK, HELP_MASTER_PASSWORD); +} +//--------------------------------------------------------------------------- +void __fastcall TPreferencesDialog::ChangeMasterPassword(UnicodeString Message) +{ + UnicodeString NewPassword; + if (DoChangeMasterPasswordDialog(NewPassword)) + { + std::auto_ptr RecryptPasswordErrors(new TStringList()); + WinConfiguration->ChangeMasterPassword(NewPassword, RecryptPasswordErrors.get()); + MasterPasswordChanged(Message, RecryptPasswordErrors.get()); + } +} +//--------------------------------------------------------------------------- void __fastcall TPreferencesDialog::UseMasterPasswordCheckClick( TObject * /*Sender*/) { @@ -1866,19 +1928,20 @@ void __fastcall TPreferencesDialog::UseMasterPasswordCheckClick( { try { - if (UseMasterPasswordCheck->Checked) + if (CanSetMasterPassword()) { - if (DoChangeMasterPasswordDialog()) + if (UseMasterPasswordCheck->Checked) { - MessageDialog(LoadStr(MASTER_PASSWORD_SET), qtInformation, qaOK, HELP_MASTER_PASSWORD); + ChangeMasterPassword(LoadStr(MASTER_PASSWORD_SET)); } - } - else - { - if (DoMasterPasswordDialog()) + else { - WinConfiguration->ClearMasterPassword(); - MessageDialog(LoadStr(MASTER_PASSWORD_CLEARED), qtInformation, qaOK, HELP_MASTER_PASSWORD); + if (DoMasterPasswordDialog()) + { + std::auto_ptr RecryptPasswordErrors(new TStringList()); + WinConfiguration->ClearMasterPassword(RecryptPasswordErrors.get()); + MasterPasswordChanged(LoadStr(MASTER_PASSWORD_CLEARED), RecryptPasswordErrors.get()); + } } } } @@ -1893,9 +1956,9 @@ void __fastcall TPreferencesDialog::UseMasterPasswordCheckClick( void __fastcall TPreferencesDialog::SetMasterPasswordButtonClick( TObject * /*Sender*/) { - if (DoChangeMasterPasswordDialog()) + if (CanSetMasterPassword()) { - MessageDialog(LoadStr(MASTER_PASSWORD_CHANGED), qtInformation, qaOK, HELP_MASTER_PASSWORD); + ChangeMasterPassword(LoadStr(MASTER_PASSWORD_CHANGED)); } } //--------------------------------------------------------------------------- diff --git a/source/forms/Preferences.dfm b/source/forms/Preferences.dfm index cc8731d7..5c9bf2eb 100644 --- a/source/forms/Preferences.dfm +++ b/source/forms/Preferences.dfm @@ -1387,14 +1387,14 @@ object PreferencesDialog: TPreferencesDialog TabOrder = 5 OnClick = AddSearchPathButtonClick end - object ShellIconsText: TStaticText + object ShellIconsText2: TStaticText Left = 11 Top = 116 Width = 330 Height = 17 Hint = - 'To add shortcuts, which directly open site, use button '#39'Shell ic' + - 'on'#39' on '#39'Sites'#39' page of Login dialog.' + 'To add shortcuts, which directly open site, use icon commands in' + + ' '#39'Manage'#39' menu on Login dialog.' Alignment = taRightJustify Anchors = [akTop, akRight] AutoSize = False diff --git a/source/forms/Preferences.h b/source/forms/Preferences.h index 4587d23a..22673c76 100644 --- a/source/forms/Preferences.h +++ b/source/forms/Preferences.h @@ -171,7 +171,7 @@ class TPreferencesDialog : public TForm TComboBox *DoubleClickActionCombo; TLabel *Label8; TComboBox *NortonLikeModeCombo; - TStaticText *ShellIconsText; + TStaticText *ShellIconsText2; TCheckBox *FullRowSelectCheck; TGroupBox *SessionReopenGroup; TLabel *SessionReopenAutoLabel; @@ -405,6 +405,10 @@ class TPreferencesDialog : public TForm TListViewScrollOnDragOver * __fastcall ScrollOnDragOver(TObject * ListView); void __fastcall LoadLanguages(); TTabSheet * __fastcall FindPageForTreeNode(TTreeNode * Node); + bool __fastcall CanSetMasterPassword(); + void __fastcall ChangeMasterPassword(UnicodeString Message); + void __fastcall MasterPasswordChanged( + UnicodeString Message, TStrings * RecryptPasswordErrors); }; //---------------------------------------------------------------------------- #endif diff --git a/source/forms/SiteAdvanced.cpp b/source/forms/SiteAdvanced.cpp index 72565afc..a393004d 100644 --- a/source/forms/SiteAdvanced.cpp +++ b/source/forms/SiteAdvanced.cpp @@ -54,6 +54,7 @@ __fastcall TSiteAdvancedDialog::TSiteAdvancedDialog( // (so that CM_SHOWINGCHANGED handling is applied) UseSystemSettings(this); InitControls(); + PageControl->ActivePage = EnvironmentSheet; } //--------------------------------------------------------------------- void __fastcall TSiteAdvancedDialog::InitControls() @@ -100,7 +101,7 @@ void __fastcall TSiteAdvancedDialog::InitControls() UpdateNavigationTree(); - if (FLAGSET(FOptions, loLocalDirectory)) + if (FLAGCLEAR(FOptions, loLocalDirectory)) { LocalDirectoryLabel->Visible = false; LocalDirectoryEdit->Visible = false; @@ -385,6 +386,10 @@ void __fastcall TSiteAdvancedDialog::LoadSession() // hide selection, which is wrongly shown initially even when the box has not focus TunnelLocalPortNumberEdit->SelLength = 0; + // connection/tls/ssl page + MinTlsVersionCombo->ItemIndex = TlsVersionToIndex(FSessionData->MinTlsVersion); + MaxTlsVersionCombo->ItemIndex = TlsVersionToIndex(FSessionData->MaxTlsVersion); + // color SetSessionColor((TColor)FSessionData->Color); } @@ -613,6 +618,10 @@ void __fastcall TSiteAdvancedDialog::SaveSession() FSessionData->TunnelLocalPortNumber = StrToIntDef(TunnelLocalPortNumberEdit->Text, 0); } + // connection/tls/ssl page + FSessionData->MinTlsVersion = IndexToTlsVersion(MinTlsVersionCombo->ItemIndex); + FSessionData->MaxTlsVersion = IndexToTlsVersion(MaxTlsVersionCombo->ItemIndex); + // color FSessionData->Color = FColor; } @@ -733,6 +742,7 @@ void __fastcall TSiteAdvancedDialog::UpdateControls() bool ScpProtocol = (FSessionData->FSProtocol == fsSCPonly); bool FtpProtocol = (FSessionData->FSProtocol == fsFTP); bool WebDavProtocol = (FSessionData->FSProtocol == fsWebDAV); + bool Ssl = (FtpProtocol || WebDavProtocol) && (FSessionData->Ftps != ftpsNone); // connection sheet EnableControl(FtpPasvModeCheck, FtpProtocol); @@ -947,6 +957,9 @@ void __fastcall TSiteAdvancedDialog::UpdateControls() EnableControl(TunnelOptionsGroup, TunnelSessionGroup->Enabled); EnableControl(TunnelAuthenticationParamsGroup, TunnelSessionGroup->Enabled); + // connection/ssl/tls + SslSheet->Enabled = Ssl; + UpdateNavigationTree(); // color @@ -1375,3 +1388,61 @@ void __fastcall TSiteAdvancedDialog::SetSessionColor(TColor Color) } } //--------------------------------------------------------------------------- +TTlsVersion __fastcall TSiteAdvancedDialog::IndexToTlsVersion(int Index) +{ + switch (Index) + { + default: + FAIL; + case 0: + return ssl2; + case 1: + return ssl3; + case 2: + return tls10; + case 3: + return tls11; + case 4: + return tls12; + } +} +//--------------------------------------------------------------------------- +int __fastcall TSiteAdvancedDialog::TlsVersionToIndex(TTlsVersion TlsVersion) +{ + switch (TlsVersion) + { + default: + FAIL; + case ssl2: + return 0; + case ssl3: + return 1; + case tls10: + return 2; + case tls11: + return 3; + case tls12: + return 4; + } +} +//--------------------------------------------------------------------------- +void __fastcall TSiteAdvancedDialog::MinTlsVersionComboChange(TObject */*Sender*/) +{ + TTlsVersion MinTlsVersion = IndexToTlsVersion(MinTlsVersionCombo->ItemIndex); + TTlsVersion MaxTlsVersion = IndexToTlsVersion(MaxTlsVersionCombo->ItemIndex); + if (MaxTlsVersion < MinTlsVersion) + { + MaxTlsVersionCombo->ItemIndex = MinTlsVersionCombo->ItemIndex; + } +} +//--------------------------------------------------------------------------- +void __fastcall TSiteAdvancedDialog::MaxTlsVersionComboChange(TObject * /*Sender*/) +{ + TTlsVersion MinTlsVersion = IndexToTlsVersion(MinTlsVersionCombo->ItemIndex); + TTlsVersion MaxTlsVersion = IndexToTlsVersion(MaxTlsVersionCombo->ItemIndex); + if (MinTlsVersion > MaxTlsVersion) + { + MinTlsVersionCombo->ItemIndex = MaxTlsVersionCombo->ItemIndex; + } +} +//--------------------------------------------------------------------------- diff --git a/source/forms/SiteAdvanced.dfm b/source/forms/SiteAdvanced.dfm index d241d7bb..3971a58a 100644 --- a/source/forms/SiteAdvanced.dfm +++ b/source/forms/SiteAdvanced.dfm @@ -1503,6 +1503,77 @@ object SiteAdvancedDialog: TSiteAdvancedDialog end end end + object SslSheet: TTabSheet + Tag = 2 + HelpType = htKeyword + HelpKeyword = 'ui_login_tls' + Caption = 'TLS/SSL' + ImageIndex = 13 + TabVisible = False + DesignSize = ( + 353 + 382) + object SslGroup: TGroupBox + Left = 0 + Top = 6 + Width = 345 + Height = 71 + Anchors = [akLeft, akTop, akRight] + Caption = 'TLS/SSL options' + TabOrder = 0 + DesignSize = ( + 345 + 71) + object Label1: TLabel + Left = 12 + Top = 20 + Width = 123 + Height = 13 + Caption = 'Mi&nimum TLS/SSL version:' + FocusControl = MinTlsVersionCombo + end + object Label2: TLabel + Left = 12 + Top = 44 + Width = 127 + Height = 13 + Caption = 'Ma&ximum TLS/SSL version:' + FocusControl = MaxTlsVersionCombo + end + object MinTlsVersionCombo: TComboBox + Left = 256 + Top = 15 + Width = 77 + Height = 21 + Style = csDropDownList + Anchors = [akTop, akRight] + TabOrder = 0 + OnChange = MinTlsVersionComboChange + Items.Strings = ( + 'SSL 2.0' + 'SSL 3.0' + 'TLS 1.0' + 'TLS 1.1' + 'TLS 1.2') + end + object MaxTlsVersionCombo: TComboBox + Left = 256 + Top = 39 + Width = 77 + Height = 21 + Style = csDropDownList + Anchors = [akTop, akRight] + TabOrder = 1 + OnChange = MaxTlsVersionComboChange + Items.Strings = ( + 'SSL 2.0' + 'SSL 3.0' + 'TLS 1.0' + 'TLS 1.1' + 'TLS 1.2') + end + end + end object AdvancedSheet: TTabSheet Tag = 1 HelpType = htKeyword diff --git a/source/forms/SiteAdvanced.h b/source/forms/SiteAdvanced.h index cd9993a8..da162701 100644 --- a/source/forms/SiteAdvanced.h +++ b/source/forms/SiteAdvanced.h @@ -239,6 +239,12 @@ class TSiteAdvancedDialog : public TForm TMenuItem *PickColorItem; TImageList *ColorImageList; TButton *ColorButton; + TTabSheet *SslSheet; + TGroupBox *SslGroup; + TLabel *Label1; + TComboBox *MinTlsVersionCombo; + TLabel *Label2; + TComboBox *MaxTlsVersionCombo; void __fastcall DataChange(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall PageControlChange(TObject *Sender); @@ -265,6 +271,8 @@ class TSiteAdvancedDialog : public TForm void __fastcall ColorButtonClick(TObject *Sender); void __fastcall ColorDefaultItemClick(TObject *Sender); void __fastcall PickColorItemClick(TObject *Sender); + void __fastcall MinTlsVersionComboChange(TObject *Sender); + void __fastcall MaxTlsVersionComboChange(TObject *Sender); public: virtual __fastcall TSiteAdvancedDialog(TComponent * AOwner, int Options); @@ -301,6 +309,8 @@ class TSiteAdvancedDialog : public TForm void __fastcall UpdateNavigationTree(); TSshProt __fastcall GetSshProt(); void __fastcall SetSessionColor(TColor Color); + TTlsVersion __fastcall IndexToTlsVersion(int Index); + int __fastcall TlsVersionToIndex(TTlsVersion TlsVersion); }; //---------------------------------------------------------------------------- #endif diff --git a/source/forms/SynchronizeChecklist.dfm b/source/forms/SynchronizeChecklist.dfm index a5d03a23..2ecd8599 100644 --- a/source/forms/SynchronizeChecklist.dfm +++ b/source/forms/SynchronizeChecklist.dfm @@ -1002,7 +1002,7 @@ object SynchronizeChecklistDialog: TSynchronizeChecklistDialog Left = 648 Top = 360 Bitmap = { - 494C010102000400100010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C0101020004000C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000001000000001002000000000000010 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/source/packages/dragndrop/DragDropFilesEx.pas b/source/packages/dragndrop/DragDropFilesEx.pas index cf8ec606..cd65c30f 100644 --- a/source/packages/dragndrop/DragDropFilesEx.pas +++ b/source/packages/dragndrop/DragDropFilesEx.pas @@ -549,30 +549,15 @@ constructor TDataObjectFilesEx.Create(AFileList: TFileList; RenderPIDL, RenderFi end; if FilenamesAreMapped then begin - if Win32Platform=VER_PLATFORM_WIN32_WINDOWS then - begin - with FE do - begin - cfFormat:=CF_FILENAMEMAP; - ptd:=nil; - dwAspect:=DVASPECT_CONTENT; - lindex:=-1; - tymed:=TYMED_HGLOBAL; - end; - SetData(FE,SM,false); - end - else - begin - with FE do - begin - cfFormat:=CF_FILENAMEMAPW; - ptd:=nil; - dwAspect:=DVASPECT_CONTENT; - lindex:=-1; - tymed:=TYMED_HGLOBAL; - end; - SetData(FE,SM,false); - end; + with FE do + begin + cfFormat:=CF_FILENAMEMAPW; + ptd:=nil; + dwAspect:=DVASPECT_CONTENT; + lindex:=-1; + tymed:=TYMED_HGLOBAL; + end; + SetData(FE,SM,false); end; end; end; diff --git a/source/packages/filemng/CustomDirView.pas b/source/packages/filemng/CustomDirView.pas index 2265af66..dd9f414f 100644 --- a/source/packages/filemng/CustomDirView.pas +++ b/source/packages/filemng/CustomDirView.pas @@ -137,7 +137,6 @@ TCustomDirView = class(TCustomIEListView) FFormatSizeBytes: Boolean; FSortByExtension: Boolean; FWantUseDragImages: Boolean; - FCanUseDragImages: Boolean; FDragDropFilesEx: TCustomizableDragDropFilesEx; FSingleClickToExec: Boolean; FUseSystemContextMenu: Boolean; @@ -874,7 +873,6 @@ constructor TCustomDirView.Create(AOwner: TComponent); FShowSubDirSize := False; FFormatSizeBytes := False; FWantUseDragImages := True; - FCanUseDragImages := (Win32PlatForm = VER_PLATFORM_WIN32_NT) or (WinVer.dwMinorVersion > 0); FAddParentDir := False; FullDrag := True; FSingleClickToExec := False; @@ -1203,7 +1201,7 @@ function TCustomDirView.GetDragSourceEffects: TDropEffectSet; function TCustomDirView.GetUseDragImages: Boolean; begin - Result := FWantUseDragImages and FCanUseDragImages; + Result := FWantUseDragImages; end; procedure TCustomDirView.SetTargetPopupMenu(Value: Boolean); diff --git a/source/packages/filemng/CustomDriveView.pas b/source/packages/filemng/CustomDriveView.pas index 84d59474..e12ccead 100644 --- a/source/packages/filemng/CustomDriveView.pas +++ b/source/packages/filemng/CustomDriveView.pas @@ -26,7 +26,6 @@ TCustomDriveView = class(TCustomTreeView) protected FParentForm: TCustomForm; FDragFileList: TStringList; - FUseDragImages: Boolean; FDragDropFilesEx: TCustomizableDragDropFilesEx; FDragImageList: TDragImageList; FDragDrive: TDrive; @@ -204,9 +203,6 @@ TCustomDriveView = class(TCustomTreeView) read FOnDDCreateDataObject write FOnDDCreateDataObject; property OnDDMenuPopup: TOnMenuPopup read FOnDDMenuPopup write FOnDDMenuPopup; - { Show drag images during a drag&drop operation } - property UseDragImages: Boolean read FUseDragImages write FUseDragImages default True; - { Show popupmenu when dropping a file with the right mouse button } property TargetPopUpMenu: Boolean read GetTargetPopUpMenu write SetTargetPopUpMenu default True; @@ -238,7 +234,6 @@ constructor TCustomDriveView.Create(AOwner: TComponent); DragMode := dmAutomatic; FDragFileList := TStringList.Create; - FUseDragImages := (Win32PlatForm = VER_PLATFORM_WIN32_NT) or (WinVer.dwMinorVersion > 0); FDragDrive := #0; FExeDrag := False; FDDLinkOnExeDrag := True; @@ -700,7 +695,7 @@ procedure TCustomDriveView.DDDragDetect(KeyState: Longint; DetectStart, Point: T try {Create the dragimage:} GlobalDragImageList := FDragImageList; - if UseDragImages and (not AvoidDragImage) then + if not AvoidDragImage then begin {Hide the selection mark to get a proper dragimage:} if Selected = FDragNode then diff --git a/source/packages/filemng/DirView.pas b/source/packages/filemng/DirView.pas index 88d95866..32eb2093 100644 --- a/source/packages/filemng/DirView.pas +++ b/source/packages/filemng/DirView.pas @@ -2123,8 +2123,6 @@ function TDirView.GetAttrString(Attr: Integer): string; if Attr <> 0 then begin LowBound := Low(Attrs); - if Win32PlatForm <> VER_PLATFORM_WIN32_NT then - Inc(LowBound); for Index := LowBound to High(Attrs) do if (Attr and Attrs[Index] <> 0) then @@ -3148,7 +3146,7 @@ procedure TDirView.DisplayContextMenu(Where: TPoint); end; end; - if Win32PlatForm = VER_PLATFORM_WIN32_NT then Sleep(250); + Sleep(250); ValidateSelectedFiles; finally @@ -3168,11 +3166,11 @@ procedure TDirView.GetDisplayInfo(ListItem: TListItem; if Empty then GetDisplayData(ListItem, IconEmpty and (not FUseIconUpdateThread or - ((ViewStyle <> vsReport) and (Win32PlatForm = VER_PLATFORM_WIN32_NT)))); + (ViewStyle <> vsReport))); if IconEmpty and (not FUseIconUpdateThread or - ((ViewStyle <> vsReport) and (Win32PlatForm = VER_PLATFORM_WIN32_NT))) and + (ViewStyle <> vsReport)) and ((DispInfo.Mask and LVIF_IMAGE) <> 0) then GetDisplayData(ListItem, True); @@ -4407,13 +4405,8 @@ procedure TDirView.SetItemImageIndex(Item: TListItem; Index: Integer); {=================================================================} -var - IsWin7: Boolean; initialization LastClipBoardOperation := cboNone; LastIOResult := 0; - IsWin7 := - (Win32MajorVersion > 6) or - ((Win32MajorVersion = 6) and (Win32MinorVersion >= 1)); DaylightHack := (not IsWin7) or IsExactly2008R2; end. diff --git a/source/packages/filemng/DriveView.pas b/source/packages/filemng/DriveView.pas index 3cbada09..b7a70021 100644 --- a/source/packages/filemng/DriveView.pas +++ b/source/packages/filemng/DriveView.pas @@ -397,8 +397,6 @@ TDriveView = class(TCustomDriveView) property DDLinkOnExeDrag; - property UseDragImages; - property TargetPopUpMenu; property OnDDDragEnter; @@ -2124,7 +2122,7 @@ function TDriveView.DeleteDirectory(Node: TTreeNode; AllowUndo: Boolean): Boolea else begin Result := False; - if (Win32PlatForm = VER_PLATFORM_WIN32_NT) and (not AllowUndo) then + if not AllowUndo then begin {WinNT4-Bug: FindFirst still returns the directories search record, even if the directory was deleted:} diff --git a/source/packages/filemng/IEComboBox.pas b/source/packages/filemng/IEComboBox.pas index 0e52477f..8b72fdd7 100644 --- a/source/packages/filemng/IEComboBox.pas +++ b/source/packages/filemng/IEComboBox.pas @@ -428,4 +428,5 @@ procedure TIECustomComboBox.SetUseSystemImageList(Value: Boolean); end; end; +initialization end. diff --git a/source/packages/my/ComboEdit.pas b/source/packages/my/ComboEdit.pas index a7770422..622d5682 100644 --- a/source/packages/my/ComboEdit.pas +++ b/source/packages/my/ComboEdit.pas @@ -1331,4 +1331,5 @@ function TDirectoryEdit.GetShortName: string; end; end; +initialization end. diff --git a/source/packages/my/GrayedCheckBox.pas b/source/packages/my/GrayedCheckBox.pas index 9e82eb31..e758a48b 100644 --- a/source/packages/my/GrayedCheckBox.pas +++ b/source/packages/my/GrayedCheckBox.pas @@ -16,7 +16,7 @@ procedure Register; implementation uses - Classes; + Classes, Windows, SysUtils; procedure Register; begin @@ -35,4 +35,5 @@ procedure TGrayedCheckBox.Toggle; end; end; +initialization end. diff --git a/source/packages/my/HistoryComboBox.pas b/source/packages/my/HistoryComboBox.pas index 186d8273..09eb90c5 100644 --- a/source/packages/my/HistoryComboBox.pas +++ b/source/packages/my/HistoryComboBox.pas @@ -172,4 +172,5 @@ function THistoryComboBox.GetMaxItemWidth: Integer; end; end; +initialization end. diff --git a/source/packages/my/NortonLikeListView.pas b/source/packages/my/NortonLikeListView.pas index 41e5e207..dd368956 100644 --- a/source/packages/my/NortonLikeListView.pas +++ b/source/packages/my/NortonLikeListView.pas @@ -222,9 +222,7 @@ constructor TCustomNortonLikeListView.Create(AOwner: TComponent); // Doing the same on WinXP makes list view down from the item flicker, // so we avoid this there. // Not sure about Vista - FForceUpdateOnItemUnfocus := - (Win32MajorVersion > 6) or - ((Win32MajorVersion = 6) and (Win32MinorVersion >= 1)); + FForceUpdateOnItemUnfocus := IsWin7; FNextCharToIgnore := 0; end; diff --git a/source/packages/my/PasTools.pas b/source/packages/my/PasTools.pas index ccd098f4..b8499569 100644 --- a/source/packages/my/PasTools.pas +++ b/source/packages/my/PasTools.pas @@ -11,6 +11,8 @@ function IsVista: Boolean; function IsExactly2008R2: Boolean; +function IsWin7: Boolean; + function CutToChar(var Str: string; Ch: Char; Trim: Boolean): string; procedure FilterToFileTypes(Filter: string; FileTypes: TFileTypeItems); @@ -139,6 +141,11 @@ function IsExactly2008R2: Boolean; end; end; +function IsWin7: Boolean; +begin + Result := CheckWin32Version(6, 1); +end; + function CutToChar(var Str: string; Ch: Char; Trim: Boolean): string; var P: Integer; diff --git a/source/packages/my/PasswordEdit.pas b/source/packages/my/PasswordEdit.pas index cccd33e3..674603eb 100644 --- a/source/packages/my/PasswordEdit.pas +++ b/source/packages/my/PasswordEdit.pas @@ -79,7 +79,7 @@ procedure Register; implementation -uses Windows; +uses Windows, SysUtils; procedure Register; begin @@ -110,4 +110,5 @@ procedure TPasswordEdit.CreateParams(var Params: TCreateParams); end; end; +initialization end. diff --git a/source/packages/png/PngImageList.pas b/source/packages/png/PngImageList.pas index 73908911..18525dd6 100644 --- a/source/packages/png/PngImageList.pas +++ b/source/packages/png/PngImageList.pas @@ -1281,8 +1281,6 @@ procedure TPngImageCollectionItem.SetPngImage(const Value: TPngImage); end; initialization - finalization MethodPatches.Free; - end. diff --git a/source/packages/tb2k/TB2Common.pas b/source/packages/tb2k/TB2Common.pas index ad7ec281..f5444fd2 100644 --- a/source/packages/tb2k/TB2Common.pas +++ b/source/packages/tb2k/TB2Common.pas @@ -70,7 +70,6 @@ procedure HandleWMPrint(const Wnd: HWND; var Message: TMessage; const NCPaintFunc: THandleWMPrintNCPaintProc; const AppData: Longint); procedure HandleWMPrintClient(const Control: TWinControl; var Message: TMessage); -function IsWindowsXP: Boolean; procedure ListSortEx(const List: TList; const Compare: TListSortExCompare; const ExtraData: Pointer); procedure InitTrackMouseEvent; @@ -510,11 +509,7 @@ function AreFlatMenusEnabled: Boolean; var FlatMenusEnabled: BOOL; begin - { Interestingly, on Windows 2000, SystemParametersInfo(SPI_GETFLATMENU, ...) - succeeds and can return True in pvParam^ if the proper bit is set in - UserPreferencesMask. Since flat menus are not really used on Windows - 2000, call IsWindowsXP first to see if we're running at least XP. } - Result := IsWindowsXP and SystemParametersInfo(SPI_GETFLATMENU, 0, + Result := SystemParametersInfo(SPI_GETFLATMENU, 0, @FlatMenusEnabled, 0) and FlatMenusEnabled; end; @@ -526,7 +521,7 @@ function AreKeyboardCuesEnabled: Boolean; var CuesEnabled: BOOL; begin - Result := (Win32MajorVersion < 5) or + Result := not SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, @CuesEnabled, 0) or CuesEnabled; end; @@ -999,12 +994,6 @@ function NeedToPlaySound(const Alias: String): Boolean; DataSize: DWORD; ErrorCode: Longint; begin - if (Win32MajorVersion < 5) or (Win32Platform <> VER_PLATFORM_WIN32_NT) then begin - { No need to check pre-Windows 2000 versions since their PlaySound - functions don't have the delay; always return True. } - Result := True; - Exit; - end; Result := False; if RegOpenKeyEx(HKEY_CURRENT_USER, PChar('AppEvents\Schemes\Apps\.Default\' + Alias + '\.Current'), @@ -1055,13 +1044,6 @@ function FindAccelChar(const S: String): Char; end; end; -function IsWindowsXP: Boolean; -begin - Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and - ((Win32MajorVersion > 5) or - ((Win32MajorVersion = 5) and (Win32MinorVersion >= 1))); -end; - function GetInputLocaleCodePage: UINT; { Returns the code page identifier of the active input locale, or CP_ACP if for some unknown reason it couldn't be determined. } diff --git a/source/packages/tb2k/TB2Dock.pas b/source/packages/tb2k/TB2Dock.pas index a171f8be..a41a302f 100644 --- a/source/packages/tb2k/TB2Dock.pas +++ b/source/packages/tb2k/TB2Dock.pas @@ -4447,9 +4447,7 @@ procedure TTBCustomDockableWindow.WMNCMouseMove(var Message: TWMNCMouseMove); begin inherited; { Note: TME_NONCLIENT was introduced in Windows 98 and 2000 } - if (Win32MajorVersion >= 5) or - (Win32MajorVersion = 4) and (Win32MinorVersion >= 10) then - CallTrackMouseEvent(Handle, TME_LEAVE or $10 {TME_NONCLIENT}); + CallTrackMouseEvent(Handle, TME_LEAVE or $10 {TME_NONCLIENT}); InArea := Message.HitTest = HT_TB2k_Close; if FCloseButtonHover <> InArea then begin FCloseButtonHover := InArea; diff --git a/source/packages/tb2k/TB2Hook.pas b/source/packages/tb2k/TB2Hook.pas index d4c585d8..b85436e7 100644 --- a/source/packages/tb2k/TB2Hook.pas +++ b/source/packages/tb2k/TB2Hook.pas @@ -179,12 +179,8 @@ procedure InstallHooks(ATypes: THookTypes; var InstalledTypes: THookTypes); This is needed for compatibility with the combination of Tnt Unicode Controls and Keyman. See "Widechar's and tb2k" thread on the newsgroup from 2003-09-23 for more information. } - if Win32Platform = VER_PLATFORM_WIN32_NT then - HookHandles[T] := SetWindowsHookExW(HookIDs[T], HookProcs[T], - 0, GetCurrentThreadId) - else - HookHandles[T] := SetWindowsHookEx(HookIDs[T], HookProcs[T], - 0, GetCurrentThreadId); + HookHandles[T] := SetWindowsHookExW(HookIDs[T], HookProcs[T], + 0, GetCurrentThreadId) end; end; end; diff --git a/source/packages/tb2k/TB2Item.pas b/source/packages/tb2k/TB2Item.pas index 4a2ce12f..722014dc 100644 --- a/source/packages/tb2k/TB2Item.pas +++ b/source/packages/tb2k/TB2Item.pas @@ -6454,9 +6454,7 @@ procedure TTBPopupWindow.CreateParams(var Params: TCreateParams); Style := (Style and not (WS_CHILD or WS_GROUP or WS_TABSTOP)) or WS_POPUP; ExStyle := ExStyle or WS_EX_TOPMOST or WS_EX_TOOLWINDOW; WindowClass.Style := WindowClass.Style or CS_SAVEBITS; - { Enable drop shadow effect on Windows XP and later } - if IsWindowsXP then - WindowClass.Style := WindowClass.Style or CS_DROPSHADOW; + WindowClass.Style := WindowClass.Style or CS_DROPSHADOW; end; end; diff --git a/source/packages/tbx/TBX.pas b/source/packages/tbx/TBX.pas index 69a78c51..b1e42fa8 100644 --- a/source/packages/tbx/TBX.pas +++ b/source/packages/tbx/TBX.pas @@ -2214,7 +2214,7 @@ procedure TTBXPopupWindow.CreateParams(var Params: TCreateParams); with Params do begin WindowClass.Style := WindowClass.Style and not (CS_DROPSHADOW or CS_DBLCLKS); - if GetShowShadow and (CurrentTheme.GetPopupShadowType = PST_WINDOWSXP) and IsWindowsXP then + if GetShowShadow and (CurrentTheme.GetPopupShadowType = PST_WINDOWSXP) then begin WindowClass.Style := WindowClass.Style or CS_DROPSHADOW; StrPCopy(WinClassName, ClassName + 'S'); @@ -2229,9 +2229,6 @@ procedure TTBXPopupWindow.CreateShadow; VT: Integer; ChevronParent: Boolean; begin - if (CurrentTheme.GetPopupShadowType = PST_WINDOWS2K) and not - ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion >= 5)) then Exit; - PR := Rect(0, 0, 0, 0); if CurrentTheme.GetPopupShadowType = PST_OFFICEXP then begin @@ -3153,9 +3150,7 @@ procedure TTBXFloatingWindowParent.WMNCMouseMove(var Message: TWMNCMouseMove); begin inherited; { Note: TME_NONCLIENT was introduced in Windows 98 and 2000 } - if (Win32MajorVersion >= 5) or - (Win32MajorVersion = 4) and (Win32MinorVersion >= 10) then - CallTrackMouseEvent (Handle, TME_LEAVE or $10 {TME_NONCLIENT}); + CallTrackMouseEvent (Handle, TME_LEAVE or $10 {TME_NONCLIENT}); InArea := Message.HitTest = 2001; {HT_TB2k_Close} if FCloseButtonHover <> InArea then begin @@ -3779,16 +3774,8 @@ constructor TTBXMenuAnimation.Create(AAnimationMode: TAnimationMode = amSysDefau end; function TTBXMenuAnimation.GetAvailableModes: TAnimationModes; -var IsWindows2K: Boolean; begin - Result := [amNone]; - IsWindows2K := (Win32Platform = VER_PLATFORM_WIN32_NT) and - TBXCheckWin32Version(5); { MP } - if IsWindows2K or ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and - TBXCheckWin32Version(4, 10){Win98}) { MP } then - Result := Result+ [amSysDefault, amRandom, amUnfold, amSlide]; - if IsWindows2K then - Include(Result, amFade); + Result := [amNone, amSysDefault, amRandom, amUnfold, amSlide, amFade]; end; function TTBXMenuAnimation.GetMenuAnimation: TMenuAnimation; @@ -3854,8 +3841,7 @@ function FixPlaySoundThreadFunc(Param: Pointer): Integer; stdcall; procedure FixPlaySoundDelay; var ThreadId: TThreadID; begin - if (Win32Platform = VER_PLATFORM_WIN32_NT) and CheckWin32Version(5) and - (FixPlaySoundThreadHandle = 0) then + if (FixPlaySoundThreadHandle = 0) then FixPlaySoundThreadHandle := CreateThread(nil, $1000, @FixPlaySoundThreadFunc, nil, 0, ThreadId); end; diff --git a/source/packages/tbx/TBXOfficeXPTheme.pas b/source/packages/tbx/TBXOfficeXPTheme.pas index f09f6bfa..913fb746 100644 --- a/source/packages/tbx/TBXOfficeXPTheme.pas +++ b/source/packages/tbx/TBXOfficeXPTheme.pas @@ -96,7 +96,7 @@ TTBXOfficeXPTheme = class(TTBXTheme) implementation -uses TBXUtils, TB2Common, TB2Item, Classes, Controls, Commctrl, Forms; +uses TBXUtils, TB2Common, TB2Item, Classes, Controls, Commctrl, Forms, SysUtils; var StockImgList: TImageList; diff --git a/source/packages/tbx/TBXStatusBars.pas b/source/packages/tbx/TBXStatusBars.pas index c56b8f8f..b72ccf50 100644 --- a/source/packages/tbx/TBXStatusBars.pas +++ b/source/packages/tbx/TBXStatusBars.pas @@ -1027,4 +1027,5 @@ procedure TTBXCustomStatusBar.WMNCHitTest(var Message: TWMNCHitTest); end; end; +initialization end. diff --git a/source/packages/tbx/TBXThemes.pas b/source/packages/tbx/TBXThemes.pas index e8230b0b..ff13769d 100644 --- a/source/packages/tbx/TBXThemes.pas +++ b/source/packages/tbx/TBXThemes.pas @@ -782,12 +782,7 @@ procedure TTBXThemeManager.UpdateVariables; end; SysFlatMenus := False; - if (Win32Platform = VER_PLATFORM_WIN32_NT) and - ((Win32MajorVersion > 5) or - ((Win32MajorVersion = 5) and (Win32MinorVersion >= 1))) then - begin - SystemParametersInfo(SPI_GETFLATMENU, 0, @SysFlatMenus, 0); - end; + SystemParametersInfo(SPI_GETFLATMENU, 0, @SysFlatMenus, 0); if SysFlatMenus then // System indicates support for flat menus @@ -852,8 +847,7 @@ procedure TTBXThemeManager.VisualStylesClose; procedure TTBXThemeManager.VisualStylesOpen; begin USE_THEMES := False; - if (Win32Platform = VER_PLATFORM_WIN32_NT) and ((Win32MajorVersion > 5) or - ((Win32MajorVersion = 5) and (Win32MinorVersion >= 1))) and EnableVisualStyles then + if EnableVisualStyles then begin InitedThemeLibrary := InitThemeLibrary; USE_THEMES := UseThemes; diff --git a/source/packages/tbx/TBXUtils.pas b/source/packages/tbx/TBXUtils.pas index 6b5f6c53..d707763f 100644 --- a/source/packages/tbx/TBXUtils.pas +++ b/source/packages/tbx/TBXUtils.pas @@ -24,11 +24,6 @@ function StripAccelCharsW(const S: WideString): WideString; function StripTrailingPunctuationW(const S: WideString): WideString; {$ENDIF} -{ MP (the function in VCL is buggy even in C++Builder 6) } -{//$IFNDEF JR_D6} -{ MP } -function TBXCheckWin32Version(AMajor: Integer; AMinor: Integer = 0): Boolean; {vb+} -{//$ENDIF} procedure GetRGB(C: TColor; out R, G, B: Integer); function MixColors(C1, C2: TColor; W1: Integer): TColor; function SameColors(C1, C2: TColor): Boolean; @@ -402,16 +397,6 @@ function StripTrailingPunctuationW(const S: WideString): WideString; {$ENDIF} -{ MP (the function in VCL is buggy even in C++Builder 6) } -{//$IFNDEF JR_D6} -{ MP } -function TBXCheckWin32Version(AMajor: Integer; AMinor: Integer = 0): Boolean; {vb+} -begin - Result := (Win32MajorVersion > AMajor) or - ((Win32MajorVersion = AMajor) and (Win32MinorVersion >= AMinor)); -end; -{//$ENDIF} - type PPoints = ^TPoints; TPoints = array [0..0] of TPoint; diff --git a/source/resource/HelpWin.h b/source/resource/HelpWin.h index 582e931d..c1f9406b 100644 --- a/source/resource/HelpWin.h +++ b/source/resource/HelpWin.h @@ -46,7 +46,7 @@ #define HELP_MASTER_PASSWORD "master_password" #define HELP_MASTER_PASSWORD_SIMPLE HELP_MASTER_PASSWORD #define HELP_USAGE "usagestatistics" -#define HELP_WORKSPACE_SAVE "workspace" +#define HELP_WORKSPACE_SAVE "ui_save_workspace" #define HELP_EDITOR_AUTO_CONFIG "ui_pref_editor#auto" #define HELP_IMPORT_SESSIONS "ui_import" #define HELP_IMPORT_CONFIGURATION "config" diff --git a/source/resource/TextsCore.h b/source/resource/TextsCore.h index af90f63a..b573aecf 100644 --- a/source/resource/TextsCore.h +++ b/source/resource/TextsCore.h @@ -25,7 +25,7 @@ #define SCRIPT_GET_HELP6 21 #define SCRIPT_PUT_HELP6 22 #define SCRIPT_OPTION_HELP6 23 -#define SCRIPT_SYNCHRONIZE_HELP6 24 +#define SCRIPT_SYNCHRONIZE_HELP7 24 #define SCRIPT_KEEPUPTODATE_HELP4 25 #define SCRIPT_CALL_HELP2 26 #define SCRIPT_ECHO_HELP 27 @@ -385,6 +385,13 @@ #define SCRIPT_CMDLINE_SESSION 520 #define ANY_HOSTKEY 521 #define ANY_CERTIFICATE 522 +#define SCRIPT_SYNC_UPLOAD_NEW 523 +#define SCRIPT_SYNC_DOWNLOAD_NEW 524 +#define SCRIPT_SYNC_UPLOAD_UPDATE 525 +#define SCRIPT_SYNC_DOWNLOAD_UPDATE 526 +#define SCRIPT_SYNC_DELETE_REMOTE 527 +#define SCRIPT_SYNC_DELETE_LOCAL 528 +#define SCRIPT_SYNCHRONIZE_CHECKLIST 529 #define CORE_VARIABLE_STRINGS 600 #define PUTTY_BASED_ON 601 diff --git a/source/resource/TextsCore1.rc b/source/resource/TextsCore1.rc index fe2d7978..f4868294 100644 --- a/source/resource/TextsCore1.rc +++ b/source/resource/TextsCore1.rc @@ -338,7 +338,7 @@ BEGIN SCRIPT_SYNCHRONIZE_SYNCHRONIZING, "Synchronizing..." SCRIPT_SYNCHRONIZE_NODIFFERENCE, "Nothing to synchronize." SPEED_UNLIMITED, "Unlimited" - FTPS_IMPLICIT, "SSL/TLS Implicit encryption" + FTPS_IMPLICIT, "TLS/SSL Implicit encryption" FTPS_EXPLICIT_SSL, "SSL Explicit encryption" FTPS_EXPLICIT_TLS, "TLS Explicit encryption" SCRIPT_ECHO_DESC, "Displays its arguments as message" @@ -350,6 +350,13 @@ BEGIN SCRIPT_CMDLINE_SESSION, "Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead." ANY_HOSTKEY, "WARNING! Giving up security and accepting any key as configured!" ANY_CERTIFICATE, "WARNING! Giving up security and accepting any certificate as configured!" + SCRIPT_SYNC_UPLOAD_NEW, "New local file %s" + SCRIPT_SYNC_DOWNLOAD_NEW, "New remote file %s" + SCRIPT_SYNC_UPLOAD_UPDATE, "Local file %s newer than remote file %s" + SCRIPT_SYNC_DOWNLOAD_UPDATE, "Remote file %s newer than local file %s" + SCRIPT_SYNC_DELETE_REMOTE, "Orphan remote file %s" + SCRIPT_SYNC_DELETE_LOCAL, "Orphan local file %s" + SCRIPT_SYNCHRONIZE_CHECKLIST, "Differences found:" CORE_VARIABLE_STRINGS, "CORE_VARIABLE" PUTTY_BASED_ON, "SSH and SCP code based on PuTTY %s" diff --git a/source/resource/TextsCore2.rc b/source/resource/TextsCore2.rc index 2855a52c..004267c0 100644 --- a/source/resource/TextsCore2.rc +++ b/source/resource/TextsCore2.rc @@ -67,11 +67,11 @@ BEGIN " -privatekey= Private key file\n" " -timeout= Server response timeout\n" " -hostkey= Fingerprint of server hostkey (SFTP and SCP only).\n" - " -certificate= Fingerprint of SSL/TLS certificate (FTPS only)\n" + " -certificate= Fingerprint of TLS/SSL certificate (FTPS only)\n" " -passive=on|off Passive mode (FTP protocol only)\n" " -implicit Implicit TLS/SSL (FTPS protocol only)\n" - " -explicitssl Explicit SSL (FTPS protocol only)\n" " -explicittls Explicit TLS (FTPS protocol only)\n" + " -explicitssl Explicit SSL (FTPS protocol only)\n" " -rawsettings setting1=value1 setting2=value2 ...\n" " Configures any session settings using raw format\n" " as in an INI file\n" @@ -278,7 +278,7 @@ BEGIN " option\n" " option batch\n" " option confirm off\n" - SCRIPT_SYNCHRONIZE_HELP6, + SCRIPT_SYNCHRONIZE_HELP7, "synchronize local|remote|both [ [ ] ]\n" " When the first parameter is 'local' synchronises local directory with\n" " remote one. When the first parameter is 'remote' synchronises remote\n" @@ -288,6 +288,7 @@ BEGIN " synchronized.\n" " Note: Overwrite confirmations are always off for the command.\n" "switches:\n" + " -preview Preview changes only, do not synchronize\n" " -delete Delete obsolete files\n" " -mirror Mirror mode (synchronize also older files).\n" " Ignored for 'both'.\n" diff --git a/source/resource/TextsFileZilla.rc b/source/resource/TextsFileZilla.rc index 54c7fdc1..f59899b0 100644 --- a/source/resource/TextsFileZilla.rc +++ b/source/resource/TextsFileZilla.rc @@ -41,16 +41,16 @@ END STRINGTABLE BEGIN IDS_ERRORMSG_CANTCREATEDUETOPORTRANGE, "Could not create socket in the specified port range." - IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, "Can't establish SSL connection" + IDS_ERRORMSG_CANTESTABLISHSSLCONNECTION, "Can't establish TLS connection" IDS_ERRORMSG_CANTGETLIST, "Could not retrieve directory listing" - IDS_ERRORMSG_CANTINITSSL, "Can't initialize SSL library" + IDS_ERRORMSG_CANTINITSSL, "Can't initialize TLS library" END STRINGTABLE BEGIN IDS_STATUSMSG_CONNECTED, "Connected" IDS_STATUSMSG_CONNECTEDWITH, "Connected with %s. Waiting for welcome message..." - IDS_STATUSMSG_CONNECTEDWITHSSL, "Connected with %s, negotiating SSL connection..." + IDS_STATUSMSG_CONNECTEDWITHSSL, "Connected with %s, negotiating TLS connection..." IDS_STATUSMSG_CONNECTING, "Connecting to %s ..." IDS_STATUSMSG_DIRLISTSUCCESSFUL, "Directory listing successful" IDS_STATUSMSG_DISCONNECTED, "Disconnected from server" @@ -62,8 +62,8 @@ END STRINGTABLE BEGIN IDS_STATUSMSG_RETRIEVINGDIRLIST, "Retrieving directory listing..." - IDS_STATUSMSG_SSLESTABLISHED, "SSL connection established. Waiting for welcome message..." - IDS_STATUSMSG_SSLESTABLISHEDTRANSFER, "SSL connection established" + IDS_STATUSMSG_SSLESTABLISHED, "TLS connection established. Waiting for welcome message..." + IDS_STATUSMSG_SSLESTABLISHEDTRANSFER, "TLS connection established" IDS_STATUSMSG_UPLOADSTART, "Starting upload of %s" IDS_STATUSMSG_UPLOADSUCCESSFUL, "Upload successful" END @@ -78,6 +78,6 @@ END STRINGTABLE BEGIN IDS_ERRORMSG_SETFILEPOINTER, "Could not set file pointer" - IDS_ERRORMSG_UNKNOWNSSLERROR, "Unknown error in SSL layer" - IDS_ERRORMSG_SSLCERTIFICATEERROR, "Could not verify SSL certificate" + IDS_ERRORMSG_UNKNOWNSSLERROR, "Unknown error in TLS layer" + IDS_ERRORMSG_SSLCERTIFICATEERROR, "Could not verify TLS certificate" END diff --git a/source/resource/TextsWin.h b/source/resource/TextsWin.h index 30d84b85..e55a3909 100644 --- a/source/resource/TextsWin.h +++ b/source/resource/TextsWin.h @@ -64,6 +64,7 @@ #define WORKSPACE_NOT_FOLDER 1173 #define FOLDER_NOT_WORKSPACE 1174 #define SHELL_PATTERN_ERROR 1175 +#define PATH_ENV_TOO_LONG 1176 #define WIN_CONFIRMATION_STRINGS 1300 #define CONFIRM_OVERWRITE_SESSION 1301 @@ -122,6 +123,7 @@ #define ALL_BUTTON 1359 #define YES_TO_ALL_BUTTON 1360 #define REPORT_BUTTON 1361 +#define MASTER_PASSWORD_OTHER_INSTANCE 1362 #define WIN_INFORMATION_STRINGS 1400 #define APP_CAPTION 1401 @@ -210,6 +212,7 @@ #define DD_TRANSFER_CONFIRM_OFF 1531 #define COPY_PARAM_PRESET_HEADER 1532 #define QUEUE_DONE 1533 +#define MASTER_PASSWORD_RECRYPT_ERRORS 1534 #define WIN_FORMS_STRINGS 1600 #define LOG_NOLOG 1601 @@ -356,7 +359,7 @@ #define STATUS_SECURE 1784 #define FSINFO_PROTOCOL_ANY_COMMAND 1785 #define FSINFO_REMOTE_SYSTEM 1786 -#define FSINFO_SESSION_PROTOCOL 1787 +#define FSINFO_CRYPTOGRAPHIC_PROTOCOL 1787 #define SPECIAL_FOLDER_MY_DOCUMENTS 1790 #define SPECIAL_FOLDER_DESKTOP 1791 #define COMMAND_LINE_LABEL 1792 diff --git a/source/resource/TextsWin1.rc b/source/resource/TextsWin1.rc index c57e91a5..554b51aa 100644 --- a/source/resource/TextsWin1.rc +++ b/source/resource/TextsWin1.rc @@ -69,6 +69,7 @@ BEGIN WORKSPACE_NOT_FOLDER, "'%s' is workspace, not site folder." FOLDER_NOT_WORKSPACE, "'%s' is site folder, not workspace." SHELL_PATTERN_ERROR, "Error executing command \"%s\" (%s)." + PATH_ENV_TOO_LONG, "Cannot add new path to %PATH%, %PATH% is already too long." WIN_CONFIRMATION_STRINGS, "WIN_CONFIRMATION" CONFIRM_OVERWRITE_SESSION, "Site with name '%s' already exists. Overwrite?" @@ -123,6 +124,7 @@ BEGIN ALL_BUTTON, "A&ll" YES_TO_ALL_BUTTON, "Yes to A&ll" REPORT_BUTTON, "Re&port" + MASTER_PASSWORD_OTHER_INSTANCE, "There is other instance of WinSCP running.\n\nSetting or clearing master password, while another instance of WinSCP is running, can cause loss of your stored passwords.\n\nPlease quit other instances of WinSCP before continuing." WIN_INFORMATION_STRINGS, "WIN_INFORMATION" APP_CAPTION, "%s - %s" @@ -212,6 +214,7 @@ BEGIN COPY_PARAM_PRESET_HEADER, "Presets" QUEUE_DONE, "Completed" EDITOR_AUTO_CONFIG, "Custom text editor '%s' was detected.\n\nDo you want to use '%s' instead of default internal editor?" + MASTER_PASSWORD_RECRYPT_ERRORS, "%s\n\nThere were some errors when encrypting passwords using new master password or decrypting passwords." WIN_FORMS_STRINGS, "WIN_FORMS_STRINGS" LOG_NOLOG, "No session log." @@ -359,7 +362,7 @@ BEGIN STATUS_SECURE, "Secure connection (%s)" FSINFO_PROTOCOL_ANY_COMMAND, "Protocol commands only" FSINFO_REMOTE_SYSTEM, "Remote system" - FSINFO_SESSION_PROTOCOL, "Session protocol" + FSINFO_CRYPTOGRAPHIC_PROTOCOL, "Cryptographic protocol" SPECIAL_FOLDER_MY_DOCUMENTS, "My documents" SPECIAL_FOLDER_DESKTOP, "Desktop" COMMAND_LINE_LABEL, "Command" diff --git a/source/resource/TextsWin2.rc b/source/resource/TextsWin2.rc index 13bc54a1..425f3930 100644 --- a/source/resource/TextsWin2.rc +++ b/source/resource/TextsWin2.rc @@ -23,7 +23,7 @@ BEGIN "G:%APP% [session] /synchronize [local_dir] [remote_dir] [/defaults]\n" "G:%APP% [session] /keepuptodate [local_dir] [remote_dir] [/defaults]\n" "G:%APP% [session] /privatekey= /hostkey=\n" -"G:%APP% [session] /certificate= /implicit|explicitssl|explicittls\n" +"G:%APP% [session] /certificate= /implicit|explicittls|explicitssl\n" "G:%APP% [session] /passive=on|off /timeout=\n" "G:%APP% [session] /rawsettings setting1=value1 settings2=value2 ...\n" "G:%APP% [/console] [/script=file] [/command command1...] [/parameter param1...]\n" @@ -51,10 +51,10 @@ BEGIN "G: /passive= Passive mode (FTP protocol only).\n" "G: /rawsettings= Configures any session settings using raw format\n" "G: as in an INI file.\n" -"G: /certificate= Fingerprint of SSL/TLS certificate.\n" +"G: /certificate= Fingerprint of TLS/SSL certificate.\n" "G: /implicit Implicit TLS/SSL (FTPS protocol only).\n" -"G: /explicitssl Explicit SSL (FTPS protocol only).\n" "G: /explicittls Explicit TLS (FTPS protocol only).\n" +"G: /explicitssl Explicit SSL (FTPS protocol only).\n" "G: /update Queries application homepage for updates.\n" "B: /help Prints this usage.\n" END diff --git a/source/windows/ConsoleRunner.cpp b/source/windows/ConsoleRunner.cpp index e7e598e3..707a0aef 100644 --- a/source/windows/ConsoleRunner.cpp +++ b/source/windows/ConsoleRunner.cpp @@ -1,4 +1,4 @@ -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- #include #pragma hdrstop @@ -1753,9 +1753,23 @@ bool __fastcall TConsoleRunner::DoInput(UnicodeString & Str, bool Echo, //--------------------------------------------------------------------------- void __fastcall TConsoleRunner::MasterPasswordPrompt() { - UnicodeString Password; - Input(LoadStr(CONSOLE_MASTER_PASSWORD_PROMPT), Password, false, true); - WinConfiguration->SetMasterPassword(Password); + bool Retry; + do + { + UnicodeString Password; + Input(LoadStr(CONSOLE_MASTER_PASSWORD_PROMPT), Password, false, true); + Retry = !WinConfiguration->ValidateMasterPassword(Password); + if (Retry) + { + PrintLine(LoadStr(MASTER_PASSWORD_INCORRECT)); + } + else + { + WinConfiguration->SetMasterPassword(Password); + } + } + while (Retry); + } //--------------------------------------------------------------------------- UnicodeString TConsoleRunner::ExpandCommand(UnicodeString Command, TStrings * ScriptParameters) @@ -1917,10 +1931,10 @@ void __fastcall LoadScriptFromFile(UnicodeString FileName, TStrings * Lines) void __fastcall Usage(TConsole * Console) { UnicodeString Usage = LoadStr(USAGE8, 10240); - UnicodeString ExeBaseName = ChangeFileExt(ExtractFileName(Application->ExeName), L""); + UnicodeString ExeBaseName = ExtractFileBaseName(Application->ExeName); Usage = ReplaceText(Usage, L"%APP%", ExeBaseName); UnicodeString Copyright = - ReplaceText(LoadStr(WINSCP_COPYRIGHT), "©", "(c)"); + ReplaceText(LoadStr(WINSCP_COPYRIGHT), L"©", L"(c)"); Usage = FORMAT(Usage, (Configuration->VersionStr, Copyright)); TStrings * Lines = new TStringList(); try diff --git a/source/windows/CustomWinConfiguration.cpp b/source/windows/CustomWinConfiguration.cpp index 601612fc..49251b4b 100644 --- a/source/windows/CustomWinConfiguration.cpp +++ b/source/windows/CustomWinConfiguration.cpp @@ -8,6 +8,7 @@ #include #include #include "CustomWinConfiguration.h" +#include //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- @@ -330,15 +331,29 @@ void __fastcall TCustomWinConfiguration::LoadAdmin(THierarchicalStorage * Storag FDefaultInterface = TInterface(Storage->ReadInteger(L"DefaultInterfaceInterface", FDefaultInterface)); } //--------------------------------------------------------------------------- -void __fastcall TCustomWinConfiguration::RecryptPasswords() +void __fastcall TCustomWinConfiguration::RecryptPasswords(TStrings * RecryptPasswordErrors) { Busy(true); try { - StoredSessions->RecryptPasswords(); + StoredSessions->RecryptPasswords(RecryptPasswordErrors); + if (OnMasterPasswordRecrypt != NULL) { - OnMasterPasswordRecrypt(NULL); + try + { + OnMasterPasswordRecrypt(NULL); + } + catch (Exception & E) + { + UnicodeString Message; + if (ExceptionMessage(&E, Message)) + { + // we do not expect this really to happen, + // so we do not bother providing context + RecryptPasswordErrors->Add(Message); + } + } } } __finally @@ -347,6 +362,17 @@ void __fastcall TCustomWinConfiguration::RecryptPasswords() } } //--------------------------------------------------------------------- +void __fastcall TCustomWinConfiguration::AskForMasterPasswordIfNotSetAndNeededToPersistSessionData( + TSessionData * SessionData) +{ + if (!DisablePasswordStoring && + SessionData->HasAnyPassword() && + UseMasterPassword) + { + AskForMasterPasswordIfNotSet(); + } +} +//--------------------------------------------------------------------- void __fastcall TCustomWinConfiguration::SetLogView(TLogView value) { SET_CONFIG_PROPERTY(LogView); diff --git a/source/windows/CustomWinConfiguration.h b/source/windows/CustomWinConfiguration.h index efa8d2e8..5b78c0e4 100644 --- a/source/windows/CustomWinConfiguration.h +++ b/source/windows/CustomWinConfiguration.h @@ -65,7 +65,7 @@ static const int MaxHistoryCount = 50; virtual void __fastcall Saved(); void __fastcall ClearHistory(); virtual void __fastcall DefaultHistory(); - void __fastcall RecryptPasswords(); + void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors); virtual bool __fastcall GetUseMasterPassword() = 0; public: @@ -73,6 +73,7 @@ static const int MaxHistoryCount = 50; virtual __fastcall ~TCustomWinConfiguration(); virtual void __fastcall Default(); virtual void __fastcall AskForMasterPasswordIfNotSet() = 0; + void __fastcall AskForMasterPasswordIfNotSetAndNeededToPersistSessionData(TSessionData * SessionData); __property TLogView LogView = { read = FLogView, write = SetLogView }; __property TInterface Interface = { read = FInterface, write = SetInterface }; diff --git a/source/windows/Setup.cpp b/source/windows/Setup.cpp index be15b029..1dceb5ec 100644 --- a/source/windows/Setup.cpp +++ b/source/windows/Setup.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -22,28 +23,15 @@ #include "Setup.h" #include //--------------------------------------------------------------------------- -/* Using quotes or not should make no difference but some programs (for - instance cygwin and msys) don't like them. */ -/* #define USE_QUOTES */ -//--------------------------------------------------------------------------- -#define APP_NAME "WinSCP" #define KEY _T("SYSTEM\\CurrentControlSet\\Control\\") \ _T("Session Manager\\Environment") -#define AUTOEXEC_PATH _T("c:\\autoexec.bat") -#define AUTOEXEC_INTRO _T("rem ***** The following line was added by " \ - APP_NAME " *****") -#ifdef USE_QUOTES -# define AUTOEXEC_CMD _T("set PATH=%%PATH%%;\"%s\"") -#else -# define AUTOEXEC_CMD _T("set PATH=%%PATH%%;%s") -#endif +// when the PATH registry key is over aprox 2048 characters, +// PATH as well as WINDIR variables are actually not set, breaking the system +#define MAX_PATH_LEN 2000 /* Command line options. */ UnicodeString LastPathError; //--------------------------------------------------------------------------- -#define verb_out(msg) ((void)0) -#define verb_out_param(msg, param) ((void)0) -//--------------------------------------------------------------------------- // Display the error "err_msg". void err_out(LPCTSTR err_msg) { @@ -169,27 +157,28 @@ BOOL add_path_reg(LPCTSTR path){ else{ if (!find_reg_str(reg_str, path, NULL)){ _tcscat(reg_str, _T(";")); -#ifdef USE_QUOTES - _tcscat(reg_str, _T(";\"")); -#endif _tcscat(reg_str, path); -#ifdef USE_QUOTES - _tcscat(reg_str, _T("\"")); -#endif - ret = RegSetValueEx(key, _T("PATH"), 0, REG_EXPAND_SZ, - (LPBYTE)reg_str, - (_tcslen(reg_str) + 1) * sizeof(TCHAR)); - if (ret != ERROR_SUCCESS){ - err_out_sys(_T("Cannot write \"PATH\" key."), ret); - func_ret = FALSE; + size_t len = _tcslen(reg_str); + if (len >= MAX_PATH_LEN) + { + err_out(LoadStr(PATH_ENV_TOO_LONG).c_str()); + func_ret = FALSE; + } + else + { + ret = RegSetValueEx(key, _T("PATH"), 0, REG_EXPAND_SZ, + (LPBYTE)reg_str, + (_tcslen(reg_str) + 1) * sizeof(TCHAR)); + if (ret != ERROR_SUCCESS){ + err_out_sys(_T("Cannot write \"PATH\" key."), ret); + func_ret = FALSE; + } + /* Is this needed to make the new key avaible? */ + RegFlushKey(key); + SetLastError(0); + path_reg_propagate(); } - /* Is this needed to make the new key avaible? */ - RegFlushKey(key); - SetLastError(0); - path_reg_propagate(); } - else - verb_out(_T("Value already exists in the registry.")); } RegCloseKey(key); @@ -248,8 +237,6 @@ BOOL remove_path_reg(LPCTSTR path){ SetLastError(0); path_reg_propagate(); } - else - verb_out(_T("Value does not exist in the registry.")); } RegCloseKey(key); @@ -257,163 +244,10 @@ BOOL remove_path_reg(LPCTSTR path){ return func_ret; } //--------------------------------------------------------------------------- -/* Can this program run under Win9x if compiled with unicode support? */ -//--------------------------------------------------------------------------- -// Add "path" to "autoexec.bat". Return "TRUE" if the path has been added or -// was already in the file, "FALSE" otherwise. -BOOL add_path_autoexec(LPCTSTR long_path){ - FILE * file; - LPTSTR path; - size_t path_size; - LPTSTR line; - LPTSTR out_line; - size_t line_size; - size_t sz1, sz2; - LPTSTR autoexec_intro; - BOOL found; - BOOL func_ret = TRUE; - - file = _wfopen(AUTOEXEC_PATH, _T("r+")); - if (!file){ - err_out(_T("Cannot open \"autoexec.bat\".")); - return FALSE; - } - - path_size = _tcslen(long_path) + 1; - path = (LPTSTR)malloc(path_size * sizeof(TCHAR)); - if (!GetShortPathName(long_path, path, path_size)) - _tcsncpy(path, long_path, path_size); - sz1 = _tcslen(path) + _tcslen(AUTOEXEC_CMD); - sz2 = _tcslen(AUTOEXEC_INTRO) + 2 /* '\n' and '\0'. */; - line_size = sz1 > sz2 ? sz1 : sz2; - line = (LPTSTR)malloc(line_size * sizeof(TCHAR)); - out_line = (LPTSTR)malloc(line_size * sizeof(TCHAR)); - _stprintf(out_line, AUTOEXEC_CMD, path); - _tcscat(out_line, _T("\n")); - autoexec_intro = (LPTSTR)malloc((_tcslen(AUTOEXEC_INTRO) + 2 /* '\0', '\n' */) - * sizeof(TCHAR)); - _tcscpy(autoexec_intro, AUTOEXEC_INTRO); - _tcscat(autoexec_intro, _T("\n")); - - found = FALSE; - while (!found && _fgetts(line, line_size, file)){ - if (_tcscmp(autoexec_intro, line) == 0){ - _fgetts(line, line_size, file); - if (_tcscmp(out_line, line) == 0) - found = TRUE; - } - } - - if (!found){ - if (fseek(file, 0, SEEK_END) != 0 || - _fputts(_T("\n"), file) == _TEOF || - _fputts(autoexec_intro, file) == _TEOF || - _fputts(out_line, file) == _TEOF) - func_ret = FALSE; - } - else - verb_out(_T("Value already exists in \"autoexec.bat\".")); - - fclose(file); - free(path); - free(line); - free(out_line); - free(autoexec_intro); - - return func_ret; -} -//--------------------------------------------------------------------------- -// Removes "path" from "autoexec.bat". Return "TRUE" if the path has been -// removed or it wasn't in the file, "FALSE" otherwise. -BOOL remove_path_autoexec(LPTSTR long_path){ - FILE * file; - LPTSTR path; - size_t path_size; - LPTSTR data; - long file_size; - LPTSTR expected_text; - size_t expected_text_size; - LPTSTR buff; - size_t buff_size; - LPTSTR begin_pos; - LPTSTR final_part; - size_t fread_ret; - BOOL func_ret = TRUE; - - file = _wfopen(AUTOEXEC_PATH, _T("rb")); - if (!file){ - err_out(_T("Cannot open \"autoexec.bat\" for reading.")); - return FALSE; - } - fseek(file, 0, SEEK_END); - file_size = ftell(file); - data = (LPTSTR)malloc(file_size + sizeof(TCHAR) /* '\0'. */); - data[file_size / sizeof(TCHAR)] = '\0'; - fseek(file, 0, SEEK_SET); - fread_ret = fread(data, file_size, 1, file); - fclose(file); - if (fread_ret != 1){ - err_out(_T("Cannot read \"autoexec.bat\".")); - return FALSE; - } - - path_size = _tcslen(long_path) + 1; - path = (LPTSTR)malloc(path_size * sizeof(TCHAR)); - if (!GetShortPathName(long_path, path, path_size)) - _tcsncpy(path, long_path, path_size); - buff_size = _tcslen(AUTOEXEC_CMD) + _tcslen(path); - buff = (LPTSTR)malloc(buff_size * sizeof(TCHAR)); - expected_text_size = buff_size + _tcslen(AUTOEXEC_INTRO) - + 4 /* 2 * '\r\n' */; - expected_text = (LPTSTR)malloc(expected_text_size * sizeof(TCHAR)); - _tcscpy(expected_text, AUTOEXEC_INTRO); - _tcscat(expected_text, _T("\r\n")); - _stprintf(buff, AUTOEXEC_CMD, path); - _tcscat(expected_text, buff); - _tcscat(expected_text, _T("\r\n")); - - begin_pos = _tcsstr(data, expected_text); - if (begin_pos){ - file = _wfopen(AUTOEXEC_PATH, _T("wb")); - if (!file){ - err_out(_T("Cannot open \"autoexec.bat\" for writing.")); - func_ret = FALSE; - } - else{ - final_part = begin_pos + _tcslen(expected_text); - if ((fwrite(data, begin_pos - data, 1, file) != 1 && - (begin_pos - data)) || /* "fwrite"fails if the - second argument is 0 */ - (fwrite(final_part, _tcslen(final_part), 1, file) != 1 && - _tcslen(final_part))) - func_ret = FALSE; - fclose(file); - } - } - else - verb_out(_T("Value does not exist in \"autoexec.bat\".")); - - free(data); - free(path); - free(buff); - free(expected_text); - - return func_ret; -} //--------------------------------------------------------------------------- void __fastcall AddSearchPath(const UnicodeString Path) { - bool Result; - if (Win32Platform == VER_PLATFORM_WIN32_NT) - { - Result = add_path_reg(Path.c_str()); - } - else - { - Result = add_path_autoexec(Path.c_str()); - } - - if (!Result) + if (!add_path_reg(Path.c_str())) { throw ExtException(FMTLOAD(ADD_PATH_ERROR, (Path)), LastPathError); } @@ -421,17 +255,7 @@ void __fastcall AddSearchPath(const UnicodeString Path) //--------------------------------------------------------------------------- void __fastcall RemoveSearchPath(const UnicodeString Path) { - bool Result; - if (Win32Platform == VER_PLATFORM_WIN32_NT) - { - Result = remove_path_reg(Path.c_str()); - } - else - { - Result = remove_path_autoexec(Path.c_str()); - } - - if (!Result) + if (!remove_path_reg(Path.c_str())) { throw ExtException(FMTLOAD(REMOVE_PATH_ERROR, (Path)), LastPathError); } @@ -1151,3 +975,40 @@ void __fastcall UpdateJumpList(TStrings * SessionNames, TStrings * WorkspaceName delete Removed; } } +//--------------------------------------------------------------------------- +bool __fastcall AnyOtherInstanceOfSelf() +{ + + HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); + + bool Result = false; + + try + { + unsigned int Process = GetCurrentProcessId(); + UnicodeString ExeBaseName = ExtractFileBaseName(Application->ExeName); + + PROCESSENTRY32 ProcessEntry; + ProcessEntry.dwSize = sizeof(PROCESSENTRY32); + + if (Process32First(Snapshot, &ProcessEntry)) + { + while (!Result && Process32Next(Snapshot, &ProcessEntry)) + { + // we should check if the process is running in the same session, + // but for that we probably need some special priviledges + if ((Process != ProcessEntry.th32ProcessID) && + SameText(ExtractFileBaseName(ProcessEntry.szExeFile), ExeBaseName)) + { + Result = true; + } + } + } + } + __finally + { + CloseHandle(Snapshot); + } + + return Result; +} diff --git a/source/windows/Setup.h b/source/windows/Setup.h index 9e1a02be..343ab215 100644 --- a/source/windows/Setup.h +++ b/source/windows/Setup.h @@ -16,5 +16,6 @@ void __fastcall StartUpdateThread(TThreadMethod OnUpdatesChecked); void __fastcall StopUpdateThread(); UnicodeString __fastcall CampaignUrl(UnicodeString URL); void __fastcall UpdateJumpList(TStrings * SessionNames, TStrings * WorkspaceNames); +bool __fastcall AnyOtherInstanceOfSelf(); //--------------------------------------------------------------------------- #endif diff --git a/source/windows/UserInterface.cpp b/source/windows/UserInterface.cpp index 9f2b78d8..cfbb985d 100644 --- a/source/windows/UserInterface.cpp +++ b/source/windows/UserInterface.cpp @@ -609,7 +609,7 @@ class TMasterPasswordDialog : public TCustomDialog public: __fastcall TMasterPasswordDialog(bool Current); - bool __fastcall Execute(); + bool __fastcall Execute(UnicodeString & CurrentPassword, UnicodeString & NewPassword); protected: virtual void __fastcall DoValidate(); @@ -653,18 +653,19 @@ __fastcall TMasterPasswordDialog::TMasterPasswordDialog(bool Current) : } } //--------------------------------------------------------------------------- -bool __fastcall TMasterPasswordDialog::Execute() +bool __fastcall TMasterPasswordDialog::Execute( + UnicodeString & CurrentPassword, UnicodeString & NewPassword) { bool Result = TCustomDialog::Execute(); if (Result) { if (CurrentEdit->Enabled) { - WinConfiguration->SetMasterPassword(CurrentEdit->Text); + CurrentPassword = CurrentEdit->Text; } if (NewEdit != NULL) { - WinConfiguration->SetMasterPassword(NewEdit->Text); + NewPassword = NewEdit->Text; } } return Result; @@ -715,13 +716,23 @@ void __fastcall TMasterPasswordDialog::DoValidate() } } //--------------------------------------------------------------------------- -static bool __fastcall DoMasterPasswordDialog(bool Current) +static bool __fastcall DoMasterPasswordDialog(bool Current, + UnicodeString & NewPassword) { bool Result; TMasterPasswordDialog * Dialog = new TMasterPasswordDialog(Current); try { - Result = Dialog->Execute(); + UnicodeString CurrentPassword; + Result = Dialog->Execute(CurrentPassword, NewPassword); + if (Result) + { + if ((Current || WinConfiguration->UseMasterPassword) && + ALWAYS_TRUE(!CurrentPassword.IsEmpty())) + { + WinConfiguration->SetMasterPassword(CurrentPassword); + } + } } __finally { @@ -732,12 +743,16 @@ static bool __fastcall DoMasterPasswordDialog(bool Current) //--------------------------------------------------------------------------- bool __fastcall DoMasterPasswordDialog() { - return DoMasterPasswordDialog(true); + UnicodeString NewPassword; + bool Result = DoMasterPasswordDialog(true, NewPassword); + assert(NewPassword.IsEmpty()); + return Result; } //--------------------------------------------------------------------------- -bool __fastcall DoChangeMasterPasswordDialog() +bool __fastcall DoChangeMasterPasswordDialog(UnicodeString & NewPassword) { - return DoMasterPasswordDialog(false); + bool Result = DoMasterPasswordDialog(false, NewPassword); + return Result; } //--------------------------------------------------------------------------- void __fastcall MessageWithNoHelp(const UnicodeString & Message) diff --git a/source/windows/WinConfiguration.cpp b/source/windows/WinConfiguration.cpp index 14a68585..dbb6657c 100644 --- a/source/windows/WinConfiguration.cpp +++ b/source/windows/WinConfiguration.cpp @@ -383,6 +383,8 @@ __fastcall TWinConfiguration::TWinConfiguration(): TCustomWinConfiguration() FEditorList = new TEditorList(); FDefaultUpdatesPeriod = 0; FDontDecryptPasswords = 0; + FMasterPasswordSession = 0; + FMasterPasswordSessionAsked = false; Default(); try @@ -622,11 +624,8 @@ void __fastcall TWinConfiguration::DefaultLocalized() FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_GREP), FORMAT(L"grep \"!?%s?!\" !&", (LoadStr(CUSTOM_COMMAND_GREP_PATTERN))), ccShowResults); - if (Win32Platform == VER_PLATFORM_WIN32_NT) - { - FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_FC), - L"cmd /c fc \"!\" \"\!^!\" | more && pause", ccLocal); - } + FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_FC), + L"cmd /c fc \"!\" \"\!^!\" | more && pause", ccLocal); FCustomCommandList->Add(LoadStr(CUSTOM_COMMAND_PRINT), L"notepad.exe /p \"!\"", ccLocal); FCustomCommandList->Reset(); FCustomCommandsDefaults = true; @@ -725,14 +724,28 @@ void __fastcall TWinConfiguration::Saved() FEditorList->Saved(); } //--------------------------------------------------------------------------- -void __fastcall TWinConfiguration::RecryptPasswords() +void __fastcall TWinConfiguration::RecryptPasswords(TStrings * RecryptPasswordErrors) { - TCustomWinConfiguration::RecryptPasswords(); - TTerminalManager * Manager = TTerminalManager::Instance(false); - assert(Manager != NULL); - if (Manager != NULL) + TCustomWinConfiguration::RecryptPasswords(RecryptPasswordErrors); + + try { - Manager->RecryptPasswords(); + TTerminalManager * Manager = TTerminalManager::Instance(false); + assert(Manager != NULL); + if (Manager != NULL) + { + Manager->RecryptPasswords(); + } + } + catch (Exception & E) + { + UnicodeString Message; + if (ExceptionMessage(&E, Message)) + { + // we do not expect this really to happen, + // so we do not bother providing context + RecryptPasswordErrors->Add(Message); + } } } //--------------------------------------------------------------------------- @@ -1205,7 +1218,8 @@ RawByteString __fastcall TWinConfiguration::StronglyRecryptPassword(RawByteStrin TCustomWinConfiguration::DecryptPassword(Password, Key); if (!PasswordText.IsEmpty()) { - assert(!FPlainMasterPasswordEncrypt.IsEmpty()); + // can be not set for instance, when editing=>saving site with no prior password + AskForMasterPasswordIfNotSet(); Password = ScramblePassword(PasswordText); AES256EncyptWithMAC(Password, FPlainMasterPasswordEncrypt, Result); Result = SetExternalEncryptedPassword(Result); @@ -1222,10 +1236,12 @@ UnicodeString __fastcall TWinConfiguration::DecryptPassword(RawByteString Passwo { if (FDontDecryptPasswords == 0) { + // As opposite to AskForMasterPasswordIfNotSet, we test here + // for decrypt password. This is important while recrypting password, + // when clearing master password, when encrypt password is already empty. if (FPlainMasterPasswordDecrypt.IsEmpty()) { - assert(FOnMasterPasswordPrompt != NULL); - FOnMasterPasswordPrompt(); + AskForMasterPassword(); } if (!AES256DecryptWithMAC(Buf, FPlainMasterPasswordDecrypt, Buf) || !UnscramblePassword(Buf, Result)) @@ -1242,32 +1258,46 @@ UnicodeString __fastcall TWinConfiguration::DecryptPassword(RawByteString Passwo { Result = TCustomWinConfiguration::DecryptPassword(Password, Key); } + return Result; } //--------------------------------------------------------------------------- void __fastcall TWinConfiguration::SetMasterPassword(UnicodeString value) { - if (FUseMasterPassword && ValidateMasterPassword(value)) + // just stores the plain-text version of the password + + // we can get here even if master password is off, + // when we encounter stray encrypted password (e.g. manually imported site), + // make sure we do not set encrypt password to avoid starting encrypting + // new passwords + // (this is bit of edge case, not really well tested) + if (!FUseMasterPassword) { - // just store the plain-text version of the password - FPlainMasterPasswordEncrypt = value; FPlainMasterPasswordDecrypt = value; } - else + else if (ALWAYS_TRUE(FUseMasterPassword) && + ALWAYS_TRUE(ValidateMasterPassword(value))) { - RawByteString Verifier; - AES256CreateVerifier(value, Verifier); - FMasterPasswordVerifier = BytesToHex(Verifier); FPlainMasterPasswordEncrypt = value; - FUseMasterPassword = true; - try - { - RecryptPasswords(); - } - __finally - { - FPlainMasterPasswordDecrypt = value; - } + FPlainMasterPasswordDecrypt = value; + } +} +//--------------------------------------------------------------------------- +void __fastcall TWinConfiguration::ChangeMasterPassword( + UnicodeString value, TStrings * RecryptPasswordErrors) +{ + RawByteString Verifier; + AES256CreateVerifier(value, Verifier); + FMasterPasswordVerifier = BytesToHex(Verifier); + FPlainMasterPasswordEncrypt = value; + FUseMasterPassword = true; + try + { + RecryptPasswords(RecryptPasswordErrors); + } + __finally + { + FPlainMasterPasswordDecrypt = value; } } //--------------------------------------------------------------------------- @@ -1275,17 +1305,18 @@ bool __fastcall TWinConfiguration::ValidateMasterPassword(UnicodeString value) { assert(UseMasterPassword); assert(!FMasterPasswordVerifier.IsEmpty()); - return AES256Verify(value, HexToBytes(FMasterPasswordVerifier)); + bool Result = AES256Verify(value, HexToBytes(FMasterPasswordVerifier)); + return Result; } //--------------------------------------------------------------------------- -void __fastcall TWinConfiguration::ClearMasterPassword() +void __fastcall TWinConfiguration::ClearMasterPassword(TStrings * RecryptPasswordErrors) { FMasterPasswordVerifier = L""; FUseMasterPassword = false; Shred(FPlainMasterPasswordEncrypt); try { - RecryptPasswords(); + RecryptPasswords(RecryptPasswordErrors); } __finally { @@ -1293,16 +1324,60 @@ void __fastcall TWinConfiguration::ClearMasterPassword() } } //--------------------------------------------------------------------------- -void __fastcall TWinConfiguration::AskForMasterPasswordIfNotSet() +void __fastcall TWinConfiguration::AskForMasterPassword() { - if (FPlainMasterPasswordEncrypt.IsEmpty()) + if (FMasterPasswordSession > 0) + { + if (FMasterPasswordSessionAsked) + { + Abort(); + } + + // set before call to OnMasterPasswordPrompt as it may abort + FMasterPasswordSessionAsked = true; + } + + // this can happen from TStoredSessionList::UpdateStaticUsage(), + // when the default session settings have password set (and no other basic property, + // like hostname/username), and master password is enabled + if (FOnMasterPasswordPrompt == NULL) + { + throw Exception(L"Master password handler not set"); + } + else { - assert(FOnMasterPasswordPrompt != NULL); FOnMasterPasswordPrompt(); + assert(!FPlainMasterPasswordDecrypt.IsEmpty()); } } //--------------------------------------------------------------------------- +void __fastcall TWinConfiguration::AskForMasterPasswordIfNotSet() +{ + if (FPlainMasterPasswordEncrypt.IsEmpty()) + { + AskForMasterPassword(); + } +} +//--------------------------------------------------------------------------- +void __fastcall TWinConfiguration::BeginMasterPasswordSession() +{ + // We do not expect nesting + assert(FMasterPasswordSession == 0); + assert(!FMasterPasswordSessionAsked || (FMasterPasswordSession > 0)); + // This should better be thread-specific + FMasterPasswordSession++; +} +//--------------------------------------------------------------------------- +void __fastcall TWinConfiguration::EndMasterPasswordSession() +{ + if (ALWAYS_TRUE(FMasterPasswordSession > 0)) + { + FMasterPasswordSession--; + } + FMasterPasswordSessionAsked = false; +} +//--------------------------------------------------------------------------- void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value) { SET_CONFIG_PROPERTY(LogWindowOnStartup); diff --git a/source/windows/WinConfiguration.h b/source/windows/WinConfiguration.h index fe48eae8..08f512a4 100644 --- a/source/windows/WinConfiguration.h +++ b/source/windows/WinConfiguration.h @@ -342,6 +342,8 @@ class TWinConfiguration : public TCustomWinConfiguration UnicodeString FOpenedStoredSessionFolders; bool FAutoImportedFromPuttyOrFilezilla; int FDontDecryptPasswords; + int FMasterPasswordSession; + bool FMasterPasswordSessionAsked; void __fastcall SetDoubleClickAction(TDoubleClickAction value); void __fastcall SetCopyOnDoubleClickConfirmation(bool value); @@ -436,7 +438,7 @@ class TWinConfiguration : public TCustomWinConfiguration virtual void __fastcall CopyData(THierarchicalStorage * Source, THierarchicalStorage * Target); virtual UnicodeString __fastcall GetDefaultKeyFile(); virtual void __fastcall Saved(); - void __fastcall RecryptPasswords(); + void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors); virtual bool __fastcall GetUseMasterPassword(); bool __fastcall SameStringLists(TStrings * Strings1, TStrings * Strings2); bool __fastcall InternalReloadComponentRes(const UnicodeString ResName, @@ -454,6 +456,7 @@ class TWinConfiguration : public TCustomWinConfiguration bool __fastcall CanWriteToStorage(); bool __fastcall DoIsBeta(const UnicodeString & ReleaseType); UnicodeString __fastcall FormatDefaultWindowParams(int Width, int Height); + void __fastcall AskForMasterPassword(); public: __fastcall TWinConfiguration(); @@ -470,8 +473,11 @@ class TWinConfiguration : public TCustomWinConfiguration virtual UnicodeString __fastcall DecryptPassword(RawByteString Password, UnicodeString Key); virtual RawByteString __fastcall StronglyRecryptPassword(RawByteString Password, UnicodeString Key); void __fastcall SetMasterPassword(UnicodeString value); + void __fastcall ChangeMasterPassword(UnicodeString value, TStrings * RecryptPasswordErrors); bool __fastcall ValidateMasterPassword(UnicodeString value); - void __fastcall ClearMasterPassword(); + void __fastcall ClearMasterPassword(TStrings * RecryptPasswordErrors); + void __fastcall BeginMasterPasswordSession(); + void __fastcall EndMasterPasswordSession(); virtual void __fastcall AskForMasterPasswordIfNotSet(); void __fastcall AddSessionToJumpList(UnicodeString SessionName); void __fastcall DeleteSessionFromJumpList(UnicodeString SessionName); diff --git a/source/windows/WinInterface.h b/source/windows/WinInterface.h index 29dc0126..1b81bf46 100644 --- a/source/windows/WinInterface.h +++ b/source/windows/WinInterface.h @@ -107,7 +107,7 @@ bool __fastcall DoShortCutDialog(TShortCut & ShortCut, // windows\UserInterface.cpp bool __fastcall DoMasterPasswordDialog(); -bool __fastcall DoChangeMasterPasswordDialog(); +bool __fastcall DoChangeMasterPasswordDialog(UnicodeString & NewPassword); // windows\WinMain.cpp int __fastcall Execute();