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 EasyProjectMultipleOptionsTemplateViewModel(
            IOptionsViewModelParent parent,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel prototypeModel,
            IViewOptions viewOptions)
        {
            _parent = parent;
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (prototypeModel == null)
            {
                throw new ArgumentNullException(nameof(prototypeModel));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _prototypeModel = prototypeModel;
            ViewOptions     = viewOptions;


            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _mergeResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                MergeResourcesAsync();
            });

            SelectFolderCommand = new DelegateCommand(_ => SelectFolder());

            _networkSettingsViewModel = new NetworkSettingsViewModel(_prototypeModel);
            Items = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _optionTasks             = optionTasks;

            var folder = _optionTasks.GetDefaultCalendarFolderOrNull();

            if (folder != null)
            {
                _selectedFolder    = folder;
                SelectedFolderName = folder.Name;
            }

            RegisterPropertyChangePropagation(_prototypeModel, nameof(_prototypeModel.Name), nameof(Name));
        }
예제 #3
0
 private void NetworkSettingsView_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
 {
     _viewModel = e.NewValue as NetworkSettingsViewModel;
     if (_viewModel != null)
     {
         // Password is just a OneWayBinding. Therefore just set the initial value
         _passwordBox.Password = SecureStringUtility.ToUnsecureString(_viewModel.ProxyPassword);
     }
 }
        public MultipleOptionsTemplateViewModel(
            IOptionsViewModelParent parent,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel prototypeModel,
            IViewOptions viewOptions)

        {
            _parent = parent;
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (prototypeModel == null)
            {
                throw new ArgumentNullException(nameof(prototypeModel));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            ViewOptions = viewOptions;

            _prototypeModel = prototypeModel;

            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                GetAccountSettings();
            });

            _networkSettingsViewModel = new NetworkSettingsViewModel(_prototypeModel);

            Items = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _optionTasks             = optionTasks;

            RegisterPropertyChangePropagation(_prototypeModel, nameof(_prototypeModel.Name), nameof(Name));
        }
        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 cardDavDataAccess = new CardDavDataAccess(url, webDavClient);

            var resources = await GetUserResources(calDavDataAccess, cardDavDataAccess, true);

            return(resources.ContainsResources ? resources : await GetUserResources(calDavDataAccess, cardDavDataAccess, false));
        }
 private IWebDavClient CreateWebDavClient(NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions)
 {
     return(SynchronizerFactory.CreateWebDavClient(
                UserName,
                Password,
                CalenderUrl,
                TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]),
                ServerAdapterType.WebDavHttpClientBased,
                networkSettings.CloseConnectionAfterEachRequest,
                networkSettings.PreemptiveAuthentication,
                networkSettings.ForceBasicAuthentication,
                networkSettings.CreateProxyOptions(),
                generalOptions.AcceptInvalidCharsInServerResponse));
 }
 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.AcceptInvalidCharsInServerResponse));
 }
예제 #8
0
 private IWebDavClient CreateWebDavClient(NetworkSettingsViewModel networkSettings, GeneralOptions generalOptions)
 {
     return(SynchronizerFactory.CreateWebDavClient(
                EmailAddress,
                SecureStringUtility.ToSecureString(string.Empty),
                CalenderUrl,
                TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]),
                ServerAdapterType.WebDavHttpClientBasedWithGoogleOAuth,
                networkSettings.CloseConnectionAfterEachRequest,
                networkSettings.PreemptiveAuthentication,
                networkSettings.ForceBasicAuthentication,
                networkSettings.CreateProxyOptions(),
                generalOptions.AcceptInvalidCharsInServerResponse));
 }
        public MultipleOptionsTemplateViewModel(
            NameSpace session,
            IOptionsViewModelParent parent,
            GeneralOptions generalOptions,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            ProfileType profileType)

        {
            _parent  = parent;
            _session = session;
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }

            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                GetAccountSettings();
            });

            _networkSettingsViewModel = new NetworkSettingsViewModel();

            SubOptions = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _profileType             = profileType;
            _generalOptions          = generalOptions;
        }
예제 #10
0
        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));
        }