Integrate FTP debug logging into UI toggle
This commit is contained in:
@@ -75,14 +75,15 @@ namespace keepass2android.Io
|
||||
}
|
||||
|
||||
private readonly ICertificateValidationHandler _app;
|
||||
private readonly Func<bool> _debugLogPrefGetter;
|
||||
|
||||
public MemoryStream traceStream;
|
||||
|
||||
public NetFtpFileStorage(Context context, ICertificateValidationHandler app)
|
||||
public NetFtpFileStorage(Context context, ICertificateValidationHandler app, Func<bool> debugLogPrefGetter)
|
||||
{
|
||||
_app = app;
|
||||
traceStream = new MemoryStream();
|
||||
|
||||
_debugLogPrefGetter = debugLogPrefGetter;
|
||||
traceStream = new MemoryStream();
|
||||
}
|
||||
|
||||
public IEnumerable<string> SupportedProtocols
|
||||
@@ -155,8 +156,11 @@ namespace keepass2android.Io
|
||||
};
|
||||
|
||||
client.Config.EncryptionMode = settings.EncryptionMode;
|
||||
|
||||
client.Connect();
|
||||
|
||||
if (_debugLogPrefGetter())
|
||||
client.Logger = new Kp2aLogFTPLogger();
|
||||
|
||||
client.Connect();
|
||||
return client;
|
||||
|
||||
}
|
||||
@@ -589,7 +593,7 @@ namespace keepass2android.Io
|
||||
{
|
||||
public void Log(FtpLogEntry entry)
|
||||
{
|
||||
Kp2aLog.Log("FluentFTP: " + entry.Message);
|
||||
Kp2aLog.Log("[FluentFTP] " + entry.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -391,8 +391,8 @@ namespace keepass2android
|
||||
string user = dlgContents.FindViewById<EditText>(Resource.Id.ftp_user).Text;
|
||||
string password = dlgContents.FindViewById<EditText>(Resource.Id.ftp_password).Text;
|
||||
string initialPath = dlgContents.FindViewById<EditText>(Resource.Id.ftp_initial_dir).Text;
|
||||
string ftpPath = new NetFtpFileStorage(_activity, App.Kp2a).BuildFullPath(host, port, initialPath, user,
|
||||
password, encryption);
|
||||
string ftpPath = new NetFtpFileStorage(_activity, App.Kp2a, () => false)
|
||||
.BuildFullPath(host, port, initialPath, user, password, encryption);
|
||||
onStartBrowse(ftpPath);
|
||||
});
|
||||
EventHandler<DialogClickEventArgs> evtH = new EventHandler<DialogClickEventArgs>((sender, e) => onCancel());
|
||||
|
@@ -98,7 +98,7 @@
|
||||
<string name="TrayTotp_SeedField_key">TrayTotp_SeedField_key</string>
|
||||
<string name="TrayTotp_prefs_key">TrayTotp_prefs_key</string>
|
||||
<string name="DebugLog_key">DebugLog_key</string>
|
||||
<string name="JSchDebug_key">JSchDebug_key</string>
|
||||
<string name="FtpDebug_key">FtpDebug_key</string>
|
||||
<string name="DebugLog_prefs_key">DebugLog_prefs_key</string>
|
||||
<string name="DebugLog_send_key">DebugLog_send</string>
|
||||
<string name="AutofillDisabledQueriesPreference_key">AutofillDisabledQueriesPreference_key</string>
|
||||
@@ -216,4 +216,4 @@
|
||||
|
||||
<string name="ClearPasswordOnLeave_key">ClearPasswordOnLeave</string>
|
||||
|
||||
</resources>
|
||||
</resources>
|
||||
|
@@ -699,7 +699,7 @@
|
||||
<string name="TrayTotp_prefs">TrayTotp</string>
|
||||
<string name="DebugLog_prefs_prefs">Log-File for Debugging</string>
|
||||
<string name="DebugLog_title">Use log file</string>
|
||||
<string name="JSchDebug_title">SFTP debug logging</string>
|
||||
<string name="FtpDebug_title">FTP/SFTP debug logging</string>
|
||||
<string name="DebugLog_summary">Write app output to a local log file</string>
|
||||
<string name="DebugLog_send">Send debug log...</string>
|
||||
|
||||
|
@@ -677,10 +677,10 @@
|
||||
android:key="@string/DebugLog_send_key" />
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="false"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/JSchDebug_title"
|
||||
android:key="@string/JSchDebug_key" />
|
||||
android:title="@string/FtpDebug_title"
|
||||
android:key="@string/FtpDebug_key" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
||||
|
@@ -748,7 +748,7 @@ namespace keepass2android
|
||||
new OneDrive2MyFilesFileStorage(),
|
||||
new OneDrive2AppFolderFileStorage(),
|
||||
new SftpFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled),
|
||||
new WebDavFileStorage(this),
|
||||
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new MegaFileStorage(App.Context),
|
||||
@@ -763,6 +763,12 @@ namespace keepass2android
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsFtpDebugEnabled()
|
||||
{
|
||||
return PreferenceManager.GetDefaultSharedPreferences(LocaleManager.LocalizedAppContext)
|
||||
.GetBoolean(LocaleManager.LocalizedAppContext.GetString(Resource.String.FtpDebug_key), false);
|
||||
}
|
||||
|
||||
public void TriggerReload(Context ctx, Action<bool> actionOnResult)
|
||||
{
|
||||
Handler handler = new Handler(Looper.MainLooper);
|
||||
|
@@ -179,9 +179,9 @@ namespace keepass2android
|
||||
FindPreference(GetString(Resource.String.DebugLog_send_key)).PreferenceClick += OnSendDebug;
|
||||
|
||||
#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
|
||||
FindPreference(GetString(Resource.String.JSchDebug_key)).PreferenceChange += OnJSchDebugChanged;
|
||||
FindPreference(GetString(Resource.String.FtpDebug_key)).PreferenceChange += OnJSchDebugChanged;
|
||||
#else
|
||||
FindPreference(GetString(Resource.String.JSchDebug_key)).Enabled = false;
|
||||
FindPreference(GetString(Resource.String.FtpDebug_key)).Enabled = false;
|
||||
#endif
|
||||
|
||||
HashSet<string> supportedLocales = new HashSet<string>() { "en", "af", "ar", "az", "be", "bg", "ca", "cs", "da", "de", "el", "es", "eu", "fa", "fi", "fr", "gl", "he", "hr", "hu", "id", "in", "it", "iw", "ja", "ko", "ml", "nb", "nl", "nn", "no", "pl", "pt", "ro", "ru", "si", "sk", "sl", "sr", "sv", "tr", "uk", "vi", "zh" };
|
||||
@@ -393,9 +393,8 @@ namespace keepass2android
|
||||
Kp2aLog.FinishLogFile();
|
||||
|
||||
#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
|
||||
bool jschLogEnable = PreferenceManager.GetDefaultSharedPreferences(Application.Context)
|
||||
.GetBoolean(Application.Context.GetString(Resource.String.JSchDebug_key), false);
|
||||
SetJSchLogging(jschLogEnable);
|
||||
SetJSchLogging(PreferenceManager.GetDefaultSharedPreferences(Application.Context)
|
||||
.GetBoolean(Application.Context.GetString(Resource.String.FtpDebug_key), false));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -415,6 +414,7 @@ namespace keepass2android
|
||||
}
|
||||
sftpStorage.SetJschLogging(enabled, logFilename);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private void AlgorithmPrefChange(object sender, Preference.PreferenceChangeEventArgs preferenceChangeEventArgs)
|
||||
|
Reference in New Issue
Block a user