diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj index 8b97a68..2a9292a 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj @@ -241,7 +241,6 @@ - Form diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Constants.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Constants.cs index d03a91d..d928f6e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Constants.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Constants.cs @@ -71,7 +71,6 @@ namespace Acacia public const string ZPUSH_HEADER_GAB_NAME = "X-Push-GAB-Name"; public const string ZPUSH_HEADER_CAPABILITIES = "X-Push-Capabilities"; - public const string ZPUSH_HEADER_CLIENT_CAPABILITIES = "X-Push-Plugin-Capabilities"; public const string ZPUSH_HEADER_PLUGIN = "X-Push-Plugin"; public const string ZPUSH_HEADER_VERSION = "X-Z-Push-Version"; diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs index 72acc4e..a90ee32 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Features.cs @@ -33,7 +33,6 @@ 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/SecondaryContacts/FeatureSecondaryContacts.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs deleted file mode 100644 index d79feb4..0000000 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs +++ /dev/null @@ -1,138 +0,0 @@ -/// 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 System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -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. - // Also allow again if the sync type is user contact, it may not have been fully patched. - if (FolderUtils.GetFolderSyncType(folder) != OutlookConstants.SyncType.Unknown && - FolderUtils.GetFolderSyncType(folder) != OutlookConstants.SyncType.UserContact) - return false; - - // Check the hidden suffix - if (!folder.Name.EndsWith(SUFFIX_CONTACTS)) - return false; - - return true; - } - } - - // Contains the ids of folders for which we've shown a warning. This is both to prevent - // warning multiple times and to detect the case when the app has been restarted. - private readonly HashSet _warnedFolders = new HashSet(); - - public FeatureSecondaryContacts() - { - - } - - public override void Startup() - { - Watcher.WatchFolder(new FolderRegistrationSecondaryContacts(this), - OnUnpatchedFolderDiscovered); - } - - private void OnUnpatchedFolderDiscovered(IFolder folder) - { - string strippedName = folder.Name.StripSuffix(SUFFIX_CONTACTS); - Logger.Instance.Debug(this, "Patching secondary contacts folder: {0}", strippedName); - - // To patch we need to do the following - // 1) Update the sync type from 18 to 14 - // 2) Update the container class from Note to Contact - // 3) Patch the name - // Note that the above steps need to be done in this order and individually for this to work. - // - // At some point after 2 we also need to restart Outlook to make it appear in the list of contact folders. - // So, when the folder is detected, we make it invisible and perform steps 1 and 2. We issue a warning - // that Outlook must be restarted. When the folder is detected again and is invisible, that means we've restarted - // At this point the name is patched and the folder is made visible. - - if (!folder.AttrHidden) - { - // Stage 1 - - // Sync type - Logger.Instance.Trace(this, "Setting sync type"); - folder.SetProperty(OutlookConstants.PR_EAS_SYNCTYPE, (int)OutlookConstants.SyncType.UserContact); - - // Container type - Logger.Instance.Trace(this, "Setting container class"); - folder.SetProperty(OutlookConstants.PR_CONTAINER_CLASS, "IPF.Contact"); - - // Make it invisible. - folder.AttrHidden = true; - - Logger.Instance.Debug(this, "Patched secondary contacts folder: {0}", strippedName); - // Register and show a warning, if not already done. - // Note that patching may be done multiple times. - if (!_warnedFolders.Contains(folder.EntryID)) - { - _warnedFolders.Add(folder.EntryID); - - if (MessageBox.Show(StringUtil.GetResourceString("SecondaryContactsPatched_Body", strippedName), - StringUtil.GetResourceString("SecondaryContactsPatched_Title"), - MessageBoxButtons.YesNo, - MessageBoxIcon.Warning - ) == DialogResult.Yes) - { - ThisAddIn.Instance.Restart(); - } - } - } - // If _warnedFolders does not contain the folder (and it's hidden), this means Outlook was restarted. - else if (!_warnedFolders.Contains(folder.EntryID)) - { - // Stage 2 - - // Patch the name - Logger.Instance.Trace(this, "Patching name"); - folder.Name = strippedName; - - // Show it - folder.AttrHidden = false; - Logger.Instance.Debug(this, "Shown secondary contacts folder: {0}", strippedName); - } - } - } -} \ No newline at end of file diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs index 204b24a..5783e2e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs @@ -803,24 +803,6 @@ namespace Acacia.Properties { } } - /// - /// Looks up a localized string similar to To synchronise the contacts folder '{0}', Outlook must be restarted. Click 'Yes' to restart Outlook now, or 'No' if you plan to restart Outlook later.. - /// - internal static string SecondaryContactsPatched_Body { - get { - return ResourceManager.GetString("SecondaryContactsPatched_Body", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Contacts folder. - /// - internal static string SecondaryContactsPatched_Title { - get { - return ResourceManager.GetString("SecondaryContactsPatched_Title", resourceCulture); - } - } - /// /// Looks up a localized string similar to Unable to open the shared folder. Please ensure you have permission to open the shared folder.. /// diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx index a8eb0c0..25c391c 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx @@ -431,14 +431,6 @@ Shows the about dialog, which contains licensing and version information. - - To synchronise the contacts folder '{0}', Outlook must be restarted. Click 'Yes' to restart Outlook now, or 'No' if you plan to restart Outlook later. - Shown when a secondary contact folder is detected, to inform the user that a restart is required - - - Contacts folder - Shown when a secondary contact folder is detected, to inform the user that a restart is required - The password for account '{0}' is not available. Advanced Z-Push features will not work. diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs index 29441eb..c0747aa 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs @@ -62,10 +62,6 @@ namespace Acacia.Stubs /// void SendReceive(IAccount account = null); - /// - /// Restarts the application - /// - void Restart(); void Quit(); void InvokeUI(Action action); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs index 88f531a..939df10 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs @@ -71,25 +71,7 @@ namespace Acacia.Stubs.OutlookWrappers { _stores.Start(); } - - public void Restart() - { - // Can not use the assembly location, as that is in the GAC - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - // Create the path to the restarter - path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), "OutlookRestarter.exe"); - - // Run that - Process process = new Process(); - process.StartInfo = new ProcessStartInfo(path, Environment.CommandLine); - process.Start(); - - // And close us - _app.Quit(); - } - + public void Quit() { _app.Quit(); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/ZPushConnection.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/ZPushConnection.cs index aa846de..e6f9cdd 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/ZPushConnection.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/ZPushConnection.cs @@ -293,9 +293,7 @@ namespace Acacia.ZPush.Connect { Logger.Instance.Trace(this, "Sending request: {0} -> {1}", _account.Account.ServerURL, doc.ToXMLString()); content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-sync.wbxml"); - string caps = ZPushCapabilities.Client.ToString(); - Logger.Instance.Trace(this, "Sending request: {0} -> {1}: {2}", _account.Account.ServerURL, caps, doc.ToXMLString()); - content.Headers.Add(Constants.ZPUSH_HEADER_CLIENT_CAPABILITIES, caps); + Logger.Instance.Trace(this, "Sending request: {0} -> {1}", _account.Account.ServerURL, doc.ToXMLString()); using (HttpResponseMessage response = _client.PostAsync(url, content, _cancel).Result) { return new Response(response);