public static async Task <Uri> AddResource(Uri davUri, IWebDavClient webDavClient, OlItemType selectedOutlookFolderType) { switch (selectedOutlookFolderType) { case OlItemType.olAppointmentItem: case OlItemType.olTaskItem: var calDavDataAccess = new CalDavDataAccess(davUri, webDavClient); using (var addResourceForm = new AddResourceForm(true)) { addResourceForm.Text = Strings.Get($"Add calendar resource on server"); if (addResourceForm.ShowDialog() == DialogResult.OK) { try { var newUri = await calDavDataAccess.AddResource(addResourceForm.ResourceName, addResourceForm.UseRandomUri); MessageBox.Show(Strings.Get($"Added calendar resource '{addResourceForm.ResourceName}' successfully!"), CreateDavResourceCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); if (!await new CalDavDataAccess(newUri, webDavClient).SetCalendarColorNoThrow(new ArgbColor(addResourceForm.CalendarColor.ToArgb()))) { MessageBox.Show(Strings.Get($"Can't set the calendar color!'"), CreateDavResourceCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newUri); } catch (Exception ex) { s_logger.Error($"Can't add calendar resource '{addResourceForm.ResourceName}'", ex); MessageBox.Show(Strings.Get($"Can't add calendar resource '{addResourceForm.ResourceName}'"), CreateDavResourceCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } break; case OlItemType.olContactItem: var cardDavDataAccess = new CardDavDataAccess(davUri, webDavClient, string.Empty, contentType => true); using (var addResourceForm = new AddResourceForm(false)) { addResourceForm.Text = Strings.Get($"Add addressbook resource on server"); if (addResourceForm.ShowDialog() == DialogResult.OK) { try { var newUri = await cardDavDataAccess.AddResource(addResourceForm.ResourceName, addResourceForm.UseRandomUri); MessageBox.Show(Strings.Get($"Added addressbook resource '{addResourceForm.ResourceName}' successfully!"), CreateDavResourceCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); return(newUri); } catch (Exception ex) { s_logger.Error($"Can't add addressbook resource '{addResourceForm.ResourceName}'", ex); MessageBox.Show(Strings.Get($"Can't add addressbook resource '{addResourceForm.ResourceName}'"), CreateDavResourceCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } break; } return(davUri); }
// Für tests // Todo,jac: Buildscirpt anpassen, dass im AssemblyInfo InternalsVisibleTo gesetzt wird. public WebDavService(IWebDavClient client, string localPath, string profileName) { this.WebDavClient = client; this.LocalPath = localPath; this.ProfileName = profileName; //client.DownloadComplete += new DownloadCompleteDel(client_DownloadComplete); }
public YaDiskVolumeDriver(string url, string username, string password, string root) { Root = root; Client = new WebDavClient(new WebDavClientParams { BaseAddress = new Uri(url), Credentials = new System.Net.NetworkCredential(username, password) }); Task.Run(() => Init()).GetAwaiter().GetResult(); }
protected WebDavDataAccess (Uri serverUrl, IWebDavClient webDavClient) { if (serverUrl == null) throw new ArgumentNullException ("serverUrl"); _serverUrl = serverUrl; _webDavClient = webDavClient; s_logger.DebugFormat ("Created with Url '{0}'", _serverUrl); }
protected WebDavDataAccess(Uri serverUrl, IWebDavClient webDavClient) { if (serverUrl == null) { throw new ArgumentNullException("serverUrl"); } _serverUrl = serverUrl; _webDavClient = webDavClient; s_logger.DebugFormat("Created with Url '{0}'", _serverUrl); }
async internal Task <String> Download(LinkDto linkDto, string destinationDir, IMainWindowModelAction action) { try { Action = action; using (Client = new WebDavClient(ConnectParams(linkDto))) { await DownloadFolder(linkDto.Path, destinationDir); } } catch (Exception ex) { return(ex.ToString()); } return(""); }
private void LoginButton_Clicked_1(object sender, EventArgs e) { var clientParams = new WebDavClientParams { BaseAddress = new Uri(setPars.webDavAdress), Credentials = new NetworkCredential(setPars.webLogin, setPars.webPass) }; _client = new WebDavClient(clientParams); documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); TryConnect(); }
public CardDavDataAccess(Uri serverUrl, IWebDavClient webDavClient, string writeContentType, Predicate <string> contentTypeReadPredicate) : base(serverUrl, webDavClient) { if (writeContentType == null) { throw new ArgumentNullException(nameof(writeContentType)); } if (contentTypeReadPredicate == null) { throw new ArgumentNullException(nameof(contentTypeReadPredicate)); } _contentTypeReadPredicate = contentTypeReadPredicate; _writeContentType = writeContentType; }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient); // Note: CalDav Calendars can contain Events and Todos. Therefore an calender resource is always a calendar and a task list. var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar | ResourceType.TaskList : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); return(new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None)); }
public static async Task<TestResult> TestConnection (Uri url, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess (url, webDavClient); var cardDavDataAccess = new CardDavDataAccess (url, webDavClient); var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); return new TestResult ( ressourceType, ressourceType.HasFlag (ResourceType.Calendar) ? await GetCalendarProperties (calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag (ResourceType.AddressBook) ? await GetAddressBookProperties (cardDavDataAccess) : AddressBookProperties.None); }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient, string.Empty, contentType => true); // Note: CalDav Calendars can contain Events and Todos. Therefore an calender resource is always a calendar and a task list. var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar | ResourceType.TaskList : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); return(new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None, await calDavDataAccess.GetPrivileges(), await calDavDataAccess.DoesSupportWebDavCollectionSync(), ressourceType.HasFlag(ResourceType.Calendar) ? await calDavDataAccess.GetCalendarOwnerPropertiesOrNull() : null)); }
public static async Task<TestResult> TestConnection (Uri url, IWebDavClient webDavClient, ResourceType supposedRessourceType) { var calDavDataAccess = new CalDavDataAccess (url, webDavClient); var cardDavDataAccess = new CardDavDataAccess (url, webDavClient); TestResult result; switch (supposedRessourceType) { case ResourceType.None: var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); result = new TestResult ( ressourceType, ressourceType.HasFlag (ResourceType.Calendar) ? await GetCalendarProperties (calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag (ResourceType.AddressBook) ? await GetAddressBookProperties (cardDavDataAccess) : AddressBookProperties.None); break; case ResourceType.Calendar: result = new TestResult ( supposedRessourceType, CalendarProperties.CalendarAccessSupported | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None), AddressBookProperties.None); break; case ResourceType.AddressBook: result = new TestResult ( supposedRessourceType, CalendarProperties.None, AddressBookProperties.AddressBookAccessSupported | (await cardDavDataAccess.IsWriteable() ? AddressBookProperties.IsWriteable : AddressBookProperties.None)); break; default: throw new ArgumentOutOfRangeException ("supposedRessourceType"); } return result; }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient, ResourceType supposedRessourceType) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient); TestResult result; switch (supposedRessourceType) { case ResourceType.None: var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); result = new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None); break; case ResourceType.Calendar: result = new TestResult( supposedRessourceType, CalendarProperties.CalendarAccessSupported | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None), AddressBookProperties.None); break; case ResourceType.AddressBook: result = new TestResult( supposedRessourceType, CalendarProperties.None, AddressBookProperties.AddressBookAccessSupported | (await cardDavDataAccess.IsWriteable() ? AddressBookProperties.IsWriteable : AddressBookProperties.None)); break; default: throw new ArgumentOutOfRangeException("supposedRessourceType"); } return(result); }
static async Task Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Needed arguments:\r\n1. Webdav base address\r\n2. User\r\n3. Password\r\n4. Localshare"); return; } var baseAddress = args[0].ToString(); var user = args[1].ToString(); var pass = args[2].ToString(); var localShare = args[3].ToString(); Console.WriteLine($"1. Webdav base address: {baseAddress}\r\n2. User: {user}\r\n3. Password: ****\r\n4. Localshare: {localShare}"); var clientParams = new WebDavClientParams { BaseAddress = new Uri(baseAddress), Credentials = new NetworkCredential(user, pass) }; _client = new WebDavClient(clientParams); var files = Directory.GetFiles(localShare, "*.*", SearchOption.AllDirectories); foreach (var file in files) { //var isUploaded = await CheckIfFileIsUploaded(baseAddress, file.Replace(localShare, string.Empty)); var size = new System.IO.FileInfo(file).Length; var isUploadedAndSameSize = await CheckIfFileIsUploadedAndSameSize(baseAddress, file.Replace(localShare, string.Empty), size); if (!isUploadedAndSameSize) { Console.WriteLine($"MISSING: {file}"); } else { Console.WriteLine($"OKAY: {file}"); } } }
public ContactSynchronizerComponents(Options options, OutlookContactRepository <ICardDavRepositoryLogger> atypeRepository, IEntityRepository <WebResourceName, string, vCard, ICardDavRepositoryLogger> btypeRepository, EntitySyncStateFactory <string, DateTime, IContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> syncStateFactory, EntityRelationDataAccess <string, DateTime, OutlookContactRelationData, WebResourceName, string> storageDataAccess, OutlookContactRelationDataFactory entityRelationDataFactory, IEqualityComparer <WebResourceName> btypeIdEqualityComparer, EqualityComparer <string> atypeIdEqulityComparer, IWebDavClient webDavClientOrNullIfFileAccess, LoggingCardDavRepositoryDecorator repository, ContactMappingConfiguration mappingParameters, string storageDataDirectory, Uri serverUrl, ICardDavDataAccess cardDavDataAccess, IStateAwareEntityRepository <WebResourceName, string, ICardDavRepositoryLogger, string> btypeStateAwareEntityRepository, IStateTokenDataAccess <int, string> stateTokenDataAccess, EqualityComparer <string> btypeVersionComparer) { Options = options; AtypeRepository = atypeRepository; BtypeRepository = btypeRepository; SyncStateFactory = syncStateFactory; StorageDataAccess = storageDataAccess; EntityRelationDataFactory = entityRelationDataFactory; BtypeIdEqualityComparer = btypeIdEqualityComparer; AtypeIdEqulityComparer = atypeIdEqulityComparer; WebDavClientOrNullIfFileAccess = webDavClientOrNullIfFileAccess; Repository = repository; MappingParameters = mappingParameters; StorageDataDirectory = storageDataDirectory; ServerUrl = serverUrl; CardDavDataAccess = cardDavDataAccess; BtypeStateAwareEntityRepository = btypeStateAwareEntityRepository; StateTokenDataAccess = stateTokenDataAccess; BtypeVersionComparer = btypeVersionComparer; }
public static async Task<TestResult> TestConnection (Uri url, IWebDavClient webDavClient, ResourceType autoRessourceType) { var calDavDataAccess = new CalDavDataAccess (url, webDavClient); var cardDavDataAccess = new CardDavDataAccess (url, webDavClient); TestResult result; if (autoRessourceType == ResourceType.None) { var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); result = new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None); } else if (autoRessourceType == ResourceType.Calendar) { result = new TestResult( autoRessourceType, CalendarProperties.CalendarAccessSupported | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None), AddressBookProperties.None); } else { result = new TestResult( autoRessourceType, CalendarProperties.None, AddressBookProperties.AddressBookAccessSupported | (await cardDavDataAccess.IsWriteable() ? AddressBookProperties.IsWriteable : AddressBookProperties.None)); } return result; }
public Player(IWebDavClient client) { _client = client; _resourceItemQueue = new FixedSizedQueue <ResourceItem>(3, (resourceItem, size) => { Log(string.Format("Disposing : '{0}'", resourceItem.DisplayName)); if (resourceItem.Stream != null) { resourceItem.Stream.Close(); resourceItem.Stream.Dispose(); resourceItem.Stream = null; } }); if (WasapiOut.IsSupportedOnCurrentPlatform) { _soundOut = new WasapiOut(); } else { _soundOut = new DirectSoundOut(); } }
public CardDavDataAccess (Uri serverUrl, IWebDavClient webDavClient) : base (serverUrl, webDavClient) { }
public CalDavDataAccess(Uri calendarUrl, IWebDavClient calDavWebClient) : base(calendarUrl, calDavWebClient) { }
private IOutlookSynchronizer CreateContactSynchronizer(Options options, GeneralOptions generalOptions, AvailableSynchronizerComponents componentsToFill) { var atypeRepository = new OutlookContactRepository <ICardDavRepositoryLogger> ( _outlookSession, options.OutlookFolderEntryId, options.OutlookFolderStoreId, _daslFilterProvider, _queryFolderStrategy); ICardDavDataAccess cardDavDataAccess; var serverUrl = new Uri(options.CalenderUrl); IWebDavClient webDavClientOrNullIfFileAccess = null; if (serverUrl.Scheme == Uri.UriSchemeFile) { cardDavDataAccess = new FileSystemDavDataAccess(serverUrl); } else { webDavClientOrNullIfFileAccess = CreateWebDavClient( options.UserName, options.GetEffectivePassword(_outlookAccountPasswordProvider), options.CalenderUrl, generalOptions.CalDavConnectTimeout, options.ServerAdapterType, options.CloseAfterEachRequest, options.PreemptiveAuthentication, options.ForceBasicAuthentication, options.ProxyOptions, generalOptions.EnableClientCertificate, generalOptions.AcceptInvalidCharsInServerResponse); cardDavDataAccess = new CardDavDataAccess( serverUrl, webDavClientOrNullIfFileAccess, contentType => contentType != "text/x-vlist"); } componentsToFill.CardDavDataAccess = cardDavDataAccess; var chunkedExecutor = options.IsChunkedSynchronizationEnabled ? new ChunkedExecutor(options.ChunkSize) : NullChunkedExecutor.Instance; var cardDavRepository = new CardDavRepository( cardDavDataAccess, chunkedExecutor); var btypeRepository = new LoggingCardDavRepositoryDecorator( cardDavRepository); componentsToFill.CardDavEntityRepository = cardDavRepository; var mappingParameters = GetMappingParameters <ContactMappingConfiguration> (options); var entityMapper = new ContactEntityMapper(mappingParameters); var entityRelationDataFactory = new OutlookContactRelationDataFactory(); var syncStateFactory = new EntitySyncStateFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> ( entityMapper, entityRelationDataFactory, ExceptionHandler.Instance); var btypeIdEqualityComparer = WebResourceName.Comparer; var atypeIdEqulityComparer = EqualityComparer <string> .Default; var storageDataDirectory = _profileDataDirectoryFactory(options.Id); var storageDataAccess = new EntityRelationDataAccess <string, DateTime, OutlookContactRelationData, WebResourceName, string> (storageDataDirectory); var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository); var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository); var synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> ( atypeRepository, btypeRepository, atypeWriteRepository, btypeWriteRepository, InitialSyncStateCreationStrategyFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> .Create( syncStateFactory, syncStateFactory.Environment, options.SynchronizationMode, options.ConflictResolution, e => new ContactConflictInitialSyncStateCreationStrategyAutomatic(e)), storageDataAccess, entityRelationDataFactory, new InitialContactEntityMatcher(btypeIdEqualityComparer), atypeIdEqulityComparer, btypeIdEqualityComparer, _totalProgressFactory, EqualityComparer <DateTime> .Default, EqualityComparer <string> .Default, syncStateFactory); if (mappingParameters.MapDistributionLists) { CardDavEntityRepository <DistributionList, int, DistributionListSychronizationContext> bDistListRepository; // TODO: muss auch für das file funktionieren ICardDavDataAccess distListDataAccess = new CardDavDataAccess( serverUrl, webDavClientOrNullIfFileAccess, contentType => contentType == "text/x-vlist"); componentsToFill.DistListDataAccess = distListDataAccess; switch (mappingParameters.DistributionListType) { case DistributionListType.Sogo: bDistListRepository = new SogoDistributionListRepository(distListDataAccess, chunkedExecutor); break; default: throw new NotImplementedException($"{nameof(DistributionListType)} '{mappingParameters.DistributionListType}' not implemented."); } var distributionListSynchronizer = CreateDistListSynchronizer(options, generalOptions, bDistListRepository); return(new OutlookSynchronizer <WebResourceName, string>( new ContactAndDistListSynchronizer( synchronizer, distributionListSynchronizer, new EmailAddressCacheDataAccess(Path.Combine(storageDataDirectory, "emailAddressCache.xml")), btypeRepository, storageDataAccess, atypeRepository, _outlookSession))); } else { return(new OutlookSynchronizer <WebResourceName, string>( new ContextCreatingSynchronizerDecorator <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger>( synchronizer, new SynchronizationContextFactory <ICardDavRepositoryLogger>(() => NullCardDavRepositoryLogger.Instance)))); } }
public CardDavDataAccess(Uri serverUrl, IWebDavClient webDavClient) : base(serverUrl, webDavClient) { }
public static async Task <AutoDiscoveryResult> DoAutoDiscovery(Uri autoDiscoveryUri, IWebDavClient webDavClient, bool useWellKnownCalDav, bool useWellKnownCardDav, OlItemType selectedOutlookFolderType) { switch (selectedOutlookFolderType) { case OlItemType.olAppointmentItem: var calDavDataAccess = new CalDavDataAccess(autoDiscoveryUri, webDavClient); var foundCalendars = (await calDavDataAccess.GetUserResourcesIncludingCalendarProxies(useWellKnownCalDav)).CalendarResources; if (foundCalendars.Count == 0) { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.NoResourcesFound)); } var selectedCalendar = SelectCalendar(foundCalendars); if (selectedCalendar != null) { return(new AutoDiscoveryResult(selectedCalendar.Uri, AutoDiscoverResultStatus.ResourceSelected)); } else { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.UserCancelled)); } case OlItemType.olTaskItem: var calDavDataAccessTasks = new CalDavDataAccess(autoDiscoveryUri, webDavClient); var foundTasks = (await calDavDataAccessTasks.GetUserResourcesIncludingCalendarProxies(useWellKnownCalDav)).TaskListResources; if (foundTasks.Count == 0) { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.NoResourcesFound)); } var selectedTask = SelectTaskList(foundTasks); if (selectedTask != null) { return(new AutoDiscoveryResult(new Uri(selectedTask.Id), AutoDiscoverResultStatus.ResourceSelected)); } else { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.UserCancelled)); } case OlItemType.olContactItem: var cardDavDataAccess = new CardDavDataAccess(autoDiscoveryUri, webDavClient, string.Empty, contentType => true); var foundAddressBooks = await cardDavDataAccess.GetUserAddressBooksNoThrow(useWellKnownCardDav); if (foundAddressBooks.Count == 0) { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.NoResourcesFound)); } var selectedAddressBook = SelectAddressBook(foundAddressBooks); if (selectedAddressBook != null) { return(new AutoDiscoveryResult(selectedAddressBook.Uri, AutoDiscoverResultStatus.ResourceSelected)); } else { return(new AutoDiscoveryResult(null, AutoDiscoverResultStatus.UserCancelled)); } default: throw new NotImplementedException($"'{selectedOutlookFolderType}' not implemented."); } }
private async Task<AutoDiscoveryResult> DoAutoDiscovery (Uri autoDiscoveryUri, IWebDavClient webDavClient, bool useWellKnownUrl) { IReadOnlyList<Tuple<Uri, string>> foundResources; var calDavDataAccess = new CalDavDataAccess (autoDiscoveryUri, webDavClient); foundResources = await calDavDataAccess.GetUserCalendars (useWellKnownUrl); if (foundResources.Count > 0) { using (ListCalendarsForm listCalendarsForm = new ListCalendarsForm (foundResources)) { if (listCalendarsForm.ShowDialog() == DialogResult.OK) return new AutoDiscoveryResult (new Uri (autoDiscoveryUri.GetLeftPart (UriPartial.Authority) + listCalendarsForm.getCalendarUri()), false); else return new AutoDiscoveryResult (null, true); } } else { MessageBox.Show ("No resources were found via autodiscovery!", c_connectionTestCaption); } return new AutoDiscoveryResult (null, false); }
private async Task<Uri> DoAutoDiscovery (Uri autoDiscoveryUri, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess (autoDiscoveryUri, webDavClient); var foundCalendars = await calDavDataAccess.GetUserCalendars(); if (foundCalendars.Count > 0) { using (ListCalendarsForm listCalendarsForm = new ListCalendarsForm (foundCalendars)) { if (listCalendarsForm.ShowDialog() == DialogResult.OK) { return new Uri (autoDiscoveryUri.GetLeftPart (UriPartial.Authority) + listCalendarsForm.getCalendarUri()); } } } else { MessageBox.Show ("No calendars were found via autodiscovery!", c_connectionTestCaption); } return null; }
public CardDavDataAccess(Uri serverUrl, IWebDavClient webDavClient, Predicate <string> contentTypePredicate) : base(serverUrl, webDavClient) { _contentTypePredicate = contentTypePredicate; }
protected override async Task OnInitializedAsync() { base.OnInitialized(); _client = Factory.GetClient(); _player = new Player(_client) { Log = Log, PlayStarted = (selectedIndex, resourceItem) => { Log($"PlayStarted - {resourceItem.DisplayName}"); SelectedPlayListItem = PlayListItems[selectedIndex]; CurrentTime = TIME_ZERO; TotalTime = $@"{_player.TotalTime:hh\:mm\:ss}"; SliderMax = (int)_player.TotalTime.TotalSeconds; SliderEnabled = _player.CanSeek; PlayListItems[selectedIndex].Bitrate = $"{resourceItem.MediaDetails.BitrateKbps}"; PlayListItems[selectedIndex].Length = $@"{_player.TotalTime:hh\:mm\:ss}"; }, PlayContinue = resourceItem => { Log($"PlayContinue - {resourceItem.DisplayName}"); }, PlayPaused = resourceItem => { Log($"PlayPaused - {resourceItem.DisplayName}"); }, PlayStopped = () => { // Log($"PlayStopped"); SliderMax = 1; SliderValue = 0; SliderEnabled = false; CurrentTime = TIME_ZERO; }, //DoubleClickFolderAndPlayFirstSong = async resourceItem => //{ // Log($"DoubleClickFolderAndPlayFirstSong - {resourceItem.DisplayName}"); // //var nodeToDoubleClick = treeView.Nodes.Find(resourceItem.DisplayName, true).FirstOrDefault(); // //if (nodeToDoubleClick != null) // //{ // // await FetchChildResourcesAsync(nodeToDoubleClick, resourceItem); // //} //} }; Log($"Using : '{_player.SoundOut}-SoundOut'"); _timer = new Timer(async state => { await InvokeAsync(OnTimerCallback); }, null, 0, 249); Root = new TreeNode <ResourceItem> { Item = new ResourceItem { DisplayName = Options.Value.RootFolder, FullPath = OnlinePathBuilder.Combine(Options.Value.StorageUri, Options.Value.RootFolder) } }; await RefreshTreeAsync(); }
public MainForm(AssemblyConfig config) { _config = config; InitializeComponent(); Icon = Resources.icon; InitCancellationTokenSource(); _client = new MyWebDavClient(config); Func <ResourceItem, string, string> updateTitle = (resourceItem, action) => { string text = $"{action} : '{resourceItem.Parent.DisplayName}\\{resourceItem.DisplayName}' ({resourceItem.MediaDetails.Mode} {resourceItem.MediaDetails.BitrateKbps} kbps)"; Text = @"WebDAV-AudioPlayer " + text; return(text); }; _player = new Player(_client) { Log = Log, PlayStarted = (selectedIndex, resourceItem) => { string bitrate = $"{resourceItem.MediaDetails.BitrateKbps}"; string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; labelTotalTime.Text = $@"{_player.TotalTime:hh\:mm\:ss}"; trackBarSong.Maximum = (int)_player.TotalTime.TotalSeconds; trackBarSong.Enabled = _player.CanSeek; listView.SetCells(selectedIndex, $@"{_player.TotalTime:h\:mm\:ss}", bitrate); listView.SetSelectedIndex(selectedIndex); }, PlayContinue = resourceItem => { string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; }, PlayPaused = resourceItem => { string text = updateTitle(resourceItem, "Pausing"); textBoxSong.Text = text; }, PlayStopped = () => { trackBarSong.Value = 0; trackBarSong.Maximum = 1; labelCurrentTime.Text = labelTotalTime.Text = @"00:00:00"; Text = @"WebDAV-AudioPlayer"; }, DoubleClickFolderAndPlayFirstSong = async resourceItem => { var nodeToDoubleClick = treeView.Nodes.Find(resourceItem.DisplayName, true).FirstOrDefault(); if (nodeToDoubleClick != null) { await FetchChildResourcesAsync(nodeToDoubleClick, resourceItem); } } }; Log($"Using : '{_player.SoundOut}-SoundOut'"); }
public MainForm(AssemblyConfig config) { _config = config; InitializeComponent(); Icon = Resources.icon; InitCancellationTokenSource(); //_client = new DecaTecWebDavClient(config); _client = new MyWebDavClient(config); Func <ResourceItem, string, string> updateTitle = (resourceItem, action) => { string bitrate = resourceItem.MediaDetails.Bitrate != null ? $"{resourceItem.MediaDetails.Bitrate / 1000}" : "?"; string text = $"{action} : '{resourceItem.Parent.DisplayName}\\{resourceItem.DisplayName}' ({resourceItem.MediaDetails.Mode} {bitrate} kbps)"; Text = @"WebDAV-AudioPlayer " + text; return(text); }; _player = new Player(_client) { Log = Log, PlayStarted = (selectedIndex, resourceItem) => { string bitrate = resourceItem.MediaDetails.Bitrate != null ? $"{resourceItem.MediaDetails.Bitrate / 1000}" : "?"; string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; labelTotalTime.Text = $@"{_player.TotalTime:hh\:mm\:ss}"; trackBarSong.Maximum = (int)_player.TotalTime.TotalSeconds; listView.SetSelectedIndex(selectedIndex); listView.SetCells(selectedIndex, $@"{_player.TotalTime:h\:mm\:ss}", bitrate); }, PlayContinue = resourceItem => { string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; }, PlayPaused = resourceItem => { string text = updateTitle(resourceItem, "Pausing"); textBoxSong.Text = text; }, PlayStopped = () => { trackBarSong.Value = 0; trackBarSong.Maximum = 1; labelCurrentTime.Text = labelTotalTime.Text = @"00:00:00"; Text = @"WebDAV-AudioPlayer"; } }; Log($"Using : '{_player.SoundOut}-SoundOut'"); }
public CalDavDataAccess (Uri calendarUrl, IWebDavClient calDavWebClient) : base (calendarUrl, calDavWebClient) { }
private async Task<AutoDiscoveryResult> DoAutoDiscovery (Uri autoDiscoveryUri, IWebDavClient webDavClient, bool useWellKnownUrl) { var calDavDataAccess = new CalDavDataAccess (autoDiscoveryUri, webDavClient); IReadOnlyList<Tuple<Uri, string>> foundCaldendars = await calDavDataAccess.GetUserCalendarsNoThrow (useWellKnownUrl); var cardDavDataAccess = new CardDavDataAccess (autoDiscoveryUri, webDavClient); IReadOnlyList<Tuple<Uri, string>> foundAddressBooks = await cardDavDataAccess.GetUserAddressBooksNoThrow (useWellKnownUrl); if (foundCaldendars.Count > 0 || foundAddressBooks.Count > 0) { using (SelectResourceForm listCalendarsForm = new SelectResourceForm (foundCaldendars, foundAddressBooks, _folderType == OlItemType.olContactItem)) { if (listCalendarsForm.ShowDialog() == DialogResult.OK) return new AutoDiscoveryResult (new Uri (autoDiscoveryUri.GetLeftPart (UriPartial.Authority) + listCalendarsForm.SelectedUrl), false, listCalendarsForm.ResourceType); else return new AutoDiscoveryResult (null, true, ResourceType.None); } } else { MessageBox.Show ("No resources were found via autodiscovery!", c_connectionTestCaption); return new AutoDiscoveryResult (null, false, ResourceType.None); } }
public static async Task <AutoDiscoveryResult> DoAutoDiscovery(Uri autoDiscoveryUri, IWebDavClient webDavClient, bool useWellKnownCalDav, bool useWellKnownCardDav, OlItemType?selectedOutlookFolderType) { var calDavDataAccess = new CalDavDataAccess(autoDiscoveryUri, webDavClient); IReadOnlyList <Tuple <Uri, string, string> > foundCaldendars = await calDavDataAccess.GetUserCalendarsNoThrow(useWellKnownCalDav); var cardDavDataAccess = new CardDavDataAccess(autoDiscoveryUri, webDavClient); IReadOnlyList <Tuple <Uri, string> > foundAddressBooks = await cardDavDataAccess.GetUserAddressBooksNoThrow(useWellKnownCardDav); if (foundCaldendars.Count > 0 || foundAddressBooks.Count > 0) { using (SelectResourceForm listCalendarsForm = new SelectResourceForm(foundCaldendars, foundAddressBooks, selectedOutlookFolderType == OlItemType.olContactItem)) { if (listCalendarsForm.ShowDialog() == DialogResult.OK) { return(new AutoDiscoveryResult(new Uri(autoDiscoveryUri.GetLeftPart(UriPartial.Authority) + listCalendarsForm.SelectedUrl), false, listCalendarsForm.ResourceType)); } else { return(new AutoDiscoveryResult(null, true, ResourceType.None)); } } } else { MessageBox.Show(useWellKnownCalDav ? "No resources were found via well-known URLs!" : "No resources were found via autodiscovery!", OptionTasks.ConnectionTestCaption); return(new AutoDiscoveryResult(null, false, ResourceType.None)); } }