mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
[KOE-50] Showing information dialog if password is not available.
This commit is contained in:
parent
ef4ee3827a
commit
99e939a5b2
@ -276,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" />
|
||||||
|
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;
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user