Exemplo n.º 1
0
 public MediaSyncManagerImpl(IMediaGalleryScanner scanner,
                             INotificationManager notificationManager,
                             IHttpTransferManager transferManager,
                             IRepository repository)
 {
     this.scanner             = scanner;
     this.transferManager     = transferManager;
     this.notificationManager = notificationManager;
     this.repository          = repository;
 }
Exemplo n.º 2
0
 public SyncJob(IMediaSyncManager syncManager,
                IMediaGalleryScanner scanner,
                IHttpTransferManager transfers,
                INotificationManager notifications,
                IMediaSyncDelegate syncDelegate,
                IRepository repository)
 {
     this.syncManager   = syncManager;
     this.scanner       = scanner;
     this.transfers     = transfers;
     this.notifications = notifications;
     this.syncDelegate  = syncDelegate;
     this.repository    = repository;
 }
Exemplo n.º 3
0
        public PendingViewModel(INavigationService navigation,
                                IHttpTransferManager httpTransfers,
                                IUserDialogs dialogs)
        {
            this.httpTransfers = httpTransfers;
            this.dialogs       = dialogs;

            this.Create = navigation.NavigateCommand("CreateTransfer");

            this.Load = ReactiveCommand.CreateFromTask(async() =>
            {
                var transfers  = await httpTransfers.GetTransfers();
                this.Transfers = transfers
                                 .Select(transfer =>
                {
                    var vm = new HttpTransferViewModel
                    {
                        Identifier = transfer.Identifier,
                        Uri        = transfer.Uri,
                        IsUpload   = transfer.IsUpload,

                        Cancel = ReactiveCommand.CreateFromTask(async() =>
                        {
                            var confirm = await dialogs.Confirm("Are you sure you want to cancel all transfers?", "Confirm", "Yes", "No");
                            if (confirm)
                            {
                                await this.httpTransfers.Cancel(transfer.Identifier);
                                await this.Load.Execute();
                            }
                        })
                    };

                    ToViewModel(vm, transfer);
                    return(vm);
                })
                                 .ToList();
            });
            this.CancelAll = ReactiveCommand.CreateFromTask(async() =>
            {
                await httpTransfers.Cancel();
                await this.Load.Execute().ToTask();
            });
            this.BindBusyCommand(this.Load);
        }
Exemplo n.º 4
0
        public CreateViewModel(INavigationService navigationService,
                               IHttpTransferManager httpTransfers,
                               IDialogs dialogs,
                               IPlatform platform,
                               AppSettings appSettings)
        {
            this.platform = platform;
            this.Url      = appSettings.LastTransferUrl;

            this.WhenAnyValue(x => x.IsUpload)
            .Subscribe(upload =>
            {
                if (!upload && this.FileName.IsEmpty())
                {
                    this.FileName = Guid.NewGuid().ToString();
                }

                this.Title = upload ? "New Upload" : "New Download";
            });

            this.ManageUploads = navigationService.NavigateCommand("ManageUploads");

            this.ResetUrl = ReactiveCommand.Create(() =>
            {
                appSettings.LastTransferUrl = null;
                this.Url = appSettings.LastTransferUrl;
            });

            this.SelectUpload = ReactiveCommand.CreateFromTask(async() =>
            {
                var files = platform.AppData.GetFiles("upload.*", SearchOption.TopDirectoryOnly);
                if (!files.Any())
                {
                    await dialogs.Alert("There are not files to upload.  Use 'Manage Uploads' below to create them");
                }
                else
                {
                    var cfg = new Dictionary <string, Action>();
                    foreach (var file in files)
                    {
                        cfg.Add(file.Name, () => this.FileName = file.Name);
                    }

                    await dialogs.ActionSheet("Actions", cfg);
                }
            });
            this.Save = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var path    = Path.Combine(this.platform.AppData.FullName, this.FileName);
                var request = new HttpTransferRequest(this.Url, path, this.IsUpload)
                {
                    UseMeteredConnection = this.UseMeteredConnection
                };
                await httpTransfers.Enqueue(request);
                appSettings.LastTransferUrl = this.Url;
                await navigationService.GoBackAsync();
            },
                this.WhenAny
                (
                    x => x.IsUpload,
                    x => x.Url,
                    x => x.FileName,
                    (up, url, fn) =>
            {
                this.ErrorMessage = String.Empty;
                if (!Uri.TryCreate(url.GetValue(), UriKind.Absolute, out _))
                {
                    this.ErrorMessage = "Invalid URL";
                }

                else if (up.GetValue() && fn.GetValue().IsEmpty())
                {
                    this.ErrorMessage = "You must select or enter a filename";
                }

                return(this.ErrorMessage.IsEmpty());
            }
                )
                );
        }
Exemplo n.º 5
0
 public HttpTransferViewModel(IHttpTransferManager transfers)
 {
 }