Merge branch 'master' of C:\ph\keepass2android
This commit is contained in:
38
src/Kp2aBusinessLogic/Io/OneDriveFileStorage.cs
Normal file
38
src/Kp2aBusinessLogic/Io/OneDriveFileStorage.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
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 KeePassLib.Serialization;
|
||||||
|
#if !EXCLUDE_JAVAFILESTORAGE
|
||||||
|
using Keepass2android.Javafilestorage;
|
||||||
|
|
||||||
|
namespace keepass2android.Io
|
||||||
|
{
|
||||||
|
public class OneDriveFileStorage: JavaFileStorage
|
||||||
|
{
|
||||||
|
private const string ClientId = "000000004010C234";
|
||||||
|
|
||||||
|
public OneDriveFileStorage(Context ctx, IKp2aApp app) :
|
||||||
|
base(new Keepass2android.Javafilestorage.OneDriveStorage(ctx, ClientId), app)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> SupportedProtocols
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return "skydrive";
|
||||||
|
yield return "onedrive";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
71
src/Kp2aBusinessLogic/Io/WebDavFileStorage.cs
Normal file
71
src/Kp2aBusinessLogic/Io/WebDavFileStorage.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
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;
|
||||||
|
#if !NoNet
|
||||||
|
using Keepass2android.Javafilestorage;
|
||||||
|
#endif
|
||||||
|
using KeePassLib.Serialization;
|
||||||
|
|
||||||
|
namespace keepass2android.Io
|
||||||
|
{
|
||||||
|
#if !NoNet
|
||||||
|
public class WebDavFileStorage: JavaFileStorage
|
||||||
|
{
|
||||||
|
public WebDavFileStorage(IKp2aApp app) : base(new Keepass2android.Javafilestorage.WebDavStorage(app.CertificateErrorHandler), app)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> SupportedProtocols
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return "http";
|
||||||
|
yield return "https";
|
||||||
|
yield return "owncloud";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Owncloud2Webdav(string owncloudUrl)
|
||||||
|
{
|
||||||
|
string owncloudPrefix = "owncloud://";
|
||||||
|
if (owncloudUrl.StartsWith(owncloudPrefix))
|
||||||
|
{
|
||||||
|
owncloudUrl = owncloudUrl.Substring(owncloudPrefix.Length);
|
||||||
|
}
|
||||||
|
if (!owncloudUrl.Contains("://"))
|
||||||
|
owncloudUrl = "https://" + owncloudUrl;
|
||||||
|
if (!owncloudUrl.EndsWith("/"))
|
||||||
|
owncloudUrl += "/";
|
||||||
|
owncloudUrl += "remote.php/webdav/";
|
||||||
|
return owncloudUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode,
|
||||||
|
string protocolId)
|
||||||
|
{
|
||||||
|
//need to override so we can loop the protocolId through
|
||||||
|
activity.PerformManualFileSelect(isForSave, requestCode, protocolId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string IocToPath(IOConnectionInfo ioc)
|
||||||
|
{
|
||||||
|
if (ioc.Path.StartsWith("owncloud"))
|
||||||
|
throw new Exception("owncloud-URIs must be converted to https:// after credential input!");
|
||||||
|
if (!String.IsNullOrEmpty(ioc.UserName))
|
||||||
|
{
|
||||||
|
//legacy support. Some users may have stored IOCs with UserName inside.
|
||||||
|
return ((WebDavStorage)Jfs).BuildFullPath(ioc.Path, ioc.UserName, ioc.Password);
|
||||||
|
}
|
||||||
|
return base.IocToPath(ioc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user