mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Merge branch 'master' of https://stash.kopano.io/scm/koe/kopano_ol_extension_source
This commit is contained in:
commit
ec3f323261
@ -133,8 +133,12 @@
|
|||||||
-->
|
-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Accessibility" />
|
<Reference Include="Accessibility" />
|
||||||
|
<Reference Include="Heijden.Dns, Version=2.0.0.6, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Heijden.Dns.2.0.0\lib\net35\Heijden.Dns.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NLog.4.2.3\lib\net45\NLog.dll</HintPath>
|
<HintPath>..\packages\NLog.4.4.1\lib\net45\NLog.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
@ -272,6 +276,7 @@
|
|||||||
<Compile Include="Features\SharedFolders\FolderTreeNode.cs" />
|
<Compile Include="Features\SharedFolders\FolderTreeNode.cs" />
|
||||||
<Compile Include="GlobalOptions.cs" />
|
<Compile Include="GlobalOptions.cs" />
|
||||||
<Compile Include="Logging.cs" />
|
<Compile Include="Logging.cs" />
|
||||||
|
<Compile Include="Native\IOleWindow.cs" />
|
||||||
<Compile Include="OutlookConstants.cs" />
|
<Compile Include="OutlookConstants.cs" />
|
||||||
<Compile Include="UI\Outlook\OutlookImageList.cs" />
|
<Compile Include="UI\Outlook\OutlookImageList.cs" />
|
||||||
<Compile Include="UI\Outlook\RibbonToggleButton.cs" />
|
<Compile Include="UI\Outlook\RibbonToggleButton.cs" />
|
||||||
|
@ -124,7 +124,7 @@ namespace Acacia.Features.WebApp
|
|||||||
private string PerformAutoDiscover(ZPushAccount account)
|
private string PerformAutoDiscover(ZPushAccount account)
|
||||||
{
|
{
|
||||||
// Fetch the txt record
|
// Fetch the txt record
|
||||||
List<string> txt = DnsUtil.GetTxtRecord(account.DomainName);
|
IList<string> txt = DnsUtil.GetTxtRecord(account.DomainName);
|
||||||
if (txt == null)
|
if (txt == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
18
src/AcaciaZPushPlugin/AcaciaZPushPlugin/Native/IOleWindow.cs
Normal file
18
src/AcaciaZPushPlugin/AcaciaZPushPlugin/Native/IOleWindow.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Acacia.Native
|
||||||
|
{
|
||||||
|
[ComImport]
|
||||||
|
[Guid("00000114-0000-0000-C000-000000000046")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
|
public interface IOleWindow
|
||||||
|
{
|
||||||
|
void GetWindow(out IntPtr phwnd);
|
||||||
|
void ContextSensitiveHelp([In, MarshalAs(UnmanagedType.Bool)] bool fEnterMode);
|
||||||
|
}
|
||||||
|
}
|
@ -60,6 +60,24 @@ namespace Acacia.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to The password for account '{0}' is not available. Advanced Z-Push features will not work..
|
||||||
|
/// </summary>
|
||||||
|
internal static string AccountNoPassword_Body {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AccountNoPassword_Body", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Password unavailable.
|
||||||
|
/// </summary>
|
||||||
|
internal static string AccountNoPassword_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AccountNoPassword_Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Support.
|
/// Looks up a localized string similar to Support.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -439,4 +439,10 @@
|
|||||||
<value>Contacts folder</value>
|
<value>Contacts folder</value>
|
||||||
<comment>Shown when a secondary contact folder is detected, to inform the user that a restart is required</comment>
|
<comment>Shown when a secondary contact folder is detected, to inform the user that a restart is required</comment>
|
||||||
</data>
|
</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>
|
||||||
|
<data name="AccountNoPassword_Title" xml:space="preserve">
|
||||||
|
<value>Password unavailable</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -32,6 +32,7 @@ using Acacia.UI.Outlook;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Acacia.Native;
|
||||||
|
|
||||||
namespace Acacia
|
namespace Acacia
|
||||||
{
|
{
|
||||||
@ -244,6 +245,41 @@ namespace Acacia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Window handle
|
||||||
|
|
||||||
|
private class WindowHandle : IWin32Window
|
||||||
|
{
|
||||||
|
private IntPtr hWnd;
|
||||||
|
|
||||||
|
public WindowHandle(IntPtr hWnd)
|
||||||
|
{
|
||||||
|
this.hWnd = hWnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Handle
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return hWnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWin32Window Window
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var win = Application.ActiveWindow() as IOleWindow;
|
||||||
|
if (win == null)
|
||||||
|
return null;
|
||||||
|
IntPtr hWnd;
|
||||||
|
win.GetWindow(out hWnd);
|
||||||
|
return new WindowHandle(hWnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
|
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
|
||||||
{
|
{
|
||||||
return OutlookUI;
|
return OutlookUI;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
/// Copyright 2016 Kopano b.v.
|
|
||||||
|
using Heijden.DNS;
|
||||||
|
/// Copyright 2016 Kopano b.v.
|
||||||
///
|
///
|
||||||
/// This program is free software: you can redistribute it and/or modify
|
/// 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,
|
/// it under the terms of the GNU Affero General Public License, version 3,
|
||||||
@ -13,7 +15,6 @@
|
|||||||
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
|
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
|
||||||
///
|
///
|
||||||
/// Consult LICENSE file for details
|
/// Consult LICENSE file for details
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -26,73 +27,11 @@ namespace Acacia.Utils
|
|||||||
{
|
{
|
||||||
public static class DnsUtil
|
public static class DnsUtil
|
||||||
{
|
{
|
||||||
public static List<string> GetTxtRecord(string name)
|
public static IList<string> GetTxtRecord(string name)
|
||||||
{
|
{
|
||||||
const Int16 DNS_TYPE_TEXT = 0x0010;
|
Resolver resolver = new Resolver();
|
||||||
const Int32 DNS_QUERY_STANDARD = 0x00000000;
|
Response response = resolver.Query(name, QType.TXT, QClass.IN);
|
||||||
const Int32 DNS_ERROR_RCODE_NAME_ERROR = 9003;
|
return response.RecordsTXT.Select(r => r.ToString()).ToList();
|
||||||
const Int32 DNS_INFO_NO_RECORDS = 9501;
|
|
||||||
var queryResultsSet = IntPtr.Zero;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dnsStatus = DnsQuery(
|
|
||||||
name,
|
|
||||||
DNS_TYPE_TEXT,
|
|
||||||
DNS_QUERY_STANDARD,
|
|
||||||
IntPtr.Zero,
|
|
||||||
ref queryResultsSet,
|
|
||||||
IntPtr.Zero
|
|
||||||
);
|
|
||||||
if (dnsStatus == DNS_ERROR_RCODE_NAME_ERROR || dnsStatus == DNS_INFO_NO_RECORDS)
|
|
||||||
return null;
|
|
||||||
if (dnsStatus != 0)
|
|
||||||
throw new Win32Exception(dnsStatus);
|
|
||||||
DnsRecordTxt dnsRecord;
|
|
||||||
var lines = new List<String>();
|
|
||||||
for (var pointer = queryResultsSet; pointer != IntPtr.Zero; pointer = dnsRecord.pNext)
|
|
||||||
{
|
|
||||||
dnsRecord = (DnsRecordTxt)Marshal.PtrToStructure(pointer, typeof(DnsRecordTxt));
|
|
||||||
if (dnsRecord.wType == DNS_TYPE_TEXT)
|
|
||||||
{
|
|
||||||
var stringArrayPointer = pointer + Marshal.OffsetOf(typeof(DnsRecordTxt), "pStringArray").ToInt32();
|
|
||||||
for (var i = 0; i < dnsRecord.dwStringCount; ++i)
|
|
||||||
{
|
|
||||||
var stringPointer = (IntPtr)Marshal.PtrToStructure(stringArrayPointer, typeof(IntPtr));
|
|
||||||
lines.Add(Marshal.PtrToStringUni(stringPointer));
|
|
||||||
stringArrayPointer += IntPtr.Size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lines.Count == 0)
|
|
||||||
return null;
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
const Int32 DnsFreeRecordList = 1;
|
|
||||||
if (queryResultsSet != IntPtr.Zero)
|
|
||||||
DnsRecordListFree(queryResultsSet, DnsFreeRecordList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("Dnsapi.dll", EntryPoint = "DnsQuery_W", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
|
|
||||||
static extern Int32 DnsQuery(String lpstrName, Int16 wType, Int32 options, IntPtr pExtra, ref IntPtr ppQueryResultsSet, IntPtr pReserved);
|
|
||||||
|
|
||||||
[DllImport("Dnsapi.dll")]
|
|
||||||
static extern void DnsRecordListFree(IntPtr pRecordList, Int32 freeType);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
struct DnsRecordTxt
|
|
||||||
{
|
|
||||||
public IntPtr pNext;
|
|
||||||
public String pName;
|
|
||||||
public Int16 wType;
|
|
||||||
public Int16 wDataLength;
|
|
||||||
public Int32 flags;
|
|
||||||
public Int32 dwTtl;
|
|
||||||
public Int32 dwReserved;
|
|
||||||
public Int32 dwStringCount;
|
|
||||||
public String pStringArray;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,12 @@ namespace Acacia.ZPush
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public bool HasPassword
|
||||||
|
{
|
||||||
|
get { return Registry.GetValue(_regPath, OutlookConstants.REG_VAL_EAS_PASSWORD, null) != null; }
|
||||||
|
}
|
||||||
|
|
||||||
public string StoreID
|
public string StoreID
|
||||||
{
|
{
|
||||||
get { return GetStoreId(_regPath); }
|
get { return GetStoreId(_regPath); }
|
||||||
|
@ -141,24 +141,39 @@ namespace Acacia.ZPush
|
|||||||
// Register any events
|
// Register any events
|
||||||
HandleFolderWatchers(account);
|
HandleFolderWatchers(account);
|
||||||
|
|
||||||
// Send an OOF request to get the OOF state and capabilities
|
if (account.HasPassword)
|
||||||
Tasks.Task(null, "ZPushCheck: " + account.DisplayName, () =>
|
|
||||||
{
|
{
|
||||||
// TODO: if this fails, retry?
|
// Send an OOF request to get the OOF state and capabilities
|
||||||
ActiveSync.SettingsOOF oof;
|
Tasks.Task(null, "ZPushCheck: " + account.DisplayName, () =>
|
||||||
using (ZPushConnection connection = new ZPushConnection(account, new System.Threading.CancellationToken(false)))
|
|
||||||
{
|
{
|
||||||
oof = connection.Execute(new ActiveSync.SettingsOOFGet());
|
// TODO: if this fails, retry?
|
||||||
}
|
ActiveSync.SettingsOOF oof;
|
||||||
account.OnConfirmationResponse(oof.RawResponse);
|
using (ZPushConnection connection = new ZPushConnection(account, new System.Threading.CancellationToken(false)))
|
||||||
|
{
|
||||||
|
oof = connection.Execute(new ActiveSync.SettingsOOFGet());
|
||||||
|
}
|
||||||
|
account.OnConfirmationResponse(oof.RawResponse);
|
||||||
|
|
||||||
// [ZO-109] Always update the current selection, it might have changed.
|
// [ZO-109] Always update the current selection, it might have changed.
|
||||||
Explorer_SelectionChange();
|
Explorer_SelectionChange();
|
||||||
|
|
||||||
// Notify the OOF feature.
|
// Notify the OOF feature.
|
||||||
// TODO: this coupling is pretty hideous
|
// TODO: this coupling is pretty hideous
|
||||||
ThisAddIn.Instance.GetFeature<FeatureOutOfOffice>()?.OnOOFSettings(account, oof);
|
ThisAddIn.Instance.GetFeature<FeatureOutOfOffice>()?.OnOOFSettings(account, oof);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ThisAddIn.Instance.InvokeUI(() =>
|
||||||
|
{
|
||||||
|
Logger.Instance.Warning(this, "Password not available for account: {0}", account);
|
||||||
|
System.Windows.Forms.MessageBox.Show(ThisAddIn.Instance.Window,
|
||||||
|
string.Format(Properties.Resources.AccountNoPassword_Body, account.DisplayName),
|
||||||
|
Properties.Resources.AccountNoPassword_Title,
|
||||||
|
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnAccountsScanned()
|
internal void OnAccountsScanned()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="NLog" version="4.2.3" targetFramework="net452" />
|
<package id="Heijden.Dns" version="2.0.0" targetFramework="net452" />
|
||||||
|
<package id="NLog" version="4.4.1" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
@ -670,6 +670,18 @@ msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\SecondaryContactsPatched_Titl
|
|||||||
msgid "Contacts folder"
|
msgid "Contacts folder"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: AcaciaZPushPlugin\Properties\Resources\AccountNoPassword_Body
|
||||||
|
#, csharp-format
|
||||||
|
msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\AccountNoPassword_Body"
|
||||||
|
msgid "The password for account \'{0}\' is not available. Advanced Z-Push features will not work."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: AcaciaZPushPlugin\Properties\Resources\AccountNoPassword_Title
|
||||||
|
#, csharp-format
|
||||||
|
msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\AccountNoPassword_Title"
|
||||||
|
msgid "Password unavailable"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: AcaciaZPushPlugin\UI\ProgressDialog\labelMessage.Text
|
#: AcaciaZPushPlugin\UI\ProgressDialog\labelMessage.Text
|
||||||
#, csharp-format
|
#, csharp-format
|
||||||
msgctxt "AcaciaZPushPlugin\\UI\\ProgressDialog\\labelMessage.Text"
|
msgctxt "AcaciaZPushPlugin\\UI\\ProgressDialog\\labelMessage.Text"
|
||||||
|
@ -672,6 +672,18 @@ msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\SecondaryContactsPatched_Titl
|
|||||||
msgid "Contacts folder"
|
msgid "Contacts folder"
|
||||||
msgstr "Contacts folder"
|
msgstr "Contacts folder"
|
||||||
|
|
||||||
|
#: AcaciaZPushPlugin\Properties\Resources\AccountNoPassword_Body
|
||||||
|
#, csharp-format
|
||||||
|
msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\AccountNoPassword_Body"
|
||||||
|
msgid "The password for account \'{0}\' is not available. Advanced Z-Push features will not work."
|
||||||
|
msgstr "The password for account \'{0}\' is not available. Advanced Z-Push features will not work."
|
||||||
|
|
||||||
|
#: AcaciaZPushPlugin\Properties\Resources\AccountNoPassword_Title
|
||||||
|
#, csharp-format
|
||||||
|
msgctxt "AcaciaZPushPlugin\\Properties\\Resources\\AccountNoPassword_Title"
|
||||||
|
msgid "Password unavailable"
|
||||||
|
msgstr "Password unavailable"
|
||||||
|
|
||||||
#: AcaciaZPushPlugin\UI\ProgressDialog\labelMessage.Text
|
#: AcaciaZPushPlugin\UI\ProgressDialog\labelMessage.Text
|
||||||
#, csharp-format
|
#, csharp-format
|
||||||
msgctxt "AcaciaZPushPlugin\\UI\\ProgressDialog\\labelMessage.Text"
|
msgctxt "AcaciaZPushPlugin\\UI\\ProgressDialog\\labelMessage.Text"
|
||||||
|
Loading…
Reference in New Issue
Block a user