public GenericOptionsViewModel ( IOptionsViewModelParent parent, GeneralOptions generalOptions, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, Func<ISettingsFaultFinder, ICurrentOptions, IServerSettingsViewModel> serverSettingsViewModelFactory, Func<ICurrentOptions, IMappingConfigurationViewModelFactory> mappingConfigurationViewModelFactoryFactory, IOptionTasks optionTasks) : base (parent) { if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); if (outlookAccountPasswordProvider == null) throw new ArgumentNullException (nameof (outlookAccountPasswordProvider)); if (mappingConfigurationViewModelFactoryFactory == null) throw new ArgumentNullException (nameof (mappingConfigurationViewModelFactoryFactory)); _syncSettingsViewModel = new SyncSettingsViewModel(); _networkSettingsViewModel = new NetworkSettingsViewModel(); var faultFinder = generalOptions.FixInvalidSettings ? new SettingsFaultFinder (this) : NullSettingsFaultFinder.Instance; _serverSettingsViewModel = serverSettingsViewModelFactory (faultFinder, this); _generalOptions = generalOptions; _outlookAccountPasswordProvider = outlookAccountPasswordProvider; _mappingConfigurationViewModelFactory = mappingConfigurationViewModelFactoryFactory(this); _outlookFolderViewModel = new OutlookFolderViewModel (faultFinder, optionTasks); _outlookFolderViewModel.PropertyChanged += OutlookFolderViewModel_PropertyChanged; _timeRangeViewModel = new TimeRangeViewModel(); }
public void SaveOptions (GeneralOptions options) { using (var key = OpenOptionsKey()) { key.SetValue (s_shouldCheckForNewerVersionsValueName, options.ShouldCheckForNewerVersions ? 1 : 0); key.SetValue (s_storeAppDataInRoamingFolder, options.StoreAppDataInRoamingFolder ? 1 : 0); key.SetValue (s_disableCertificateValidation, options.DisableCertificateValidation ? 1 : 0); key.SetValue (s_enableTls12, options.EnableTls12 ? 1 : 0); key.SetValue (s_enableSsl3, options.EnableSsl3 ? 1 : 0); key.SetValue (s_fixInvalidSettings, options.FixInvalidSettings ? 1 : 0); } }
public void SaveOptions (GeneralOptions options) { using (var key = OpenOptionsKey()) { key.SetValue (s_shouldCheckForNewerVersionsValueName, options.ShouldCheckForNewerVersions ? 1 : 0); key.SetValue (s_checkIfOnline, options.CheckIfOnline ? 1 : 0); key.SetValue (s_storeAppDataInRoamingFolder, options.StoreAppDataInRoamingFolder ? 1 : 0); key.SetValue (s_disableCertificateValidation, options.DisableCertificateValidation ? 1 : 0); key.SetValue (s_enableTls12, options.EnableTls12 ? 1 : 0); key.SetValue (s_enableSsl3, options.EnableSsl3 ? 1 : 0); key.SetValue (s_fixInvalidSettings, options.FixInvalidSettings ? 1 : 0); key.SetValue (s_DisplayAllProfilesAsGeneric, options.DisplayAllProfilesAsGeneric ? 1 : 0); key.SetValue (s_LogReportsWithoutWarningsOrErrors, options.LogReportsWithoutWarningsOrErrors ? 1 : 0); key.SetValue (s_LogReportsWithWarnings, options.LogReportsWithWarnings ? 1 : 0); key.SetValue (s_ShowReportsWithWarningsImmediately, options.ShowReportsWithWarningsImmediately ? 1 : 0); key.SetValue (s_ShowReportsWithErrorsImmediately, options.ShowReportsWithErrorsImmediately ? 1 : 0); key.SetValue (s_MaxReportAgeInDays, options.MaxReportAgeInDays); key.SetValue (s_EnableDebugLog, options.EnableDebugLog ? 1 : 0); } }
public OptionsCollectionViewModel ( GeneralOptions generalOptions, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList<string> availableEventCategories, Func<Guid, string> profileDataDirectoryFactory, IUiService uiService, IOptionTasks optionTasks) { _optionTasks = optionTasks; _profileDataDirectoryFactory = profileDataDirectoryFactory; _uiService = uiService; if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); if (profileDataDirectoryFactory == null) throw new ArgumentNullException (nameof (profileDataDirectoryFactory)); if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks)); _generalOptions = generalOptions; _optionsViewModelFactory = new OptionsViewModelFactory ( this, outlookAccountPasswordProvider, availableEventCategories, optionTasks); AddCommand = new DelegateCommand (_ => Add()); AddMultipleCommand = new DelegateCommand (_ => AddMultiple()); CloseCommand = new DelegateCommand (shouldSaveNewOptions => Close((bool)shouldSaveNewOptions)); DeleteSelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => DeleteSelected (), _ => CanDeleteSelected); CopySelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => CopySelected (), _ => CanCopySelected); MoveSelectedUpCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedUp (), _ => CanMoveSelectedUp); MoveSelectedDownCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedDown (), _ => CanMoveSelectedDown); OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested (_ => OpenProfileDataDirectory (), _ => CanOpenProfileDataDirectory); ExpandAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExpandAll (), _ => _options.Count > 0); CollapseAllCommand = new DelegateCommandHandlingRequerySuggested (_ => CollapseAll (), _ => _options.Count > 0); ExportAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExportAll (), _ => _options.Count > 0); ImportCommand = new DelegateCommandHandlingRequerySuggested (_ => Import (), _ => true); }
public MultipleOptionsTemplateViewModel ( IOptionsViewModelParent parent, GeneralOptions generalOptions, IServerSettingsTemplateViewModel serverSettingsViewModel, ProfileType profileType, IOptionTasks optionTasks) { _parent = parent; if (parent == null) throw new ArgumentNullException (nameof (parent)); if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks)); _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation (_ => { ComponentContainer.EnsureSynchronizationContext(); DiscoverResourcesAsync(); }); _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ => { ComponentContainer.EnsureSynchronizationContext(); GetAccountSettings(); }); _networkSettingsViewModel = new NetworkSettingsViewModel(); Items = new[] { _networkSettingsViewModel }; _serverSettingsViewModel = serverSettingsViewModel; _profileType = profileType; _optionTasks = optionTasks; _generalOptions = generalOptions; }
public void SaveOptions (GeneralOptions options) { using (var key = OpenOptionsKey()) { key.SetValue (s_shouldCheckForNewerVersionsValueName, options.ShouldCheckForNewerVersions ? 1 : 0); key.SetValue (s_checkIfOnline, options.CheckIfOnline ? 1 : 0); key.SetValue (s_storeAppDataInRoamingFolder, options.StoreAppDataInRoamingFolder ? 1 : 0); key.SetValue (s_disableCertificateValidation, options.DisableCertificateValidation ? 1 : 0); key.SetValue (s_enableClientCertificate, options.EnableClientCertificate ? 1 : 0); key.SetValue (s_enableTls12, options.EnableTls12 ? 1 : 0); key.SetValue (s_enableSsl3, options.EnableSsl3 ? 1 : 0); key.SetValue (s_calDavConnectTimeout, options.CalDavConnectTimeout.ToString()); key.SetValue (s_fixInvalidSettings, options.FixInvalidSettings ? 1 : 0); key.SetValue (s_IncludeCustomMessageClasses, options.IncludeCustomMessageClasses ? 1 : 0); key.SetValue (s_LogReportsWithoutWarningsOrErrors, options.LogReportsWithoutWarningsOrErrors ? 1 : 0); key.SetValue (s_LogReportsWithWarnings, options.LogReportsWithWarnings ? 1 : 0); key.SetValue (s_ShowReportsWithWarningsImmediately, options.ShowReportsWithWarningsImmediately ? 1 : 0); key.SetValue (s_ShowReportsWithErrorsImmediately, options.ShowReportsWithErrorsImmediately ? 1 : 0); key.SetValue (s_MaxReportAgeInDays, options.MaxReportAgeInDays); key.SetValue (s_EnableDebugLog, options.EnableDebugLog ? 1 : 0); key.SetValue (s_EnableTrayIcon, options.EnableTrayIcon ? 1 : 0); key.SetValue (s_AcceptInvalidCharsInServerResponse, options.AcceptInvalidCharsInServerResponse ? 1 : 0); key.SetValue (s_UseUnsafeHeaderParsing, options.UseUnsafeHeaderParsing ? 1 : 0); key.SetValue (s_TriggerSyncAfterSendReceive, options.TriggerSyncAfterSendReceive ? 1 : 0); key.SetValue (s_ExpandAllSyncProfiles, options.ExpandAllSyncProfiles ? 1 : 0); } }
public async Task UpdateOptions (Options options, GeneralOptions generalOptions) { if (options == null) throw new ArgumentNullException (nameof (options)); if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); _pendingOutlookItems.Clear(); _fullSyncPending = false; _profileName = options.Name; _profileId = options.Id; _proxyOptions = options.ProxyOptions; _synchronizer = options.Inactive ? NullOutlookSynchronizer.Instance : await _synchronizerFactory.CreateSynchronizer (options, generalOptions); _interval = TimeSpan.FromMinutes (options.SynchronizationIntervalInMinutes); _inactive = options.Inactive; _checkIfOnline = generalOptions.CheckIfOnline; if (_folderChangeWatcher != null) { _folderChangeWatcher.ItemSavedOrDeleted -= FolderChangeWatcher_ItemSavedOrDeleted; _folderChangeWatcher.Dispose(); _folderChangeWatcher = null; } if (!_inactive && options.EnableChangeTriggeredSynchronization) { _folderChangeWatcher = _folderChangeWatcherFactory.Create (options.OutlookFolderEntryId, options.OutlookFolderStoreId); _folderChangeWatcher.ItemSavedOrDeleted += FolderChangeWatcher_ItemSavedOrDeleted; } }
private IWebDavClient CreateWebDavClient (NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions, string davUrl) { return SynchronizerFactory.CreateWebDavClient ( UserName, UseAccountPassword ? _outlookAccountPasswordProvider.GetPassword (null) : Password, davUrl, generalOptions.CalDavConnectTimeout, ServerAdapterType.WebDavHttpClientBased, networkSettings.CloseConnectionAfterEachRequest, networkSettings.PreemptiveAuthentication, networkSettings.ForceBasicAuthentication, networkSettings.CreateProxyOptions (), generalOptions.EnableClientCertificate, generalOptions.AcceptInvalidCharsInServerResponse); }
public async Task<ServerResources> GetServerResources (NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions) { string caldavUrlString ; string carddavUrlString; if (string.IsNullOrEmpty (CalenderUrl) && !string.IsNullOrEmpty (EmailAddress)) { bool success; caldavUrlString = OptionTasks.DoSrvLookup (EmailAddress, OlItemType.olAppointmentItem, out success); carddavUrlString = OptionTasks.DoSrvLookup (EmailAddress, OlItemType.olContactItem, out success); } else { caldavUrlString = CalenderUrl; carddavUrlString = CalenderUrl; } var trimmedCaldavUrl = caldavUrlString.Trim(); var caldavUrl = new Uri (trimmedCaldavUrl.EndsWith ("/") ? trimmedCaldavUrl : trimmedCaldavUrl + "/"); var trimmedCarddavUrl = carddavUrlString.Trim(); var carddavUrl = new Uri (trimmedCarddavUrl.EndsWith("/") ? trimmedCarddavUrl : trimmedCarddavUrl + "/"); var webDavClientCaldav = CreateWebDavClient (networkSettings, generalOptions, trimmedCaldavUrl); var webDavClientCarddav = CreateWebDavClient (networkSettings, generalOptions, trimmedCarddavUrl); var calDavDataAccess = new CalDavDataAccess (caldavUrl, webDavClientCaldav); var cardDavDataAccess = new CardDavDataAccess (carddavUrl, webDavClientCarddav); return await GetUserResources (calDavDataAccess, cardDavDataAccess); }
public IOptionsViewModel CreateTemplate (Contracts.Options options, GeneralOptions generalOptions, ProfileType type) { throw new NotSupportedException(); }
public List<IOptionsViewModel> Create (IReadOnlyCollection<Contracts.Options> options, GeneralOptions generalOptions) { return new List<IOptionsViewModel>(); }
private static void ConfigureServicePointManager (GeneralOptions options) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11; if (options.EnableTls12) ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; if (options.EnableSsl3) ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3; if (options.DisableCertificateValidation) ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; else ServicePointManager.ServerCertificateValidationCallback = null; }
public async Task SetOptions (Options[] options, GeneralOptions generalOptions) { if (options == null) throw new ArgumentNullException (nameof (options)); if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); Dictionary<Guid, SynchronizationProfileRunner> workersById = new Dictionary<Guid, SynchronizationProfileRunner>(); foreach (var option in options) { try { SynchronizationProfileRunner profileRunner; if (!_runnersById.TryGetValue (option.Id, out profileRunner)) { profileRunner = new SynchronizationProfileRunner ( _synchronizerFactory, _reportSink, _folderChangeWatcherFactory, _ensureSynchronizationContext, _runLogger); } await profileRunner.UpdateOptions (option, generalOptions); workersById.Add (option.Id, profileRunner); } catch (Exception x) { ExceptionHandler.Instance.LogException (x, s_logger); } } _runnersById = workersById; }
private ReportPopupMode GetReportPopupMode (GeneralOptions options) { if (options.ShowReportsWithWarningsImmediately) { // HINT: althoug it is possible that in this case ShowReportsWithErrorsImmediately is false, // the UI doesnt offer that feature to just show reports with warnings immediately return ReportPopupMode.WarningsAndErrors; } else if (options.ShowReportsWithErrorsImmediately) { return ReportPopupMode.JustErrors; } else { return ReportPopupMode.NoPopup; } }
private ReportLogMode GetReportLogMode (GeneralOptions options) { if (options.LogReportsWithoutWarningsOrErrors) { // HINT: althoug it is possible that in this case LogReportsWithWarnings is false, // the UI doesnt offer that feature to just configure logging of reports without errors and warning return ReportLogMode.All; } else if (options.LogReportsWithWarnings) { return ReportLogMode.WarningsOrErrors; } else { return ReportLogMode.OnlyWithErrors; } }
private IWebDavClient CreateWebDavClient (NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions) { return SynchronizerFactory.CreateWebDavClient ( EmailAddress, SecureStringUtility.ToSecureString (string.Empty), CalenderUrl, generalOptions.CalDavConnectTimeout, ServerAdapterType.WebDavHttpClientBasedWithGoogleOAuth, networkSettings.CloseConnectionAfterEachRequest, networkSettings.PreemptiveAuthentication, networkSettings.ForceBasicAuthentication, networkSettings.CreateProxyOptions(), false, generalOptions.AcceptInvalidCharsInServerResponse); }
public async Task<ServerResources> GetServerResources (NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions) { var trimmedUrl = CalenderUrl.Trim(); var url = new Uri (trimmedUrl.EndsWith ("/") ? trimmedUrl : trimmedUrl + "/"); var webDavClient = CreateWebDavClient (networkSettings, generalOptions); var calDavDataAccess = new CalDavDataAccess (url, webDavClient); var foundResources = await calDavDataAccess.GetUserResourcesNoThrow (false); var foundAddressBooks = new[] { new AddressBookData (new Uri ("googleApi://defaultAddressBook"), "Default AddressBook") }; var service = await GoogleHttpClientFactory.LoginToGoogleTasksService (EmailAddress, SynchronizerFactory.CreateProxy (networkSettings.CreateProxyOptions())); var taskLists = await service.Tasklists.List().ExecuteAsync(); var taskListsData = taskLists?.Items.Select (i => new TaskListData (i.Id, i.Title)).ToArray() ?? new TaskListData[] { }; return new ServerResources (foundResources.CalendarResources, foundAddressBooks, taskListsData); }