mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
[KOE-51] Added tracking of changed names. To this end, the flag "TrackShareName" (=2) has been added. If this is set, and the name does not match the original folder's name, the name will be updated. The flag is set automatically when shares are applied and the share name matches the original name. Note that this flag does not cause the apply button to become enabled, to prevent having changes on existing shares.
This commit is contained in:
parent
8ab30b53c1
commit
7773d7f973
@ -301,6 +301,17 @@ namespace Acacia.Features.SharedFolders
|
|||||||
textName.Text = value ?? "";
|
textName.Text = value ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private bool? OptionTrackName
|
||||||
|
{
|
||||||
|
get { return textName.Visible ? !_labelName.Enabled : (bool?)null; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
_labelName.Enabled = !value.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private FolderTreeNode _optionNameNode;
|
private FolderTreeNode _optionNameNode;
|
||||||
|
|
||||||
private CheckState? OptionSendAs
|
private CheckState? OptionSendAs
|
||||||
@ -367,6 +378,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
_optionSendAsInitial.Clear();
|
_optionSendAsInitial.Clear();
|
||||||
_optionPermissionNodes.Clear();
|
_optionPermissionNodes.Clear();
|
||||||
OptionName = null;
|
OptionName = null;
|
||||||
|
OptionTrackName = null;
|
||||||
OptionSendAs = null;
|
OptionSendAs = null;
|
||||||
OptionPermissions = null;
|
OptionPermissions = null;
|
||||||
|
|
||||||
@ -406,6 +418,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
if (_optionNameNode != null && nodes.Length == 1)
|
if (_optionNameNode != null && nodes.Length == 1)
|
||||||
{
|
{
|
||||||
OptionName = _optionNameNode.SharedFolder.Name;
|
OptionName = _optionNameNode.SharedFolder.Name;
|
||||||
|
OptionTrackName = _optionNameNode.SharedFolder.FlagUpdateShareName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -461,6 +474,10 @@ namespace Acacia.Features.SharedFolders
|
|||||||
if (_optionNameNode != null)
|
if (_optionNameNode != null)
|
||||||
{
|
{
|
||||||
_optionNameNode.SharedFolder = _optionNameNode.SharedFolder.WithName(textName.Text);
|
_optionNameNode.SharedFolder = _optionNameNode.SharedFolder.WithName(textName.Text);
|
||||||
|
|
||||||
|
// If the share name matches the folder name, track update
|
||||||
|
bool track = _optionNameNode.SharedFolder.Name == _optionNameNode.AvailableFolder.DefaultName;
|
||||||
|
_optionNameNode.SharedFolder = _optionNameNode.SharedFolder.WithFlagUpdateShareName(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
internal SharedFolder AddShare(AvailableFolder folder, SharedFolder state)
|
internal SharedFolder AddShare(AvailableFolder folder, SharedFolder state)
|
||||||
{
|
{
|
||||||
state = state ?? CreateDefaultShare(folder);
|
state = state ?? CreateDefaultShare(folder);
|
||||||
_currentShares[folder.BackendId] = state;
|
_currentShares[folder.BackendId] = state.PatchInformation(folder);
|
||||||
CheckDirty();
|
CheckDirty();
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -98,10 +98,6 @@ namespace Acacia.Features.SharedFolders
|
|||||||
if (folder.IsMailFolder)
|
if (folder.IsMailFolder)
|
||||||
share = share.WithFlagSendAsOwner(true);
|
share = share.WithFlagSendAsOwner(true);
|
||||||
|
|
||||||
// Default include the store name in root folders
|
|
||||||
if (folder.ParentId.IsNone)
|
|
||||||
share = share.WithName(folder.Name + " - " + folder.Store.UserName);
|
|
||||||
|
|
||||||
return share;
|
return share;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +114,12 @@ namespace Acacia.Features.SharedFolders
|
|||||||
SharedFolder state;
|
SharedFolder state;
|
||||||
if (_initialShares.TryGetValue(folder.BackendId, out state))
|
if (_initialShares.TryGetValue(folder.BackendId, out state))
|
||||||
{
|
{
|
||||||
|
// If the folder has been renamed, update if we're tracing it.
|
||||||
|
if (state.Name != folder.DefaultName)
|
||||||
|
{
|
||||||
|
if (state.FlagUpdateShareName)
|
||||||
|
state = state.WithName(folder.DefaultName);
|
||||||
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -73,9 +73,23 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
|
|
||||||
public SyncId ServerId { get { return _data.ServerId; } }
|
public SyncId ServerId { get { return _data.ServerId; } }
|
||||||
public SyncId ParentId { get { return _data.ParentId; } }
|
public SyncId ParentId { get { return _data.ParentId; } }
|
||||||
|
public BackendId ParentIdAsBackend { get { return Parent?.BackendId ?? BackendId.NONE; } }
|
||||||
public BackendId BackendId { get { return _data.BackendId; } }
|
public BackendId BackendId { get { return _data.BackendId; } }
|
||||||
|
|
||||||
public string Name { get { return _data.DisplayName; } }
|
public string Name { get { return _data.DisplayName; } }
|
||||||
|
|
||||||
|
public string DefaultName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Default include the store name in root folders
|
||||||
|
if (ParentId.IsNone)
|
||||||
|
return Name + " - " + Store.UserName;
|
||||||
|
else
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public OutlookConstants.SyncType Type { get { return _data.Type; } }
|
public OutlookConstants.SyncType Type { get { return _data.Type; } }
|
||||||
|
|
||||||
public GABUser Store { get; private set; }
|
public GABUser Store { get; private set; }
|
||||||
|
@ -55,13 +55,16 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
return false;
|
return false;
|
||||||
SoapData rhs = (SoapData)o;
|
SoapData rhs = (SoapData)o;
|
||||||
|
|
||||||
|
// TODO: this isn't really a full equality test, as flags is masked. This is because Equals is only used
|
||||||
|
// to test if there are changes that need to be applied. It would be nicer to rename this, and
|
||||||
|
// equals in SharedFolder to something like NeedsApply.
|
||||||
return
|
return
|
||||||
store == rhs.store &&
|
store == rhs.store &&
|
||||||
folderid == rhs.folderid &&
|
folderid == rhs.folderid &&
|
||||||
parentid == rhs.parentid &&
|
parentid == rhs.parentid &&
|
||||||
name == rhs.name &&
|
name == rhs.name &&
|
||||||
type == rhs.type &&
|
type == rhs.type &&
|
||||||
flags == rhs.flags;
|
(flags & ShareFlags.Mask_Apply) == (rhs.flags & ShareFlags.Mask_Apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
@ -86,6 +89,17 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches in any information that is available on AvailableFolder, but not SharedFolder. This is specifically the parent id.
|
||||||
|
/// </summary>
|
||||||
|
public SharedFolder PatchInformation(AvailableFolder folder)
|
||||||
|
{
|
||||||
|
if (folder.ParentIdAsBackend != _data.parentid)
|
||||||
|
{
|
||||||
|
_data.parentid = folder.ParentIdAsBackend;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -100,8 +114,8 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
{
|
{
|
||||||
store = folder.Store.UserName,
|
store = folder.Store.UserName,
|
||||||
folderid = folder.BackendId,
|
folderid = folder.BackendId,
|
||||||
parentid = folder.Parent?.BackendId ?? BackendId.NONE,
|
parentid = folder.ParentIdAsBackend,
|
||||||
name = folder.Name,
|
name = folder.DefaultName,
|
||||||
type = OutlookConstants.USER_SYNC_TYPES[(int)folder.Type],
|
type = OutlookConstants.USER_SYNC_TYPES[(int)folder.Type],
|
||||||
flags = folder.IsMailFolder ? ShareFlags.SendAsOwner : ShareFlags.None
|
flags = folder.IsMailFolder ? ShareFlags.SendAsOwner : ShareFlags.None
|
||||||
};
|
};
|
||||||
@ -161,6 +175,7 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool FlagSendAsOwner { get { return Flags.HasFlag(ShareFlags.SendAsOwner); } }
|
public bool FlagSendAsOwner { get { return Flags.HasFlag(ShareFlags.SendAsOwner); } }
|
||||||
|
public bool FlagUpdateShareName { get { return Flags.HasFlag(ShareFlags.TrackShareName); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a copy with the specified 'send as owner' flag.
|
/// Returns a copy with the specified 'send as owner' flag.
|
||||||
@ -170,6 +185,14 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
return WithFlags(value ? (_data.flags | ShareFlags.SendAsOwner) : (_data.flags & ~ShareFlags.SendAsOwner));
|
return WithFlags(value ? (_data.flags | ShareFlags.SendAsOwner) : (_data.flags & ~ShareFlags.SendAsOwner));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a copy with the specified 'update share name' flag.
|
||||||
|
/// </summary>
|
||||||
|
public SharedFolder WithFlagUpdateShareName(bool value)
|
||||||
|
{
|
||||||
|
return WithFlags(value ? (_data.flags | ShareFlags.TrackShareName) : (_data.flags & ~ShareFlags.TrackShareName));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Standard overrides
|
#region Standard overrides
|
||||||
|
@ -29,7 +29,22 @@ namespace Acacia.ZPush.API.SharedFolders
|
|||||||
public enum ShareFlags
|
public enum ShareFlags
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mails from folders containing this flag will be sent as the owner of the share, not the user.
|
||||||
|
/// </summary>
|
||||||
SendAsOwner = 1,
|
SendAsOwner = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Folders with this flag will be renamed when the original folder is renamed.
|
||||||
|
/// </summary>
|
||||||
|
TrackShareName = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mask indicating which flag changes cause an Apply to become needed. I.e. flags not in the mask
|
||||||
|
/// are updated only if other changes are made.
|
||||||
|
/// </summary>
|
||||||
|
Mask_Apply = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -169,7 +169,21 @@ namespace Acacia.ZPush.Connect.Soap
|
|||||||
}
|
}
|
||||||
private class TypeHandlerInt : TypeHandler
|
private class TypeHandlerInt : TypeHandler
|
||||||
{
|
{
|
||||||
public TypeHandlerInt() : base(SoapConstants.XMLNS_XSD, "int", typeof(long)) { }
|
public TypeHandlerInt() : base(SoapConstants.XMLNS_XSD, null, typeof(int)) { }
|
||||||
|
|
||||||
|
public override void Serialize(string name, object value, StringBuilder s)
|
||||||
|
{
|
||||||
|
s.Append(string.Format("<{0} xsi:type=\"xsd:int\">{1}</{0}>", name, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override object DeserializeContents(XmlNode node, Type expectedType)
|
||||||
|
{
|
||||||
|
return long.Parse(node.InnerText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private class TypeHandlerLong : TypeHandler
|
||||||
|
{
|
||||||
|
public TypeHandlerLong() : base(SoapConstants.XMLNS_XSD, "int", typeof(long)) { }
|
||||||
|
|
||||||
public override void Serialize(string name, object value, StringBuilder s)
|
public override void Serialize(string name, object value, StringBuilder s)
|
||||||
{
|
{
|
||||||
@ -439,6 +453,8 @@ namespace Acacia.ZPush.Connect.Soap
|
|||||||
static SoapSerializer()
|
static SoapSerializer()
|
||||||
{
|
{
|
||||||
RegisterTypeHandler(new TypeHandlerBoolean());
|
RegisterTypeHandler(new TypeHandlerBoolean());
|
||||||
|
// What is called an int in soap might actually be a long here.
|
||||||
|
RegisterTypeHandler(new TypeHandlerLong());
|
||||||
RegisterTypeHandler(new TypeHandlerInt());
|
RegisterTypeHandler(new TypeHandlerInt());
|
||||||
RegisterTypeHandler(new TypeHandlerString());
|
RegisterTypeHandler(new TypeHandlerString());
|
||||||
RegisterTypeHandler(new TypeHandlerList());
|
RegisterTypeHandler(new TypeHandlerList());
|
||||||
|
@ -130,11 +130,14 @@ namespace Acacia.ZPush.Connect
|
|||||||
{
|
{
|
||||||
// Content
|
// Content
|
||||||
using (HttpContent content = request.GetContent())
|
using (HttpContent content = request.GetContent())
|
||||||
using (HttpResponseMessage response = _client.PostAsync(url, content, _cancel ?? CancellationToken.None).Result)
|
|
||||||
using (HttpContent responseContent = response.Content)
|
|
||||||
{
|
{
|
||||||
Logger.Instance.Debug(this, "Response: {0}", responseContent.ReadAsStringAsync().Result);
|
Logger.Instance.Trace(this, "Request: {0}", content.ReadAsStringAsync().Result);
|
||||||
return request.ParseResponse(responseContent.ReadAsStreamAsync().Result);
|
using (HttpResponseMessage response = _client.PostAsync(url, content, _cancel ?? CancellationToken.None).Result)
|
||||||
|
using (HttpContent responseContent = response.Content)
|
||||||
|
{
|
||||||
|
Logger.Instance.Trace(this, "Response: {0}", responseContent.ReadAsStringAsync().Result);
|
||||||
|
return request.ParseResponse(responseContent.ReadAsStreamAsync().Result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user