mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
[KOE-14] Initial version of patcher. Does all the patching, but somehow doesn't work
This commit is contained in:
parent
6d135c0ddc
commit
9e05601fe9
@ -237,7 +237,7 @@
|
|||||||
<Compile Include="Controls\KUITask.cs" />
|
<Compile Include="Controls\KUITask.cs" />
|
||||||
<Compile Include="Controls\KUIUtil.cs" />
|
<Compile Include="Controls\KUIUtil.cs" />
|
||||||
<Compile Include="DebugOptions.cs" />
|
<Compile Include="DebugOptions.cs" />
|
||||||
<Compile Include="Features\Contacts\FeatureContacts.cs" />
|
<Compile Include="Features\SecondaryContacts\FeatureSecondaryContacts.cs" />
|
||||||
<Compile Include="Features\DebugSupport\AboutDialog.cs">
|
<Compile Include="Features\DebugSupport\AboutDialog.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -33,6 +33,7 @@ namespace Acacia.Features
|
|||||||
typeof(FreeBusy.FeatureFreeBusy),
|
typeof(FreeBusy.FeatureFreeBusy),
|
||||||
typeof(GAB.FeatureGAB),
|
typeof(GAB.FeatureGAB),
|
||||||
typeof(Notes.FeatureNotes),
|
typeof(Notes.FeatureNotes),
|
||||||
|
typeof(SecondaryContacts.FeatureSecondaryContacts),
|
||||||
typeof(SendAs.FeatureSendAs),
|
typeof(SendAs.FeatureSendAs),
|
||||||
typeof(DebugSupport.FeatureDebugSupport)
|
typeof(DebugSupport.FeatureDebugSupport)
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ namespace Acacia.Features.Notes
|
|||||||
PatchIfConfirmed(folder);
|
PatchIfConfirmed(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsNotesFolder(OutlookConstants.SyncType type)
|
private bool IsNotesFolder(OutlookConstants.SyncType? type)
|
||||||
{
|
{
|
||||||
return type == OutlookConstants.SyncType.Note || type == OutlookConstants.SyncType.UserNote;
|
return type == OutlookConstants.SyncType.Note || type == OutlookConstants.SyncType.UserNote;
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ namespace Acacia.Features.Notes
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Patch if needed
|
// Patch if needed
|
||||||
OutlookConstants.SyncType type = FolderUtils.GetFolderSyncType(folder);
|
OutlookConstants.SyncType? type = FolderUtils.GetFolderSyncType(folder);
|
||||||
Logger.Instance.Trace(this, "Notes folder type: {0}", type);
|
Logger.Instance.Trace(this, "Notes folder type: {0}", type);
|
||||||
if (IsNotesFolder(type))
|
if (IsNotesFolder(type))
|
||||||
{
|
{
|
||||||
@ -174,7 +174,7 @@ namespace Acacia.Features.Notes
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Unpatch if needed
|
// Unpatch if needed
|
||||||
OutlookConstants.SyncType type = FolderUtils.GetFolderSyncType(folder, true);
|
OutlookConstants.SyncType? type = FolderUtils.GetFolderSyncType(folder, true);
|
||||||
Logger.Instance.Trace(this, "Notes folder type: {0}", type);
|
Logger.Instance.Trace(this, "Notes folder type: {0}", type);
|
||||||
// Unpatch only if the original type is a notes folder, but the current type isn't
|
// Unpatch only if the original type is a notes folder, but the current type isn't
|
||||||
if (IsNotesFolder(type) && !IsNotesFolder(FolderUtils.GetFolderSyncType(folder)))
|
if (IsNotesFolder(type) && !IsNotesFolder(FolderUtils.GetFolderSyncType(folder)))
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/// Copyright 2017 Kopano b.v.
|
||||||
|
///
|
||||||
|
/// This program is free software: you can redistribute it and/or modify
|
||||||
|
/// it under the terms of the GNU Affero General Public License, version 3,
|
||||||
|
/// as published by the Free Software Foundation.
|
||||||
|
///
|
||||||
|
/// This program is distributed in the hope that it will be useful,
|
||||||
|
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||||
|
/// GNU Affero General Public License for more details.
|
||||||
|
///
|
||||||
|
/// You should have received a copy of the GNU Affero General Public License
|
||||||
|
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
|
||||||
|
///
|
||||||
|
/// Consult LICENSE file for details
|
||||||
|
|
||||||
|
using Acacia.Stubs;
|
||||||
|
using Acacia.Stubs.OutlookWrappers;
|
||||||
|
using Acacia.Utils;
|
||||||
|
using Acacia.ZPush;
|
||||||
|
using Microsoft.Office.Interop.Outlook;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static Acacia.DebugOptions;
|
||||||
|
|
||||||
|
namespace Acacia.Features.SecondaryContacts
|
||||||
|
{
|
||||||
|
[AcaciaOption("Provides the possibility to synchronise multiple contacts folders to and from a Z-Push server.")]
|
||||||
|
public class FeatureSecondaryContacts : Feature
|
||||||
|
{
|
||||||
|
private const string SUFFIX_CONTACTS = "\x200B";
|
||||||
|
|
||||||
|
private class FolderRegistrationSecondaryContacts : FolderRegistration
|
||||||
|
{
|
||||||
|
public FolderRegistrationSecondaryContacts(Feature feature) : base(feature)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsApplicable(IFolder folder)
|
||||||
|
{
|
||||||
|
// Check the sync type
|
||||||
|
if (FolderUtils.GetFolderSyncType(folder) != OutlookConstants.SyncType.Unknown)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check the hidden suffix
|
||||||
|
if (!folder.Name.EndsWith(SUFFIX_CONTACTS))
|
||||||
|
return false;
|
||||||
|
Logger.Instance.Debug(this.Feature, "CONTACTS: {0} - {1}", folder.Name, StringUtil.BytesToHex(Encoding.UTF8.GetBytes(folder.Name)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeatureSecondaryContacts()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Startup()
|
||||||
|
{
|
||||||
|
Watcher.WatchFolder(new FolderRegistrationSecondaryContacts(this),
|
||||||
|
OnUnpatchedFolderDiscovered);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnUnpatchedFolderDiscovered(IFolder folder)
|
||||||
|
{
|
||||||
|
string strippedName = folder.Name.StripSuffix(SUFFIX_CONTACTS);
|
||||||
|
// Update the properties
|
||||||
|
folder.SetProperties(new string[]
|
||||||
|
{
|
||||||
|
OutlookConstants.PR_EAS_SYNCTYPE,
|
||||||
|
OutlookConstants.PR_CONTAINER_CLASS,
|
||||||
|
OutlookConstants.PR_EAS_NAME,
|
||||||
|
OutlookConstants.PR_DISPLAY_NAME,
|
||||||
|
OutlookConstants.PR_EAS_SYNC1,
|
||||||
|
OutlookConstants.PR_EAS_SYNC2
|
||||||
|
}, new object[]
|
||||||
|
{
|
||||||
|
(int)OutlookConstants.SyncType.UserContact,
|
||||||
|
"IPF.Contact",
|
||||||
|
strippedName,
|
||||||
|
strippedName,
|
||||||
|
true, true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -83,6 +83,8 @@ namespace Acacia
|
|||||||
|
|
||||||
public const string PR_SUBJECT = PROP + "0037" + PT_UNICODE;
|
public const string PR_SUBJECT = PROP + "0037" + PT_UNICODE;
|
||||||
|
|
||||||
|
public const string PR_CONTAINER_CLASS = PROP + "3613" + PT_UNICODE;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Email specific
|
#region Email specific
|
||||||
@ -120,6 +122,7 @@ namespace Acacia
|
|||||||
public const string PR_EAS_SYNCTYPE = PROP + "6A1A" + PT_LONG;
|
public const string PR_EAS_SYNCTYPE = PROP + "6A1A" + PT_LONG;
|
||||||
public const string PR_EAS_SYNC2 = PROP + "6A1D" + PT_BOOLEAN;
|
public const string PR_EAS_SYNC2 = PROP + "6A1D" + PT_BOOLEAN;
|
||||||
public const string PR_NET_FOLDER_FLAGS = PROP + "36DE" + PT_LONG;
|
public const string PR_NET_FOLDER_FLAGS = PROP + "36DE" + PT_LONG;
|
||||||
|
public const string PR_EAS_NAME = PROP + "6915" + PT_UNICODE;
|
||||||
|
|
||||||
public enum SyncType
|
public enum SyncType
|
||||||
{
|
{
|
||||||
|
@ -28,17 +28,19 @@ namespace Acacia.Utils
|
|||||||
{
|
{
|
||||||
public static class FolderUtils
|
public static class FolderUtils
|
||||||
{
|
{
|
||||||
public static OutlookConstants.SyncType GetFolderSyncType(IFolder folder, bool orig = false)
|
public static OutlookConstants.SyncType? GetFolderSyncType(IFolder folder, bool orig = false)
|
||||||
{
|
{
|
||||||
if (orig)
|
if (orig)
|
||||||
{
|
{
|
||||||
string type = (string)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE_ORIG);
|
string type = (string)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE_ORIG);
|
||||||
|
if (string.IsNullOrEmpty(type))
|
||||||
|
return null;
|
||||||
return (OutlookConstants.SyncType)int.Parse(type);
|
return (OutlookConstants.SyncType)int.Parse(type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int type = (int)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE);
|
int? type = (int?)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE);
|
||||||
return (OutlookConstants.SyncType)type;
|
return (OutlookConstants.SyncType?)type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user