Compare commits
10 Commits
pcloud-hel
...
1.05d-none
Author | SHA1 | Date | |
---|---|---|---|
![]() |
832d3b3a95 | ||
![]() |
37867634cd | ||
![]() |
d9713f8e18 | ||
![]() |
c583b58cb9 | ||
![]() |
bfeaf5dbf5 | ||
![]() |
0907fa5685 | ||
![]() |
ff8dc76c75 | ||
![]() |
0b09e2790f | ||
![]() |
781350aa5f | ||
![]() |
9716130336 |
10
crowdin.yml
10
crowdin.yml
@@ -1,10 +0,0 @@
|
||||
files:
|
||||
- source: src/keepass2android/Resources/values/strings.xml
|
||||
translation: >-
|
||||
/src/keepass2android/Resources/values-%two_letters_code%/%original_file_name%
|
||||
translate_attributes: '0'
|
||||
content_segmentation: '0'
|
||||
languages_mapping:
|
||||
two_letters_code:
|
||||
zh-CN: zh
|
||||
zh-TW: zh-rTW
|
@@ -7,12 +7,11 @@ If you think something is missing in the documentation, please create an issue a
|
||||
If you store important information using Keepass2Android, you should know a little bit about what's going on:
|
||||
* Keepass2Android stores your password in an encrypted file. It is *your responsibility* to backup this file regularly and safely.
|
||||
* There is no way for anyone, including the app's author, to access the information stored in your password database without
|
||||
* having the database file
|
||||
* knowing the master password (and additional second factor if you chose one)
|
||||
This means that **if you forget the master password, your database is lost**! So make sure you remember the password and retain any second factor method (if one is used).
|
||||
* You might also want to think about:
|
||||
* What happens if I have an accident? Should any trusted person be able to access my database?
|
||||
* What happens if my phone gets lost or stolen? Do I know how to recover my database from a backup or the cloud?
|
||||
** having the database file
|
||||
** knowing the master password (and additional second factor if you chose one)
|
||||
This means that **if you forget the master password, your database is lost**! So make sure you remember the password. You might also want to think about:
|
||||
** What happens if I have an accident? Should any trusted person be able to access my database?
|
||||
** What happens if my phone gets lost or stolen? Do I know how to recover my database from a backup or the cloud?
|
||||
|
||||
|
||||
# Getting started
|
||||
|
@@ -4,28 +4,28 @@
|
||||
on how to set up a Keepass 2 database with Yubikey/OTP protection.<br>
|
||||
<br>
|
||||
After successful setup you should have the database file, e.g. yubi.kdbx, and the OTP auxiliary file, e.g. yubi.otp.xml, both in the same folder.<br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_OTPAuxFile_2.png"><img title="OTPAuxFile" src="How to use Keepass2Android with YubiKey NEO_OTPAuxFile_thumb.png" alt="OTPAuxFile" width="513" height="40" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767825"><img title="OTPAuxFile" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767826" alt="OTPAuxFile" width="513" height="40" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p>Make sure you make <strong>both files</strong> available to Keepass2Android, e.g. by placing them both in your Dropbox.</p>
|
||||
<p>Now you should check your NDEF setup of the Yubikey NEO. Therefore, go to the Tools menu in the Yubico Personalization Utility. Select the same slot as used for OTPs with Keepass 2. The default setting for NDEF type and payload should work. If you experience
|
||||
problems, you may use the configuration as shown in this screenshot or simply press the “Reset” button:</p>
|
||||
<p><a href="How to use Keepass2Android with YubiKey NEO_image_2.png"><img title="image" src="How to use Keepass2Android with YubiKey NEO_image_thumb.png" alt="image" width="760" height="622" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767911"><img title="image" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767912" alt="image" width="760" height="622" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><br>
|
||||
<br>
|
||||
In Keepass2Android, select "Open file" and locate your database file, e.g. yubi.kdbx.<br>
|
||||
<br>
|
||||
In the password screen under "Select master key type" select "Password + OTP".</p>
|
||||
<p><a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-50_2.png"><img title="Screenshot_2013-12-13-06-38-50" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-50_thumb.png" alt="Screenshot_2013-12-13-06-38-50" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767913"><img title="Screenshot_2013-12-13-06-38-50" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767914" alt="Screenshot_2013-12-13-06-38-50" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p>Click "Load auxiliary OTP file". This is required to load the information how many OTPs must be entered. As loading the file might require user action in some cases, this is not performed automatically.<br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-12_2.png"><img title="Screenshot_2013-12-13-06-38-12" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-12_thumb.png" alt="Screenshot_2013-12-13-06-38-12" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767915"><img title="Screenshot_2013-12-13-06-38-12" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767916" alt="Screenshot_2013-12-13-06-38-12" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
After loading the OTP auxiliary file, you should see a few text fields for entering the OTPs. Now swipe your YubiKey NEO at the back of your Android device. If you have multiple apps which can handle NFC actions, you might be prompted to select which app to
|
||||
use. Select Keepass2Android in this case. Swipe your YubiKey again until all OTP fields are filled. Note: You don't need to select the next text field, this is done automatically!<br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-36_2.png"><img title="Screenshot_2013-12-13-06-38-36" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-36_thumb.png" alt="Screenshot_2013-12-13-06-38-36" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767917"><img title="Screenshot_2013-12-13-06-38-36" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767918" alt="Screenshot_2013-12-13-06-38-36" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
Don't forget to also enter your password and click OK. You will see the “Saving auxiliary OTP file…” dialog. Note that there is some encryption envolved which is probably fast on your PC but might take some time on your mobile device. You
|
||||
can reduce the look-ahead window length to speed this up.<br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-39-47_2.png"><img title="Screenshot_2013-12-13-06-39-47" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-39-47_thumb.png" alt="Screenshot_2013-12-13-06-39-47" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767919"><img title="Screenshot_2013-12-13-06-39-47" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767920" alt="Screenshot_2013-12-13-06-39-47" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<h2> </h2>
|
||||
<h2>A note about offline access</h2>
|
||||
<p>If your database is stored in the cloud or on the web, you can still access it if you have enabled file caching (which is on by default). With OTPs, this becomes a little bit more complicated: If you repeatedly open your datbase while being offline, the
|
||||
OTP counter stored on the Yubikey will be increased. Don’t forget to synchronize the database (which will also synchronize the OTP auxiliary file) as soon as possible to avoid problems with accessing your database on other devices! If you often need
|
||||
to open the database while you’re offline, consider increasing the look-ahead window length!</p>
|
||||
</div><div class="ClearBoth"></div>
|
||||
</div><div class="ClearBoth"></div>
|
@@ -2,7 +2,7 @@ Keepass2Android's apk is pretty big, e.g. when comparing to Keepassdroid. The ma
|
||||
|
||||
Here's a list of what is contained in the Keepass2Android 0.9.1 application package:
|
||||
|
||||
```
|
||||
{{
|
||||
Mono for Android
|
||||
.net dlls 5.0 MB
|
||||
Runtime 2.5 MB
|
||||
@@ -22,4 +22,4 @@ Java/Mono bindings 0.5 MB
|
||||
rest 0.3 MB
|
||||
|
||||
TOTAL 13 MB
|
||||
```
|
||||
}}
|
@@ -1,6 +1,3 @@
|
||||
<h1 align="center"><img src="/src/keepass2android/Resources/mipmap-xxxhdpi/ic_launcher_online.png" align="center" width="100" alt="Keepass2Android Logo">Keepass2Android</h1>
|
||||
|
||||
|
||||
# What is Keepass2Android?
|
||||
Keepass2Android is a password manager app. It allows to store and retrieve passwords and other sensitive information in a file called "database". This database is secured with a so-called master password. The master password typically is a strong password and can be complemented with a second factor for additional security.
|
||||
The password database file can be synchronized across different devices. This works best using one of the built-in cloud storage options, but can also be performed with third-party apps. Keepass2Android is compatible with Keepass 1 and Keepass 2 on Windows and KeepassX on Linux.
|
||||
@@ -18,4 +15,4 @@ Beta-releases can be obtained by opting in to the [Beta testing channel](https:/
|
||||
# How do I learn more?
|
||||
Please see the [documentation](Documentation.md).
|
||||
|
||||
[](https://www.bitrise.io/app/43a23ab54dee9f7e)
|
||||
[](https://www.bitrise.io/app/43a23ab54dee9f7e)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0B109C0E-0514-4340-8779-5BD6A0DDE84E}</ProjectGuid>
|
||||
<ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AdalBindings</RootNamespace>
|
||||
<AssemblyName>AdalBindings</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\adal-1.14.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
<TransformFile Include="Transforms\EnumFields.xml" />
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\gson-2.3.1.jar" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -1,48 +0,0 @@
|
||||
Additions allow you to add arbitrary C# to the generated classes
|
||||
before they are compiled. This can be helpful for providing convenience
|
||||
methods or adding pure C# classes.
|
||||
|
||||
== Adding Methods to Generated Classes ==
|
||||
|
||||
Let's say the library being bound has a Rectangle class with a constructor
|
||||
that takes an x and y position, and a width and length size. It will look like
|
||||
this:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
// JNI bindings
|
||||
}
|
||||
}
|
||||
|
||||
Imagine we want to add a constructor to this class that takes a Point and
|
||||
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
|
||||
with a partial class containing our new method:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (Point location, Size size) :
|
||||
this (location.X, location.Y, size.Width, size.Height)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
At compile time, the additions class will be added to the generated class
|
||||
and the final assembly will a Rectangle class with both constructors.
|
||||
|
||||
|
||||
== Adding C# Classes ==
|
||||
|
||||
Another thing that can be done is adding fully C# managed classes to the
|
||||
generated library. In the above example, let's assume that there isn't a
|
||||
Point class available in Java or our library. The one we create doesn't need
|
||||
to interact with Java, so we'll create it like a normal class in C#.
|
||||
|
||||
By adding a Point.cs file with this class, it will end up in the binding library:
|
||||
|
||||
public class Point
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
This directory is for Android .jars.
|
||||
|
||||
There are 2 types of jars that are supported:
|
||||
|
||||
== Input Jar ==
|
||||
|
||||
This is the jar that bindings should be generated for.
|
||||
|
||||
For example, if you were binding the Google Maps library, this would
|
||||
be Google's "maps.jar".
|
||||
|
||||
Set the build action for these jars in the properties page to "InputJar".
|
||||
|
||||
|
||||
== Reference Jars ==
|
||||
|
||||
These are jars that are referenced by the input jar. C# bindings will
|
||||
not be created for these jars. These jars will be used to resolve
|
||||
types used by the input jar.
|
||||
|
||||
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
|
||||
based on the Target Framework selected.
|
||||
|
||||
Set the build action for these jars in the properties page to "ReferenceJar".
|
Binary file not shown.
@@ -1,30 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AdalBindings")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AdalBindings")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -1,14 +0,0 @@
|
||||
<enum-field-mappings>
|
||||
<!--
|
||||
This example converts the constants Fragment_id, Fragment_name,
|
||||
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
|
||||
to an enum called Android.Support.V4.App.FragmentTagType with values
|
||||
Id, Name, and Tag.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
|
||||
<field jni-name="Fragment_name" clr-name="Name" value="0" />
|
||||
<field jni-name="Fragment_id" clr-name="Id" value="1" />
|
||||
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-field-mappings>
|
@@ -1,13 +0,0 @@
|
||||
<enum-method-mappings>
|
||||
<!--
|
||||
This example changes the Java method:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
|
||||
to be:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
|
||||
when bound in C#.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
|
||||
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-method-mappings>
|
@@ -1,13 +0,0 @@
|
||||
<metadata>
|
||||
<!--
|
||||
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
|
||||
|
||||
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
|
||||
-->
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']/class[@name='AuthenticationActivity']" />
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']/class[@name='DateTimeAdapter']" />
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']" />
|
||||
|
||||
</metadata>
|
@@ -26,7 +26,6 @@
|
||||
android:hint="@string/http_auth_dialog_password"
|
||||
android:inputType="textPassword"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:importantForAccessibility="no" />
|
||||
android:paddingBottom="20dp" />
|
||||
|
||||
</LinearLayout>
|
@@ -60,6 +60,7 @@
|
||||
</LibraryProjectZip>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\adal-1.14.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
@@ -80,9 +81,6 @@
|
||||
<Visible>False</Visible>
|
||||
</XamarinComponentReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PCloudBindings\PCloudBindings.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\okhttp-digest-1.7.jar" />
|
||||
</ItemGroup>
|
||||
|
@@ -11,8 +11,6 @@
|
||||
<remove-node path="/api/package[@name='com.jcraft.jsch.jcraft']" />
|
||||
<remove-node path="/api/package[@name='com.jcraft.jzlib']" />
|
||||
|
||||
<remove-node path="/api/package[@name='com.pcloud.sdk']" />
|
||||
|
||||
<remove-node path="/api/package[@name='com.dropbox.core']" />
|
||||
<remove-node path="/api/package[@name='com.dropbox.core.util']" />
|
||||
<remove-node path="/api/package[@name='com.dropbox.core.http']" />
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27004.2009
|
||||
VisualStudioVersion = 15.0.27130.2010
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeePassLib2Android", "KeePassLib2Android\KeePassLib2Android.csproj", "{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}"
|
||||
EndProject
|
||||
@@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kp2aBusinessLogic", "Kp2aBu
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwofishCipher", "TwofishCipher\TwofishCipher.csproj", "{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaFileStorageBindings", "JavaFileStorageBindings\JavaFileStorageBindings.csproj", "{48574278-4779-4B3A-A9E4-9CF1BC285D0B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidFileChooserBinding", "AndroidFileChooserBinding\AndroidFileChooserBinding.csproj", "{3C0F7FE5-639F-4422-A087-8B26CF862D1B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KP2AKdbLibraryBinding", "KP2AKdbLibraryBinding\KP2AKdbLibraryBinding.csproj", "{70D3844A-D9FA-4A64-B205-A84C6A822196}"
|
||||
@@ -23,12 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginSdkBinding", "PluginS
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZlibAndroid", "ZlibAndroid\ZlibAndroid.csproj", "{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.FtpClient.Android", "netftpandroid\System.Net.FtpClient\System.Net.FtpClient.Android.csproj", "{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungPass", "SamsungPass\Xamarin.SamsungPass\SamsungPass\SamsungPass.csproj", "{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCloudBindings", "PCloudBindings\PCloudBindings.csproj", "{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -111,8 +105,8 @@ Global
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -153,30 +147,6 @@ Global
|
||||
{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Win32.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|x64.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
@@ -189,8 +159,8 @@ Global
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -207,8 +177,8 @@ Global
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -225,8 +195,8 @@ Global
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -255,24 +225,6 @@ Global
|
||||
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|Win32.Build.0 = Release|Any CPU
|
||||
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
|
||||
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.Build.0 = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
@@ -291,30 +243,6 @@ Global
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Win32.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|x64.Build.0 = ReleaseNoNet|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@@ -21,7 +21,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using keepass2android;
|
||||
|
||||
#if KeePassUAP
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
@@ -144,7 +144,6 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
||||
ulong uNumRounds)
|
||||
{
|
||||
Kp2aLog.Log("Warning: transforming key managed. Expect this to be slow!");
|
||||
#if KeePassUAP
|
||||
KeyParameter kp = new KeyParameter(pbKeySeed32);
|
||||
AesEngine aes = new AesEngine();
|
||||
|
@@ -38,11 +38,9 @@ namespace KeePassLib.Keys
|
||||
get;
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Clear the key and securely erase all security-critical information.
|
||||
// /// </summary>
|
||||
// void Clear();
|
||||
|
||||
uint GetMinKdbxVersion();
|
||||
// /// <summary>
|
||||
// /// Clear the key and securely erase all security-critical information.
|
||||
// /// </summary>
|
||||
// void Clear();
|
||||
}
|
||||
}
|
||||
|
@@ -45,12 +45,7 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKey; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public KcpCustomKey(string strName, byte[] pbKeyData, bool bPerformHash)
|
||||
public KcpCustomKey(string strName, byte[] pbKeyData, bool bPerformHash)
|
||||
{
|
||||
Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName");
|
||||
Debug.Assert(pbKeyData != null); if(pbKeyData == null) throw new ArgumentNullException("pbKeyData");
|
||||
|
@@ -64,12 +64,7 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public IOConnectionInfo Ioc
|
||||
public IOConnectionInfo Ioc
|
||||
{
|
||||
get { return m_ioc; }
|
||||
}
|
||||
|
@@ -53,12 +53,7 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public KcpPassword(byte[] pbPasswordUtf8)
|
||||
public KcpPassword(byte[] pbPasswordUtf8)
|
||||
{
|
||||
SetKey(pbPasswordUtf8);
|
||||
}
|
||||
|
@@ -60,12 +60,7 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Construct a user account key.
|
||||
/// </summary>
|
||||
public KcpUserAccount()
|
||||
|
@@ -85,8 +85,8 @@ namespace keepass2android
|
||||
{
|
||||
if (!File.Exists(LogFilename))
|
||||
{
|
||||
File.Create(LogFilename).Dispose();
|
||||
_logToFile = true;
|
||||
File.Create(LogFilename);
|
||||
_logToFile = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ namespace keepass2android
|
||||
int count = 0;
|
||||
while (File.Exists(LogFilename + "." + count))
|
||||
count++;
|
||||
File.Move(LogFilename, LogFilename + "." + count);
|
||||
if (count > 0)
|
||||
File.Move(LogFilename, LogFilename + "." + count);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -302,7 +302,7 @@ namespace KeePassLib.Native
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.Log(e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -485,6 +485,12 @@ namespace KeePassLib
|
||||
set { m_pbHashOfLastIO = value; }
|
||||
}
|
||||
|
||||
public bool UseFileTransactions
|
||||
{
|
||||
get { return m_bUseFileTransactions; }
|
||||
set { m_bUseFileTransactions = value; }
|
||||
}
|
||||
|
||||
public bool UseFileLocks
|
||||
{
|
||||
get { return m_bUseFileLocks; }
|
||||
|
@@ -360,12 +360,5 @@ namespace KeePassLib.Serialization
|
||||
m_ioCredProtMode = IOCredProtMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSameFileAs(IOConnectionInfo other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Path == other.Path && UserName == other.UserName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -127,8 +126,8 @@ namespace KeePassLib.Serialization
|
||||
/// </summary>
|
||||
private const uint FileVersion32 = 0x00040000;
|
||||
|
||||
public const uint FileVersion32_4 = 0x00040000; // First of 4.x series
|
||||
public const uint FileVersion32_3 = 0x00030001; // Old format 3.1
|
||||
internal const uint FileVersion32_4 = 0x00040000; // First of 4.x series
|
||||
internal const uint FileVersion32_3 = 0x00030001; // Old format 3.1
|
||||
|
||||
private const uint FileVersionCriticalMask = 0xFFFF0000;
|
||||
|
||||
@@ -373,19 +372,16 @@ namespace KeePassLib.Serialization
|
||||
{
|
||||
if(m_uForceVersion != 0) return m_uForceVersion;
|
||||
|
||||
// See also KeePassKdb2x3.Export (KDBX 3.1 export module)
|
||||
uint minVersionForKeys = m_pwDatabase.MasterKey.UserKeys.Select(key => key.GetMinKdbxVersion()).Max();
|
||||
|
||||
AesKdf kdfAes = new AesKdf();
|
||||
// See also KeePassKdb2x3.Export (KDBX 3.1 export module)
|
||||
|
||||
AesKdf kdfAes = new AesKdf();
|
||||
if(!kdfAes.Uuid.Equals(m_pwDatabase.KdfParameters.KdfUuid))
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
return FileVersion32;
|
||||
|
||||
if(m_pwDatabase.PublicCustomData.Count > 0)
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
return FileVersion32;
|
||||
|
||||
|
||||
|
||||
bool bCustomData = false;
|
||||
bool bCustomData = false;
|
||||
GroupHandler gh = delegate(PwGroup pg)
|
||||
{
|
||||
if(pg == null) { Debug.Assert(false); return true; }
|
||||
@@ -400,10 +396,9 @@ namespace KeePassLib.Serialization
|
||||
};
|
||||
gh(m_pwDatabase.RootGroup);
|
||||
m_pwDatabase.RootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh);
|
||||
if(bCustomData)
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
if(bCustomData) return FileVersion32;
|
||||
|
||||
return Math.Max(FileVersion32_3, minVersionForKeys); ; // KDBX 3.1 is sufficient
|
||||
return FileVersion32_3; // KDBX 3.1 is sufficient
|
||||
}
|
||||
|
||||
private void ComputeKeys(out byte[] pbCipherKey, int cbCipherKey,
|
||||
|
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using keepass2android.Io;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
using KeePassLib.Utility;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public class ElementAndDatabaseId
|
||||
{
|
||||
private const char Separator = '+';
|
||||
|
||||
public ElementAndDatabaseId(Database db, IStructureItem element)
|
||||
{
|
||||
DatabaseId = db.IocAsHexString();
|
||||
ElementIdString = element.Uuid.ToHexString();
|
||||
}
|
||||
|
||||
public ElementAndDatabaseId(string fullId)
|
||||
{
|
||||
string[] parts = fullId.Split(Separator);
|
||||
if (parts.Length != 2)
|
||||
throw new Exception("Invalid full id " + fullId);
|
||||
DatabaseId = parts[0];
|
||||
ElementIdString = parts[1];
|
||||
}
|
||||
|
||||
public string DatabaseId { get; set; }
|
||||
public string ElementIdString { get; set; }
|
||||
public PwUuid ElementId { get { return new PwUuid(MemUtil.HexStringToByteArray(ElementIdString));} }
|
||||
|
||||
public string FullId
|
||||
{
|
||||
get { return DatabaseId + Separator + ElementIdString; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Android.App;
|
||||
@@ -10,7 +9,6 @@ using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
using keepass2android.Io;
|
||||
using KeePassLib.Interfaces;
|
||||
#if !NoNet
|
||||
using Keepass2android.Javafilestorage;
|
||||
#endif
|
||||
@@ -35,41 +33,31 @@ namespace keepass2android
|
||||
/// This also contains methods which are UI specific and should be replacable for testing.
|
||||
public interface IKp2aApp : ICertificateValidationHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Locks all currently open databases, quicklocking if available (unless false is passed for allowQuickUnlock)
|
||||
/// </summary>
|
||||
void Lock(bool allowQuickUnlock);
|
||||
/// <summary>
|
||||
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
|
||||
/// </summary>
|
||||
void LockDatabase(bool allowQuickUnlock = true);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the specified data as the currently open database, as unlocked.
|
||||
/// </summary>
|
||||
void LoadDatabase(IOConnectionInfo ioConnectionInfo, MemoryStream memoryStream, CompositeKey compKey,
|
||||
ProgressDialogStatusLogger statusLogger, IDatabaseFormat databaseFormat);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the specified data as the currently open database, as unlocked.
|
||||
/// </summary>
|
||||
Database LoadDatabase(IOConnectionInfo ioConnectionInfo, MemoryStream memoryStream, CompositeKey compKey, ProgressDialogStatusLogger statusLogger, IDatabaseFormat databaseFormat, bool makeCurrent);
|
||||
/// <summary>
|
||||
/// Returns the current database
|
||||
/// </summary>
|
||||
Database GetDb();
|
||||
|
||||
|
||||
HashSet<PwGroup> DirtyGroups { get; }
|
||||
|
||||
void MarkAllGroupsAsDirty();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current database
|
||||
/// </summary>
|
||||
Database CurrentDb { get; }
|
||||
|
||||
IEnumerable<Database> OpenDatabases { get; }
|
||||
void CloseDatabase(Database db);
|
||||
|
||||
Database FindDatabaseForElement(IStructureItem element);
|
||||
|
||||
/// <summary>
|
||||
/// Tell the app that the file from ioc was opened with keyfile.
|
||||
/// </summary>
|
||||
void StoreOpenedFileAsRecent(IOConnectionInfo ioc, string keyfile, bool updateTimestamp, string displayName = "");
|
||||
/// <summary>
|
||||
/// Tell the app that the file from ioc was opened with keyfile.
|
||||
/// </summary>
|
||||
void StoreOpenedFileAsRecent(IOConnectionInfo ioc, string keyfile, string displayName = "");
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new database and returns it
|
||||
/// </summary>
|
||||
Database CreateNewDatabase(bool makeCurrent);
|
||||
Database CreateNewDatabase();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the user-displayable string identified by stringKey
|
||||
@@ -88,8 +76,7 @@ namespace keepass2android
|
||||
EventHandler<DialogClickEventArgs> yesHandler,
|
||||
EventHandler<DialogClickEventArgs> noHandler,
|
||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
||||
Context ctx,
|
||||
string messageSuffix = "");
|
||||
Context ctx);
|
||||
|
||||
/// <summary>
|
||||
/// Asks the user the question "messageKey" with the options Yes/No/Cancel, but the yes/no strings can be selected freely, calls the handler corresponding to the answer.
|
||||
@@ -99,8 +86,7 @@ namespace keepass2android
|
||||
EventHandler<DialogClickEventArgs> yesHandler,
|
||||
EventHandler<DialogClickEventArgs> noHandler,
|
||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
||||
Context ctx,
|
||||
string messageSuffix = "");
|
||||
Context ctx);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a Handler object which can run tasks on the UI thread
|
||||
@@ -125,10 +111,6 @@ namespace keepass2android
|
||||
bool CheckForDuplicateUuids { get; }
|
||||
#if !NoNet
|
||||
ICertificateErrorHandler CertificateErrorHandler { get; }
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
@@ -10,7 +10,6 @@ using Android.OS;
|
||||
using Android.Provider;
|
||||
using Java.IO;
|
||||
using KeePassLib.Serialization;
|
||||
using KeePassLib.Utility;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace keepass2android.Io
|
||||
@@ -78,9 +77,8 @@ namespace keepass2android.Io
|
||||
|
||||
public string GetFilenameWithoutPathAndExt(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.StripExtension(
|
||||
UrlUtil.GetFileName(ioc.Path));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
@@ -207,7 +205,8 @@ namespace keepass2android.Io
|
||||
|
||||
public IOConnectionInfo GetParentPath(IOConnectionInfo ioc)
|
||||
{
|
||||
return IoUtil.GetParentPath(ioc);
|
||||
//TODO: required for OTP Aux file retrieval
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IOConnectionInfo GetFilePath(IOConnectionInfo folderPath, string filename)
|
||||
|
@@ -255,8 +255,7 @@ namespace keepass2android.Io
|
||||
if (ioc.IsLocalFile())
|
||||
{
|
||||
bool requiresPermission = !(ioc.Path.StartsWith(activity.Activity.FilesDir.CanonicalPath)
|
||||
|| ioc.Path.StartsWith(IoUtil.GetInternalDirectory(activity.Activity).CanonicalPath)
|
||||
|| ioc.Path.StartsWith(IoUtil.GetInternalDirectory(activity.Activity).CanonicalPath));
|
||||
|| ioc.Path.StartsWith(IoUtil.GetInternalDirectory(activity.Activity).CanonicalPath));
|
||||
|
||||
var extDirectory = activity.Activity.GetExternalFilesDir(null);
|
||||
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))
|
||||
|
@@ -65,28 +65,22 @@ namespace keepass2android.Io
|
||||
|
||||
protected readonly OfflineSwitchableFileStorage _cachedStorage;
|
||||
private readonly ICacheSupervisor _cacheSupervisor;
|
||||
private readonly string _legacyCacheDir;
|
||||
private readonly string _cacheDir;
|
||||
private readonly string _streamCacheDir;
|
||||
|
||||
public CachingFileStorage(IFileStorage cachedStorage, Context cacheDirContext, ICacheSupervisor cacheSupervisor)
|
||||
public CachingFileStorage(IFileStorage cachedStorage, string cacheDir, ICacheSupervisor cacheSupervisor)
|
||||
{
|
||||
_cachedStorage = new OfflineSwitchableFileStorage(cachedStorage);
|
||||
_cacheSupervisor = cacheSupervisor;
|
||||
_legacyCacheDir = cacheDirContext.CacheDir.Path + Java.IO.File.Separator + "OfflineCache" + Java.IO.File.Separator;
|
||||
if (!Directory.Exists(_legacyCacheDir))
|
||||
Directory.CreateDirectory(_legacyCacheDir);
|
||||
|
||||
_cacheDir = IoUtil.GetInternalDirectory(cacheDirContext).Path + Java.IO.File.Separator + "OfflineCache" + Java.IO.File.Separator;
|
||||
if (!Directory.Exists(_cacheDir))
|
||||
Directory.CreateDirectory(_cacheDir);
|
||||
|
||||
}
|
||||
_streamCacheDir = cacheDir + Java.IO.File.Separator + "OfflineCache" + Java.IO.File.Separator;
|
||||
if (!Directory.Exists(_streamCacheDir))
|
||||
Directory.CreateDirectory(_streamCacheDir);
|
||||
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
IoUtil.DeleteDir(new Java.IO.File(_legacyCacheDir), true);
|
||||
IoUtil.DeleteDir(new Java.IO.File(_cacheDir), true);
|
||||
}
|
||||
IoUtil.DeleteDir(new Java.IO.File(_streamCacheDir), true);
|
||||
}
|
||||
|
||||
public IEnumerable<string> SupportedProtocols { get { return _cachedStorage.SupportedProtocols; } }
|
||||
|
||||
@@ -111,11 +105,7 @@ namespace keepass2android.Io
|
||||
{
|
||||
SHA256Managed sha256 = new SHA256Managed();
|
||||
string iocAsHexString = MemUtil.ByteArrayToHexString(sha256.ComputeHash(Encoding.Unicode.GetBytes(ioc.Path.ToCharArray())))+".cache";
|
||||
if (File.Exists(_legacyCacheDir + iocAsHexString))
|
||||
return _legacyCacheDir + iocAsHexString;
|
||||
|
||||
return _cacheDir + iocAsHexString;
|
||||
|
||||
return _streamCacheDir + iocAsHexString;
|
||||
}
|
||||
|
||||
public bool IsCached(IOConnectionInfo ioc)
|
||||
@@ -178,9 +168,7 @@ namespace keepass2android.Io
|
||||
if (!IsCached(ioc))
|
||||
throw;
|
||||
|
||||
#if DEBUG
|
||||
Kp2aLog.Log("couldn't open from remote " + ioc.Path);
|
||||
#endif
|
||||
Kp2aLog.Log("couldn't open from remote " + ioc.Path);
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
|
||||
_cacheSupervisor.CouldntOpenFromRemote(ioc, ex);
|
||||
@@ -357,7 +345,57 @@ namespace keepass2android.Io
|
||||
|
||||
private class CachedWriteTransaction: IWriteTransaction
|
||||
{
|
||||
|
||||
private class CachedWriteMemoryStream : MemoryStream
|
||||
{
|
||||
private readonly IOConnectionInfo ioc;
|
||||
private readonly CachingFileStorage _cachingFileStorage;
|
||||
private readonly bool _useFileTransaction;
|
||||
private bool _closed;
|
||||
|
||||
public CachedWriteMemoryStream(IOConnectionInfo ioc, CachingFileStorage cachingFileStorage, bool useFileTransaction)
|
||||
{
|
||||
this.ioc = ioc;
|
||||
_cachingFileStorage = cachingFileStorage;
|
||||
_useFileTransaction = useFileTransaction;
|
||||
}
|
||||
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if (_closed) return;
|
||||
|
||||
//write file to cache:
|
||||
//(note: this might overwrite local changes. It's assumed that a sync operation or check was performed before
|
||||
string hash;
|
||||
using (var hashingStream = new HashingStreamEx(File.Create(_cachingFileStorage.CachedFilePath(ioc)), true, new SHA256Managed()))
|
||||
{
|
||||
Position = 0;
|
||||
CopyTo(hashingStream);
|
||||
|
||||
hashingStream.Close();
|
||||
hash = MemUtil.ByteArrayToHexString(hashingStream.Hash);
|
||||
}
|
||||
|
||||
File.WriteAllText(_cachingFileStorage.VersionFilePath(ioc), hash);
|
||||
//update file on remote. This might overwrite changes there as well, see above.
|
||||
Position = 0;
|
||||
if (_cachingFileStorage.IsCached(ioc))
|
||||
{
|
||||
//if the file already is in the cache, it's ok if writing to remote fails.
|
||||
_cachingFileStorage.TryUpdateRemoteFile(this, ioc, _useFileTransaction, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if not, we don't accept a failure (e.g. invalid credentials would always remain a problem)
|
||||
_cachingFileStorage.UpdateRemoteFile(this, ioc, _useFileTransaction, hash);
|
||||
}
|
||||
|
||||
base.Close();
|
||||
|
||||
_closed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
private readonly bool _useFileTransaction;
|
||||
@@ -391,48 +429,17 @@ namespace keepass2android.Io
|
||||
|
||||
public Stream OpenFile()
|
||||
{
|
||||
_memoryStream = new MemoryStream();
|
||||
_memoryStream = new CachedWriteMemoryStream(_ioc, _cachingFileStorage, _useFileTransaction);
|
||||
return _memoryStream;
|
||||
}
|
||||
|
||||
public void CommitWrite()
|
||||
{
|
||||
//the transaction is committed in the stream's Close
|
||||
_committed = true;
|
||||
_memoryStream.Close();
|
||||
|
||||
//write file to cache:
|
||||
//(note: this might overwrite local changes. It's assumed that a sync operation or check was performed before
|
||||
|
||||
byte[] output = _memoryStream.ToArray();
|
||||
|
||||
string hash;
|
||||
using (var hashingStream = new HashingStreamEx(File.Create(_cachingFileStorage.CachedFilePath(_ioc)), true, new SHA256Managed()))
|
||||
{
|
||||
hashingStream.Write(output, 0, output.Length);
|
||||
|
||||
hashingStream.Close();
|
||||
hash = MemUtil.ByteArrayToHexString(hashingStream.Hash);
|
||||
}
|
||||
|
||||
File.WriteAllText(_cachingFileStorage.VersionFilePath(_ioc), hash);
|
||||
//create another memory stream which is open for reading again
|
||||
MemoryStream openMemStream = new MemoryStream(output);
|
||||
//update file on remote. This might overwrite changes there as well, see above.
|
||||
if (_cachingFileStorage.IsCached(_ioc))
|
||||
{
|
||||
//if the file already is in the cache, it's ok if writing to remote fails.
|
||||
_cachingFileStorage.TryUpdateRemoteFile(openMemStream, _ioc, _useFileTransaction, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if not, we don't accept a failure (e.g. invalid credentials would always remain a problem)
|
||||
_cachingFileStorage.UpdateRemoteFile(openMemStream, _ioc, _useFileTransaction, hash);
|
||||
}
|
||||
|
||||
openMemStream.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction)
|
||||
|
@@ -2,12 +2,12 @@ namespace keepass2android.Io
|
||||
{
|
||||
public partial class DropboxFileStorage
|
||||
{
|
||||
private const string AppKey = "dummy";
|
||||
private const string AppSecret = "dummy";
|
||||
private const string AppKey = "";
|
||||
private const string AppSecret = "";
|
||||
}
|
||||
public partial class DropboxAppFolderFileStorage
|
||||
{
|
||||
private const string AppKey = "dummy";
|
||||
private const string AppSecret = "dummy";
|
||||
private const string AppKey = "";
|
||||
private const string AppSecret = "";
|
||||
}
|
||||
}
|
||||
}
|
@@ -233,6 +233,7 @@ namespace keepass2android.Io
|
||||
|
||||
public FileDescription GetFileDescription(IOConnectionInfo ioc)
|
||||
{
|
||||
Kp2aLog.Log("GetFileDescription "+ioc.Path);
|
||||
try
|
||||
{
|
||||
return ConvertToFileDescription(Jfs.GetFileEntry(IocToPath(ioc)));
|
||||
@@ -301,9 +302,7 @@ namespace keepass2android.Io
|
||||
|
||||
public void OnResume(IFileStorageSetupActivity activity)
|
||||
{
|
||||
#if DEBUG
|
||||
Kp2aLog.Log("JFS/OnResume Ioc.Path=" +activity.Ioc.Path+". Path="+((IJavaFileStorageFileStorageSetupActivity)activity).Path);
|
||||
#endif
|
||||
_jfs.OnResume(((IJavaFileStorageFileStorageSetupActivity) activity));
|
||||
}
|
||||
|
||||
@@ -367,4 +366,4 @@ namespace keepass2android.Io
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
using Android.Content;
|
||||
#if !EXCLUDE_JAVAFILESTORAGE
|
||||
|
||||
namespace keepass2android.Io
|
||||
{
|
||||
public partial class PCloudFileStorage: JavaFileStorage
|
||||
{
|
||||
private const string ClientId = "CkRWTQXY6Lm";
|
||||
|
||||
public PCloudFileStorage(Context ctx, IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.PCloudFileStorage(ctx, ClientId), app)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override bool UserShouldBackup
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
@@ -5,8 +5,8 @@ namespace keepass2android.Io
|
||||
{
|
||||
public class SftpFileStorage: JavaFileStorage
|
||||
{
|
||||
public SftpFileStorage(Context ctx, IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.SftpStorage(ctx.ApplicationContext), app)
|
||||
public SftpFileStorage(IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.SftpStorage(), app)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -30,8 +30,7 @@ namespace keepass2android.Io
|
||||
yield return "http";
|
||||
yield return "https";
|
||||
yield return "owncloud";
|
||||
yield return "nextcloud";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UserShouldBackup
|
||||
@@ -39,15 +38,12 @@ namespace keepass2android.Io
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public static string owncloudPrefix = "owncloud://";
|
||||
public static string nextcloudPrefix = "nextcloud://";
|
||||
|
||||
public static string Owncloud2Webdav(string owncloudUrl, string prefix)
|
||||
public static string Owncloud2Webdav(string owncloudUrl)
|
||||
{
|
||||
|
||||
if (owncloudUrl.StartsWith(prefix))
|
||||
string owncloudPrefix = "owncloud://";
|
||||
if (owncloudUrl.StartsWith(owncloudPrefix))
|
||||
{
|
||||
owncloudUrl = owncloudUrl.Substring(prefix.Length);
|
||||
owncloudUrl = owncloudUrl.Substring(owncloudPrefix.Length);
|
||||
}
|
||||
if (!owncloudUrl.Contains("://"))
|
||||
owncloudUrl = "https://" + owncloudUrl;
|
||||
|
@@ -31,7 +31,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;NoNet;EXCLUDE_JAVAFILESTORAGE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
@@ -53,7 +53,6 @@
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@@ -91,7 +90,7 @@
|
||||
<Compile Include="database\CheckDatabaseForChanges.cs" />
|
||||
<Compile Include="database\edit\AddTemplateEntries.cs" />
|
||||
<Compile Include="database\edit\CopyEntry.cs" />
|
||||
<Compile Include="database\edit\DeleteMultipleItemsFromOneDatabase.cs" />
|
||||
<Compile Include="database\edit\DeleteMultipleItems.cs" />
|
||||
<Compile Include="database\edit\EditGroup.cs" />
|
||||
<Compile Include="database\edit\MoveElements.cs" />
|
||||
<Compile Include="database\KdbDatabaseFormat.cs" />
|
||||
@@ -103,25 +102,15 @@
|
||||
<Compile Include="DataExchange\Formats\KeePassKdb2x.cs" />
|
||||
<Compile Include="DataExchange\Formats\KeePassXml2x.cs" />
|
||||
<Compile Include="DataExchange\PwExportInfo.cs" />
|
||||
<Compile Include="ElementAndDatabaseId.cs" />
|
||||
<Compile Include="Io\AndroidContentStorage.cs" />
|
||||
<Compile Include="Io\BuiltInFileStorage.cs" />
|
||||
<Compile Include="Io\CachingFileStorage.cs" />
|
||||
<Compile Include="Io\DropboxFileStorage.cs" />
|
||||
<Compile Include="Io\DropboxFileStorageKeys.cs" />
|
||||
<Compile Include="Io\FileDescription.cs" />
|
||||
<Compile Include="Io\FileStorageSetupActivity.cs" />
|
||||
<Compile Include="Io\FileStorageSetupInitiatorActivity.cs" />
|
||||
<Compile Include="Io\GDriveFileStorage.cs" />
|
||||
<Compile Include="Io\IFileStorage.cs" />
|
||||
<Compile Include="Io\IoUtil.cs" />
|
||||
<Compile Include="Io\JavaFileStorage.cs" />
|
||||
<Compile Include="Io\NetFtpFileStorage.cs" />
|
||||
<Compile Include="Io\OfflineSwitchableFileStorage.cs" />
|
||||
<Compile Include="Io\PCloudFileStorage.cs" />
|
||||
<Compile Include="Io\SftpFileStorage.cs" />
|
||||
<Compile Include="Io\OneDriveFileStorage.cs" />
|
||||
<Compile Include="Io\WebDavFileStorage.cs" />
|
||||
<Compile Include="IProgressDialog.cs" />
|
||||
<Compile Include="PreferenceKey.cs" />
|
||||
<Compile Include="SelectStorageLocationActivityBase.cs" />
|
||||
@@ -130,15 +119,15 @@
|
||||
<Compile Include="database\edit\ActionOnFinish.cs" />
|
||||
<Compile Include="database\edit\AddEntry.cs" />
|
||||
<Compile Include="database\edit\AddGroup.cs" />
|
||||
<Compile Include="database\edit\CreateDB.cs" />
|
||||
<Compile Include="database\edit\CreateDb.cs" />
|
||||
<Compile Include="database\edit\DeleteEntry.cs" />
|
||||
<Compile Include="database\edit\DeleteGroup.cs" />
|
||||
<Compile Include="database\edit\DeleteRunnable.cs" />
|
||||
<Compile Include="database\edit\FileOnFinish.cs" />
|
||||
<Compile Include="database\edit\LoadDB.cs" />
|
||||
<Compile Include="database\edit\LoadDb.cs" />
|
||||
<Compile Include="database\edit\OnFinish.cs" />
|
||||
<Compile Include="database\edit\RunnableOnFinish.cs" />
|
||||
<Compile Include="database\edit\SaveDB.cs" />
|
||||
<Compile Include="database\edit\SaveDb.cs" />
|
||||
<Compile Include="database\edit\SetPassword.cs" />
|
||||
<Compile Include="database\edit\UpdateEntry.cs" />
|
||||
<Compile Include="IKp2aApp.cs" />
|
||||
@@ -157,10 +146,6 @@
|
||||
<Compile Include="Utils\Spr\SprEngine.PickChars.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JavaFileStorageBindings\JavaFileStorageBindings.csproj">
|
||||
<Project>{48574278-4779-4b3a-a9e4-9cf1bc285d0b}</Project>
|
||||
<Name>JavaFileStorageBindings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KeePassLib2Android\KeePassLib2Android.csproj">
|
||||
<Project>{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}</Project>
|
||||
<Name>KeePassLib2Android</Name>
|
||||
@@ -169,10 +154,6 @@
|
||||
<Project>{70D3844A-D9FA-4A64-B205-A84C6A822196}</Project>
|
||||
<Name>KP2AKdbLibraryBinding</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\netftpandroid\System.Net.FtpClient\System.Net.FtpClient.Android.csproj">
|
||||
<Project>{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}</Project>
|
||||
<Name>System.Net.FtpClient.Android</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TwofishCipher\TwofishCipher.csproj">
|
||||
<Project>{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}</Project>
|
||||
<Name>TwofishCipher</Name>
|
||||
|
@@ -30,12 +30,8 @@ namespace keepass2android
|
||||
readonly IKp2aApp _app;
|
||||
private readonly Handler _handler;
|
||||
private string _message = "";
|
||||
private string _submessage;
|
||||
|
||||
public String SubMessage => _submessage;
|
||||
public String Message => _message;
|
||||
|
||||
public ProgressDialogStatusLogger() {
|
||||
public ProgressDialogStatusLogger() {
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +48,7 @@ namespace keepass2android
|
||||
|
||||
public void UpdateMessage (String message)
|
||||
{
|
||||
Kp2aLog.Log("status message: " + message);
|
||||
_message = message;
|
||||
_message = message;
|
||||
if ( _app!= null && _progressDialog != null && _handler != null ) {
|
||||
_handler.Post(() => {_progressDialog.SetMessage(message); } );
|
||||
}
|
||||
@@ -61,8 +56,6 @@ namespace keepass2android
|
||||
|
||||
public void UpdateSubMessage(String submessage)
|
||||
{
|
||||
Kp2aLog.Log("status submessage: " + submessage);
|
||||
_submessage = submessage;
|
||||
if (_app != null && _progressDialog != null && _handler != null)
|
||||
{
|
||||
_handler.Post(() =>
|
||||
|
@@ -25,107 +25,39 @@ namespace keepass2android
|
||||
/// <summary>
|
||||
/// Class to run a task while a progress dialog is shown
|
||||
/// </summary>
|
||||
public class ProgressTask
|
||||
{
|
||||
//for handling Activity recreation situations, we need access to the currently active task. It must hold that there is no more than one active task.
|
||||
private static ProgressTask _currentTask = null;
|
||||
|
||||
public static void SetNewActiveActivity(Activity activeActivity)
|
||||
{
|
||||
if (_currentTask != null)
|
||||
{
|
||||
_currentTask.ActiveActivity = activeActivity;
|
||||
}
|
||||
}
|
||||
public static void RemoveActiveActivity(Activity activity)
|
||||
{
|
||||
if ((_currentTask != null) && (_currentTask._activeActivity == activity))
|
||||
_currentTask.ActiveActivity = null;
|
||||
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
private set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (_task != null)
|
||||
_task.ActiveActivity = _activeActivity;
|
||||
if (_activeActivity != null)
|
||||
{
|
||||
SetupProgressDialog(_app);
|
||||
_progressDialog.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Handler _handler;
|
||||
public class ProgressTask {
|
||||
private readonly Handler _handler;
|
||||
private readonly RunnableOnFinish _task;
|
||||
private IProgressDialog _progressDialog;
|
||||
private readonly IProgressDialog _progressDialog;
|
||||
private readonly IKp2aApp _app;
|
||||
private Thread _thread;
|
||||
private Activity _activeActivity;
|
||||
private ProgressDialogStatusLogger _progressDialogStatusLogger;
|
||||
|
||||
public ProgressTask(IKp2aApp app, Activity activity, RunnableOnFinish task)
|
||||
{
|
||||
_activeActivity = activity;
|
||||
public ProgressTask(IKp2aApp app, Context ctx, RunnableOnFinish task) {
|
||||
_task = task;
|
||||
_handler = app.UiThreadHandler;
|
||||
_app = app;
|
||||
|
||||
SetupProgressDialog(app);
|
||||
|
||||
// Set code to run when this is finished
|
||||
_task.OnFinishToRun = new AfterTask(activity, task.OnFinishToRun, _handler, this);
|
||||
|
||||
_task.SetStatusLogger(_progressDialogStatusLogger);
|
||||
// Show process dialog
|
||||
_progressDialog = app.CreateProgressDialog(ctx);
|
||||
_progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
|
||||
_progressDialog.SetMessage("Initializing...");
|
||||
|
||||
// Set code to run when this is finished
|
||||
_task.OnFinishToRun = new AfterTask(task.OnFinishToRun, _handler, _progressDialog);
|
||||
_task.SetStatusLogger(new ProgressDialogStatusLogger(_app, _handler, _progressDialog));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetupProgressDialog(IKp2aApp app)
|
||||
{
|
||||
string currentMessage = "Initializing...";
|
||||
string currentSubmessage = "";
|
||||
|
||||
if (_progressDialogStatusLogger != null)
|
||||
{
|
||||
currentMessage = _progressDialogStatusLogger.Message;
|
||||
currentSubmessage = _progressDialogStatusLogger.SubMessage;
|
||||
}
|
||||
|
||||
if (_progressDialog != null)
|
||||
{
|
||||
var pd = _progressDialog;
|
||||
app.UiThreadHandler.Post(() =>
|
||||
{
|
||||
pd.Dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
// Show process dialog
|
||||
_progressDialog = app.CreateProgressDialog(_activeActivity);
|
||||
_progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
|
||||
_progressDialogStatusLogger = new ProgressDialogStatusLogger(_app, _handler, _progressDialog);
|
||||
_progressDialogStatusLogger.UpdateMessage(currentMessage);
|
||||
_progressDialogStatusLogger.UpdateSubMessage(currentSubmessage);
|
||||
}
|
||||
|
||||
public void Run(bool allowOverwriteCurrentTask = false)
|
||||
{
|
||||
if ((!allowOverwriteCurrentTask) && (_currentTask != null))
|
||||
throw new Exception("Cannot start another ProgressTask while ProgressTask is already running! " + _task.GetType().Name + "/" + _currentTask._task.GetType().Name);
|
||||
_currentTask = this;
|
||||
|
||||
// Show process dialog
|
||||
_progressDialog.Show();
|
||||
|
||||
public void Run() {
|
||||
// Show process dialog
|
||||
_progressDialog.Show();
|
||||
|
||||
|
||||
// Start Thread to Run task
|
||||
_thread = new Thread(_task.Run);
|
||||
_thread.Start();
|
||||
|
||||
}
|
||||
|
||||
public void JoinWorkerThread()
|
||||
@@ -134,11 +66,11 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
private class AfterTask : OnFinish {
|
||||
readonly ProgressTask _progressTask;
|
||||
readonly IProgressDialog _progressDialog;
|
||||
|
||||
public AfterTask (Activity activity, OnFinish finish, Handler handler, ProgressTask pt): base(activity, finish, handler)
|
||||
public AfterTask (OnFinish finish, Handler handler, IProgressDialog pd): base(finish, handler)
|
||||
{
|
||||
_progressTask = pt;
|
||||
_progressDialog = pd;
|
||||
}
|
||||
|
||||
public override void Run() {
|
||||
@@ -147,22 +79,17 @@ namespace keepass2android
|
||||
if (Handler != null) //can be null in tests
|
||||
{
|
||||
// Remove the progress dialog
|
||||
Handler.Post(delegate
|
||||
{
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
});
|
||||
Handler.Post(delegate { _progressDialog.Dismiss(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
_progressDialog.Dismiss();
|
||||
}
|
||||
_currentTask = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ namespace keepass2android
|
||||
/// <summary>
|
||||
/// EqualityComparer implementation to compare PwGroups based on their Id
|
||||
/// </summary>
|
||||
public class PwGroupEqualityFromIdComparer: IEqualityComparer<PwGroup>
|
||||
class PwGroupEqualityFromIdComparer: IEqualityComparer<PwGroup>
|
||||
{
|
||||
#region IEqualityComparer implementation
|
||||
public bool Equals (PwGroup x, PwGroup y)
|
||||
|
@@ -103,7 +103,7 @@ namespace keepass2android
|
||||
PwGroup pgResults = new PwGroup(true, true, strGroupName, PwIcon.EMailSearch) {IsVirtual = true};
|
||||
if (String.IsNullOrWhiteSpace(host))
|
||||
return pgResults;
|
||||
foreach (PwEntry entry in database.EntriesById.Values)
|
||||
foreach (PwEntry entry in database.Entries.Values)
|
||||
{
|
||||
string otherUrl = entry.Strings.ReadSafe(PwDefs.UrlField);
|
||||
otherUrl = SprEngine.Compile(otherUrl, new SprContext(entry, database.KpDatabase, SprCompileFlags.References));
|
||||
|
@@ -86,8 +86,6 @@ namespace keepass2android
|
||||
ReadOnlyReason_PreKitKat,
|
||||
ReadOnlyReason_ReadOnlyFlag,
|
||||
ReadOnlyReason_ReadOnlyKitKat,
|
||||
ReadOnlyReason_LocalBackup,
|
||||
Ok,
|
||||
cancel
|
||||
ReadOnlyReason_LocalBackup
|
||||
}
|
||||
}
|
||||
|
@@ -18,8 +18,8 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
|
||||
public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
public CheckDatabaseForChanges(Context context, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
@@ -29,7 +29,7 @@ namespace keepass2android
|
||||
{
|
||||
try
|
||||
{
|
||||
IOConnectionInfo ioc = _app.CurrentDb.Ioc;
|
||||
IOConnectionInfo ioc = _app.GetDb().Ioc;
|
||||
IFileStorage fileStorage = _app.GetFileStorage(ioc);
|
||||
if (fileStorage is CachingFileStorage)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace keepass2android
|
||||
hashingRemoteStream.CopyTo(remoteData);
|
||||
hashingRemoteStream.Close();
|
||||
|
||||
if (!MemUtil.ArraysEqual(_app.CurrentDb.KpDatabase.HashOfFileOnDisk, hashingRemoteStream.Hash))
|
||||
if (!MemUtil.ArraysEqual(_app.GetDb().KpDatabase.HashOfFileOnDisk, hashingRemoteStream.Hash))
|
||||
{
|
||||
_app.TriggerReload(_context);
|
||||
Finish(true);
|
||||
|
@@ -21,12 +21,12 @@ using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Android.Content;
|
||||
using Java.Lang;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
using keepass2android.Io;
|
||||
using KeePassLib.Interfaces;
|
||||
using KeePassLib.Utility;
|
||||
using Exception = System.Exception;
|
||||
using String = System.String;
|
||||
@@ -34,23 +34,27 @@ using String = System.String;
|
||||
namespace keepass2android
|
||||
{
|
||||
|
||||
public class Database
|
||||
{
|
||||
public HashSet<IStructureItem> Elements = new HashSet<IStructureItem>();
|
||||
public Dictionary<PwUuid, PwGroup> GroupsById = new Dictionary<PwUuid, PwGroup>(new PwUuidEqualityComparer());
|
||||
public Dictionary<PwUuid, PwEntry> EntriesById = new Dictionary<PwUuid, PwEntry>(new PwUuidEqualityComparer());
|
||||
public class Database {
|
||||
|
||||
|
||||
public Dictionary<PwUuid, PwGroup> Groups = new Dictionary<PwUuid, PwGroup>(new PwUuidEqualityComparer());
|
||||
public Dictionary<PwUuid, PwEntry> Entries = new Dictionary<PwUuid, PwEntry>(new PwUuidEqualityComparer());
|
||||
public HashSet<PwGroup> Dirty = new HashSet<PwGroup>(new PwGroupEqualityFromIdComparer());
|
||||
public PwGroup Root;
|
||||
public PwDatabase KpDatabase;
|
||||
public IOConnectionInfo Ioc
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return KpDatabase?.IOConnectionInfo;
|
||||
|
||||
return KpDatabase == null ? null : KpDatabase.IOConnectionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Information about the last opened entry. Includes the entry but also transformed fields.
|
||||
/// </summary>
|
||||
public PwEntryOutput LastOpenedEntry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// if an OTP key was used, this property tells the location of the OTP auxiliary file.
|
||||
/// Must be set after loading.
|
||||
@@ -70,14 +74,31 @@ namespace keepass2android
|
||||
_app = app;
|
||||
CanWrite = true; //default
|
||||
}
|
||||
|
||||
private bool _loaded;
|
||||
|
||||
private IDatabaseFormat _databaseFormat = new KdbxDatabaseFormat(KdbxFormat.Default);
|
||||
private bool _reloadRequested;
|
||||
private IDatabaseFormat _databaseFormat = new KdbxDatabaseFormat(KdbxFormat.Default);
|
||||
|
||||
public bool ReloadRequested { get; set; }
|
||||
public bool ReloadRequested
|
||||
{
|
||||
get { return _reloadRequested; }
|
||||
set { _reloadRequested = value; }
|
||||
}
|
||||
|
||||
public bool DidOpenFileChange()
|
||||
public bool Loaded {
|
||||
get { return _loaded;}
|
||||
set { _loaded = value; }
|
||||
}
|
||||
|
||||
public bool DidOpenFileChange()
|
||||
{
|
||||
if (Loaded == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _app.GetFileStorage(Ioc).CheckForFileChangeFast(Ioc, LastFileVersion);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,20 +113,32 @@ namespace keepass2android
|
||||
Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo);
|
||||
var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo);
|
||||
PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat);
|
||||
LastFileVersion = fileVersion;
|
||||
try
|
||||
{
|
||||
LastFileVersion = fileVersion;
|
||||
|
||||
status.UpdateSubMessage("");
|
||||
status.UpdateSubMessage("");
|
||||
|
||||
Root = pwDatabase.RootGroup;
|
||||
PopulateGlobals(Root);
|
||||
Root = pwDatabase.RootGroup;
|
||||
PopulateGlobals(Root);
|
||||
|
||||
|
||||
KpDatabase = pwDatabase;
|
||||
SearchHelper = new SearchDbHelper(app);
|
||||
KpDatabase = pwDatabase;
|
||||
SearchHelper = new SearchDbHelper(app);
|
||||
|
||||
_databaseFormat = databaseFormat;
|
||||
_databaseFormat = databaseFormat;
|
||||
|
||||
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
|
||||
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
|
||||
Loaded = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Clear();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -185,9 +218,10 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
|
||||
public void SaveData() {
|
||||
public void SaveData(Context ctx) {
|
||||
|
||||
using (IWriteTransaction trans = _app.GetFileStorage(Ioc).OpenWriteTransaction(Ioc, _app.GetBooleanPreference(PreferenceKey.UseFileTransactions)))
|
||||
KpDatabase.UseFileTransactions = _app.GetBooleanPreference(PreferenceKey.UseFileTransactions);
|
||||
using (IWriteTransaction trans = _app.GetFileStorage(Ioc).OpenWriteTransaction(Ioc, KpDatabase.UseFileTransactions))
|
||||
{
|
||||
DatabaseFormat.Save(KpDatabase, trans.OpenFile());
|
||||
|
||||
@@ -206,18 +240,14 @@ namespace keepass2android
|
||||
{
|
||||
if (checkForDuplicateUuids)
|
||||
{
|
||||
if (EntriesById.ContainsKey(e.Uuid))
|
||||
if (Entries.ContainsKey(e.Uuid))
|
||||
{
|
||||
throw new DuplicateUuidsException("Same UUID for entries '"+EntriesById[e.Uuid].Strings.ReadSafe(PwDefs.TitleField)+"' and '"+e.Strings.ReadSafe(PwDefs.TitleField)+"'.");
|
||||
throw new DuplicateUuidsException("Same UUID for entries '"+Entries[e.Uuid].Strings.ReadSafe(PwDefs.TitleField)+"' and '"+e.Strings.ReadSafe(PwDefs.TitleField)+"'.");
|
||||
}
|
||||
|
||||
}
|
||||
EntriesById [e.Uuid] = e;
|
||||
Elements.Add(e);
|
||||
Entries [e.Uuid] = e;
|
||||
}
|
||||
|
||||
GroupsById[currentGroup.Uuid] = currentGroup;
|
||||
Elements.Add(currentGroup);
|
||||
foreach (PwGroup g in childGroups)
|
||||
{
|
||||
if (checkForDuplicateUuids)
|
||||
@@ -229,6 +259,7 @@ namespace keepass2android
|
||||
}
|
||||
* */
|
||||
}
|
||||
Groups[g.Uuid] = g;
|
||||
PopulateGlobals(g);
|
||||
}
|
||||
}
|
||||
@@ -236,15 +267,33 @@ namespace keepass2android
|
||||
{
|
||||
PopulateGlobals(currentGroup, _app.CheckForDuplicateUuids);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_loaded = false;
|
||||
|
||||
Groups.Clear();
|
||||
Entries.Clear();
|
||||
Dirty.Clear();
|
||||
DrawableFactory.Clear();
|
||||
|
||||
Root = null;
|
||||
KpDatabase = null;
|
||||
|
||||
CanWrite = true;
|
||||
_reloadRequested = false;
|
||||
OtpAuxFileIoc = null;
|
||||
LastOpenedEntry = null;
|
||||
}
|
||||
|
||||
public void MarkAllGroupsAsDirty() {
|
||||
foreach ( PwGroup group in Groups.Values ) {
|
||||
Dirty.Add(group);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void UpdateGlobals()
|
||||
{
|
||||
EntriesById.Clear();
|
||||
GroupsById.Clear();
|
||||
Elements.Clear();
|
||||
PopulateGlobals(Root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
@@ -216,16 +216,9 @@ namespace keepass2android
|
||||
|
||||
private DateTime JavaTimeToCSharp(long javatime)
|
||||
{
|
||||
try
|
||||
{
|
||||
var utcTime = new DateTime(1970, 1, 1).AddMilliseconds(javatime);
|
||||
return TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
var utcTime = new DateTime(1970, 1, 1).AddMilliseconds(javatime);
|
||||
return TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@@ -14,13 +14,13 @@ namespace keepass2android
|
||||
public class PwEntryOutput
|
||||
{
|
||||
private readonly PwEntry _entry;
|
||||
private readonly Database _db;
|
||||
private readonly PwDatabase _db;
|
||||
private readonly ProtectedStringDictionary _outputStrings = new ProtectedStringDictionary();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs the PwEntryOutput by replacing the placeholders
|
||||
/// </summary>
|
||||
public PwEntryOutput(PwEntry entry, Database db)
|
||||
public PwEntryOutput(PwEntry entry, PwDatabase db)
|
||||
{
|
||||
_entry = entry;
|
||||
_db = db;
|
||||
@@ -34,7 +34,7 @@ namespace keepass2android
|
||||
string GetStringAndReplacePlaceholders(string key)
|
||||
{
|
||||
String value = Entry.Strings.ReadSafe(key);
|
||||
value = SprEngine.Compile(value, new SprContext(Entry, _db.KpDatabase, SprCompileFlags.All));
|
||||
value = SprEngine.Compile(value, new SprContext(Entry, _db, SprCompileFlags.All));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@@ -11,12 +11,12 @@ namespace keepass2android
|
||||
{
|
||||
public class SynchronizeCachedDatabase: RunnableOnFinish
|
||||
{
|
||||
private readonly Activity _context;
|
||||
private readonly Context _context;
|
||||
private readonly IKp2aApp _app;
|
||||
private SaveDb _saveDb;
|
||||
|
||||
public SynchronizeCachedDatabase(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
public SynchronizeCachedDatabase(Context context, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
@@ -26,7 +26,7 @@ namespace keepass2android
|
||||
{
|
||||
try
|
||||
{
|
||||
IOConnectionInfo ioc = _app.CurrentDb.Ioc;
|
||||
IOConnectionInfo ioc = _app.GetDb().Ioc;
|
||||
IFileStorage fileStorage = _app.GetFileStorage(ioc);
|
||||
if (!(fileStorage is CachingFileStorage))
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace keepass2android
|
||||
if (cachingFileStorage.HasLocalChanges(ioc))
|
||||
{
|
||||
//conflict! need to merge
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnFinish(ActiveActivity, (success, result, activity) =>
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnFinish((success, result) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
@@ -70,12 +70,10 @@ namespace keepass2android
|
||||
Finish(true, _app.GetResourceString(UiStringKey.SynchronizedDatabaseSuccessfully));
|
||||
}
|
||||
_saveDb = null;
|
||||
}), _app.CurrentDb, false, remoteData);
|
||||
}), false, remoteData);
|
||||
_saveDb.Run();
|
||||
|
||||
_app.CurrentDb.UpdateGlobals();
|
||||
|
||||
_app.MarkAllGroupsAsDirty();
|
||||
_app.GetDb().MarkAllGroupsAsDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -105,7 +103,6 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Finish(false, e.Message);
|
||||
}
|
||||
|
||||
|
@@ -16,37 +16,41 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public class ActionOnFinish: OnFinish
|
||||
{
|
||||
public delegate void ActionToPerformOnFinsh(bool success, String message, Activity activeActivity);
|
||||
public delegate void ActionToPerformOnFinsh(bool success, String message);
|
||||
|
||||
readonly ActionToPerformOnFinsh _actionToPerform;
|
||||
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform) : base(activity, null, null)
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform) : base(null, null)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(activity, finish)
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(finish)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform, Handler handler) : base(handler)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
if (Message == null)
|
||||
Message = "";
|
||||
if (Handler != null)
|
||||
{
|
||||
Handler.Post(() => {_actionToPerform(Success, Message, ActiveActivity);});
|
||||
Handler.Post(() => {_actionToPerform(Success, Message);});
|
||||
}
|
||||
else
|
||||
_actionToPerform(Success, Message, ActiveActivity);
|
||||
_actionToPerform(Success, Message);
|
||||
base.Run();
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -24,26 +23,26 @@ namespace keepass2android
|
||||
public class AddEntry : RunnableOnFinish {
|
||||
protected Database Db
|
||||
{
|
||||
get { return _app.CurrentDb; }
|
||||
get { return _app.GetDb(); }
|
||||
}
|
||||
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly PwEntry _entry;
|
||||
private readonly PwGroup _parentGroup;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
|
||||
public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish) {
|
||||
public static AddEntry GetInstance(Context ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish) {
|
||||
|
||||
return new AddEntry(ctx, app, entry, parentGroup, finish);
|
||||
}
|
||||
|
||||
public AddEntry(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish):base(ctx, finish) {
|
||||
protected AddEntry(Context ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish):base(finish) {
|
||||
_ctx = ctx;
|
||||
_parentGroup = parentGroup;
|
||||
_app = app;
|
||||
_entry = entry;
|
||||
|
||||
_onFinishToRun = new AfterAdd(ctx, app.CurrentDb, entry, app,OnFinishToRun);
|
||||
_onFinishToRun = new AfterAdd(app.GetDb(), entry, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +59,7 @@ namespace keepass2android
|
||||
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -68,13 +67,12 @@ namespace keepass2android
|
||||
private class AfterAdd : OnFinish {
|
||||
private readonly Database _db;
|
||||
private readonly PwEntry _entry;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public AfterAdd(Activity activity, Database db, PwEntry entry, IKp2aApp app, OnFinish finish):base(activity, finish) {
|
||||
public AfterAdd(Database db, PwEntry entry, OnFinish finish):base(finish) {
|
||||
_db = db;
|
||||
_entry = entry;
|
||||
_app = app;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,12 +82,11 @@ namespace keepass2android
|
||||
PwGroup parent = _entry.ParentGroup;
|
||||
|
||||
// Mark parent group dirty
|
||||
_app.DirtyGroups.Add(parent);
|
||||
_db.Dirty.Add(parent);
|
||||
|
||||
// Add entry to global
|
||||
_db.EntriesById[_entry.Uuid] = _entry;
|
||||
_db.Elements.Add(_entry);
|
||||
|
||||
_db.Entries[_entry.Uuid] = _entry;
|
||||
|
||||
} else
|
||||
{
|
||||
StatusLogger.UpdateMessage(UiStringKey.UndoingChanges);
|
||||
|
@@ -16,7 +16,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -26,28 +25,25 @@ namespace keepass2android
|
||||
public class AddGroup : RunnableOnFinish {
|
||||
internal Database Db
|
||||
{
|
||||
get { return _app.CurrentDb; }
|
||||
get { return _app.GetDb(); }
|
||||
}
|
||||
|
||||
public IKp2aApp App { get => _app; }
|
||||
|
||||
private IKp2aApp _app;
|
||||
private IKp2aApp _app;
|
||||
private readonly String _name;
|
||||
private readonly int _iconId;
|
||||
private readonly PwUuid _groupCustomIconId;
|
||||
public PwGroup Group;
|
||||
internal PwGroup Group;
|
||||
internal PwGroup Parent;
|
||||
protected bool DontSave;
|
||||
readonly Activity _ctx;
|
||||
readonly Context _ctx;
|
||||
|
||||
|
||||
public static AddGroup GetInstance(Activity ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave) {
|
||||
public static AddGroup GetInstance(Context ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave) {
|
||||
return new AddGroup(ctx, app, name, iconid, groupCustomIconId, parent, finish, dontSave);
|
||||
}
|
||||
|
||||
|
||||
private AddGroup(Activity ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
private AddGroup(Context ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -57,7 +53,7 @@ namespace keepass2android
|
||||
DontSave = dontSave;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterAdd(ctx, this, OnFinishToRun);
|
||||
_onFinishToRun = new AfterAdd(this, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +66,9 @@ namespace keepass2android
|
||||
Group.CustomIconUuid = _groupCustomIconId;
|
||||
}
|
||||
Parent.AddGroup(Group, true);
|
||||
_app.CurrentDb.GroupsById[Group.Uuid] = Group;
|
||||
_app.CurrentDb.Elements.Add(Group);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun, DontSave);
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, DontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -82,7 +76,7 @@ namespace keepass2android
|
||||
private class AfterAdd : OnFinish {
|
||||
readonly AddGroup _addGroup;
|
||||
|
||||
public AfterAdd(Activity activity, AddGroup addGroup,OnFinish finish): base(activity, finish) {
|
||||
public AfterAdd(AddGroup addGroup,OnFinish finish): base(finish) {
|
||||
_addGroup = addGroup;
|
||||
}
|
||||
|
||||
@@ -91,15 +85,13 @@ namespace keepass2android
|
||||
|
||||
if ( Success ) {
|
||||
// Mark parent group dirty
|
||||
_addGroup.App.DirtyGroups.Add(_addGroup.Parent);
|
||||
_addGroup.Db.Dirty.Add(_addGroup.Parent);
|
||||
|
||||
// Add group to global list
|
||||
_addGroup.Db.GroupsById[_addGroup.Group.Uuid] = _addGroup.Group;
|
||||
_addGroup.Db.Elements.Add(_addGroup.Group);
|
||||
_addGroup.Db.Groups[_addGroup.Group.Uuid] = _addGroup.Group;
|
||||
} else {
|
||||
StatusLogger.UpdateMessage(UiStringKey.UndoingChanges);
|
||||
_addGroup.Parent.Groups.Remove(_addGroup.Group);
|
||||
|
||||
}
|
||||
|
||||
base.Run();
|
||||
|
@@ -18,7 +18,6 @@ This file is part of Keepass2Android, Copyright 2016 Philipp Crocoll. This file
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Security;
|
||||
@@ -28,7 +27,7 @@ namespace keepass2android
|
||||
{
|
||||
public class AddTemplateEntries : RunnableOnFinish {
|
||||
|
||||
public class TemplateEntry
|
||||
class TemplateEntry
|
||||
{
|
||||
public UiStringKey Title { get; set; }
|
||||
public PwIcon Icon { get; set; }
|
||||
@@ -47,12 +46,11 @@ namespace keepass2android
|
||||
void AddToEntry(IKp2aApp app, PwEntry entry, int position);
|
||||
}
|
||||
|
||||
public enum FieldType
|
||||
internal enum FieldType
|
||||
{
|
||||
Inline, ProtectedInline
|
||||
}
|
||||
|
||||
public enum SpecialFieldKey
|
||||
internal enum SpecialFieldKey
|
||||
{
|
||||
ExpDate, OverrideUrl, Tags
|
||||
}
|
||||
@@ -126,14 +124,14 @@ namespace keepass2android
|
||||
|
||||
protected Database Db
|
||||
{
|
||||
get { return _app.CurrentDb; }
|
||||
get { return _app.GetDb(); }
|
||||
}
|
||||
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
|
||||
public AddTemplateEntries(Activity ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public AddTemplateEntries(Context ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -141,7 +139,7 @@ namespace keepass2android
|
||||
//_onFinishToRun = new AfterAdd(this, OnFinishToRun);
|
||||
}
|
||||
|
||||
public static readonly List<TemplateEntry> TemplateEntries = new List<TemplateEntry>()
|
||||
static readonly List<TemplateEntry> TemplateEntries = new List<TemplateEntry>()
|
||||
{
|
||||
new TemplateEntry()
|
||||
{
|
||||
@@ -286,23 +284,12 @@ namespace keepass2android
|
||||
|
||||
};
|
||||
|
||||
public static bool ContainsAllTemplates(Database db)
|
||||
public static bool ContainsAllTemplates(IKp2aApp app)
|
||||
{
|
||||
return TemplateEntries.All(t =>
|
||||
{
|
||||
string hexId = t.Uuid.ToHexString();
|
||||
|
||||
return db.EntriesById.Any(kvp => kvp.Key.Equals(t.Uuid) ||
|
||||
kvp.Value.Strings.ReadSafe(TemplateIdStringKey) == hexId);
|
||||
});
|
||||
return TemplateEntries.All(t => app.GetDb().Entries.ContainsKey(t.Uuid));
|
||||
}
|
||||
|
||||
public static string TemplateIdStringKey
|
||||
{
|
||||
get { return "KP2A_TemplateId"; }
|
||||
}
|
||||
|
||||
public override void Run() {
|
||||
public override void Run() {
|
||||
StatusLogger.UpdateMessage(UiStringKey.AddingEntry);
|
||||
|
||||
List<PwEntry> addedEntries;
|
||||
@@ -310,10 +297,10 @@ namespace keepass2android
|
||||
|
||||
if (addedEntries.Any())
|
||||
{
|
||||
_app.DirtyGroups.Add(templateGroup);
|
||||
_app.GetDb().Dirty.Add(templateGroup);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -327,28 +314,26 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
PwGroup templateGroup;
|
||||
if (!_app.CurrentDb.GroupsById.TryGetValue(_app.CurrentDb.KpDatabase.EntryTemplatesGroup, out templateGroup))
|
||||
if (!_app.GetDb().Groups.TryGetValue(_app.GetDb().KpDatabase.EntryTemplatesGroup, out templateGroup))
|
||||
{
|
||||
//create template group
|
||||
templateGroup = new PwGroup(true, true, _app.GetResourceString(UiStringKey.TemplateGroupName), PwIcon.Folder);
|
||||
_app.CurrentDb.KpDatabase.RootGroup.AddGroup(templateGroup, true);
|
||||
_app.CurrentDb.KpDatabase.EntryTemplatesGroup = templateGroup.Uuid;
|
||||
_app.CurrentDb.KpDatabase.EntryTemplatesGroupChanged = DateTime.Now;
|
||||
_app.DirtyGroups.Add(_app.CurrentDb.KpDatabase.RootGroup);
|
||||
_app.CurrentDb.GroupsById[templateGroup.Uuid] = templateGroup;
|
||||
_app.CurrentDb.Elements.Add(templateGroup);
|
||||
|
||||
_app.GetDb().KpDatabase.RootGroup.AddGroup(templateGroup, true);
|
||||
_app.GetDb().KpDatabase.EntryTemplatesGroup = templateGroup.Uuid;
|
||||
_app.GetDb().KpDatabase.EntryTemplatesGroupChanged = DateTime.Now;
|
||||
_app.GetDb().Dirty.Add(_app.GetDb().KpDatabase.RootGroup);
|
||||
_app.GetDb().Groups[templateGroup.Uuid] = templateGroup;
|
||||
}
|
||||
addedEntries = new List<PwEntry>();
|
||||
|
||||
foreach (var template in TemplateEntries)
|
||||
{
|
||||
if (_app.CurrentDb.EntriesById.ContainsKey(template.Uuid))
|
||||
if (_app.GetDb().Entries.ContainsKey(template.Uuid))
|
||||
continue;
|
||||
PwEntry entry = CreateEntry(template);
|
||||
templateGroup.AddEntry(entry, true);
|
||||
addedEntries.Add(entry);
|
||||
_app.CurrentDb.EntriesById[entry.Uuid] = entry;
|
||||
_app.GetDb().Entries[entry.Uuid] = entry;
|
||||
}
|
||||
return templateGroup;
|
||||
}
|
||||
@@ -373,7 +358,7 @@ namespace keepass2android
|
||||
private readonly Database _db;
|
||||
private readonly List<PwEntry> _entries;
|
||||
|
||||
public AfterAdd(Activity activity, Database db, List<PwEntry> entries, OnFinish finish):base(activity, finish) {
|
||||
public AfterAdd(Database db, List<PwEntry> entries, OnFinish finish):base(finish) {
|
||||
_db = db;
|
||||
_entries = entries;
|
||||
|
||||
@@ -387,12 +372,8 @@ namespace keepass2android
|
||||
base.Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsTemplateId(PwUuid pwUuid)
|
||||
{
|
||||
return TemplateEntries.Any(te => te.Uuid.Equals(pwUuid));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ namespace keepass2android.database.edit
|
||||
{
|
||||
public class CopyEntry: AddEntry
|
||||
{
|
||||
public CopyEntry(Activity ctx, IKp2aApp app, PwEntry entry, OnFinish finish)
|
||||
public CopyEntry(Context ctx, IKp2aApp app, PwEntry entry, OnFinish finish)
|
||||
: base(ctx, app, CreateCopy(entry, app), entry.ParentGroup, finish)
|
||||
{
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Cryptography.KeyDerivation;
|
||||
@@ -27,36 +26,36 @@ namespace keepass2android
|
||||
{
|
||||
|
||||
public class CreateDb : RunnableOnFinish {
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
|
||||
private const ulong DefaultEncryptionRounds = PwDefs.DefaultKeyEncryptionRounds;
|
||||
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
private readonly bool _dontSave;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
private readonly IKp2aApp _app;
|
||||
private CompositeKey _key;
|
||||
private readonly bool _makeCurrent;
|
||||
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, bool makeCurrent): base(ctx, finish) {
|
||||
public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave): base(finish) {
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
_dontSave = dontSave;
|
||||
_makeCurrent = makeCurrent;
|
||||
_app = app;
|
||||
_app = app;
|
||||
}
|
||||
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key, bool makeCurrent)
|
||||
: base(ctx, finish)
|
||||
public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
_dontSave = dontSave;
|
||||
_app = app;
|
||||
_key = key;
|
||||
_makeCurrent = makeCurrent;
|
||||
}
|
||||
|
||||
|
||||
public override void Run() {
|
||||
StatusLogger.UpdateMessage(UiStringKey.progress_create);
|
||||
Database db = _app.CreateNewDatabase(_makeCurrent);
|
||||
Database db = _app.CreateNewDatabase();
|
||||
|
||||
db.KpDatabase = new KeePassLib.PwDatabase();
|
||||
|
||||
@@ -74,6 +73,7 @@ namespace keepass2android
|
||||
|
||||
// Set Database state
|
||||
db.Root = db.KpDatabase.RootGroup;
|
||||
db.Loaded = true;
|
||||
db.SearchHelper = new SearchDbHelper(_app);
|
||||
|
||||
// Add a couple default groups
|
||||
@@ -87,14 +87,12 @@ namespace keepass2android
|
||||
addTemplates.AddTemplates(out addedEntries);
|
||||
|
||||
// Commit changes
|
||||
SaveDb save = new SaveDb(_ctx, _app, db, OnFinishToRun, _dontSave);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
_onFinishToRun = null;
|
||||
save.Run();
|
||||
|
||||
db.UpdateGlobals();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
@@ -29,9 +28,9 @@ namespace keepass2android
|
||||
private readonly PwEntry _entry;
|
||||
private UiStringKey _statusMessage;
|
||||
|
||||
public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnFinish finish):base(activiy, finish, app) {
|
||||
Ctx = activiy;
|
||||
Db = app.FindDatabaseForElement(entry);
|
||||
public DeleteEntry(Context ctx, IKp2aApp app, PwEntry entry, OnFinish finish):base(finish, app) {
|
||||
Ctx = ctx;
|
||||
Db = app.GetDb();
|
||||
_entry = entry;
|
||||
|
||||
}
|
||||
@@ -40,7 +39,7 @@ namespace keepass2android
|
||||
{
|
||||
get
|
||||
{
|
||||
return Db.DatabaseFormat.CanRecycle && CanRecycleGroup(_entry.ParentGroup);
|
||||
return App.GetDb().DatabaseFormat.CanRecycle && CanRecycleGroup(_entry.ParentGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -29,10 +28,10 @@ namespace keepass2android
|
||||
private PwGroup _group;
|
||||
protected bool DontSave;
|
||||
|
||||
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnFinish finish)
|
||||
: base(activity, finish, app)
|
||||
public DeleteGroup(Context ctx, IKp2aApp app, PwGroup group, OnFinish finish)
|
||||
: base(finish, app)
|
||||
{
|
||||
SetMembers(activity, app, group, false);
|
||||
SetMembers(ctx, app, group, false);
|
||||
}
|
||||
/*
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnFinish finish, bool dontSave)
|
||||
@@ -45,9 +44,9 @@ namespace keepass2android
|
||||
SetMembers(ctx, db, group, null, dontSave);
|
||||
}
|
||||
*/
|
||||
private void SetMembers(Activity activity, IKp2aApp app, PwGroup group, bool dontSave)
|
||||
private void SetMembers(Context ctx, IKp2aApp app, PwGroup group, bool dontSave)
|
||||
{
|
||||
base.SetMembers(activity, app.FindDatabaseForElement(group));
|
||||
base.SetMembers(ctx, app.GetDb());
|
||||
|
||||
_group = group;
|
||||
DontSave = dontSave;
|
||||
@@ -58,7 +57,7 @@ namespace keepass2android
|
||||
{
|
||||
get
|
||||
{
|
||||
return Db.DatabaseFormat.CanRecycle && CanRecycleGroup(_group);
|
||||
return App.GetDb().DatabaseFormat.CanRecycle && CanRecycleGroup(_group);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,33 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public class DeleteMultipleItemsFromOneDatabase : DeleteRunnable
|
||||
public class DeleteMultipleItems : DeleteRunnable
|
||||
{
|
||||
private readonly List<IStructureItem> _elementsToDelete;
|
||||
private readonly bool _canRecycle;
|
||||
|
||||
public DeleteMultipleItemsFromOneDatabase(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish, app)
|
||||
public DeleteMultipleItems(Context ctx, Database db, List<IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
|
||||
: base(finish, app)
|
||||
{
|
||||
_elementsToDelete = elementsToDelete;
|
||||
SetMembers(activity, db);
|
||||
SetMembers(ctx, db);
|
||||
|
||||
//determine once. The property is queried for each delete operation, but might return false
|
||||
//after one entry/group is deleted (and thus in recycle bin and thus can't be recycled anymore)
|
||||
_canRecycle = DetermineCanRecycle();
|
||||
ShowDatabaseIocInStatus = true;
|
||||
}
|
||||
|
||||
private bool DetermineCanRecycle()
|
||||
{
|
||||
Android.Util.Log.Debug("KP2A", "CanRecycle?");
|
||||
if (!Db.DatabaseFormat.CanRecycle)
|
||||
if (!App.GetDb().DatabaseFormat.CanRecycle)
|
||||
{
|
||||
Android.Util.Log.Debug("KP2A", "CanRecycle? No because of DB format.");
|
||||
return false;
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -8,8 +7,8 @@ namespace keepass2android
|
||||
{
|
||||
public abstract class DeleteRunnable : RunnableOnFinish
|
||||
{
|
||||
protected DeleteRunnable(Activity activity, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish)
|
||||
protected DeleteRunnable(OnFinish finish, IKp2aApp app)
|
||||
: base(finish)
|
||||
{
|
||||
App = app;
|
||||
}
|
||||
@@ -18,11 +17,11 @@ namespace keepass2android
|
||||
|
||||
protected Database Db;
|
||||
|
||||
protected Activity Ctx;
|
||||
protected Context Ctx;
|
||||
|
||||
protected void SetMembers(Activity activity, Database db)
|
||||
protected void SetMembers(Context ctx, Database db)
|
||||
{
|
||||
Ctx = activity;
|
||||
Ctx = ctx;
|
||||
Db = db;
|
||||
}
|
||||
|
||||
@@ -100,8 +99,7 @@ namespace keepass2android
|
||||
};
|
||||
|
||||
Db.KpDatabase.RootGroup.AddGroup(pgRecycleBin, true);
|
||||
Db.GroupsById[pgRecycleBin.Uuid] = pgRecycleBin;
|
||||
Db.Elements.Add(pgRecycleBin);
|
||||
Db.Groups[pgRecycleBin.Uuid] = pgRecycleBin;
|
||||
Db.KpDatabase.RecycleBinUuid = pgRecycleBin.Uuid;
|
||||
|
||||
bGroupListUpdateRequired = true;
|
||||
@@ -122,27 +120,24 @@ namespace keepass2android
|
||||
|
||||
public void Start()
|
||||
{
|
||||
string messageSuffix = ShowDatabaseIocInStatus ? "(" + App.GetFileStorage(Db.Ioc).GetDisplayName(Db.Ioc) + ")" : "";
|
||||
|
||||
if (CanRecycle)
|
||||
if (CanRecycle)
|
||||
{
|
||||
App.AskYesNoCancel(UiStringKey.AskDeletePermanently_title,
|
||||
QuestionRecycleResourceId,
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
DeletePermanently = true;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
|
||||
DeletePermanently = true;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
},
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
DeletePermanently = false;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
DeletePermanently = false;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
},
|
||||
(dlgSender, dlgEvt) => { },
|
||||
Ctx, messageSuffix);
|
||||
Ctx);
|
||||
|
||||
|
||||
|
||||
@@ -153,12 +148,12 @@ namespace keepass2android
|
||||
QuestionNoRecycleResourceId,
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
pt.Run();
|
||||
},
|
||||
null,
|
||||
(dlgSender, dlgEvt) => { },
|
||||
Ctx, messageSuffix);
|
||||
Ctx);
|
||||
|
||||
|
||||
}
|
||||
@@ -186,8 +181,7 @@ namespace keepass2android
|
||||
PwDeletedObject pdo = new PwDeletedObject(pe.Uuid, dtNow);
|
||||
pd.DeletedObjects.Add(pdo);
|
||||
touchedGroups.Add(pgParent);
|
||||
Db.EntriesById.Remove(pe.Uuid);
|
||||
Db.Elements.Remove(pe);
|
||||
Db.Entries.Remove(pe.Uuid);
|
||||
}
|
||||
else // Recycle
|
||||
{
|
||||
@@ -215,46 +209,36 @@ namespace keepass2android
|
||||
Android.Util.Log.Debug("KP2A", "Calling PerformDelete..");
|
||||
PerformDelete(touchedGroups, permanentlyDeletedGroups);
|
||||
|
||||
_onFinishToRun = new ActionOnFinish(ActiveActivity,(success, message, activity) =>
|
||||
_onFinishToRun = new ActionOnFinish((success, message) =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
foreach (var g in touchedGroups)
|
||||
App.DirtyGroups.Add(g);
|
||||
Db.Dirty.Add(g);
|
||||
foreach (var g in permanentlyDeletedGroups)
|
||||
{
|
||||
//remove groups from global lists if present there
|
||||
App.DirtyGroups.Remove(g);
|
||||
Db.GroupsById.Remove(g.Uuid);
|
||||
Db.Elements.Remove(g);
|
||||
|
||||
//remove groups from global lists if present there
|
||||
Db.Dirty.Remove(g);
|
||||
Db.Groups.Remove(g.Uuid);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's not bother recovering from a failure to save. It is too much work.
|
||||
App.Lock(false);
|
||||
App.LockDatabase(false);
|
||||
}
|
||||
}, OnFinishToRun);
|
||||
|
||||
// Commit database
|
||||
SaveDb save = new SaveDb(Ctx, App, Db, OnFinishToRun, false);
|
||||
save.ShowDatabaseIocInStatus = ShowDatabaseIocInStatus;
|
||||
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
SaveDb save = new SaveDb(Ctx, App, OnFinishToRun, false);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool ShowDatabaseIocInStatus
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
protected abstract void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups);
|
||||
protected abstract void PerformDelete(List<PwGroup> touchedGroups, List<PwGroup> permanentlyDeletedGroups);
|
||||
|
||||
public abstract UiStringKey StatusMessage { get; }
|
||||
|
||||
|
@@ -16,7 +16,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -26,20 +25,17 @@ namespace keepass2android
|
||||
public class EditGroup : RunnableOnFinish {
|
||||
internal Database Db
|
||||
{
|
||||
get { return _app.FindDatabaseForElement(Group); }
|
||||
get { return _app.GetDb(); }
|
||||
}
|
||||
|
||||
public IKp2aApp App { get => _app; }
|
||||
|
||||
private IKp2aApp _app;
|
||||
private IKp2aApp _app;
|
||||
private readonly String _name;
|
||||
private readonly PwIcon _iconId;
|
||||
private readonly PwUuid _customIconId;
|
||||
internal PwGroup Group;
|
||||
readonly Activity _ctx;
|
||||
readonly Context _ctx;
|
||||
|
||||
public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public EditGroup(Context ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -48,7 +44,7 @@ namespace keepass2android
|
||||
_customIconId = customIconId;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterEdit(ctx, this, OnFinishToRun);
|
||||
_onFinishToRun = new AfterEdit(this, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +56,7 @@ namespace keepass2android
|
||||
Group.Touch(true);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, Db, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -68,8 +64,8 @@ namespace keepass2android
|
||||
private class AfterEdit : OnFinish {
|
||||
readonly EditGroup _editGroup;
|
||||
|
||||
public AfterEdit(Activity ctx, EditGroup editGroup, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public AfterEdit(EditGroup editGroup, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_editGroup = editGroup;
|
||||
}
|
||||
@@ -79,10 +75,10 @@ namespace keepass2android
|
||||
|
||||
if ( Success ) {
|
||||
// Mark parent group dirty
|
||||
_editGroup.App.DirtyGroups.Add(_editGroup.Group.ParentGroup);
|
||||
_editGroup.Db.Dirty.Add(_editGroup.Group.ParentGroup);
|
||||
} else
|
||||
{
|
||||
_editGroup._app.Lock(false);
|
||||
_editGroup._app.LockDatabase(false);
|
||||
}
|
||||
|
||||
base.Run();
|
||||
|
@@ -16,7 +16,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
@@ -24,7 +23,7 @@ namespace keepass2android
|
||||
public abstract class FileOnFinish : OnFinish {
|
||||
private String _filename = "";
|
||||
|
||||
protected FileOnFinish(Activity activity, FileOnFinish finish):base(activity, finish) {
|
||||
protected FileOnFinish(FileOnFinish finish):base(finish) {
|
||||
}
|
||||
|
||||
public string Filename
|
||||
|
@@ -20,8 +20,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using keepass2android.database.edit;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
@@ -37,25 +35,20 @@ namespace keepass2android
|
||||
private readonly bool _rememberKeyfile;
|
||||
IDatabaseFormat _format;
|
||||
|
||||
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish, bool updateLastUsageTimestamp, bool makeCurrent): base(activity, finish)
|
||||
public LoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish): base(finish)
|
||||
{
|
||||
_app = app;
|
||||
_ioc = ioc;
|
||||
_databaseData = databaseData;
|
||||
_compositeKey = compositeKey;
|
||||
_keyfileOrProvider = keyfileOrProvider;
|
||||
_updateLastUsageTimestamp = updateLastUsageTimestamp;
|
||||
_makeCurrent = makeCurrent;
|
||||
|
||||
|
||||
_rememberKeyfile = app.GetBooleanPreference(PreferenceKey.remember_keyfile);
|
||||
_rememberKeyfile = app.GetBooleanPreference(PreferenceKey.remember_keyfile);
|
||||
}
|
||||
|
||||
protected bool success = false;
|
||||
private bool _updateLastUsageTimestamp;
|
||||
private readonly bool _makeCurrent;
|
||||
|
||||
public override void Run()
|
||||
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -84,10 +77,6 @@ namespace keepass2android
|
||||
//ok, try to load the database. Let's start with Kdbx format and retry later if that is the wrong guess:
|
||||
_format = new KdbxDatabaseFormat(KdbpFile.GetFormatToUse(_ioc));
|
||||
TryLoad(databaseStream);
|
||||
|
||||
|
||||
|
||||
success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -99,7 +88,7 @@ namespace keepass2android
|
||||
{
|
||||
Kp2aLog.Log("KeyFileException");
|
||||
Finish(false, /*TODO Localize: use Keepass error text KPRes.KeyFileError (including "or invalid format")*/
|
||||
_app.GetResourceString(UiStringKey.keyfile_does_not_exist), false, Exception);
|
||||
_app.GetResourceString(UiStringKey.keyfile_does_not_exist), Exception);
|
||||
}
|
||||
catch (AggregateException e)
|
||||
{
|
||||
@@ -110,20 +99,20 @@ namespace keepass2android
|
||||
// Override the message shown with the last (hopefully most recent) inner exception
|
||||
Kp2aLog.LogUnexpectedError(innerException);
|
||||
}
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + message, false, Exception);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + message, Exception);
|
||||
return;
|
||||
}
|
||||
catch (DuplicateUuidsException e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), false, Exception);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), Exception);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!(e is InvalidCompositeKeyException))
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message, false, Exception);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message, Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,7 +124,7 @@ namespace keepass2android
|
||||
/// </summary>
|
||||
public Exception Exception { get; set; }
|
||||
|
||||
Database TryLoad(MemoryStream databaseStream)
|
||||
private void TryLoad(MemoryStream databaseStream)
|
||||
{
|
||||
//create a copy of the stream so we can try again if we get an exception which indicates we should change parameters
|
||||
//This is not optimal in terms of (short-time) memory usage but is hard to avoid because the Keepass library closes streams also in case of errors.
|
||||
@@ -148,16 +137,19 @@ namespace keepass2android
|
||||
//now let's go:
|
||||
try
|
||||
{
|
||||
Database newDb = _app.LoadDatabase(_ioc, workingCopy, _compositeKey, StatusLogger, _format, _makeCurrent);
|
||||
_app.LoadDatabase(_ioc, workingCopy, _compositeKey, StatusLogger, _format);
|
||||
Kp2aLog.Log("LoadDB OK");
|
||||
|
||||
//make sure the stored access time for the actual file is more recent than that of its backup
|
||||
Thread.Sleep(10);
|
||||
SaveFileData(_ioc, _keyfileOrProvider);
|
||||
|
||||
Finish(true, _format.SuccessMessage);
|
||||
return newDb;
|
||||
}
|
||||
catch (OldFormatException)
|
||||
{
|
||||
_format = new KdbDatabaseFormat(_app);
|
||||
return TryLoad(databaseStream);
|
||||
TryLoad(databaseStream);
|
||||
}
|
||||
catch (InvalidCompositeKeyException)
|
||||
{
|
||||
@@ -169,7 +161,7 @@ namespace keepass2android
|
||||
//retry without password:
|
||||
_compositeKey.RemoveUserKey(passwordKey);
|
||||
//retry:
|
||||
return TryLoad(databaseStream);
|
||||
TryLoad(databaseStream);
|
||||
}
|
||||
else throw;
|
||||
}
|
||||
@@ -182,7 +174,7 @@ namespace keepass2android
|
||||
{
|
||||
keyfileOrProvider = "";
|
||||
}
|
||||
_app.StoreOpenedFileAsRecent(ioc, keyfileOrProvider, _updateLastUsageTimestamp);
|
||||
_app.StoreOpenedFileAsRecent(ioc, keyfileOrProvider);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
@@ -14,10 +12,10 @@ namespace keepass2android.database.edit
|
||||
{
|
||||
private readonly List<IStructureItem> _elementsToMove;
|
||||
private readonly PwGroup _targetGroup;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Activity ctx, IKp2aApp app, OnFinish finish) : base(ctx, finish)
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Context ctx, IKp2aApp app, OnFinish finish) : base(finish)
|
||||
{
|
||||
_elementsToMove = elementsToMove;
|
||||
_targetGroup = targetGroup;
|
||||
@@ -51,19 +49,10 @@ namespace keepass2android.database.edit
|
||||
|
||||
}
|
||||
|
||||
HashSet<Database> removeDatabases = new HashSet<Database>();
|
||||
Database addDatabase = _app.FindDatabaseForElement(_targetGroup);
|
||||
if (addDatabase == null)
|
||||
{
|
||||
Finish(false, "Did not find target database. Did you lock it?");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var elementToMove in _elementsToMove)
|
||||
{
|
||||
|
||||
_app.DirtyGroups.Add(elementToMove.ParentGroup);
|
||||
|
||||
_app.GetDb().Dirty.Add(elementToMove.ParentGroup);
|
||||
|
||||
PwGroup pgParent = elementToMove.ParentGroup;
|
||||
if (pgParent != _targetGroup)
|
||||
@@ -73,14 +62,8 @@ namespace keepass2android.database.edit
|
||||
PwEntry entry = elementToMove as PwEntry;
|
||||
if (entry != null)
|
||||
{
|
||||
var dbRem = _app.FindDatabaseForElement(entry);
|
||||
removeDatabases.Add(dbRem);
|
||||
dbRem.EntriesById.Remove(entry.Uuid);
|
||||
dbRem.Elements.Remove(entry);
|
||||
pgParent.Entries.Remove(entry);
|
||||
_targetGroup.AddEntry(entry, true, true);
|
||||
addDatabase.EntriesById.Add(entry.Uuid, entry);
|
||||
addDatabase.Elements.Add(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,60 +73,27 @@ namespace keepass2android.database.edit
|
||||
Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere));
|
||||
return;
|
||||
}
|
||||
|
||||
var dbRem = _app.FindDatabaseForElement(@group);
|
||||
if (dbRem == null)
|
||||
{
|
||||
Finish(false, "Did not find source database. Did you lock it?");
|
||||
return;
|
||||
}
|
||||
|
||||
dbRem.GroupsById.Remove(group.Uuid);
|
||||
dbRem.Elements.Remove(group);
|
||||
removeDatabases.Add(dbRem);
|
||||
pgParent.Groups.Remove(group);
|
||||
_targetGroup.AddGroup(group, true, true);
|
||||
addDatabase.GroupsById.Add(group.Uuid, group);
|
||||
addDatabase.Elements.Add(group);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
_onFinishToRun = new ActionOnFinish((success, message) =>
|
||||
{
|
||||
if (!success)
|
||||
{ // Let's not bother recovering from a failure.
|
||||
_app.LockDatabase(false);
|
||||
}
|
||||
}, OnFinishToRun);
|
||||
|
||||
|
||||
|
||||
|
||||
//first save the database where we added the elements
|
||||
var allDatabasesToSave = new List<Database> {addDatabase};
|
||||
//then all databases where we removed elements:
|
||||
removeDatabases.RemoveWhere(db => db == addDatabase);
|
||||
allDatabasesToSave.AddRange(removeDatabases);
|
||||
|
||||
int indexToSave = 0;
|
||||
bool allSavesSuccess = true;
|
||||
void ContinueSave(bool success, string message, Activity activeActivity)
|
||||
{
|
||||
allSavesSuccess &= success;
|
||||
indexToSave++;
|
||||
if (indexToSave == allDatabasesToSave.Count)
|
||||
{
|
||||
OnFinishToRun.SetResult(allSavesSuccess);
|
||||
OnFinishToRun.Run();
|
||||
return;
|
||||
}
|
||||
SaveDb saveDb = new SaveDb(_ctx, _app, allDatabasesToSave[indexToSave], new ActionOnFinish(activeActivity, ContinueSave), false);
|
||||
saveDb.SetStatusLogger(StatusLogger);
|
||||
saveDb.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||
saveDb.Run();
|
||||
}
|
||||
|
||||
|
||||
SaveDb save = new SaveDb(_ctx, _app, allDatabasesToSave[0], new ActionOnFinish(ActiveActivity, ContinueSave), false);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||
save.Run();
|
||||
// Save
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, false);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Widget;
|
||||
@@ -29,77 +27,49 @@ namespace keepass2android
|
||||
protected bool Success;
|
||||
protected String Message;
|
||||
protected Exception Exception;
|
||||
|
||||
protected bool ImportantMessage
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
protected OnFinish BaseOnFinish;
|
||||
|
||||
protected OnFinish BaseOnFinish;
|
||||
protected Handler Handler;
|
||||
private ProgressDialogStatusLogger _statusLogger = new ProgressDialogStatusLogger(); //default: no logging but not null -> can be used whenever desired
|
||||
private Activity _activeActivity;
|
||||
|
||||
|
||||
|
||||
public ProgressDialogStatusLogger StatusLogger
|
||||
public ProgressDialogStatusLogger StatusLogger
|
||||
{
|
||||
get { return _statusLogger; }
|
||||
set { _statusLogger = value; }
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (BaseOnFinish != null)
|
||||
{
|
||||
BaseOnFinish.ActiveActivity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected OnFinish(Activity activeActivity, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
protected OnFinish(Handler handler) {
|
||||
BaseOnFinish = null;
|
||||
Handler = handler;
|
||||
|
||||
}
|
||||
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
protected OnFinish(OnFinish finish, Handler handler) {
|
||||
BaseOnFinish = finish;
|
||||
Handler = handler;
|
||||
}
|
||||
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
protected OnFinish(OnFinish finish) {
|
||||
BaseOnFinish = finish;
|
||||
Handler = null;
|
||||
}
|
||||
|
||||
public void SetResult(bool success, string message, bool importantMessage, Exception exception) {
|
||||
public void SetResult(bool success, string message, Exception exception) {
|
||||
Success = success;
|
||||
Message = message;
|
||||
ImportantMessage = importantMessage;
|
||||
Exception = exception;
|
||||
}
|
||||
|
||||
|
||||
public void SetResult(bool success) {
|
||||
|
||||
public void SetResult(bool success) {
|
||||
Success = success;
|
||||
}
|
||||
|
||||
public virtual void Run() {
|
||||
if (BaseOnFinish == null) return;
|
||||
// Pass on result on call finish
|
||||
BaseOnFinish.SetResult(Success, Message, ImportantMessage, Exception);
|
||||
BaseOnFinish.SetResult(Success, Message, Exception);
|
||||
|
||||
if ( Handler != null ) {
|
||||
Handler.Post(BaseOnFinish.Run);
|
||||
@@ -109,31 +79,14 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
protected void DisplayMessage(Context ctx) {
|
||||
DisplayMessage(ctx, Message, ImportantMessage);
|
||||
DisplayMessage(ctx, Message);
|
||||
}
|
||||
|
||||
public static void DisplayMessage(Context ctx, string message, bool makeDialog)
|
||||
public static void DisplayMessage(Context ctx, string message)
|
||||
{
|
||||
if ( !String.IsNullOrEmpty(message) ) {
|
||||
Kp2aLog.Log("OnFinish message: " + message);
|
||||
if (makeDialog && ctx != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
|
||||
builder.SetMessage(message)
|
||||
.SetPositiveButton(Android.Resource.String.Ok, (sender, args) => ((Dialog)sender).Dismiss())
|
||||
.Show();
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Toast.MakeText(ctx, message, ToastLength.Long).Show();
|
||||
}
|
||||
}
|
||||
else
|
||||
Toast.MakeText(ctx ?? Application.Context, message, ToastLength.Long).Show();
|
||||
Kp2aLog.Log("OnFinish message: "+message);
|
||||
Toast.MakeText(ctx, message, ToastLength.Long).Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
@@ -25,11 +23,8 @@ namespace keepass2android
|
||||
|
||||
protected OnFinish _onFinishToRun;
|
||||
public ProgressDialogStatusLogger StatusLogger = new ProgressDialogStatusLogger(); //default: empty but not null
|
||||
private Activity _activeActivity;
|
||||
|
||||
protected RunnableOnFinish(Activity activeActivity, OnFinish finish)
|
||||
{
|
||||
_activeActivity = activeActivity;
|
||||
protected RunnableOnFinish(OnFinish finish) {
|
||||
_onFinishToRun = finish;
|
||||
}
|
||||
|
||||
@@ -39,20 +34,9 @@ namespace keepass2android
|
||||
set { _onFinishToRun = value; }
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (_onFinishToRun != null)
|
||||
_onFinishToRun.ActiveActivity = _activeActivity;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Finish(bool result, String message, bool importantMessage = false, Exception exception = null) {
|
||||
protected void Finish(bool result, String message, Exception exception = null) {
|
||||
if ( OnFinishToRun != null ) {
|
||||
OnFinishToRun.SetResult(result, message, importantMessage, exception);
|
||||
OnFinishToRun.SetResult(result, message, exception);
|
||||
OnFinishToRun.Run();
|
||||
}
|
||||
}
|
||||
@@ -72,7 +56,7 @@ namespace keepass2android
|
||||
StatusLogger = status;
|
||||
}
|
||||
|
||||
public abstract void Run();
|
||||
abstract public void Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Java.Lang;
|
||||
@@ -34,8 +33,7 @@ namespace keepass2android
|
||||
|
||||
public class SaveDb : RunnableOnFinish {
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Database _db;
|
||||
private readonly bool _dontSave;
|
||||
private readonly bool _dontSave;
|
||||
|
||||
/// <summary>
|
||||
/// stream for reading the data from the original file. If this is set to a non-null value, we know we need to sync
|
||||
@@ -44,10 +42,9 @@ namespace keepass2android
|
||||
private readonly Context _ctx;
|
||||
private Thread _workerThread;
|
||||
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
{
|
||||
_db = db;
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_dontSave = dontSave;
|
||||
@@ -61,55 +58,46 @@ namespace keepass2android
|
||||
/// <param name="finish"></param>
|
||||
/// <param name="dontSave"></param>
|
||||
/// <param name="streamForOrigFile">Stream for reading the data from the (changed) original location</param>
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnFinish finish, Database db, bool dontSave, Stream streamForOrigFile)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish, bool dontSave, Stream streamForOrigFile)
|
||||
: base(finish)
|
||||
{
|
||||
_db = db;
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_dontSave = dontSave;
|
||||
_streamForOrigFile = streamForOrigFile;
|
||||
}
|
||||
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_db = db;
|
||||
_dontSave = false;
|
||||
_dontSave = false;
|
||||
}
|
||||
|
||||
public bool ShowDatabaseIocInStatus { get; set; }
|
||||
|
||||
public override void Run ()
|
||||
|
||||
|
||||
public override void Run ()
|
||||
{
|
||||
|
||||
if (!_dontSave)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_db.CanWrite == false)
|
||||
if (_app.GetDb().CanWrite == false)
|
||||
{
|
||||
//this should only happen if there is a problem in the UI so that the user sees an edit interface.
|
||||
Finish(false,"Cannot save changes. File is read-only!");
|
||||
return;
|
||||
}
|
||||
|
||||
string message = _app.GetResourceString(UiStringKey.saving_database);
|
||||
|
||||
if (ShowDatabaseIocInStatus)
|
||||
message += " (" + _app.GetFileStorage(_db.Ioc).GetDisplayName(_db.Ioc) + ")";
|
||||
|
||||
StatusLogger.UpdateMessage(message);
|
||||
|
||||
IOConnectionInfo ioc = _db.Ioc;
|
||||
StatusLogger.UpdateMessage(UiStringKey.saving_database);
|
||||
IOConnectionInfo ioc = _app.GetDb().Ioc;
|
||||
IFileStorage fileStorage = _app.GetFileStorage(ioc);
|
||||
|
||||
if (_streamForOrigFile == null)
|
||||
{
|
||||
if ((!_app.GetBooleanPreference(PreferenceKey.CheckForFileChangesOnSave))
|
||||
|| (_db.KpDatabase.HashOfFileOnDisk == null)) //first time saving
|
||||
|| (_app.GetDb().KpDatabase.HashOfFileOnDisk == null)) //first time saving
|
||||
{
|
||||
PerformSaveWithoutCheck(fileStorage, ioc);
|
||||
Finish(true);
|
||||
@@ -120,8 +108,8 @@ namespace keepass2android
|
||||
|
||||
if (
|
||||
(_streamForOrigFile != null)
|
||||
|| fileStorage.CheckForFileChangeFast(ioc, _db.LastFileVersion) //first try to use the fast change detection
|
||||
|| (FileHashChanged(ioc, _db.KpDatabase.HashOfFileOnDisk) == FileHashChange.Changed) //if that fails, hash the file and compare:
|
||||
|| fileStorage.CheckForFileChangeFast(ioc, _app.GetDb().LastFileVersion) //first try to use the fast change detection
|
||||
|| (FileHashChanged(ioc, _app.GetDb().KpDatabase.HashOfFileOnDisk) == FileHashChange.Changed) //if that fails, hash the file and compare:
|
||||
)
|
||||
{
|
||||
|
||||
@@ -139,7 +127,6 @@ namespace keepass2android
|
||||
//small.
|
||||
MergeIn(fileStorage, ioc);
|
||||
PerformSaveWithoutCheck(fileStorage, ioc);
|
||||
_db.UpdateGlobals();
|
||||
Finish(true);
|
||||
};
|
||||
RunInWorkerThread(runHandler);
|
||||
@@ -229,13 +216,13 @@ namespace keepass2android
|
||||
StatusLogger.UpdateSubMessage(_app.GetResourceString(UiStringKey.SynchronizingDatabase));
|
||||
|
||||
PwDatabase pwImp = new PwDatabase();
|
||||
PwDatabase pwDatabase = _db.KpDatabase;
|
||||
PwDatabase pwDatabase = _app.GetDb().KpDatabase;
|
||||
pwImp.New(new IOConnectionInfo(), pwDatabase.MasterKey);
|
||||
pwImp.MemoryProtection = pwDatabase.MemoryProtection.CloneDeep();
|
||||
pwImp.MasterKey = pwDatabase.MasterKey;
|
||||
var stream = GetStreamForBaseFile(fileStorage, ioc);
|
||||
|
||||
_db.DatabaseFormat.PopulateDatabaseFromStream(pwImp, stream, null);
|
||||
_app.GetDb().DatabaseFormat.PopulateDatabaseFromStream(pwImp, stream, null);
|
||||
|
||||
|
||||
pwDatabase.MergeIn(pwImp, PwMergeMethod.Synchronize, null);
|
||||
@@ -261,8 +248,8 @@ namespace keepass2android
|
||||
private void PerformSaveWithoutCheck(IFileStorage fileStorage, IOConnectionInfo ioc)
|
||||
{
|
||||
StatusLogger.UpdateSubMessage("");
|
||||
_db.SaveData();
|
||||
_db.LastFileVersion = fileStorage.GetCurrentFileVersionFast(ioc);
|
||||
_app.GetDb().SaveData(_ctx);
|
||||
_app.GetDb().LastFileVersion = fileStorage.GetCurrentFileVersionFast(ioc);
|
||||
}
|
||||
|
||||
public byte[] HashOriginalFile(IOConnectionInfo iocFile)
|
||||
|
@@ -15,7 +15,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
@@ -28,9 +27,9 @@ namespace keepass2android
|
||||
private readonly String _keyfile;
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly bool _dontSave;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish): base(ctx, finish) {
|
||||
public SetPassword(Context ctx, IKp2aApp app, String password, String keyfile, OnFinish finish): base(finish) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_password = password;
|
||||
@@ -38,8 +37,8 @@ namespace keepass2android
|
||||
_dontSave = false;
|
||||
}
|
||||
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
public SetPassword(Context ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -52,7 +51,7 @@ namespace keepass2android
|
||||
public override void Run ()
|
||||
{
|
||||
StatusLogger.UpdateMessage(UiStringKey.SettingPassword);
|
||||
PwDatabase pm = _app.CurrentDb.KpDatabase;
|
||||
PwDatabase pm = _app.GetDb().KpDatabase;
|
||||
CompositeKey newKey = new CompositeKey ();
|
||||
if (String.IsNullOrEmpty (_password) == false) {
|
||||
newKey.AddUserKey (new KcpPassword (_password));
|
||||
@@ -73,8 +72,8 @@ namespace keepass2android
|
||||
pm.MasterKey = newKey;
|
||||
|
||||
// Save Database
|
||||
_onFinishToRun = new AfterSave(ActiveActivity, previousKey, previousMasterKeyChanged, pm, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun, _dontSave);
|
||||
_onFinishToRun = new AfterSave(previousKey, previousMasterKeyChanged, pm, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -84,7 +83,7 @@ namespace keepass2android
|
||||
private readonly DateTime _previousKeyChanged;
|
||||
private readonly PwDatabase _db;
|
||||
|
||||
public AfterSave(Activity activity, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(activity, finish) {
|
||||
public AfterSave(CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(finish) {
|
||||
_previousKeyChanged = previousKeyChanged;
|
||||
_backup = backup;
|
||||
_db = db;
|
||||
|
@@ -15,7 +15,6 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -24,19 +23,19 @@ namespace keepass2android
|
||||
|
||||
public class UpdateEntry : RunnableOnFinish {
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Activity _ctx;
|
||||
private readonly Context _ctx;
|
||||
|
||||
public UpdateEntry(Activity ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnFinish finish):base(ctx, finish) {
|
||||
public UpdateEntry(Context ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnFinish finish):base(finish) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterUpdate(ctx, oldE, newE, app, finish);
|
||||
_onFinishToRun = new AfterUpdate(oldE, newE, app, finish);
|
||||
}
|
||||
|
||||
|
||||
public override void Run() {
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -46,7 +45,7 @@ namespace keepass2android
|
||||
private readonly PwEntry _updatedEntry;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish):base(activity, finish) {
|
||||
public AfterUpdate(PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish):base(finish) {
|
||||
_backup = backup;
|
||||
_updatedEntry = updatedEntry;
|
||||
_app = app;
|
||||
@@ -59,7 +58,7 @@ namespace keepass2android
|
||||
if ( parent != null ) {
|
||||
|
||||
// Mark parent group dirty
|
||||
_app.DirtyGroups.Add(parent);
|
||||
_app.GetDb().Dirty.Add(parent);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -63,8 +63,6 @@
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="libs\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Xamarin.Android.Bindings.targets" />
|
||||
</Project>
|
@@ -1,48 +0,0 @@
|
||||
Additions allow you to add arbitrary C# to the generated classes
|
||||
before they are compiled. This can be helpful for providing convenience
|
||||
methods or adding pure C# classes.
|
||||
|
||||
== Adding Methods to Generated Classes ==
|
||||
|
||||
Let's say the library being bound has a Rectangle class with a constructor
|
||||
that takes an x and y position, and a width and length size. It will look like
|
||||
this:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
// JNI bindings
|
||||
}
|
||||
}
|
||||
|
||||
Imagine we want to add a constructor to this class that takes a Point and
|
||||
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
|
||||
with a partial class containing our new method:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (Point location, Size size) :
|
||||
this (location.X, location.Y, size.Width, size.Height)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
At compile time, the additions class will be added to the generated class
|
||||
and the final assembly will a Rectangle class with both constructors.
|
||||
|
||||
|
||||
== Adding C# Classes ==
|
||||
|
||||
Another thing that can be done is adding fully C# managed classes to the
|
||||
generated library. In the above example, let's assume that there isn't a
|
||||
Point class available in Java or our library. The one we create doesn't need
|
||||
to interact with Java, so we'll create it like a normal class in C#.
|
||||
|
||||
By adding a Point.cs file with this class, it will end up in the binding library:
|
||||
|
||||
public class Point
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
This directory is for Android .jars.
|
||||
|
||||
There are 2 types of jars that are supported:
|
||||
|
||||
== Input Jar ==
|
||||
|
||||
This is the jar that bindings should be generated for.
|
||||
|
||||
For example, if you were binding the Google Maps library, this would
|
||||
be Google's "maps.jar".
|
||||
|
||||
Set the build action for these jars in the properties page to "InputJar".
|
||||
|
||||
|
||||
== Reference Jars ==
|
||||
|
||||
These are jars that are referenced by the input jar. C# bindings will
|
||||
not be created for these jars. These jars will be used to resolve
|
||||
types used by the input jar.
|
||||
|
||||
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
|
||||
based on the Target Framework selected.
|
||||
|
||||
Set the build action for these jars in the properties page to "ReferenceJar".
|
Binary file not shown.
Binary file not shown.
@@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}</ProjectGuid>
|
||||
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
|
||||
|
||||
|
||||
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PCloudBindings</RootNamespace>
|
||||
<AssemblyName>PCouldBindings</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseNoNet|AnyCPU'">
|
||||
<OutputPath>bin\ReleaseNoNet\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="System" />
|
||||
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.1.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
<TransformFile Include="Transforms\EnumFields.xml" />
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.1.0.jar" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -1,30 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PCloudBindings")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PCloudBindings")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
@@ -1,14 +0,0 @@
|
||||
<enum-field-mappings>
|
||||
<!--
|
||||
This example converts the constants Fragment_id, Fragment_name,
|
||||
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
|
||||
to an enum called Android.Support.V4.App.FragmentTagType with values
|
||||
Id, Name, and Tag.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
|
||||
<field jni-name="Fragment_name" clr-name="Name" value="0" />
|
||||
<field jni-name="Fragment_id" clr-name="Id" value="1" />
|
||||
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-field-mappings>
|
@@ -1,13 +0,0 @@
|
||||
<enum-method-mappings>
|
||||
<!--
|
||||
This example changes the Java method:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
|
||||
to be:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
|
||||
when bound in C#.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
|
||||
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-method-mappings>
|
@@ -1,10 +0,0 @@
|
||||
<metadata>
|
||||
<!--
|
||||
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
|
||||
|
||||
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
|
||||
-->
|
||||
<remove-node path="/api/package[@name='com.pcloud.sdk']" />
|
||||
</metadata>
|
@@ -53,8 +53,8 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<LibraryProjectZip Include="..\java\Keepass2AndroidPluginSDK2\app\build\outputs\aar\Keepass2AndroidPluginSDK2-release.aar">
|
||||
<Link>Jars\Keepass2AndroidPluginSDK2-release.aar</Link>
|
||||
<LibraryProjectZip Include="..\java\Keepass2AndroidPluginSDK2\app\build\outputs\aar\app-release.aar">
|
||||
<Link>Jars\app-release.aar</Link>
|
||||
</LibraryProjectZip>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
|
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo '*****************************************'
|
||||
echo '********** Building Java parts **********'
|
||||
echo '*****************************************'
|
||||
./build-java.sh
|
||||
|
||||
echo '*****************************************'
|
||||
echo '******** Building Xamarin parts *********'
|
||||
echo '*****************************************'
|
||||
./build-xamarin.sh
|
||||
|
||||
echo '*****************************************'
|
||||
echo '************** Building APK *************'
|
||||
echo '*****************************************'
|
||||
./build-apk.sh
|
||||
|
||||
echo
|
||||
echo 'Congratulations! You you can find the target APK in src/keepass2android/bin/Debug/.'
|
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ../keepass2android
|
||||
|
||||
xabuild keepass2android.csproj /t:SignAndroidPackage "$@"
|
||||
|
||||
popd
|
@@ -7,7 +7,4 @@ call gradlew assemble
|
||||
cd ..\Keepass2AndroidPluginSDK2
|
||||
call gradlew assemble
|
||||
|
||||
cd ..\PluginQR
|
||||
call gradlew assemble
|
||||
|
||||
cd ..\..\build-scripts
|
||||
cd ..\..\build-scripts
|
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ../java/
|
||||
|
||||
pushd JavaFileStorageTest-AS
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
pushd KP2ASoftkeyboard_AS
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
pushd Keepass2AndroidPluginSDK2
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
pushd PluginQR
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
popd
|
@@ -6,11 +6,11 @@ if exist "DropboxFileStorageKeys.cs" (
|
||||
)
|
||||
|
||||
cd ..\..\keepass2android
|
||||
call UseManifestDebug.bat
|
||||
call UseManifestNoNet.bat
|
||||
cd ..
|
||||
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
|
||||
|
||||
msbuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Debug" /p:Platform="Any CPU"
|
||||
msbuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Release" /p:Platform="Any CPU"
|
||||
|
||||
cd build-scripts
|
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ..
|
||||
|
||||
pushd Kp2aBusinessLogic/Io
|
||||
|
||||
if [ -f "DropboxFileStorageKeys.cs" ]
|
||||
then
|
||||
echo "DropboxFileStorageKeys.cs found."
|
||||
else
|
||||
cp DropboxFileStorageKeysDummy.cs DropboxFileStorageKeys.cs
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
pushd keepass2android
|
||||
./UseManifestDebug.sh
|
||||
popd
|
||||
|
||||
# call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
|
||||
|
||||
xabuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Debug" /p:Platform="Any CPU" "$@"
|
||||
|
||||
popd
|
@@ -1,55 +0,0 @@
|
||||
# How to build Keepass2Android
|
||||
|
||||
## Overview
|
||||
|
||||
Keepass2Android is a Mono for Android app. This means that you need Xamarin's Mono for Android to build it. However, it also uses several components written in Java, so there are also Android-Studio projects involved. To make things even worse, parts of the keyboard and kdb-library are written in native code.
|
||||
The current build-scripts assume that the native libraries are already built (they are included in the repo).
|
||||
|
||||
To build KP2A from scratch, make sure that you have Xamarin's Mono for Android installed and also install Android Studio. Make sure that both point to the same Android SDK location.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Install Xamarin.Android
|
||||
- Fetch all submodules (`git submodule init && git submodule update`)
|
||||
|
||||
## Build
|
||||
|
||||
### On Windows
|
||||
|
||||
```bat
|
||||
cd build-scripts
|
||||
build-java.bat
|
||||
build-xamarin.bat
|
||||
```
|
||||
|
||||
build-java.bat will call gradlew for several Java modules. build-xamarin.bat will first make sure that you have all files at their place. (There is a "secret" file for Dropbox SDK keys which is not in the repo, this is replaced with a dummy file. There are also different Android Manifest files depending on the configuration which is selected by calling the appropriate script.)
|
||||
|
||||
**Notes:**
|
||||
|
||||
- For building the java parts, it is suggested to keep a short name (e.g. "c:\projects\keepass2android") for the root project directory. Otherwise the Windows path length limit might be hit when building.
|
||||
- Before building the java parts, make sure you have set the ANDROID_HOME variable or create a local.properties file inside the directories with a gradlew file. It is recommended to use the same SDK location as that of the Xamarin build.
|
||||
|
||||
### On Linux
|
||||
|
||||
- Install [Mono](https://www.mono-project.com/)
|
||||
- Install Xamarin.Android
|
||||
- Option 1: Use the mono-project [CI builds](https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/lastSuccessfulBuild/Azure/)
|
||||
- Option 2: [Build it from source](https://github.com/xamarin/xamarin-android/blob/master/Documentation/README.md#building-from-source)
|
||||
- Setup your environment:
|
||||
- Add `xabuild` to your path: `export PATH=/path/to/xamarin.android-oss/bin/Release/bin/:$PATH`
|
||||
- Setup your `ANDROID_HOME` if it's not already: `export ANDROID_HOME=/path/to/android/`
|
||||
- Alternatively, you can set your `ANDROID_SDK_PATH` and `ANDROID_NDK_PATH`.
|
||||
- Build [jar2xml](https://github.com/xamarin/jar2xml) and copy `jar2xml.jar` to `/path/to/xamarin.android-oss/bin/Release/lib/xamarin.android/xbuild/Xamarin/Android/`
|
||||
- Install [libzip](https://libzip.org/) for your distribution.
|
||||
- Note: Xamarin seems to require `libzip4`, yet most distributions only ships `libzip5`. As a dirty workaround, it's possible to symlink `libzip.so.5` to `libzip.so.4`. Luckily, it appears to be working.
|
||||
- `sudo ln -s /usr/lib/libzip.so.5 /usr/lib/libzip.so.4`
|
||||
- Install NuGet dependencies:
|
||||
- `cd src/ && nuget restore KeePass.sln`
|
||||
- Build:
|
||||
- Option 1: `cd build-scripts && ./build-all.sh`
|
||||
- Option 2:
|
||||
- Build the Java parts: `cd build-scripts/ && ./build-java.sh`
|
||||
- Build the Xamarin parts: `./build-xamarin.sh`
|
||||
- Build the signed APK: `./build-apk.sh`
|
||||
- Enjoy:
|
||||
- `adb install ../keepass2android/bin/Debug/keepass2android.keepass2android_debug-Signed.apk`
|
23
src/build.readme.txt
Normal file
23
src/build.readme.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
How to build Keepass2Android
|
||||
|
||||
* Overview *
|
||||
Keepass2Android is a Mono for Android app. This means that you need Xamarin's Mono for Android to build it. However, it also uses several components written in Java, so there are also Android-Studio projects involved. To make things even worse, parts of the keyboard and kdb-library are written in native code.
|
||||
The current build-scripts assume that the native libraries are already built (they are included in the repo).
|
||||
|
||||
To build KP2A from scratch, make sure that you have Xamarin's Mono for Android installed and also install Android Studio. Make sure that both point to the same Android SDK location.
|
||||
|
||||
On Windows you can use
|
||||
|
||||
cd build-scripts
|
||||
build-java.bat
|
||||
build-xamarin.bat
|
||||
|
||||
build-java.bat will call gradlew for several Java modules. build-xamarin.bat will first make sure that you have all files at their place. (There is a "secret" file for Dropbox SDK keys which is not in the repo, this is replaced with a dummy file. There are also different Android Manifest files depending on the configuration which is selected by calling the appropriate script.)
|
||||
|
||||
|
||||
* Notes *
|
||||
- Please don't forget to update the git submodules before building.
|
||||
- For building the java parts on Windows, it is suggested to keep a short name (e.g. "c:\projects\keepass2android") for the root project directory. Otherwise the Windows path length limit might be hit when building.
|
||||
- Before building the java parts, make sure you have set the ANDROID_HOME variable or create a local.properties file inside the directories with a gradlew file. It is recommended to use the same SDK location as that of the Xamarin build.
|
||||
|
||||
|
@@ -35,12 +35,6 @@ dependencies {
|
||||
compile('com.onedrive.sdk:onedrive-sdk-android:1.2.0') {
|
||||
transitive = false
|
||||
}
|
||||
compile 'com.pcloud.sdk:java-core:1.1.0'
|
||||
compile 'com.pcloud.sdk:android:1.1.0'
|
||||
compile('com.microsoft.graph:msgraph-sdk-android:1.2.+')
|
||||
compile ('com.microsoft.identity.client:msal:0.1.+') {
|
||||
exclude group: 'com.android.support', module: 'appcompat-v7'
|
||||
}
|
||||
compile 'com.google.code.gson:gson:2.3.1'
|
||||
compile 'com.microsoft.services.msa:msa-auth:0.8.6'
|
||||
compile 'com.microsoft.aad:adal:1.14.0'
|
||||
|
@@ -1,21 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="keepass2android.javafilestorage"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="14" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".NotifSlave"
|
||||
android:label="Keepass2Android"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
@@ -38,8 +38,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
|
||||
public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
|
||||
@@ -312,8 +310,6 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
String driveId = path.getGDriveId();
|
||||
logDebug("id"+driveId);
|
||||
File file = driveService.files().get(driveId).execute();
|
||||
if (file.getLabels().getTrashed())
|
||||
throw new FileNotFoundException(path.getDisplayName() + " is trashed!");
|
||||
logDebug("...done.");
|
||||
return file;
|
||||
}
|
||||
@@ -784,7 +780,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
public void onRequestPermissionsResult(FileStorageSetupActivity setupAct, int requestCode, String[] permissions, int[] grantResults)
|
||||
{
|
||||
logDebug("onRequestPermissionsResult");
|
||||
if (grantResults[0] == PERMISSION_GRANTED)
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
logDebug("granted");
|
||||
initFileStorage(setupAct);
|
||||
@@ -856,10 +852,9 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
boolean allOk = true;
|
||||
for (String s: permissions)
|
||||
{
|
||||
int permissionRes = act.checkSelfPermission(s);
|
||||
logDebug("permissionRes "+s+"="+permissionRes);
|
||||
if (permissionRes != PERMISSION_GRANTED)
|
||||
allOk = false;
|
||||
int permissionRes = act.checkSelfPermission(Manifest.permission.GET_ACCOUNTS);
|
||||
logDebug("permissionRes="+permissionRes);
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
if (!allOk)
|
||||
|
@@ -132,7 +132,7 @@ public class FileEntry {
|
||||
|
||||
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception;
|
||||
|
||||
public String getCurrentFileVersionFast(String path) throws Exception;
|
||||
public String getCurrentFileVersionFast(String path);
|
||||
|
||||
public InputStream openFileForRead(String path) throws Exception;
|
||||
|
||||
@@ -157,4 +157,4 @@ public class FileEntry {
|
||||
public void onActivityResult(FileStorageSetupActivity activity, int requestCode, int resultCode, Intent data);
|
||||
public void onRequestPermissionsResult(FileStorageSetupActivity activity, int requestCode, String[] permissions, int[] grantResults);
|
||||
|
||||
}
|
||||
}
|
@@ -1,169 +0,0 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//based on https://github.com/jwise/dumload/blob/master/src/com/joshuawise/dumload/NotifSlave.java
|
||||
public class NotifSlave extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
private void say(String s) {
|
||||
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private int _nextdialog = 0;
|
||||
private Dialog dialog = null;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id)
|
||||
{
|
||||
Log.e("KP2AJ.NotifSlave", "Create for dialog "+(Integer.toString(id)));
|
||||
if (id != _nextdialog)
|
||||
return null;
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void showDialog(Dialog d)
|
||||
{
|
||||
_nextdialog++;
|
||||
dialog = d;
|
||||
Log.e("KP2AJ.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
|
||||
showDialog(_nextdialog);
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Intent i = getIntent(); /* i *am* not an intent! */
|
||||
final Activity thisact = this;
|
||||
|
||||
final Messenger m = (Messenger)i.getParcelableExtra("keepass2android.sftp.returnmessenger");
|
||||
String reqtype = i.getStringExtra("keepass2android.sftp.reqtype");
|
||||
String prompt = i.getStringExtra("keepass2android.sftp.prompt");
|
||||
|
||||
if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
|
||||
{
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reqtype.equals("yesno")) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Keepass2Android");
|
||||
builder.setMessage(prompt);
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Log.e("KP2AJ.NotifSlave", "Responding with a 1.");
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 1;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Log.e("KP2AJ.NotifSlave", "Responding with a 1.");
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 0;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
showDialog(alert);
|
||||
} else if (reqtype.equals("message")) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Keepass2Android");
|
||||
builder.setMessage(prompt);
|
||||
builder.setCancelable(false);
|
||||
builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
showDialog(alert);
|
||||
} /*else if (reqtype.equals("password")) {
|
||||
final Dialog d = new Dialog(this);
|
||||
|
||||
d.setContentView(R.layout.notfif_slave);
|
||||
d.setTitle("Keepass2Android");
|
||||
d.setCancelable(false);
|
||||
|
||||
TextView text = (TextView) d.findViewById(R.id.prompt);
|
||||
text.setText(prompt);
|
||||
|
||||
Button ok = (Button) d.findViewById(R.id.ok);
|
||||
ok.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 1;
|
||||
TextView entry = (TextView) d.findViewById(R.id.entry);
|
||||
Bundle b = new Bundle(1);
|
||||
b.putString("response", entry.getText().toString());
|
||||
me.setData(b);
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
d.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
|
||||
Button cancel = (Button) d.findViewById(R.id.cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 0;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
d.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
showDialog(d);
|
||||
} */else {
|
||||
Log.e("KP2AJ.NotifSlave", "What's a "+reqtype+"?");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,486 +0,0 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.microsoft.graph.core.ClientException;
|
||||
import com.microsoft.graph.core.DefaultClientConfig;
|
||||
import com.microsoft.graph.core.GraphErrorCodes;
|
||||
import com.microsoft.graph.extensions.DriveItem;
|
||||
import com.microsoft.graph.extensions.GraphServiceClient;
|
||||
import com.microsoft.graph.extensions.IDriveItemCollectionPage;
|
||||
import com.microsoft.graph.extensions.IDriveItemCollectionRequestBuilder;
|
||||
import com.microsoft.graph.extensions.IDriveItemRequest;
|
||||
import com.microsoft.graph.extensions.IDriveItemRequestBuilder;
|
||||
import com.microsoft.graph.extensions.IGraphServiceClient;
|
||||
import com.microsoft.identity.client.AuthenticationCallback;
|
||||
import com.microsoft.identity.client.AuthenticationResult;
|
||||
import com.microsoft.identity.client.MsalException;
|
||||
import com.microsoft.identity.client.PublicClientApplication;
|
||||
import com.microsoft.identity.client.User;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import keepass2android.javafilestorage.onedrive2.GraphServiceClientManager;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Philipp on 20.11.2016.
|
||||
*/
|
||||
public class OneDriveStorage2 extends JavaFileStorageBase
|
||||
{
|
||||
PublicClientApplication mPublicClientApp;
|
||||
|
||||
final HashMap<String /*userid*/, IGraphServiceClient> mClientByUser = new HashMap<String /*userid*/, IGraphServiceClient>();
|
||||
|
||||
private static final String[] scopes = {"openid","offline_access", "https://graph.microsoft.com/Files.ReadWrite","https://graph.microsoft.com/User.Read"};
|
||||
|
||||
|
||||
public OneDriveStorage2(final Activity context, final String clientId) {
|
||||
|
||||
mPublicClientApp = new PublicClientApplication(context, clientId);
|
||||
initAuthenticator(context);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean requiresSetup(String path)
|
||||
{
|
||||
|
||||
return !isConnected(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSelectFile(FileStorageSetupInitiatorActivity activity, boolean isForSave, int requestCode) {
|
||||
|
||||
initAuthenticator((Activity)activity.getActivity());
|
||||
|
||||
String path = getProtocolId()+":///";
|
||||
Log.d("KP2AJ", "startSelectFile "+path+", connected: "+path);
|
||||
if (isConnected(null))
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_IS_FOR_SAVE, isForSave);
|
||||
intent.putExtra(EXTRA_PATH, path);
|
||||
activity.onImmediateResult(requestCode, RESULT_FILECHOOSER_PREPARED, intent);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.startSelectFileProcess(path, isForSave, requestCode);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConnected(String path) {
|
||||
try {
|
||||
if (tryGetMsGraphClient(path) == null)
|
||||
try {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
Log.d("KP2AJ", "trying silent login");
|
||||
|
||||
String userId = extractUserId(path);
|
||||
final MsalException[] _exception = {null};
|
||||
final AuthenticationResult[] _result = {null};
|
||||
User user = mPublicClientApp.getUser(userId);
|
||||
mPublicClientApp.acquireTokenSilentAsync(scopes, user,
|
||||
new AuthenticationCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(AuthenticationResult authenticationResult) {
|
||||
_result[0] = authenticationResult;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(MsalException exception) {
|
||||
_exception[0] = exception;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
latch.countDown();
|
||||
|
||||
}
|
||||
});
|
||||
latch.await();
|
||||
if (_result[0] != null) {
|
||||
buildClient(_result[0]);
|
||||
} else if (_exception[0] != null){
|
||||
_exception[0].printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tryGetMsGraphClient(path) != null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IGraphServiceClient tryGetMsGraphClient(String path) throws Exception
|
||||
{
|
||||
String userId = extractUserId(path);
|
||||
if (mClientByUser.containsKey(userId))
|
||||
return mClientByUser.get(userId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String extractUserId(String path) throws Exception {
|
||||
String pathWithoutProtocol = removeProtocol(path);
|
||||
String[] parts = pathWithoutProtocol.split("/",1);
|
||||
if (parts.length != 2 || ("".equals(parts[0])))
|
||||
{
|
||||
throw new Exception("path does not contain user");
|
||||
}
|
||||
return parts[0];
|
||||
}
|
||||
|
||||
private void initAuthenticator(Activity activity) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(FileStorageSetupInitiatorActivity activity, String path, int requestCode, boolean alwaysReturnSuccess) {
|
||||
initAuthenticator((Activity)activity.getActivity());
|
||||
if (isConnected(path))
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_PATH, path);
|
||||
activity.onImmediateResult(requestCode, RESULT_FILEUSAGE_PREPARED, intent);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.startFileUsageProcess(path, requestCode, alwaysReturnSuccess);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocolId() {
|
||||
return "onedrive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(Context appContext, String path) throws UserInteractionRequiredException {
|
||||
if (!isConnected(null))
|
||||
{
|
||||
throw new UserInteractionRequiredException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(FileStorageSetupActivity activity, Bundle savedInstanceState) {
|
||||
|
||||
Log.d("KP2AJ", "OnCreate");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(final FileStorageSetupActivity activity) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private IGraphServiceClient buildClient(AuthenticationResult authenticationResult) throws InterruptedException {
|
||||
|
||||
IGraphServiceClient newClient = new GraphServiceClient.Builder()
|
||||
.fromConfig(DefaultClientConfig.createWithAuthenticationProvider(new GraphServiceClientManager(authenticationResult.getAccessToken())))
|
||||
.buildClient();
|
||||
mClientByUser.put(authenticationResult.getUser().getUserIdentifier(), newClient);
|
||||
|
||||
return newClient;
|
||||
}
|
||||
|
||||
|
||||
|
||||
String removeProtocol(String path) throws Exception {
|
||||
if (path == null)
|
||||
return null;
|
||||
return path.substring(getProtocolId().length()+3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String path) {
|
||||
|
||||
if (path == null)
|
||||
return null;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFilename(String path) throws Exception {
|
||||
return path.substring(path.lastIndexOf("/")+1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentFileVersionFast(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class ClientAndPath
|
||||
{
|
||||
public IGraphServiceClient client;
|
||||
public String oneDrivePath;
|
||||
public IDriveItemRequestBuilder getPathItem()
|
||||
{
|
||||
IDriveItemRequestBuilder pathItem = client.getDrive().getRoot();
|
||||
if ("".equals(oneDrivePath) == false) {
|
||||
pathItem = pathItem.getItemWithPath(oneDrivePath);
|
||||
}
|
||||
return pathItem;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openFileForRead(String path) throws Exception {
|
||||
try {
|
||||
ClientAndPath clientAndpath = getOneDriveClientAndPath(path);
|
||||
logDebug("openFileForRead. Path="+path);
|
||||
InputStream result = clientAndpath.client.getDrive()
|
||||
.getRoot()
|
||||
.getItemWithPath(clientAndpath.oneDrivePath)
|
||||
.getContent()
|
||||
.buildRequest()
|
||||
.get();
|
||||
logDebug("ok");
|
||||
return result;
|
||||
|
||||
}
|
||||
catch (ClientException e)
|
||||
{
|
||||
throw convertException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ClientAndPath getOneDriveClientAndPath(String path) throws Exception {
|
||||
ClientAndPath result = new ClientAndPath();
|
||||
|
||||
String pathWithoutProtocol = removeProtocol(path);
|
||||
String[] parts = pathWithoutProtocol.split("/",2);
|
||||
if (parts.length != 2 || ("".equals(parts[0])))
|
||||
{
|
||||
throw new Exception("path does not contain user");
|
||||
}
|
||||
result.client = mClientByUser.get(parts[0]);
|
||||
result.oneDrivePath = parts[1];
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Exception convertException(ClientException e) {
|
||||
if (e.isError(GraphErrorCodes.ItemNotFound))
|
||||
return new FileNotFoundException(e.getMessage());
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(String path, byte[] data, boolean writeTransactional) throws Exception {
|
||||
try {
|
||||
ClientAndPath clientAndPath = getOneDriveClientAndPath(path);
|
||||
clientAndPath.client.getDrive()
|
||||
.getRoot()
|
||||
.getItemWithPath(clientAndPath.oneDrivePath)
|
||||
.getContent()
|
||||
.buildRequest()
|
||||
.put(data);
|
||||
} catch (ClientException e) {
|
||||
throw convertException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFolder(String parentPath, String newDirName) throws Exception {
|
||||
throw new Exception("not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFilePath(String parentPath, String newFileName) throws Exception {
|
||||
String path = parentPath;
|
||||
if (!path.endsWith("/"))
|
||||
path = path + "/";
|
||||
path = path + newFileName;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileEntry> listFiles(String parentPath) throws Exception {
|
||||
try {
|
||||
ArrayList<FileEntry> result = new ArrayList<FileEntry>();
|
||||
ClientAndPath clientAndPath = getOneDriveClientAndPath(parentPath);
|
||||
parentPath = clientAndPath.oneDrivePath;
|
||||
|
||||
IDriveItemCollectionPage itemsPage = clientAndPath.getPathItem()
|
||||
.getChildren()
|
||||
.buildRequest()
|
||||
.get();
|
||||
if (parentPath.endsWith("/"))
|
||||
parentPath = parentPath.substring(0,parentPath.length()-1);
|
||||
while (true)
|
||||
{
|
||||
List<DriveItem> items = itemsPage.getCurrentPage();
|
||||
if (items.isEmpty())
|
||||
return result;
|
||||
|
||||
for (DriveItem i: items)
|
||||
{
|
||||
FileEntry e = getFileEntry(parentPath + "/" + i.name, i);
|
||||
Log.d("KP2AJ", e.path);
|
||||
result.add(e);
|
||||
}
|
||||
IDriveItemCollectionRequestBuilder nextPageReqBuilder = itemsPage.getNextPage();
|
||||
if (nextPageReqBuilder == null)
|
||||
return result;
|
||||
itemsPage = nextPageReqBuilder.buildRequest().get();
|
||||
|
||||
}
|
||||
} catch (ClientException e) {
|
||||
throw convertException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private FileEntry getFileEntry(String path, DriveItem i) {
|
||||
FileEntry e = new FileEntry();
|
||||
if (i.size != null)
|
||||
e.sizeInBytes = i.size;
|
||||
else if ((i.remoteItem != null) && (i.remoteItem.size != null))
|
||||
e.sizeInBytes = i.remoteItem.size;
|
||||
|
||||
e.displayName = i.name;
|
||||
e.canRead = e.canWrite = true;
|
||||
e.path = getProtocolId() +"://"+path;
|
||||
if (i.lastModifiedDateTime != null)
|
||||
e.lastModifiedTime = i.lastModifiedDateTime.getTimeInMillis();
|
||||
else if ((i.remoteItem != null)&&(i.remoteItem.lastModifiedDateTime != null))
|
||||
e.lastModifiedTime = i.remoteItem.lastModifiedDateTime.getTimeInMillis();
|
||||
e.isDirectory = (i.folder != null) || ((i.remoteItem != null) && (i.remoteItem.folder != null));
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileEntry getFileEntry(String filename) throws Exception {
|
||||
try {
|
||||
|
||||
ClientAndPath clientAndPath = getOneDriveClientAndPath(filename);
|
||||
IDriveItemRequestBuilder pathItem = clientAndPath.getPathItem();
|
||||
|
||||
IDriveItemRequest request = pathItem.buildRequest();
|
||||
DriveItem item = request.get();
|
||||
return getFileEntry(filename, item);
|
||||
} catch (ClientException e) {
|
||||
throw convertException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String path) throws Exception {
|
||||
try {
|
||||
ClientAndPath clientAndPath = getOneDriveClientAndPath(path);
|
||||
clientAndPath.client.getDrive()
|
||||
.getRoot()
|
||||
.getItemWithPath(clientAndPath.oneDrivePath)
|
||||
.buildRequest()
|
||||
.delete();
|
||||
} catch (ClientException e) {
|
||||
throw convertException(e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean acquireTokenRunning = false;
|
||||
@Override
|
||||
public void onStart(final FileStorageSetupActivity activity) {
|
||||
Log.d("KP2AJ", "onStart " + activity.getPath());
|
||||
if (activity.getProcessName().equals(PROCESS_NAME_SELECTFILE))
|
||||
activity.getState().putString(EXTRA_PATH, activity.getPath());
|
||||
|
||||
String userId = activity.getState().getString("OneDriveUser");
|
||||
if (mClientByUser.containsKey(userId)) {
|
||||
finishActivityWithSuccess(activity);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
JavaFileStorage.FileStorageSetupActivity storageSetupAct = activity;
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AuthenticationResult[] _authenticationResult = {null};
|
||||
MsalException _exception[] = {null};
|
||||
|
||||
if (!acquireTokenRunning) {
|
||||
acquireTokenRunning = true;
|
||||
|
||||
mPublicClientApp.acquireToken((Activity) activity, scopes, new AuthenticationCallback() {
|
||||
@Override
|
||||
public void onSuccess(AuthenticationResult authenticationResult) {
|
||||
Log.i(TAG, "authenticating successful");
|
||||
|
||||
try {
|
||||
buildClient(authenticationResult);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
activity.getState().putString(EXTRA_PATH, getProtocolPrefix() + authenticationResult.getUser().getUserIdentifier() + "/");
|
||||
|
||||
finishActivityWithSuccess(activity);
|
||||
acquireTokenRunning = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(MsalException exception) {
|
||||
Log.i(TAG, "authenticating not successful");
|
||||
Intent data = new Intent();
|
||||
data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not successful");
|
||||
((Activity) activity).setResult(Activity.RESULT_CANCELED, data);
|
||||
((Activity) activity).finish();
|
||||
acquireTokenRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
Log.i(TAG, "authenticating cancelled");
|
||||
Intent data = new Intent();
|
||||
data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not cancelled");
|
||||
((Activity) activity).setResult(Activity.RESULT_CANCELED, data);
|
||||
((Activity) activity).finish();
|
||||
acquireTokenRunning = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(FileStorageSetupActivity activity, int requestCode, int resultCode, Intent data) {
|
||||
mPublicClientApp.handleInteractiveRequestRedirect(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
@@ -1,408 +0,0 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.pcloud.sdk.ApiClient;
|
||||
import com.pcloud.sdk.ApiError;
|
||||
import com.pcloud.sdk.Authenticators;
|
||||
import com.pcloud.sdk.AuthorizationActivity;
|
||||
import com.pcloud.sdk.AuthorizationResult;
|
||||
import com.pcloud.sdk.Call;
|
||||
import com.pcloud.sdk.DataSource;
|
||||
import com.pcloud.sdk.PCloudSdk;
|
||||
import com.pcloud.sdk.RemoteEntry;
|
||||
import com.pcloud.sdk.RemoteFile;
|
||||
import com.pcloud.sdk.RemoteFolder;
|
||||
import com.pcloud.sdk.UploadOptions;
|
||||
|
||||
/**
|
||||
* FileStorage implementation for PCloud provider.
|
||||
* https://www.pcloud.com/
|
||||
*/
|
||||
public class PCloudFileStorage extends JavaFileStorageBase
|
||||
{
|
||||
final static private int PCLOUD_AUTHORIZATION_REQUEST_CODE = 1001845497;
|
||||
|
||||
final static private String SHARED_PREF_NAME = "PCLOUD";
|
||||
final static private String SHARED_PREF_AUTH_TOKEN = "AUTH_TOKEN";
|
||||
|
||||
private final Context ctx;
|
||||
|
||||
private ApiClient apiClient;
|
||||
private String clientId;
|
||||
|
||||
public PCloudFileStorage(Context ctx, String clientId) {
|
||||
this.ctx = ctx;
|
||||
this.clientId = clientId;
|
||||
this.apiClient = createApiClientFromSharedPrefs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresSetup(String path) {
|
||||
return !this.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSelectFile(FileStorageSetupInitiatorActivity activity, boolean isForSave, int requestCode) {
|
||||
String path = getProtocolId() + "://";
|
||||
activity.startSelectFileProcess(path, isForSave, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(Context appContext, String path) throws Throwable {
|
||||
if (!isConnected()) {
|
||||
throw new UserInteractionRequiredException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(FileStorageSetupInitiatorActivity activity, String path, int requestCode,
|
||||
boolean alwaysReturnSuccess) {
|
||||
if (this.isConnected()) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_PATH, path);
|
||||
activity.onImmediateResult(requestCode, RESULT_FILEUSAGE_PREPARED, intent);
|
||||
} else {
|
||||
activity.startFileUsageProcess(path, requestCode, alwaysReturnSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocolId() {
|
||||
return "pcloud";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFilename(String path) {
|
||||
return path.substring(path.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception {
|
||||
if (previousFileVersion == null || "".equals(previousFileVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return !remoteFile.hash().equals(previousFileVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentFileVersionFast(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return remoteFile.hash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openFileForRead(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return remoteFile.byteStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(String path, byte[] data, boolean writeTransactional) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
DataSource dataSource = DataSource.create(data);
|
||||
String filename = path.substring(path.lastIndexOf("/") + 1);
|
||||
String filePath = path.substring(0, path.lastIndexOf("/") + 1);
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(filePath);
|
||||
|
||||
try {
|
||||
RemoteFile remoteFile = this.apiClient.createFile(
|
||||
remoteFolder, filename, dataSource, null, null, UploadOptions.OVERRIDE_FILE
|
||||
).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFolder(String parentPath, String newDirName) throws Exception {
|
||||
String parentPathWithoutProtocol = this.cleanPath(parentPath);
|
||||
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(parentPathWithoutProtocol);
|
||||
|
||||
try {
|
||||
this.apiClient.createFolder(remoteFolder, newDirName).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
|
||||
return this.createFilePath(parentPath, newDirName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFilePath(String parentPath, String newFileName) throws Exception {
|
||||
return (
|
||||
this.getProtocolId() + "://" +
|
||||
this.cleanPath(parentPath) +
|
||||
("".equals(newFileName) ? "" : "/") +
|
||||
newFileName
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileEntry> listFiles(String parentPath) throws Exception {
|
||||
parentPath = this.cleanPath(parentPath);
|
||||
|
||||
ArrayList<FileEntry> fileEntries = new ArrayList<>();
|
||||
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(parentPath);
|
||||
|
||||
for (RemoteEntry remoteEntry : remoteFolder.children()) {
|
||||
fileEntries.add(this.convertRemoteEntryToFileEntry(remoteEntry, parentPath));
|
||||
}
|
||||
|
||||
return fileEntries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileEntry getFileEntry(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
return this.convertRemoteEntryToFileEntry(
|
||||
remoteEntry,
|
||||
path.substring(0, path.lastIndexOf("/"))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteEntry remoteEntry = this.getRemoteFileByPath(path);
|
||||
|
||||
try {
|
||||
this.apiClient.delete(remoteEntry).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(FileStorageSetupActivity activity, Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(FileStorageSetupActivity activity) {
|
||||
if (activity.getProcessName().equals(PROCESS_NAME_SELECTFILE)) {
|
||||
activity.getState().putString(EXTRA_PATH, activity.getPath());
|
||||
}
|
||||
|
||||
if (this.isConnected()) {
|
||||
finishActivityWithSuccess(activity);
|
||||
} else if (!activity.getState().getBoolean("hasStartedAuth", false)) {
|
||||
Activity castedActivity = (Activity)activity;
|
||||
Intent authIntent = AuthorizationActivity.createIntent(castedActivity, this.clientId);
|
||||
castedActivity.startActivityForResult(authIntent, PCLOUD_AUTHORIZATION_REQUEST_CODE);
|
||||
activity.getState().putBoolean("hasStartedAuth", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(FileStorageSetupActivity activity, int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == PCLOUD_AUTHORIZATION_REQUEST_CODE && data != null) {
|
||||
activity.getState().putBoolean("hasStartedAuth", false);
|
||||
AuthorizationResult result = (AuthorizationResult)(
|
||||
data.getSerializableExtra(AuthorizationActivity.KEY_AUTHORIZATION_RESULT)
|
||||
);
|
||||
this.handleAuthResult(activity, result, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAuthResult(FileStorageSetupActivity activity, AuthorizationResult authorizationResult,
|
||||
Intent data) {
|
||||
if (authorizationResult == AuthorizationResult.ACCESS_GRANTED) {
|
||||
String authToken = data.getStringExtra(AuthorizationActivity.KEY_ACCESS_TOKEN);
|
||||
setAuthToken(authToken);
|
||||
finishActivityWithSuccess(activity);
|
||||
} else {
|
||||
Activity castedActivity = (Activity)activity;
|
||||
Intent resultData = new Intent();
|
||||
resultData.putExtra(EXTRA_ERROR_MESSAGE, "Authentication failed.");
|
||||
castedActivity.setResult(Activity.RESULT_CANCELED, resultData);
|
||||
castedActivity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(FileStorageSetupActivity activity) {
|
||||
|
||||
}
|
||||
|
||||
private ApiClient createApiClientFromSharedPrefs() {
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
String authToken = prefs.getString(SHARED_PREF_AUTH_TOKEN, null);
|
||||
return this.createApiClient(authToken);
|
||||
}
|
||||
|
||||
private ApiClient createApiClient(String authToken) {
|
||||
if (authToken == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
PCloudSdk.newClientBuilder()
|
||||
.authenticator(Authenticators.newOAuthAuthenticator(authToken))
|
||||
.create()
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isConnected() {
|
||||
return (this.apiClient != null);
|
||||
}
|
||||
|
||||
private void clearAuthToken() {
|
||||
this.apiClient = null;
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.clear();
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
private void setAuthToken(String authToken) {
|
||||
this.apiClient = this.createApiClient(authToken);
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putString(SHARED_PREF_AUTH_TOKEN, authToken);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
private String cleanPath(String path) {
|
||||
return (
|
||||
"/" + path.replaceAll("^(" + Pattern.quote(this.getProtocolId()) + "://)?/*", "")
|
||||
);
|
||||
}
|
||||
|
||||
private RemoteFile getRemoteFileByPath(String path) throws Exception {
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
try {
|
||||
return remoteEntry.asFile();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteFolder getRemoteFolderByPath(String path) throws Exception {
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
try {
|
||||
return remoteEntry.asFolder();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteEntry getRemoteEntryByPath(String path) throws Exception {
|
||||
Call<RemoteFolder> call = this.apiClient.listFolder(RemoteFolder.ROOT_FOLDER_ID, true);
|
||||
|
||||
RemoteFolder folder;
|
||||
try {
|
||||
folder = call.execute();
|
||||
} catch (ApiError apiError) {
|
||||
throw convertApiError(apiError);
|
||||
}
|
||||
|
||||
if ("/".equals(path)) {
|
||||
return folder;
|
||||
}
|
||||
|
||||
String[] fileNames = path.substring(1).split("/");
|
||||
RemoteFolder currentFolder = folder;
|
||||
Iterator<String> fileNamesIterator = Arrays.asList(fileNames).iterator();
|
||||
while (true) {
|
||||
String fileName = fileNamesIterator.next();
|
||||
|
||||
Iterator<RemoteEntry> entryIterator = currentFolder.children().iterator();
|
||||
while (true) {
|
||||
RemoteEntry remoteEntry;
|
||||
try {
|
||||
remoteEntry = entryIterator.next();
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
if (currentFolder.folderId() == remoteEntry.parentFolderId() && fileName.equals(remoteEntry.name())) {
|
||||
if (!fileNamesIterator.hasNext()) {
|
||||
return remoteEntry;
|
||||
}
|
||||
|
||||
try {
|
||||
currentFolder = remoteEntry.asFolder();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Exception convertApiError(ApiError e) {
|
||||
String strErrorCode = String.valueOf(e.errorCode());
|
||||
if (strErrorCode.startsWith("1") || "2000".equals(strErrorCode) || "2095".equals(strErrorCode)) {
|
||||
this.clearAuthToken();
|
||||
return new UserInteractionRequiredException("Unlinked from PCloud! User must re-link.", e);
|
||||
} else if (strErrorCode.startsWith("2")) {
|
||||
return new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
private FileEntry convertRemoteEntryToFileEntry(RemoteEntry remoteEntry, String parentPath) {
|
||||
FileEntry fileEntry = new FileEntry();
|
||||
fileEntry.canRead = true;
|
||||
fileEntry.canWrite = true;
|
||||
fileEntry.path = (
|
||||
this.getProtocolId() + "://" +
|
||||
("/".equals(parentPath) ? "" : parentPath) +
|
||||
"/" + remoteEntry.name()
|
||||
);
|
||||
fileEntry.displayName = remoteEntry.name();
|
||||
fileEntry.isDirectory = !remoteEntry.isFile();
|
||||
fileEntry.lastModifiedTime = remoteEntry.lastModified().getTime();
|
||||
|
||||
if (remoteEntry.isFile()) {
|
||||
fileEntry.sizeInBytes = remoteEntry.asFile().size();
|
||||
}
|
||||
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
@@ -2,9 +2,7 @@ package keepass2android.javafilestorage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
@@ -15,7 +13,6 @@ import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.KeyPair;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
@@ -38,10 +35,8 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
public String localPath;
|
||||
public int port;
|
||||
}
|
||||
Context _appContext;
|
||||
|
||||
public SftpStorage(Context appContext) {
|
||||
_appContext = appContext;
|
||||
public SftpStorage() {
|
||||
|
||||
}
|
||||
|
||||
@@ -323,29 +318,10 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
jsch = new JSch();
|
||||
ConnectionInfo ci = splitStringToConnectionInfo(filename);
|
||||
|
||||
String base_dir = getBaseDir();
|
||||
jsch.setKnownHosts(base_dir + "/known_hosts");
|
||||
|
||||
String key_filename = getKeyFileName();
|
||||
try{
|
||||
createKeyPair(key_filename);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
}
|
||||
|
||||
try {
|
||||
jsch.addIdentity(key_filename);
|
||||
} catch (java.lang.Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Session session = jsch.getSession(ci.username, ci.host, ci.port);
|
||||
UserInfo ui = new SftpUserInfo(ci.password,_appContext);
|
||||
UserInfo ui = new SftpUserInfo(ci.password);
|
||||
session.setUserInfo(ui);
|
||||
|
||||
session.setConfig("PreferredAuthentications", "publickey,password");
|
||||
|
||||
session.connect();
|
||||
|
||||
Channel channel = session.openChannel("sftp");
|
||||
@@ -357,35 +333,6 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
|
||||
}
|
||||
|
||||
private String getBaseDir() {
|
||||
return _appContext.getFilesDir().getAbsolutePath();
|
||||
}
|
||||
|
||||
private String getKeyFileName() {
|
||||
return getBaseDir() + "/id_kp2a_rsa";
|
||||
}
|
||||
|
||||
public String createKeyPair() throws IOException, JSchException {
|
||||
return createKeyPair(getKeyFileName());
|
||||
|
||||
}
|
||||
|
||||
private String createKeyPair(String key_filename) throws JSchException, IOException {
|
||||
String public_key_filename = key_filename + ".pub";
|
||||
File file = new File(key_filename);
|
||||
if (file.exists())
|
||||
return public_key_filename;
|
||||
int type = KeyPair.RSA;
|
||||
KeyPair kpair = KeyPair.genKeyPair(jsch, type, 2048);
|
||||
kpair.writePrivateKey(key_filename);
|
||||
|
||||
kpair.writePublicKey(public_key_filename, "generated by Keepass2Android");
|
||||
//ret = "Fingerprint: " + kpair.getFingerPrint();
|
||||
kpair.dispose();
|
||||
return public_key_filename;
|
||||
|
||||
}
|
||||
|
||||
public ConnectionInfo splitStringToConnectionInfo(String filename)
|
||||
throws UnsupportedEncodingException {
|
||||
ConnectionInfo ci = new ConnectionInfo();
|
||||
|
@@ -1,119 +1,14 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jcraft.jsch.UserInfo;
|
||||
|
||||
public class SftpUserInfo implements UserInfo {
|
||||
|
||||
private Object /* pick one type, and fixate on it */ dance(final String type, final String text) /* for inside the thread */
|
||||
{
|
||||
|
||||
final Message msg = Message.obtain();
|
||||
|
||||
/* t(*A*t) */
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
int bogon = (int)SystemClock.elapsedRealtime();
|
||||
|
||||
NotificationManager mNotificationManager = (NotificationManager)_appContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(_appContext);
|
||||
builder.setContentText("SFTP prompt");
|
||||
builder.setSmallIcon(R.drawable.ic_logo_green_foreground);
|
||||
|
||||
|
||||
Handler h = new Handler() {
|
||||
public void handleMessage(Message M) {
|
||||
msg.copyFrom(M);
|
||||
Looper.myLooper().quit();
|
||||
}
|
||||
};
|
||||
Messenger m = new Messenger(h);
|
||||
|
||||
Intent intent = new Intent(_appContext, NotifSlave.class);
|
||||
|
||||
intent.setAction("keepass2android.sftp.NotifSlave");
|
||||
intent.putExtra("keepass2android.sftp.returnmessenger", m);
|
||||
intent.putExtra("keepass2android.sftp.reqtype", type);
|
||||
intent.putExtra("keepass2android.sftp.prompt", text);
|
||||
intent.setData((Uri.parse("suckit://"+SystemClock.elapsedRealtime())));
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(_appContext, 0, intent, 0);
|
||||
builder.setContentIntent(contentIntent);
|
||||
|
||||
{
|
||||
Intent directIntent = new Intent(_appContext, NotifSlave.class);
|
||||
directIntent.setAction("keepass2android.sftp.NotifSlave");
|
||||
directIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
directIntent.putExtra("keepass2android.sftp.returnmessenger", m);
|
||||
directIntent.putExtra("keepass2android.sftp.reqtype", type);
|
||||
directIntent.putExtra("keepass2android.sftp.prompt", text);
|
||||
directIntent.setData((Uri.parse("suckit://" + SystemClock.elapsedRealtime())));
|
||||
_appContext.startActivity(directIntent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log.e("KP2AJFS[thread]", "Notifying...");
|
||||
|
||||
mNotificationManager.notify(bogon, builder.build());
|
||||
|
||||
|
||||
|
||||
Log.e("KP2AJFS[thread]", "About to go to 'sleep'...");
|
||||
Looper.loop();
|
||||
Log.e("KP2AJFS[thread]", "And we're alive!");
|
||||
|
||||
Log.e("KP2AJFS[thread]", "result was: "+(Integer.toString(msg.arg1)));
|
||||
|
||||
mNotificationManager.cancel(bogon);
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
try {
|
||||
t.join();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type.equals("yesno"))
|
||||
return new Boolean(msg.arg1 == 1);
|
||||
else if (type.equals("message"))
|
||||
return null;
|
||||
else if (type.equals("password")) {
|
||||
if (msg.arg1 == 0)
|
||||
return null;
|
||||
Bundle b = msg.getData();
|
||||
return b.getString("response");
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Context _appContext;
|
||||
|
||||
String _password;
|
||||
|
||||
public SftpUserInfo(String password, Context appContext)
|
||||
{
|
||||
public SftpUserInfo(String password) {
|
||||
_password = password;
|
||||
_appContext = appContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,15 +35,12 @@ public class SftpUserInfo implements UserInfo {
|
||||
|
||||
@Override
|
||||
public boolean promptYesNo(String message) {
|
||||
return (Boolean)dance("yesno", message);
|
||||
|
||||
//test with https://www.sftp.net/public-online-sftp-servers?
|
||||
return true; //continue all operations without user action
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(String message)
|
||||
{
|
||||
dance("message", message);
|
||||
public void showMessage(String message) {
|
||||
Log.d("KP2AJ", message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
@@ -71,18 +70,9 @@ public class WebDavStorage extends JavaFileStorageBase {
|
||||
|
||||
String scheme = filename.substring(0, filename.indexOf("://"));
|
||||
filename = filename.substring(scheme.length() + 3);
|
||||
int idxAt = filename.indexOf('@');
|
||||
if (idxAt >= 0)
|
||||
{
|
||||
String userPwd = filename.substring(0, idxAt);
|
||||
int idxColon = userPwd.indexOf(":");
|
||||
if (idxColon >= 0);
|
||||
{
|
||||
ci.username = decode(userPwd.substring(0, idxColon));
|
||||
ci.password = decode(userPwd.substring(idxColon + 1));
|
||||
}
|
||||
}
|
||||
|
||||
String userPwd = filename.substring(0, filename.indexOf('@'));
|
||||
ci.username = decode(userPwd.substring(0, userPwd.indexOf(":")));
|
||||
ci.password = decode(userPwd.substring(userPwd.indexOf(":") + 1));
|
||||
ci.URL = scheme + "://" +filename.substring(filename.indexOf('@') + 1);
|
||||
return ci;
|
||||
}
|
||||
@@ -159,19 +149,13 @@ public class WebDavStorage extends JavaFileStorageBase {
|
||||
sslContext.init(null, new TrustManager[] { trustManager }, null);
|
||||
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
|
||||
builder = builder.sslSocketFactory(sslSocketFactory, trustManager)
|
||||
.hostnameVerifier(new DecoratedHostnameVerifier(OkHostnameVerifier.INSTANCE, mCertificateErrorHandler));
|
||||
|
||||
|
||||
builder.connectTimeout(25, TimeUnit.SECONDS);
|
||||
builder.readTimeout(25, TimeUnit.SECONDS);
|
||||
builder.writeTimeout(25, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
OkHttpClient client = builder.build();
|
||||
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
|
@@ -1,45 +0,0 @@
|
||||
package keepass2android.javafilestorage.onedrive2;
|
||||
|
||||
import com.microsoft.graph.authentication.IAuthenticationProvider;
|
||||
import com.microsoft.graph.core.DefaultClientConfig;
|
||||
import com.microsoft.graph.core.IClientConfig;
|
||||
import com.microsoft.graph.extensions.GraphServiceClient;
|
||||
import com.microsoft.graph.extensions.IGraphServiceClient;
|
||||
import com.microsoft.graph.http.IHttpRequest;
|
||||
|
||||
/**
|
||||
* Singleton class that manages a GraphServiceClient object.
|
||||
* It implements IAuthentication provider to authenticate requests using an access token.
|
||||
*/
|
||||
public class GraphServiceClientManager implements IAuthenticationProvider {
|
||||
private IGraphServiceClient mGraphServiceClient;
|
||||
private String mAccessToken;
|
||||
|
||||
public GraphServiceClientManager(String accessToken) {
|
||||
mAccessToken = accessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authenticateRequest(IHttpRequest request) {
|
||||
try {
|
||||
request.addHeader("Authorization", "Bearer " + mAccessToken);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized IGraphServiceClient getGraphServiceClient() {
|
||||
return getGraphServiceClient(this);
|
||||
}
|
||||
|
||||
public synchronized IGraphServiceClient getGraphServiceClient(IAuthenticationProvider authenticationProvider) {
|
||||
if (mGraphServiceClient == null) {
|
||||
IClientConfig clientConfig = DefaultClientConfig.createWithAuthenticationProvider(
|
||||
authenticationProvider
|
||||
);
|
||||
mGraphServiceClient = new GraphServiceClient.Builder().fromConfig(clientConfig).buildClient();
|
||||
}
|
||||
|
||||
return mGraphServiceClient;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user