private void SyncShares(ZPushAccount account)
        {
            using (SharedFoldersManager manager = Manage(account))
            {
                Logger.Instance.Debug(this, "Starting sync for account {0}", account);

                if (account.IsShare)
                {
                    Logger.Instance.Debug(this, "Account {0} is a share", account);
                    manager.UpdateSharedStore();
                }
                else
                {
                    // Fetch the current shares
                    ICollection <SharedFolder> shares = manager.GetCurrentShares(null);
                    Logger.Instance.Trace(this, "AdditionalFolders_Sync: {0}", shares.Count);

                    // Convert to dictionary
                    Dictionary <SyncId, SharedFolder> dict = shares.ToDictionary(x => x.SyncId);
                    Logger.Instance.Trace(this, "AdditionalFolders_Sync2: {0}", shares.Count);

                    // Store any send-as properties
                    FeatureSendAs sendAs = ThisAddIn.Instance.GetFeature <FeatureSendAs>();
                    sendAs?.UpdateSendAsAddresses(account, shares);

                    // Store with the account
                    account.SetFeatureData(this, KEY_SHARES, dict);
                }
            }
        }
Example #2
0
        public StoreTreeNode(SharedFoldersManager folders, GABHandler gab, GABUser user, string sendAsAddress, string text,
                             Dictionary <BackendId, SharedFolder> currentFolders, bool isShared, bool showRemindersWholeStore)
            :
            base(text)
        {
            this._initialShares = currentFolders;
            // Patch in send as address
            foreach (SharedFolder share in _initialShares.Values)
            {
                if (string.IsNullOrWhiteSpace(share.SendAsAddress))
                {
                    share.SendAsAddress = sendAsAddress;
                }
            }
            this._feature       = folders.Feature;
            this._featureSendAs = ThisAddIn.Instance.GetFeature <FeatureSendAs>();
            this._account       = folders.Account;
            this._gab           = gab;
            this._user          = user;
            this._sendAsAddress = sendAsAddress;
            this.IsReadOnly     = false;
            this._isShared      = isShared;

            // Create an empty current state. When loading the nodes, the shares will be added. This has the benefit of
            // cleaning up automatically any obsolote shares.
            this._currentShares = new Dictionary <BackendId, SharedFolder>();

            ChildLoader = new UserFolderLoader(this, folders, user);
            ChildLoader.ReloadOnCloseOpen = true;
            // Can only open the whole store if it's supported and there's an email address, as that's needed to open it
            // However, if it's already opened, we can remove it without the email address
            HasCheckBox = folders.SupportsWholeStore && (!string.IsNullOrWhiteSpace(user.EmailAddress) || isShared);
            ApplyReadOnly(this, IsReadOnly);

            // TODO: better icons, better way of handling this
            ImageIndex = user == GABUser.USER_PUBLIC ? 0 : 11;

            // Reloader
            _reloader           = new KAnimator();
            _reloader.Animation = Properties.Resources.TreeLoading;
            _reloader.Visible   = false;
            _reloader.Click    += (s, e) =>
            {
                ChildLoader.Reload();
            };
            Control = _reloader;

            // Set up sharing
            WantShare            = isShared;
            ShowRemindersInitial = showRemindersWholeStore;
            ShowReminders        = ShowRemindersInitial;
        }
        public SharedFoldersDialog(FeatureSharedFolders feature, ZPushAccount account, SyncId initial = null)
        {
            // If this is a shared store, open the account it's a share for, with the request account as the initial
            if (account.ShareFor != null)
            {
                _initialAccount = account;
                account         = account.ShareForAccount;
            }
            this._account       = account;
            this._feature       = feature;
            this._featureSendAs = ThisAddIn.Instance.GetFeature <FeatureSendAs>();
            this._folders       = feature.Manage(account);
            this._initialSyncId = initial;

            InitializeComponent();

            // TODO: make a specialised class out of this
            this.kTreeFolders.Images = new OutlookImageList(
                "NewFolder",              // Other
                "JunkEmailMarkAsNotJunk", // Inbox
                "GoDrafts",               // Drafts
                "RecycleBin",             // WasteBasket
                "ReceiveMenu",            // SentMail
                "NewFolder",              // Outbox
                "ShowTaskPage",           // Task
                "ShowAppointmentPage",    // Appointment
                "ShowContactPage",        // Contact
                "NewNote",                // Note
                "ShowJournalPage",        // Journal
                "LastModifiedBy"          // Store

                ).Images;

            // Set the check manager
            kTreeFolders.CheckManager = new ShareCheckManager();

            // Add the email address to the title
            Text = string.Format(Text, account.Account.SmtpAddress);

            // Set up options
            ShowOptions(new KTreeNode[0]);

            // Set up user selector
            gabLookup.GAB = FeatureGAB.FindGABForAccount(account);
        }