diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
index c727738..588180c 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
@@ -237,7 +237,7 @@
-
+
Form
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs
index a90ee32..72acc4e 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs
@@ -33,6 +33,7 @@ namespace Acacia.Features
typeof(FreeBusy.FeatureFreeBusy),
typeof(GAB.FeatureGAB),
typeof(Notes.FeatureNotes),
+ typeof(SecondaryContacts.FeatureSecondaryContacts),
typeof(SendAs.FeatureSendAs),
typeof(DebugSupport.FeatureDebugSupport)
};
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Notes/FeatureNotes.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Notes/FeatureNotes.cs
index 38bf5f6..a21892b 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Notes/FeatureNotes.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Notes/FeatureNotes.cs
@@ -84,7 +84,7 @@ namespace Acacia.Features.Notes
PatchIfConfirmed(folder);
}
- private bool IsNotesFolder(OutlookConstants.SyncType type)
+ private bool IsNotesFolder(OutlookConstants.SyncType? type)
{
return type == OutlookConstants.SyncType.Note || type == OutlookConstants.SyncType.UserNote;
}
@@ -128,7 +128,7 @@ namespace Acacia.Features.Notes
return;
// Patch if needed
- OutlookConstants.SyncType type = FolderUtils.GetFolderSyncType(folder);
+ OutlookConstants.SyncType? type = FolderUtils.GetFolderSyncType(folder);
Logger.Instance.Trace(this, "Notes folder type: {0}", type);
if (IsNotesFolder(type))
{
@@ -174,7 +174,7 @@ namespace Acacia.Features.Notes
return;
// 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);
// Unpatch only if the original type is a notes folder, but the current type isn't
if (IsNotesFolder(type) && !IsNotesFolder(FolderUtils.GetFolderSyncType(folder)))
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs
new file mode 100644
index 0000000..cde4ab9
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs
@@ -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.
+///
+/// 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
+ });
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/OutlookConstants.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/OutlookConstants.cs
index 4b6ff6d..5f45c47 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/OutlookConstants.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/OutlookConstants.cs
@@ -83,6 +83,8 @@ namespace Acacia
public const string PR_SUBJECT = PROP + "0037" + PT_UNICODE;
+ public const string PR_CONTAINER_CLASS = PROP + "3613" + PT_UNICODE;
+
#endregion
#region Email specific
@@ -120,6 +122,7 @@ namespace Acacia
public const string PR_EAS_SYNCTYPE = PROP + "6A1A" + PT_LONG;
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_EAS_NAME = PROP + "6915" + PT_UNICODE;
public enum SyncType
{
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/FolderUtils.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/FolderUtils.cs
index 3b023f6..dab4d99 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/FolderUtils.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/FolderUtils.cs
@@ -28,17 +28,19 @@ namespace Acacia.Utils
{
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)
{
string type = (string)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE_ORIG);
+ if (string.IsNullOrEmpty(type))
+ return null;
return (OutlookConstants.SyncType)int.Parse(type);
}
else
{
- int type = (int)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE);
- return (OutlookConstants.SyncType)type;
+ int? type = (int?)folder.GetProperty(OutlookConstants.PR_EAS_SYNCTYPE);
+ return (OutlookConstants.SyncType?)type;
}
}