Disabled 1.3 features

This commit is contained in:
Patrick Simpson 2017-02-15 13:40:17 +01:00
parent c55091bcc7
commit 2ebd2639ea
9 changed files with 2 additions and 193 deletions

View File

@ -241,7 +241,6 @@
<Compile Include="Controls\KUITask.cs" />
<Compile Include="Controls\KUIUtil.cs" />
<Compile Include="DebugOptions.cs" />
<Compile Include="Features\SecondaryContacts\FeatureSecondaryContacts.cs" />
<Compile Include="Features\DebugSupport\AboutDialog.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -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";

View File

@ -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)
};

View File

@ -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<http://www.gnu.org/licenses/>.
///
/// 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<string> _warnedFolders = new HashSet<string>();
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);
}
}
}
}

View File

@ -803,24 +803,6 @@ namespace Acacia.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to To synchronise the contacts folder &apos;{0}&apos;, Outlook must be restarted. Click &apos;Yes&apos; to restart Outlook now, or &apos;No&apos; if you plan to restart Outlook later..
/// </summary>
internal static string SecondaryContactsPatched_Body {
get {
return ResourceManager.GetString("SecondaryContactsPatched_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Contacts folder.
/// </summary>
internal static string SecondaryContactsPatched_Title {
get {
return ResourceManager.GetString("SecondaryContactsPatched_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unable to open the shared folder. Please ensure you have permission to open the shared folder..
/// </summary>

View File

@ -431,14 +431,6 @@
<data name="Ribbon_About_Supertip" xml:space="preserve">
<value>Shows the about dialog, which contains licensing and version information.</value>
</data>
<data name="SecondaryContactsPatched_Body" xml:space="preserve">
<value>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.</value>
<comment>Shown when a secondary contact folder is detected, to inform the user that a restart is required</comment>
</data>
<data name="SecondaryContactsPatched_Title" xml:space="preserve">
<value>Contacts folder</value>
<comment>Shown when a secondary contact folder is detected, to inform the user that a restart is required</comment>
</data>
<data name="AccountNoPassword_Body" xml:space="preserve">
<value>The password for account '{0}' is not available. Advanced Z-Push features will not work.</value>
</data>

View File

@ -62,10 +62,6 @@ namespace Acacia.Stubs
/// </summary>
void SendReceive(IAccount account = null);
/// <summary>
/// Restarts the application
/// </summary>
void Restart();
void Quit();
void InvokeUI(Action action);

View File

@ -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();

View File

@ -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);