Inheritance: ViewModelBase, ISubOptionsViewModel
Exemplo n.º 1
0
        public GenericOptionsViewModel(
            NameSpace session,
            IOptionsViewModelParent parent,
            bool fixInvalidSettings,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            Func <ISettingsFaultFinder, ICurrentOptions, IServerSettingsViewModel> serverSettingsViewModelFactory,
            Func <ICurrentOptions, IMappingConfigurationViewModelFactory> mappingConfigurationViewModelFactoryFactory)
            : base(parent)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (mappingConfigurationViewModelFactoryFactory == null)
            {
                throw new ArgumentNullException(nameof(mappingConfigurationViewModelFactoryFactory));
            }

            _syncSettingsViewModel    = new SyncSettingsViewModel();
            _networkSettingsViewModel = new NetworkSettingsViewModel();

            var faultFinder = fixInvalidSettings ? new SettingsFaultFinder(this) : NullSettingsFaultFinder.Instance;

            _serverSettingsViewModel              = serverSettingsViewModelFactory(faultFinder, this);
            _outlookAccountPasswordProvider       = outlookAccountPasswordProvider;
            _mappingConfigurationViewModelFactory = mappingConfigurationViewModelFactoryFactory(this);
            _outlookFolderViewModel = new OutlookFolderViewModel(session, faultFinder);
            _outlookFolderViewModel.PropertyChanged += OutlookFolderViewModel_PropertyChanged;
            _timeRangeViewModel = new TimeRangeViewModel();
        }
    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();
    }
Exemplo n.º 3
0
 /// <remarks>
 /// Just for creating the DesingInstance
 /// </remarks>
 public GenericOptionsViewModel(IOptionsViewModelParent parent, NetworkSettingsViewModel networkSettingsViewModel, OutlookFolderViewModel outlookFolderViewModel, IServerSettingsViewModel serverSettingsViewModel, SyncSettingsViewModel syncSettingsViewModel, IOptionsViewModel mappingConfigurationViewModel)
     : base(parent)
 {
     _networkSettingsViewModel     = networkSettingsViewModel;
     _outlookFolderViewModel       = outlookFolderViewModel;
     _serverSettingsViewModel      = serverSettingsViewModel;
     _syncSettingsViewModel        = syncSettingsViewModel;
     MappingConfigurationViewModel = mappingConfigurationViewModel;
 }
 /// <remarks>
 /// Just for creating the DesingInstance
 /// </remarks>
 public GenericOptionsViewModel (IOptionsViewModelParent parent, NetworkSettingsViewModel networkSettingsViewModel, OutlookFolderViewModel outlookFolderViewModel, IServerSettingsViewModel serverSettingsViewModel, SyncSettingsViewModel syncSettingsViewModel, ISubOptionsViewModel mappingConfigurationViewModel)
     : base (parent)
 {
   _networkSettingsViewModel = networkSettingsViewModel;
   _outlookFolderViewModel = outlookFolderViewModel;
   _serverSettingsViewModel = serverSettingsViewModel;
   _syncSettingsViewModel = syncSettingsViewModel;
   MappingConfigurationViewModel = mappingConfigurationViewModel;
 }
Exemplo n.º 5
0
        public GenericOptionsViewModel(
            IOptionsViewModelParent parent,
            IOptionsSection serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel model,
            IReadOnlyList <string> availableCategories,
            IViewOptions viewOptions)
            : base(viewOptions, model)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (serverSettingsViewModel == null)
            {
                throw new ArgumentNullException(nameof(serverSettingsViewModel));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (availableCategories == null)
            {
                throw new ArgumentNullException(nameof(availableCategories));
            }


            Model = model;
            _availableCategories = availableCategories;

            _syncSettingsViewModel    = new SyncSettingsViewModel(model, viewOptions);
            _networkSettingsViewModel = new NetworkSettingsViewModel(model);

            _serverSettingsViewModel = serverSettingsViewModel;
            _outlookFolderViewModel  = new OutlookFolderViewModel(model, optionTasks, viewOptions);
            _timeRangeViewModel      = new TimeRangeViewModel(model, viewOptions);

            RegisterPropertyChangeHandler(model, nameof(model.MappingConfigurationModelOrNull), UpdateMappingConfigurationViewModel);

            RegisterPropertyChangePropagation(model, nameof(model.SelectedFolderOrNull), nameof(OutlookFolderType));
        }
    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;
    }
 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);
    }
 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);
    }