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));
        }
Exemple #2
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));
        }
Exemple #3
0
        public async Task <ServerResources> GetServerResources()
        {
            var trimmedUrl = CalenderUrl.Trim();
            var url        = new Uri(trimmedUrl.EndsWith("/") ? trimmedUrl : trimmedUrl + "/");

            var webDavClient     = _prototypeModel.CreateWebDavClient();
            var calDavDataAccess = new CalDavDataAccess(url, webDavClient);
            var foundResources   = await calDavDataAccess.GetUserResourcesIncludingCalendarProxies(false);

            var foundAddressBooks = new[] { new AddressBookData(new Uri("googleApi://defaultAddressBook"), "Default AddressBook", AccessPrivileges.All) };

            var service = await GoogleHttpClientFactory.LoginToGoogleTasksService(EmailAddress, SynchronizerFactory.CreateProxy(_prototypeModel.CreateProxyOptions()));

            var taskLists = await service.Tasklists.List().ExecuteAsync();

            var taskListsData = taskLists?.Items.Select(i => new TaskListData(i.Id, i.Title, AccessPrivileges.All)).ToArray() ?? new TaskListData[] { };

            return(new ServerResources(foundResources.CalendarResources, foundAddressBooks, taskListsData));
        }