636 lines
14 KiB
C#
636 lines
14 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Rei.Fs.ConnectionSettingBase
|
|
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
|
|
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
|
|
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
|
|
|
|
using Microsoft.VisualBasic.CompilerServices;
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Net;
|
|
using System.Net.Security;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Rei.Fs
|
|
{
|
|
[Serializable]
|
|
public abstract class ConnectionSettingBase
|
|
{
|
|
private string pName;
|
|
private Uri pTargetUri;
|
|
private string pPersistUserName;
|
|
private string pPersistPassword;
|
|
private bool pDontSave;
|
|
public string FaviconName;
|
|
public UCSNormalization DownloadFilenameNormalization;
|
|
public UCSNormalization UploadFilenameNormalization;
|
|
public ProxyType Proxy;
|
|
private Uri pProxyUri;
|
|
private string[] pProxyByPassList;
|
|
public bool ProxyByPassLocal;
|
|
public bool ProxyUseDefaultCredential;
|
|
private string pProxyUsername;
|
|
private string pProxyPassword;
|
|
public int ReadWriteTimeout;
|
|
public int ConnectTimeout;
|
|
public bool UseEncryption;
|
|
private string pEncryptionKey;
|
|
public bool AutoSplit;
|
|
public int SplitSizeMB;
|
|
public string EscapeString;
|
|
public bool HideUnencryptedFile;
|
|
public bool HideUnencryptedDirectory;
|
|
private object pSyncObject;
|
|
private bool pNeedPersist;
|
|
private string pUserName;
|
|
private string pPassword;
|
|
private CookieContainer pCookieContainer;
|
|
private SslPolicyErrors pCertErrorIgnores;
|
|
private SslPolicyErrors pLastCertError;
|
|
|
|
protected ConnectionSettingBase()
|
|
{
|
|
this.Name = string.Empty;
|
|
this.TargetUri = (Uri) null;
|
|
this.pPersistUserName = string.Empty;
|
|
this.pPersistPassword = string.Empty;
|
|
this.pDontSave = false;
|
|
this.DownloadFilenameNormalization = UCSNormalization.NFC;
|
|
this.UploadFilenameNormalization = UCSNormalization.None;
|
|
this.Proxy = ProxyType.Default;
|
|
this.ProxyUri = (Uri) null;
|
|
this.ProxyByPassList = new string[0];
|
|
this.ProxyByPassLocal = false;
|
|
this.ProxyUseDefaultCredential = false;
|
|
this.pProxyUsername = string.Empty;
|
|
this.pProxyPassword = string.Empty;
|
|
this.ReadWriteTimeout = 10000;
|
|
this.ConnectTimeout = 10000;
|
|
this.UseEncryption = false;
|
|
this.pEncryptionKey = "";
|
|
this.AutoSplit = false;
|
|
this.SplitSizeMB = 50;
|
|
this.EscapeString = "^_";
|
|
this.HideUnencryptedDirectory = false;
|
|
this.HideUnencryptedFile = false;
|
|
this.pSyncObject = RuntimeHelpers.GetObjectValue(new object());
|
|
this.pUserName = this.pPersistUserName;
|
|
this.pPassword = this.pPersistPassword;
|
|
this.pCookieContainer = new CookieContainer();
|
|
}
|
|
|
|
public abstract SecureType SecureType { get; }
|
|
|
|
public static Icon GetDefaultFavicon()
|
|
{
|
|
return Rei.Fs.My.Resources.Resources.NetFolder;
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return this.pName;
|
|
}
|
|
set
|
|
{
|
|
this.pName = value;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public Uri TargetUri
|
|
{
|
|
get
|
|
{
|
|
return this.pTargetUri;
|
|
}
|
|
set
|
|
{
|
|
this.pTargetUri = value;
|
|
}
|
|
}
|
|
|
|
[XmlElement("TargetUri")]
|
|
public string TargetUri_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
return this.TargetUri.ToString();
|
|
}
|
|
set
|
|
{
|
|
if (value == null || value.Length == 0)
|
|
this.pTargetUri = (Uri) null;
|
|
else
|
|
this.pTargetUri = new Uri(value);
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string UserName
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pUserName;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string PersistUserName
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pPersistUserName;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlElement("UserName")]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public string UserName_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
if (this.DontSave)
|
|
return string.Empty;
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pPersistUserName;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
set
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
this.pPersistUserName = value;
|
|
this.pUserName = this.pPersistUserName;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string Password
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pPassword;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string PersistPassword
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pPersistPassword;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
[XmlElement("Password")]
|
|
public string Password_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
if (this.DontSave)
|
|
return string.Empty;
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return Convert.ToBase64String(Encoding.Unicode.GetBytes(this.pPersistPassword));
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
set
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
try
|
|
{
|
|
this.pPersistPassword = Encoding.Unicode.GetString(Convert.FromBase64String(value));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ProjectData.SetProjectError(ex);
|
|
this.pPersistPassword = string.Empty;
|
|
ProjectData.ClearProjectError();
|
|
}
|
|
this.pPassword = this.pPersistPassword;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool DontSave
|
|
{
|
|
get
|
|
{
|
|
return this.pDontSave;
|
|
}
|
|
set
|
|
{
|
|
this.pDontSave = value;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public Uri ProxyUri
|
|
{
|
|
get
|
|
{
|
|
return this.pProxyUri;
|
|
}
|
|
set
|
|
{
|
|
this.pProxyUri = value;
|
|
}
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[XmlElement("ProxyUri")]
|
|
public string ProxyUri_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
if ((object) this.pProxyUri == null)
|
|
return string.Empty;
|
|
return this.pProxyUri.ToString();
|
|
}
|
|
set
|
|
{
|
|
if (value == null || value.Length == 0)
|
|
this.pProxyUri = (Uri) null;
|
|
else
|
|
this.pProxyUri = new Uri(value);
|
|
}
|
|
}
|
|
|
|
public string ProxyUserName
|
|
{
|
|
get
|
|
{
|
|
if (this.DontSave)
|
|
return string.Empty;
|
|
return this.pProxyUsername;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
value = string.Empty;
|
|
this.pProxyUsername = value;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string ProxyPassword
|
|
{
|
|
get
|
|
{
|
|
if (this.DontSave)
|
|
return string.Empty;
|
|
return this.pProxyPassword;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
value = string.Empty;
|
|
this.pProxyPassword = value;
|
|
}
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[XmlElement("ProxyPassword")]
|
|
public string ProxyPassword_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
if (this.DontSave)
|
|
return string.Empty;
|
|
return Convert.ToBase64String(Encoding.Unicode.GetBytes(this.pProxyPassword));
|
|
}
|
|
set
|
|
{
|
|
try
|
|
{
|
|
this.pProxyPassword = Encoding.Unicode.GetString(Convert.FromBase64String(value));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ProjectData.SetProjectError(ex);
|
|
this.pProxyPassword = string.Empty;
|
|
ProjectData.ClearProjectError();
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string[] ProxyByPassList
|
|
{
|
|
get
|
|
{
|
|
return this.pProxyByPassList;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
value = new string[0];
|
|
this.pProxyByPassList = value;
|
|
}
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[XmlElement("ProxyByPassList")]
|
|
public string ProxyByPassList_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
return string.Join(",", this.pProxyByPassList);
|
|
}
|
|
set
|
|
{
|
|
this.pProxyByPassList = value.Split(new char[2]
|
|
{
|
|
' ',
|
|
','
|
|
}, StringSplitOptions.RemoveEmptyEntries);
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public string EncryptionKey
|
|
{
|
|
get
|
|
{
|
|
return this.pEncryptionKey;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
value = string.Empty;
|
|
this.pEncryptionKey = value;
|
|
}
|
|
}
|
|
|
|
[XmlElement("EncryptionKey")]
|
|
public string EncryptionKey_ForSerialization
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToBase64String(Encoding.Unicode.GetBytes(this.pEncryptionKey));
|
|
}
|
|
set
|
|
{
|
|
try
|
|
{
|
|
this.pEncryptionKey = Encoding.Unicode.GetString(Convert.FromBase64String(value));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ProjectData.SetProjectError(ex);
|
|
this.pEncryptionKey = string.Empty;
|
|
ProjectData.ClearProjectError();
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public SslPolicyErrors CertErrorIgnores
|
|
{
|
|
get
|
|
{
|
|
return this.pCertErrorIgnores;
|
|
}
|
|
set
|
|
{
|
|
this.pCertErrorIgnores = value;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public SslPolicyErrors LastCertError
|
|
{
|
|
get
|
|
{
|
|
return this.pLastCertError;
|
|
}
|
|
set
|
|
{
|
|
this.pLastCertError = value;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public bool NeedPersist
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pNeedPersist;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
set
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
this.pNeedPersist = value;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected object SyncObject
|
|
{
|
|
get
|
|
{
|
|
return this.pSyncObject;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public CookieContainer CookieContainer
|
|
{
|
|
get
|
|
{
|
|
object syncObject = this.SyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncObject);
|
|
Monitor.Enter(syncObject);
|
|
try
|
|
{
|
|
return this.pCookieContainer;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetUserPass(string username, string password)
|
|
{
|
|
object pSyncObject = this.pSyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject);
|
|
Monitor.Enter(pSyncObject);
|
|
try
|
|
{
|
|
if (username != null)
|
|
this.pUserName = username;
|
|
if (password == null)
|
|
return;
|
|
this.pPassword = password;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(pSyncObject);
|
|
}
|
|
}
|
|
|
|
public void PersistUserPass()
|
|
{
|
|
object pSyncObject = this.pSyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject);
|
|
Monitor.Enter(pSyncObject);
|
|
try
|
|
{
|
|
if (this.DontSave)
|
|
{
|
|
this.pPersistUserName = "";
|
|
this.pPersistPassword = "";
|
|
}
|
|
else
|
|
{
|
|
this.pPersistUserName = this.UserName;
|
|
this.pPersistPassword = this.Password;
|
|
}
|
|
this.NeedPersist = false;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(pSyncObject);
|
|
}
|
|
}
|
|
|
|
public FsBase GetClient()
|
|
{
|
|
FsBase @base = this.GetBaseClient();
|
|
if (this.UseEncryption)
|
|
@base = (FsBase) new EncryptFs(@base, this.EncryptionKey, this.EscapeString, this.HideUnencryptedFile, this.HideUnencryptedDirectory);
|
|
if (this.AutoSplit)
|
|
@base = (FsBase) new AutoSplitFs(@base, checked ((long) this.SplitSizeMB * 1024L * 1024L), this.EscapeString);
|
|
return @base;
|
|
}
|
|
|
|
public abstract FsBase GetBaseClient();
|
|
|
|
public abstract Form GetSettingForm();
|
|
|
|
public abstract bool DoAuthorization(Uri target, bool PersistSelectable);
|
|
|
|
public virtual void Reset()
|
|
{
|
|
object pSyncObject = this.pSyncObject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject);
|
|
Monitor.Enter(pSyncObject);
|
|
try
|
|
{
|
|
this.pUserName = this.pPersistUserName;
|
|
this.pPassword = this.pPersistPassword;
|
|
this.pCookieContainer = new CookieContainer();
|
|
this.pNeedPersist = false;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(pSyncObject);
|
|
}
|
|
}
|
|
|
|
public virtual FsSpecificContextMenuItem[] GetExtensionMethod(ResourceInfo[] ris)
|
|
{
|
|
return (FsSpecificContextMenuItem[]) null;
|
|
}
|
|
}
|
|
}
|