1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-166] Added reminders option to EASAccount for initial setup.

[KOE-166] Added private appointment suppression to impersonated stores
This commit is contained in:
Patrick Simpson 2018-07-04 13:28:52 +03:00
parent 593118f552
commit 1e92f75fe4
6 changed files with 41 additions and 19 deletions

View File

@ -234,10 +234,10 @@ namespace Acacia.Features.SharedFolders
return share; return share;
} }
public static bool IsSharedFolder(IFolder folder) public static bool IsSharedOrImpersonatedFolder(IFolder folder)
{ {
string id = (string)folder.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID); string id = (string)folder.GetProperty(OutlookConstants.PR_ZPUSH_SYNC_ID);
return id?.StartsWith("S") == true; return id?.StartsWith("S") == true || id?.StartsWith("I") == true;
} }
#endregion #endregion
@ -324,7 +324,7 @@ namespace Acacia.Features.SharedFolders
// Check if in a shared folder // Check if in a shared folder
using (IFolder parent = item.Parent) using (IFolder parent = item.Parent)
{ {
if (parent == null || !IsSharedFolder(parent)) if (parent == null || !IsSharedOrImpersonatedFolder(parent))
{ {
Logger.Instance.TraceExtra(this, "Private appointment: suppress: not in a shared folder"); Logger.Instance.TraceExtra(this, "Private appointment: suppress: not in a shared folder");
return; return;

View File

@ -54,7 +54,7 @@ namespace Acacia.Features.SharedFolders
{ {
get get
{ {
return _folder.SearchCriteria; return _folder?.SearchCriteria;
} }
set set
{ {

View File

@ -414,7 +414,7 @@ namespace Acacia.Features.SharedFolders
IRestarter restarter = ThisAddIn.Instance.Restarter(); IRestarter restarter = ThisAddIn.Instance.Restarter();
restarter.CloseWindows = true; restarter.CloseWindows = true;
foreach (StoreTreeNode node in state.stores) foreach (StoreTreeNode node in state.stores)
restarter.OpenShare(_account, node.User); restarter.OpenShare(_account, node.User, node.ShowReminders);
restarter.Restart(); restarter.Restart();
} }

View File

@ -25,7 +25,7 @@ namespace Acacia.Stubs
/// </summary> /// </summary>
/// <param name="account"></param> /// <param name="account"></param>
/// <param name="store"></param> /// <param name="store"></param>
void OpenShare(ZPushAccount account, GABUser store); void OpenShare(ZPushAccount account, GABUser store, bool showReminders);
/// <summary> /// <summary>
/// Performs the actual restart. /// Performs the actual restart.

View File

@ -15,7 +15,14 @@ namespace Acacia.Stubs.OutlookWrappers
{ {
private readonly AddInWrapper _addIn; private readonly AddInWrapper _addIn;
private readonly List<ZPushAccount> _resyncAccounts = new List<ZPushAccount>(); private readonly List<ZPushAccount> _resyncAccounts = new List<ZPushAccount>();
private readonly List<KeyValuePair<ZPushAccount, GABUser>> _shares = new List<KeyValuePair<ZPushAccount, GABUser>>();
private struct Share
{
public ZPushAccount account;
public GABUser store;
public bool showReminders;
}
private readonly List<Share> _shares = new List<Share>();
public Restarter(AddInWrapper addIn) public Restarter(AddInWrapper addIn)
{ {
@ -46,9 +53,12 @@ namespace Acacia.Stubs.OutlookWrappers
_resyncAccounts.AddRange(accounts); _resyncAccounts.AddRange(accounts);
} }
public void OpenShare(ZPushAccount account, GABUser store) public void OpenShare(ZPushAccount account, GABUser store, bool showReminders)
{ {
_shares.Add(new KeyValuePair<ZPushAccount, GABUser>(account, store)); _shares.Add(new Share()
{
account = account, store = store, showReminders = showReminders
});
} }
public void Restart() public void Restart()
@ -75,16 +85,16 @@ namespace Acacia.Stubs.OutlookWrappers
if (_shares.Count > 0) if (_shares.Count > 0)
{ {
foreach (KeyValuePair<ZPushAccount, GABUser> share in _shares) foreach (Share share in _shares)
{ {
Logger.Instance.Debug(this, "Adding KOE share: profile={0}, version={1}, accountid={2}, user={3}, email={4}", Logger.Instance.Debug(this, "Adding KOE share: profile={0}, version={1}, accountid={2}, user={3}, email={4}, reminders={5}",
_addIn.ProfileName, _addIn.VersionMajor, share.Key.Account.AccountId, share.Value.UserName, share.Value.EmailAddress); _addIn.ProfileName, _addIn.VersionMajor, share.account.Account.AccountId, share.store.UserName, share.store.EmailAddress, share.showReminders);
// TODO: escaping // TODO: escaping
commandLine += " /sharekoe " + Util.QuoteCommandLine(_addIn.ProfileName + ":" + commandLine += " /sharekoe " + Util.QuoteCommandLine(_addIn.ProfileName + ":" +
_addIn.VersionMajor + ":" + _addIn.VersionMajor + ":" +
share.Key.Account.AccountId + ":" + share.account.Account.AccountId + ":" +
share.Value.UserName + ":" + share.Value.EmailAddress + ":" + share.store.UserName + ":" + share.store.EmailAddress + ":" +
share.Value.EmailAddress); share.store.EmailAddress + ":1:" + (share.showReminders ? "1" : "0"));
} }
} }

View File

@ -54,6 +54,7 @@ static const wstring R_EMAIL = L"Email";
static const wstring R_EMAIL_ORIGINAL = L"KOE Share For"; static const wstring R_EMAIL_ORIGINAL = L"KOE Share For";
static const wstring R_PASSWORD = L"EAS Password"; static const wstring R_PASSWORD = L"EAS Password";
static const wstring R_ONE_MONTH = L"EAS SyncSlider"; static const wstring R_ONE_MONTH = L"EAS SyncSlider";
static const wstring R_SHOW_REMINDERS = L"KOE Reminders";
struct Account struct Account
{ {
@ -70,6 +71,7 @@ public:
vector<byte> encryptedPassword; vector<byte> encryptedPassword;
wstring dataFolder; wstring dataFolder;
bool syncOneMonth; bool syncOneMonth;
bool showReminders;
private: private:
wstring path; wstring path;
int initializedMAPI = 0; int initializedMAPI = 0;
@ -139,7 +141,9 @@ public:
L"\tpath=%ls\n" L"\tpath=%ls\n"
L"\tservice=%ls\n" L"\tservice=%ls\n"
L"\tentryId=%ls\n" L"\tentryId=%ls\n"
L"\taccountId=%.8X\n", L"\taccountId=%.8X\n"
L"\toneMonth=%d\n"
L"\treminders=%d\n",
prefix, prefix,
profileName.c_str(), profileName.c_str(),
outlookVersion.c_str(), outlookVersion.c_str(),
@ -156,7 +160,9 @@ public:
path.c_str(), path.c_str(),
ToHex(&service, sizeof(service)).c_str(), ToHex(&service, sizeof(service)).c_str(),
ToHex(entryId).c_str(), ToHex(entryId).c_str(),
accountId accountId,
syncOneMonth ? 1 : 0,
showReminders ? 1 : 0
); );
} }
void Create() void Create()
@ -504,6 +510,9 @@ private:
if (syncOneMonth) if (syncOneMonth)
WriteAccountKey(R_ONE_MONTH, (DWORD)1); WriteAccountKey(R_ONE_MONTH, (DWORD)1);
if (!showReminders)
WriteAccountKey(R_SHOW_REMINDERS, (DWORD)0);
WriteAccountKey(L"clsid", L"{ED475415-B0D6-11D2-8C3B-00104B2A6676}"); WriteAccountKey(L"clsid", L"{ED475415-B0D6-11D2-8C3B-00104B2A6676}");
WriteAccountKey(R_PASSWORD, &encryptedPassword[0], encryptedPassword.size()); WriteAccountKey(R_PASSWORD, &encryptedPassword[0], encryptedPassword.size());
@ -654,9 +663,9 @@ int __cdecl wmain(int argc, wchar_t **argv)
// Main // Main
try try
{ {
if (argc < 7 || argc > 8) if (argc < 7 || argc > 9)
{ {
fwprintf(stderr, L"EASAccount: <profile> <outlook version> <accountid> <username> <email> <display> [1 month]\n"); fwprintf(stderr, L"EASAccount: <profile> <outlook version> <accountid> <username> <email> <display> [1 month] [reminders]\n");
exit(3); exit(3);
} }
@ -672,6 +681,9 @@ int __cdecl wmain(int argc, wchar_t **argv)
account.syncOneMonth = true; account.syncOneMonth = true;
if (argc > 7) if (argc > 7)
account.syncOneMonth = !wcscmp(argv[7], L"1"); account.syncOneMonth = !wcscmp(argv[7], L"1");
account.showReminders = true;
if (argc > 8)
account.showReminders = !wcscmp(argv[8], L"1");
try try
{ {