Пример #1
0
        public GoogleOptionsDisplayControl(
            NameSpace session,
            Func <Guid, string> profileDataDirectoryFactory,
            bool fixInvalidSettings)
        {
            ISettingsFaultFinder faultFinder;

            InitializeComponent();

            if (fixInvalidSettings)
            {
                faultFinder = new SettingsFaultFinder(_syncSettingsControl);
            }
            else
            {
                faultFinder = NullSettingsFaultFinder.Instance;
            }

            _outlookFolderControl.Initialize(session, faultFinder);
            _serverSettingsControl.Initialize(faultFinder, this);

            _profileNameTextBox.TextChanged     += _profileNameTextBox_TextChanged;
            _inactiveCheckBox.CheckedChanged    += _inactiveCheckBox_CheckedChanged;
            _outlookFolderControl.FolderChanged += OutlookFolderControl_FolderChanged;
            _profileDataDirectoryFactory         = profileDataDirectoryFactory;

            _configurationFormFactory = OptionTasks.CreateConfigurationFormFactory(_serverSettingsControl);
        }
Пример #2
0
        public void FixSynchronizationMode(TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.CalendarProperties.HasFlag(CalendarProperties.IsWriteable) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(_syncSettingsControl.SynchronizationMode))
                {
                    _syncSettingsControl.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only calendar. Synchronization mode set to '{0}'.",
                            _syncSettingsControl.AvailableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AddressBookProperties.HasFlag(AddressBookProperties.IsWriteable) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(_syncSettingsControl.SynchronizationMode))
                {
                    _syncSettingsControl.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only addressbook. Synchronization mode set to '{0}'.",
                            _syncSettingsControl.AvailableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }
        }
Пример #3
0
        public void FixSynchronizationMode(OptionsModel options, TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        $"The specified Url is a read-only calendar. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'.",
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        $"The specified Url is a read-only addressbook. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'.",
                        OptionTasks.ConnectionTestCaption);
                }
            }
        }
Пример #4
0
        public bool Validate(StringBuilder errorMessageBuilder)
        {
            bool result = true;

            result &= OptionTasks.ValidateWebDavUrl(_serverSettingsControl.CalendarUrl, errorMessageBuilder, true);
            result &= _outlookFolderControl.Validate(errorMessageBuilder);
            result &= OptionTasks.ValidateEmailAddress(errorMessageBuilder, _serverSettingsControl.EmailAddress);
            return(result);
        }
        private void _addProfileButton_Click(object sender, EventArgs e)
        {
            var options = OptionTasks.CreateNewSynchronizationProfileOrNull();

            if (options == null)
            {
                return;
            }

            _tabControl.SelectedTab = AddTabPage(options);
        }
Пример #6
0
        public bool Validate(StringBuilder errorMessageBuilder)
        {
            bool result = true;

            if (_outlookFolderControl.OutlookFolderType != OlItemType.olTaskItem)
            {
                result &= OptionTasks.ValidateWebDavUrl(_serverSettingsControl.CalendarUrl, errorMessageBuilder, true);
            }

            result &= _outlookFolderControl.Validate(errorMessageBuilder);
            result &= OptionTasks.ValidateGoogleEmailAddress(errorMessageBuilder, _serverSettingsControl.EmailAddress);

            return(result);
        }
        public void FixSynchronizationMode(OptionsModel options, TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        Strings.Get($"The specified URL is a read-only calendar. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'."),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        Strings.Get($"The specified URL is a read-only addressbook. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'."),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (options.SynchronizationMode == readOnlyDefaultMode && options.SelectedFolderOrNull?.ItemCount > 0)
            {
                MessageBox.Show(
                    Strings.Get($"Synchronization mode is set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}' and the selected Outlook folder is not empty. Are you sure, you want to select this folder because all items will be overwritten with the DAV server resources!"),
                    OptionTasks.ConnectionTestCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (options.SynchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer && options.SelectedFolderOrNull?.ItemCount == 0)
            {
                MessageBox.Show(
                    Strings.Get($"Synchronization mode is set to '{_enumDisplayNameProvider.Get(SynchronizationMode.ReplicateOutlookIntoServer)}' and the selected Outlook folder is empty. Are you sure, you want to select this folder, because all items on the DAV server will be deleted!"),
                    OptionTasks.ConnectionTestCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #8
0
 private async void TestServerConnectionAsync()
 {
     _testConnectionButton.Enabled = false;
     try
     {
         await OptionTasks.TestWebDavConnection(this, _settingsFaultFinder);
     }
     catch (Exception x)
     {
         s_logger.Error("Exception while testing the connection.", x);
         string message = null;
         for (Exception ex = x; ex != null; ex = ex.InnerException)
         {
             message += ex.Message + Environment.NewLine;
         }
         MessageBox.Show(message, OptionTasks.ConnectionTestCaption);
     }
     finally
     {
         _testConnectionButton.Enabled = true;
     }
 }
Пример #9
0
 private void _mappingConfigurationButton_Click(object sender, EventArgs e)
 {
     try
     {
         var mappingConfiguration = OptionTasks.CoreceMappingConfiguration(_outlookFolderControl.OutlookFolderType, _mappingConfiguration, true);
         if (mappingConfiguration != null)
         {
             var configurationForm = mappingConfiguration.CreateConfigurationForm(_configurationFormFactory.Value);
             if (configurationForm.Display())
             {
                 _mappingConfiguration = configurationForm.Options;
             }
         }
         else
         {
             MessageBox.Show("Mapping configuration not available.");
         }
     }
     catch (Exception x)
     {
         ExceptionHandler.Instance.DisplayException(x, s_logger);
     }
 }
Пример #10
0
 public void UpdateFolderAccountName()
 {
     _folderAccountName = OptionTasks.GetFolderAccountNameOrNull(_session, _folderStoreId);
 }