Compare commits
	
		
			4 Commits
		
	
	
		
			754-crash-
			...
			2816-bug-y
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					26c37bcd2a | ||
| 
						 | 
					1980f05a7c | ||
| 
						 | 
					dbf10ba9fb | ||
| 
						 | 
					4be18d8373 | 
@@ -13,7 +13,7 @@ using Android.Content.PM;
 | 
				
			|||||||
using Android.OS;
 | 
					using Android.OS;
 | 
				
			||||||
using Android.Preferences;
 | 
					using Android.Preferences;
 | 
				
			||||||
using Java.IO;
 | 
					using Java.IO;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using KeePassLib.Utility;
 | 
					using KeePassLib.Utility;
 | 
				
			||||||
using File = System.IO.File;
 | 
					using File = System.IO.File;
 | 
				
			||||||
@@ -121,7 +121,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
			var response = ex.Response as HttpWebResponse;
 | 
								var response = ex.Response as HttpWebResponse;
 | 
				
			||||||
			if ((response != null) && (response.StatusCode == HttpStatusCode.NotFound))
 | 
								if ((response != null) && (response.StatusCode == HttpStatusCode.NotFound))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new FileNotFoundException(ex.Message, ioc.Path, ex);
 | 
									throw new FileNotFoundException(ExceptionUtil.GetErrorMessage(ex), ioc.Path, ex);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (ex.Status == WebExceptionStatus.TrustFailure)
 | 
								if (ex.Status == WebExceptionStatus.TrustFailure)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ using Keepass2android.Javafilestorage;
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
using Exception = System.Exception;
 | 
					using Exception = System.Exception;
 | 
				
			||||||
using FileNotFoundException = Java.IO.FileNotFoundException;
 | 
					using FileNotFoundException = Java.IO.FileNotFoundException;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace keepass2android.Io
 | 
					namespace keepass2android.Io
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -42,7 +43,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (FileNotFoundException e)
 | 
								catch (FileNotFoundException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new System.IO.FileNotFoundException(e.Message, e);
 | 
									throw new System.IO.FileNotFoundException(ExceptionUtil.GetErrorMessage(e), e);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Java.Lang.Exception e)
 | 
								catch (Java.Lang.Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -195,7 +196,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (FileNotFoundException e)
 | 
								catch (FileNotFoundException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new System.IO.FileNotFoundException(e.Message, e);
 | 
									throw new System.IO.FileNotFoundException(ExceptionUtil.GetErrorMessage(e), e);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Java.Lang.Exception e)
 | 
								catch (Java.Lang.Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -214,7 +215,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (FileNotFoundException e)
 | 
								catch (FileNotFoundException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new System.IO.FileNotFoundException(e.Message, e);
 | 
									throw new System.IO.FileNotFoundException(ExceptionUtil.GetErrorMessage(e), e);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Java.Lang.Exception e)
 | 
								catch (Java.Lang.Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -244,7 +245,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (FileNotFoundException e)
 | 
								catch (FileNotFoundException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new System.IO.FileNotFoundException(e.Message, e);
 | 
									throw new System.IO.FileNotFoundException(ExceptionUtil.GetErrorMessage(e), e);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Java.Lang.Exception e)
 | 
								catch (Java.Lang.Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ using Android.Content;
 | 
				
			|||||||
using Android.OS;
 | 
					using Android.OS;
 | 
				
			||||||
using FluentFTP;
 | 
					using FluentFTP;
 | 
				
			||||||
using FluentFTP.Exceptions;
 | 
					using FluentFTP.Exceptions;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using KeePassLib;
 | 
					using KeePassLib;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using KeePassLib.Utility;
 | 
					using KeePassLib.Utility;
 | 
				
			||||||
@@ -127,7 +128,7 @@ namespace keepass2android.Io
 | 
				
			|||||||
				var ftpEx = (FtpCommandException) exception;
 | 
									var ftpEx = (FtpCommandException) exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (ftpEx.CompletionCode == "550")
 | 
									if (ftpEx.CompletionCode == "550")
 | 
				
			||||||
					throw new FileNotFoundException(exception.Message, exception);
 | 
										throw new FileNotFoundException(ExceptionUtil.GetErrorMessage(exception), exception);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return exception;
 | 
								return exception;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ using System.Reflection;
 | 
				
			|||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using Android.Content;
 | 
					using Android.Content;
 | 
				
			||||||
using Android.Util;
 | 
					using Android.Util;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using keepass2android.Io.ItemLocation;
 | 
					using keepass2android.Io.ItemLocation;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using KeePassLib.Utility;
 | 
					using KeePassLib.Utility;
 | 
				
			||||||
@@ -522,10 +523,10 @@ namespace keepass2android.Io
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (e.IsMatch(GraphErrorCode.ItemNotFound.ToString()))
 | 
					            if (e.IsMatch(GraphErrorCode.ItemNotFound.ToString()))
 | 
				
			||||||
                return new FileNotFoundException(e.Message);
 | 
					                return new FileNotFoundException(ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
            if (e.Message.Contains("\n\n404 : ")
 | 
					            if (e.Message.Contains("\n\n404 : ")
 | 
				
			||||||
            ) //hacky solution to check for not found. errorCode was null in my tests so I had to find a workaround.
 | 
					            ) //hacky solution to check for not found. errorCode was null in my tests so I had to find a workaround.
 | 
				
			||||||
                return new FileNotFoundException(e.Message);
 | 
					                return new FileNotFoundException(ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
            return e;
 | 
					            return e;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,20 +16,32 @@ namespace keepass2android.Io
 | 
				
			|||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
	public class OneDriveFileStorage: IFileStorage
 | 
						public class OneDriveFileStorage: IFileStorage
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		
 | 
					        public OneDriveFileStorage(IKp2aApp app)
 | 
				
			||||||
		public IEnumerable<string> SupportedProtocols
 | 
					        {
 | 
				
			||||||
 | 
					            _app = app;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly IKp2aApp _app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public IEnumerable<string> SupportedProtocols
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get
 | 
								get
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				yield return "skydrive";
 | 
									yield return "skydrive";
 | 
				
			||||||
				yield return "onedrive";
 | 
									yield return "onedrive";
 | 
				
			||||||
			}
 | 
					            }
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Exception GetDeprecatedMessage()
 | 
					        string GetDeprecatedMessage()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					                "You have opened your file through a deprecated Microsoft API. Please select Change database, Open Database and then select OneDrive again.";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Exception GetDeprecatedException()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return new Exception(
 | 
					            return new Exception(
 | 
				
			||||||
                "You have opened your file through a deprecated Microsoft API. Please select Change database, Open Database and then select One Drive again.");
 | 
					                GetDeprecatedMessage());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    public bool UserShouldBackup
 | 
						    public bool UserShouldBackup
 | 
				
			||||||
@@ -39,133 +51,132 @@ namespace keepass2android.Io
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public void Delete(IOConnectionInfo ioc)
 | 
					        public void Delete(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool CheckForFileChangeFast(IOConnectionInfo ioc, string previousFileVersion)
 | 
					        public bool CheckForFileChangeFast(IOConnectionInfo ioc, string previousFileVersion)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string GetCurrentFileVersionFast(IOConnectionInfo ioc)
 | 
					        public string GetCurrentFileVersionFast(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Stream OpenFileForRead(IOConnectionInfo ioc)
 | 
					        public Stream OpenFileForRead(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction)
 | 
					        public IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string GetFilenameWithoutPathAndExt(IOConnectionInfo ioc)
 | 
					        public string GetFilenameWithoutPathAndExt(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string GetFileExtension(IOConnectionInfo ioc)
 | 
					        public string GetFileExtension(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool RequiresCredentials(IOConnectionInfo ioc)
 | 
					        public bool RequiresCredentials(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void CreateDirectory(IOConnectionInfo ioc, string newDirName)
 | 
					        public void CreateDirectory(IOConnectionInfo ioc, string newDirName)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IEnumerable<FileDescription> ListContents(IOConnectionInfo ioc)
 | 
					        public IEnumerable<FileDescription> ListContents(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public FileDescription GetFileDescription(IOConnectionInfo ioc)
 | 
					        public FileDescription GetFileDescription(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool RequiresSetup(IOConnectionInfo ioConnection)
 | 
					        public bool RequiresSetup(IOConnectionInfo ioConnection)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string IocToPath(IOConnectionInfo ioc)
 | 
					        public string IocToPath(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
 | 
					        public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode,
 | 
					        public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode,
 | 
				
			||||||
            bool alwaysReturnSuccess)
 | 
					            bool alwaysReturnSuccess)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            _app.ShowMessage(activity.Activity, GetDeprecatedMessage(), MessageSeverity.Error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void PrepareFileUsage(Context ctx, IOConnectionInfo ioc)
 | 
					        public void PrepareFileUsage(Context ctx, IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnCreate(IFileStorageSetupActivity activity, Bundle savedInstanceState)
 | 
					        public void OnCreate(IFileStorageSetupActivity activity, Bundle savedInstanceState)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnResume(IFileStorageSetupActivity activity)
 | 
					        public void OnResume(IFileStorageSetupActivity activity)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnStart(IFileStorageSetupActivity activity)
 | 
					        public void OnStart(IFileStorageSetupActivity activity)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnActivityResult(IFileStorageSetupActivity activity, int requestCode, int resultCode, Intent data)
 | 
					        public void OnActivityResult(IFileStorageSetupActivity activity, int requestCode, int resultCode, Intent data)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string GetDisplayName(IOConnectionInfo ioc)
 | 
					        public string GetDisplayName(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            return "File using deprecated Microsoft API. Please update.";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string CreateFilePath(string parent, string newFilename)
 | 
					        public string CreateFilePath(string parent, string newFilename)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IOConnectionInfo GetParentPath(IOConnectionInfo ioc)
 | 
					        public IOConnectionInfo GetParentPath(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IOConnectionInfo GetFilePath(IOConnectionInfo folderPath, string filename)
 | 
					        public IOConnectionInfo GetFilePath(IOConnectionInfo folderPath, string filename)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool IsPermanentLocation(IOConnectionInfo ioc)
 | 
					        public bool IsPermanentLocation(IOConnectionInfo ioc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut<UiStringKey> reason = null)
 | 
					        public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut<UiStringKey> reason = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw GetDeprecatedMessage();
 | 
					            throw GetDeprecatedException();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ using Android.Content;
 | 
				
			|||||||
using Android.OS;
 | 
					using Android.OS;
 | 
				
			||||||
using Android.Widget;
 | 
					using Android.Widget;
 | 
				
			||||||
using Java.Net;
 | 
					using Java.Net;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using keepass2android.Io;
 | 
					using keepass2android.Io;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -208,7 +209,7 @@ namespace keepass2android
 | 
				
			|||||||
					{
 | 
										{
 | 
				
			||||||
						return () =>
 | 
											return () =>
 | 
				
			||||||
							{
 | 
												{
 | 
				
			||||||
								ShowErrorToast(_app.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message);
 | 
													ShowErrorToast(_app.GetResourceString(UiStringKey.ErrorOcurred) + " " + ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
								ReturnCancel();
 | 
													ReturnCancel();
 | 
				
			||||||
							};
 | 
												};
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										25
									
								
								src/Kp2aBusinessLogic/Utils/ExceptionUtil.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/Kp2aBusinessLogic/Utils/ExceptionUtil.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace KeePass.Util
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ExceptionUtil
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static string GetErrorMessage(Exception e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string errorMessage = e.Message;
 | 
				
			||||||
 | 
					            if (e is Java.Lang.Exception javaException)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                errorMessage = javaException.LocalizedMessage ?? javaException.Message ?? errorMessage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return errorMessage;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -5,6 +5,7 @@ using System.Security.Cryptography;
 | 
				
			|||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using Android.App;
 | 
					using Android.App;
 | 
				
			||||||
using Android.Content;
 | 
					using Android.Content;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using KeePassLib.Cryptography;
 | 
					using KeePassLib.Cryptography;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using KeePassLib.Utility;
 | 
					using KeePassLib.Utility;
 | 
				
			||||||
@@ -65,7 +66,7 @@ namespace keepass2android
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Exception e)
 | 
								catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Finish(false, e.Message);
 | 
									Finish(false, ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,7 @@ using Com.Keepassdroid.Database.Exception;
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
using Com.Keepassdroid.Database.Save;
 | 
					using Com.Keepassdroid.Database.Save;
 | 
				
			||||||
using Java.Util;
 | 
					using Java.Util;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using KeePassLib;
 | 
					using KeePassLib;
 | 
				
			||||||
using KeePassLib.Cryptography;
 | 
					using KeePassLib.Cryptography;
 | 
				
			||||||
using KeePassLib.Cryptography.Cipher;
 | 
					using KeePassLib.Cryptography.Cipher;
 | 
				
			||||||
@@ -82,15 +83,14 @@ namespace keepass2android
 | 
				
			|||||||
			catch (Java.IO.FileNotFoundException e)
 | 
								catch (Java.IO.FileNotFoundException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				throw new FileNotFoundException(
 | 
									throw new FileNotFoundException(
 | 
				
			||||||
					e.Message, e);
 | 
					                    ExceptionUtil.GetErrorMessage(e), e);
 | 
				
			||||||
			}  
 | 
								}  
 | 
				
			||||||
			catch (Java.Lang.Exception e)
 | 
								catch (Java.Lang.Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (e.Message == "Invalid key!")
 | 
									if (e.Message == "Invalid key!")
 | 
				
			||||||
					throw new InvalidCompositeKeyException();
 | 
										throw new InvalidCompositeKeyException();
 | 
				
			||||||
				throw new Exception(e.LocalizedMessage ??
 | 
									throw new Exception(ExceptionUtil.GetErrorMessage(e) ??
 | 
				
			||||||
				e.Message ??
 | 
					                                                                  e.GetType().Name, e);
 | 
				
			||||||
				e.GetType().Name, e);
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			HashOfLastStream = hashingStream.Hash;
 | 
								HashOfLastStream = hashingStream.Hash;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ using Android.App;
 | 
				
			|||||||
using Android.Content;
 | 
					using Android.Content;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
using keepass2android.Io;
 | 
					using keepass2android.Io;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace keepass2android
 | 
					namespace keepass2android
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -109,7 +110,7 @@ namespace keepass2android
 | 
				
			|||||||
			catch (Exception e)
 | 
								catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
                Kp2aLog.LogUnexpectedError(e);
 | 
					                Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
				Finish(false, e.Message);
 | 
									Finish(false, ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ using System.Linq;
 | 
				
			|||||||
using System.Threading;
 | 
					using System.Threading;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Android.App;
 | 
					using Android.App;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using keepass2android.database.edit;
 | 
					using keepass2android.database.edit;
 | 
				
			||||||
using KeePassLib;
 | 
					using KeePassLib;
 | 
				
			||||||
using KeePassLib.Keys;
 | 
					using KeePassLib.Keys;
 | 
				
			||||||
@@ -103,10 +104,10 @@ namespace keepass2android
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (AggregateException e)
 | 
								catch (AggregateException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				string message = e.Message;
 | 
									string message = ExceptionUtil.GetErrorMessage(e);
 | 
				
			||||||
				foreach (var innerException in e.InnerExceptions)
 | 
									foreach (var innerException in e.InnerExceptions)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					message = innerException.Message;
 | 
										message = ExceptionUtil.GetErrorMessage(innerException);
 | 
				
			||||||
					// Override the message shown with the last (hopefully most recent) inner exception
 | 
										// Override the message shown with the last (hopefully most recent) inner exception
 | 
				
			||||||
					Kp2aLog.LogUnexpectedError(innerException);
 | 
										Kp2aLog.LogUnexpectedError(innerException);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -116,14 +117,14 @@ namespace keepass2android
 | 
				
			|||||||
			catch (DuplicateUuidsException e)
 | 
								catch (DuplicateUuidsException e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Kp2aLog.Log(e.ToString());
 | 
									Kp2aLog.Log(e.ToString());
 | 
				
			||||||
				Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), false, Exception);
 | 
									Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + ExceptionUtil.GetErrorMessage(e) + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), false, Exception);
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Exception e)
 | 
								catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (!(e is InvalidCompositeKeyException))
 | 
									if (!(e is InvalidCompositeKeyException))
 | 
				
			||||||
					Kp2aLog.LogUnexpectedError(e);
 | 
										Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
				Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + (e.Message ?? (e is FileNotFoundException ? _app.GetResourceString(UiStringKey.FileNotFound) :  "")), false, Exception);
 | 
									Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + (ExceptionUtil.GetErrorMessage(e) ?? (e is FileNotFoundException ? _app.GetResourceString(UiStringKey.FileNotFound) :  "")), false, Exception);
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,7 @@ using KeePassLib.Utility;
 | 
				
			|||||||
using keepass2android.Io;
 | 
					using keepass2android.Io;
 | 
				
			||||||
using Debug = System.Diagnostics.Debug;
 | 
					using Debug = System.Diagnostics.Debug;
 | 
				
			||||||
using Exception = System.Exception;
 | 
					using Exception = System.Exception;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace keepass2android
 | 
					namespace keepass2android
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -187,7 +188,7 @@ namespace keepass2android
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
					Kp2aLog.LogUnexpectedError(e);
 | 
										Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
					Finish(false, e.Message);
 | 
										Finish(false, ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
					return;
 | 
										return;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -222,8 +223,8 @@ namespace keepass2android
 | 
				
			|||||||
						catch (Exception e)
 | 
											catch (Exception e)
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							Kp2aLog.LogUnexpectedError(e);
 | 
												Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
							Kp2aLog.Log("Error in worker thread of SaveDb: " + e);
 | 
												Kp2aLog.Log("Error in worker thread of SaveDb: " + ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
							Finish(false, e.Message);
 | 
												Finish(false, ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						
 | 
											
 | 
				
			||||||
					});
 | 
										});
 | 
				
			||||||
@@ -233,7 +234,7 @@ namespace keepass2android
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				Kp2aLog.LogUnexpectedError(e);
 | 
									Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
				Kp2aLog.Log("Error starting worker thread of SaveDb: "+e);
 | 
									Kp2aLog.Log("Error starting worker thread of SaveDb: "+e);
 | 
				
			||||||
				Finish(false, e.Message);
 | 
									Finish(false, ExceptionUtil.GetErrorMessage(e));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ namespace keepass2android
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Exception e)
 | 
								catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Finish(false, e.Message);
 | 
									Finish(false, Util.GetErrorMessage(e));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -796,7 +796,7 @@ namespace keepass2android
 | 
				
			|||||||
	            {
 | 
						            {
 | 
				
			||||||
	                App.Kp2a.ShowMessage(this,
 | 
						                App.Kp2a.ShowMessage(this,
 | 
				
			||||||
	                    GetString(Resource.String.SaveAttachment_Failed, new Java.Lang.Object[] {filename})
 | 
						                    GetString(Resource.String.SaveAttachment_Failed, new Java.Lang.Object[] {filename})
 | 
				
			||||||
	                    + exWrite.Message,  MessageSeverity.Error);
 | 
						                    + Util.GetErrorMessage(exWrite),  MessageSeverity.Error);
 | 
				
			||||||
	                return null;
 | 
						                return null;
 | 
				
			||||||
	            }
 | 
						            }
 | 
				
			||||||
	            finally
 | 
						            finally
 | 
				
			||||||
@@ -1305,7 +1305,7 @@ namespace keepass2android
 | 
				
			|||||||
	            }
 | 
						            }
 | 
				
			||||||
	            catch (Exception ex)
 | 
						            catch (Exception ex)
 | 
				
			||||||
	            {
 | 
						            {
 | 
				
			||||||
	                Finish(false, ex.Message);
 | 
						                Finish(false, Util.GetErrorMessage(ex));
 | 
				
			||||||
	            }
 | 
						            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -715,7 +715,7 @@ namespace keepass2android
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch(Exception exAttach)
 | 
								catch(Exception exAttach)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				App.Kp2a.ShowMessage(this, GetString(Resource.String.AttachFailed)+" "+exAttach.Message,  MessageSeverity.Error);
 | 
									App.Kp2a.ShowMessage(this, GetString(Resource.String.AttachFailed)+" "+ Util.GetErrorMessage(exAttach),  MessageSeverity.Error);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			State.EntryModified = true;
 | 
								State.EntryModified = true;
 | 
				
			||||||
			PopulateBinaries();
 | 
								PopulateBinaries();
 | 
				
			||||||
@@ -1184,7 +1184,7 @@ namespace keepass2android
 | 
				
			|||||||
                    }))
 | 
					                    }))
 | 
				
			||||||
                    .AddOnFailureListener(new FailureListener((e) =>
 | 
					                    .AddOnFailureListener(new FailureListener((e) =>
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Console.WriteLine($"Scan failed: {e.Message}");
 | 
					                        Console.WriteLine($"Scan failed: {Util.GetErrorMessage(e)}");
 | 
				
			||||||
                    }));
 | 
					                    }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,7 +140,7 @@ namespace keepass2android
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				catch (Exception ex)
 | 
									catch (Exception ex)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Finish(false, ex.Message);
 | 
										Finish(false, Util.GetErrorMessage(ex));
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -128,7 +128,7 @@ namespace keepass2android
 | 
				
			|||||||
					catch (Exception e)
 | 
										catch (Exception e)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						toastMsg = ctx.GetString(Resource.String.private_key_save_failed,
 | 
											toastMsg = ctx.GetString(Resource.String.private_key_save_failed,
 | 
				
			||||||
							new Java.Lang.Object[] { e.Message });
 | 
												new Java.Lang.Object[] { Util.GetErrorMessage(e)});
 | 
				
			||||||
                        severity = MessageSeverity.Error;
 | 
					                        severity = MessageSeverity.Error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -543,7 +543,7 @@ namespace keepass2android
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception e) 
 | 
					            catch (Exception e) 
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
				App.Kp2a.ShowMessage(this, e.Message,  MessageSeverity.Error);
 | 
									App.Kp2a.ShowMessage(this, Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			return password;
 | 
								return password;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -148,17 +148,13 @@ namespace KeeChallenge
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    //read the secret from the stream
 | 
					                    //read the secret from the stream
 | 
				
			||||||
                    int totalBytesRead = 0;
 | 
					                    int totalBytesRead = 0;
 | 
				
			||||||
                    byte[] buffer = new byte[secret.Length];
 | 
					 | 
				
			||||||
                    var secretOutputStream = new MemoryStream(secret);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    int bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead);
 | 
					                    int bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead);
 | 
				
			||||||
                    while (bytesRead > 0 && totalBytesRead < secret.Length)
 | 
					                    while (bytesRead > 0 && totalBytesRead < secret.Length)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        secretOutputStream.Write(buffer, 0, bytesRead);
 | 
					 | 
				
			||||||
                        totalBytesRead += bytesRead;
 | 
					                        totalBytesRead += bytesRead;
 | 
				
			||||||
                        bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead);
 | 
					                        bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    secretOutputStream.Close();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    csDecrypt.Close();
 | 
					                    csDecrypt.Close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -310,7 +310,7 @@ namespace keepass2android
 | 
				
			|||||||
		            catch (Exception e)
 | 
							            catch (Exception e)
 | 
				
			||||||
		            {
 | 
							            {
 | 
				
			||||||
		                Kp2aLog.Log(e.ToString());
 | 
							                Kp2aLog.Log(e.ToString());
 | 
				
			||||||
		                App.Kp2a.ShowMessage(this, "Error: " + e.Message,  MessageSeverity.Error);
 | 
							                App.Kp2a.ShowMessage(this, "Error: " + Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
		                return;
 | 
							                return;
 | 
				
			||||||
		            }
 | 
							            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1485,7 +1485,7 @@ namespace keepass2android
 | 
				
			|||||||
				catch (Exception e)
 | 
									catch (Exception e)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Kp2aLog.LogUnexpectedError(e);
 | 
										Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
					errorMessage = e.Message;
 | 
										errorMessage = Util.GetErrorMessage(e);
 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -2273,7 +2273,7 @@ namespace keepass2android
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					Kp2aLog.LogUnexpectedError(e);
 | 
										Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					ShowError( _act.GetString(Resource.String.ErrorUpdatingOtpAuxFile) + " " + e.Message);
 | 
										ShowError( _act.GetString(Resource.String.ErrorUpdatingOtpAuxFile) + " " + Util.GetErrorMessage(e));
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,7 +121,7 @@ namespace keepass2android
 | 
				
			|||||||
                
 | 
					                
 | 
				
			||||||
            } catch (Exception e)
 | 
					            } catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				App.Kp2a.ShowMessage(this, e.Message,  MessageSeverity.Error);
 | 
									App.Kp2a.ShowMessage(this, Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
				SetResult(Result.Canceled);
 | 
									SetResult(Result.Canceled);
 | 
				
			||||||
				Finish();
 | 
									Finish();
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ namespace keepass2android
 | 
				
			|||||||
                catch (Exception e)
 | 
					                catch (Exception e)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Finish(false, e.Message);
 | 
					                    Finish(false, Util.GetErrorMessage(e));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,10 +37,12 @@ using Android.Util;
 | 
				
			|||||||
using Android.Views.InputMethods;
 | 
					using Android.Views.InputMethods;
 | 
				
			||||||
using AndroidX.Core.View.InputMethod;
 | 
					using AndroidX.Core.View.InputMethod;
 | 
				
			||||||
using Google.Android.Material.Dialog;
 | 
					using Google.Android.Material.Dialog;
 | 
				
			||||||
 | 
					using KeePass.Util;
 | 
				
			||||||
using keepass2android;
 | 
					using keepass2android;
 | 
				
			||||||
using KeePassLib;
 | 
					using KeePassLib;
 | 
				
			||||||
using KeePassLib.Security;
 | 
					using KeePassLib.Security;
 | 
				
			||||||
using KeePassLib.Serialization;
 | 
					using KeePassLib.Serialization;
 | 
				
			||||||
 | 
					using Org.Apache.Http.Util;
 | 
				
			||||||
using Uri = Android.Net.Uri;
 | 
					using Uri = Android.Net.Uri;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -198,6 +200,12 @@ namespace keepass2android
 | 
				
			|||||||
            ioc.CredSaveMode = (IOCredSaveMode)i.GetIntExtra(prefix + KeyServercredmode, (int)IOCredSaveMode.NoSave);
 | 
					            ioc.CredSaveMode = (IOCredSaveMode)i.GetIntExtra(prefix + KeyServercredmode, (int)IOCredSaveMode.NoSave);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static string GetErrorMessage(Exception e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return ExceptionUtil.GetErrorMessage(e);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static Bitmap DrawableToBitmap(Drawable drawable)
 | 
					        public static Bitmap DrawableToBitmap(Drawable drawable)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Bitmap bitmap = null;
 | 
					            Bitmap bitmap = null;
 | 
				
			||||||
@@ -865,8 +873,6 @@ namespace keepass2android
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            entry.Strings.Set(prefix + c, new ProtectedString(false, url));
 | 
					            entry.Strings.Set(prefix + c, new ProtectedString(false, url));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -836,7 +836,7 @@ namespace keepass2android
 | 
				
			|||||||
							new DropboxAppFolderFileStorage(LocaleManager.LocalizedAppContext, this),
 | 
												new DropboxAppFolderFileStorage(LocaleManager.LocalizedAppContext, this),
 | 
				
			||||||
                            GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveFileStorage(LocaleManager.LocalizedAppContext, this) : null,
 | 
					                            GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveFileStorage(LocaleManager.LocalizedAppContext, this) : null,
 | 
				
			||||||
                            GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveAppDataFileStorage(LocaleManager.LocalizedAppContext, this) : null,
 | 
					                            GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(LocaleManager.LocalizedAppContext)==ConnectionResult.Success ? new GoogleDriveAppDataFileStorage(LocaleManager.LocalizedAppContext, this) : null,
 | 
				
			||||||
							new OneDriveFileStorage(),
 | 
												new OneDriveFileStorage(this),
 | 
				
			||||||
						    new OneDrive2FullFileStorage(),
 | 
											    new OneDrive2FullFileStorage(),
 | 
				
			||||||
						    new OneDrive2MyFilesFileStorage(),
 | 
											    new OneDrive2MyFilesFileStorage(),
 | 
				
			||||||
						    new OneDrive2AppFolderFileStorage(),
 | 
											    new OneDrive2AppFolderFileStorage(),
 | 
				
			||||||
@@ -1043,9 +1043,9 @@ namespace keepass2android
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private string GetErrorMessageForFileStorageException(Exception e)
 | 
							private string GetErrorMessageForFileStorageException(Exception e)
 | 
				
			||||||
		{
 | 
					        {
 | 
				
			||||||
			string errorMessage = e.Message;
 | 
					            var errorMessage = Util.GetErrorMessage(e);
 | 
				
			||||||
			if (e is OfflineModeException)
 | 
					            if (e is OfflineModeException)
 | 
				
			||||||
				errorMessage = GetResourceString(UiStringKey.InOfflineMode);
 | 
									errorMessage = GetResourceString(UiStringKey.InOfflineMode);
 | 
				
			||||||
		    if (e is DocumentAccessRevokedException)
 | 
							    if (e is DocumentAccessRevokedException)
 | 
				
			||||||
		        errorMessage = GetResourceString(UiStringKey.DocumentAccessRevoked);
 | 
							        errorMessage = GetResourceString(UiStringKey.DocumentAccessRevoked);
 | 
				
			||||||
@@ -1054,7 +1054,7 @@ namespace keepass2android
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public void CouldntOpenFromRemote(IOConnectionInfo ioc, Exception ex)
 | 
					        public void CouldntOpenFromRemote(IOConnectionInfo ioc, Exception ex)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			var errorMessage = GetErrorMessageForFileStorageException(ex);
 | 
								var errorMessage = GetErrorMessageForFileStorageException(ex);
 | 
				
			||||||
			ShowToast(LocaleManager.LocalizedAppContext.GetString(Resource.String.CouldNotLoadFromRemote, errorMessage), MessageSeverity.Error);
 | 
								ShowToast(LocaleManager.LocalizedAppContext.GetString(Resource.String.CouldNotLoadFromRemote, errorMessage), MessageSeverity.Error);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,7 +71,7 @@ namespace keepass2android
 | 
				
			|||||||
			catch (Exception e)
 | 
								catch (Exception e)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (errorMessageBuilder != null)
 | 
									if (errorMessageBuilder != null)
 | 
				
			||||||
					errorMessageBuilder.Append(e.Message);
 | 
										errorMessageBuilder.Append(Util.GetErrorMessage(e));
 | 
				
			||||||
				Kp2aLog.Log(e.ToString());
 | 
									Kp2aLog.Log(e.ToString());
 | 
				
			||||||
				return null;
 | 
									return null;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -487,7 +487,7 @@ namespace keepass2android
 | 
				
			|||||||
            catch (Exception e)
 | 
					            catch (Exception e)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Kp2aLog.LogUnexpectedError(e);
 | 
					                Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
                App.Kp2a.ShowMessage(this, "Error: " + e.Message,  MessageSeverity.Error);
 | 
					                App.Kp2a.ShowMessage(this, "Error: " + Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
                Finish();
 | 
					                Finish();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -142,7 +142,7 @@ namespace keepass2android.search
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            } catch (Exception e) {
 | 
					            } catch (Exception e) {
 | 
				
			||||||
				Kp2aLog.LogUnexpectedError(e);
 | 
									Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
				App.Kp2a.ShowMessage(this,e.Message,  MessageSeverity.Error);
 | 
									App.Kp2a.ShowMessage(this, Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
				Finish();
 | 
									Finish();
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,7 +96,7 @@ namespace keepass2android.search
 | 
				
			|||||||
            catch (Exception e)
 | 
					            catch (Exception e)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Kp2aLog.LogUnexpectedError(e);
 | 
					                Kp2aLog.LogUnexpectedError(e);
 | 
				
			||||||
                App.Kp2a.ShowMessage(this, e.Message,  MessageSeverity.Error);
 | 
					                App.Kp2a.ShowMessage(this, Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
                Finish();
 | 
					                Finish();
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,7 +156,7 @@ namespace keepass2android.services.AutofillBase
 | 
				
			|||||||
                catch (Java.Lang.SecurityException e)
 | 
					                catch (Java.Lang.SecurityException e)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Log.Warn(CommonUtil.Tag, "Security exception handling request");
 | 
					                    Log.Warn(CommonUtil.Tag, "Security exception handling request");
 | 
				
			||||||
                    callback.OnFailure(e.Message);
 | 
					                    callback.OnFailure(Util.GetErrorMessage(e));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -455,7 +455,7 @@ namespace keepass2android.services.AutofillBase
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception e)
 | 
					            catch (Exception e)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                callback.OnFailure(e.Message);   
 | 
					                callback.OnFailure(Util.GetErrorMessage(e));   
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -261,7 +261,7 @@ namespace keepass2android
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        return () =>
 | 
					                        return () =>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            App.Kp2a.ShowMessage(Activity, App.Kp2a.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message,  MessageSeverity.Error);
 | 
					                            App.Kp2a.ShowMessage(Activity, App.Kp2a.GetResourceString(UiStringKey.ErrorOcurred) + " " + Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -357,7 +357,7 @@ namespace keepass2android
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        return () =>
 | 
					                        return () =>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            App.Kp2a.ShowMessage(Activity, App.Kp2a.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message,  MessageSeverity.Error);
 | 
					                            App.Kp2a.ShowMessage(Activity, App.Kp2a.GetResourceString(UiStringKey.ErrorOcurred) + " " + Util.GetErrorMessage(e),  MessageSeverity.Error);
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -628,7 +628,7 @@ namespace keepass2android
 | 
				
			|||||||
                            catch (Exception ex)
 | 
					                            catch (Exception ex)
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                Kp2aLog.LogUnexpectedError(ex);
 | 
					                                Kp2aLog.LogUnexpectedError(ex);
 | 
				
			||||||
                                App.Kp2a.ShowMessage(LocaleManager.LocalizedAppContext, ex.Message,  MessageSeverity.Error);
 | 
					                                App.Kp2a.ShowMessage(LocaleManager.LocalizedAppContext, Util.GetErrorMessage(ex),  MessageSeverity.Error);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,7 @@ namespace keepass2android
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex)
 | 
					                catch (Exception ex)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Finish(false, ex.Message);
 | 
					                    Finish(false, Util.GetErrorMessage(ex));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user