Пример #1
0
        public virtual void BrowseToHome()
        {
            if (this.FolderRootNode == null)
            {
                return;
            }

            MNode homeNode = null;

            switch (Type)
            {
            case ContainerType.CloudDrive:
                homeNode = this.MegaSdk.getRootNode();
                break;

            case ContainerType.RubbishBin:
                homeNode = this.MegaSdk.getRubbishNode();
                break;
            }

            if (homeNode == null)
            {
                return;
            }

            this.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, homeNode, this.Type, ChildNodes);

            LoadChildNodes();
        }
Пример #2
0
        public void DownloadLink(MNode publicNode)
        {
            var downloadNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, publicNode, ContainerType.PublicLink);

            if (downloadNode != null)
            {
                downloadNode.Download(TransfersService.MegaTransfers);
            }
        }
        public void GetContactSharedFolders()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            // First cancel any other loading task that is busy
            CancelLoad();

            // Create the option to cancel
            CreateLoadCancelOption();

            OnUiThread(() => InShares.ChildNodes.Clear());
            MNodeList inSharesList = MegaSdk.getInShares(MegaSdk.getContact(_selectedContact.Email));

            Task.Factory.StartNew(() =>
            {
                try
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        for (int i = 0; i < inSharesList.size(); i++)
                        {
                            // If the task has been cancelled, stop processing
                            if (LoadingCancelToken.IsCancellationRequested)
                            {
                                LoadingCancelToken.ThrowIfCancellationRequested();
                            }

                            // To avoid null values
                            if (inSharesList.get(i) == null)
                            {
                                continue;
                            }

                            var _inSharedFolder = NodeService.CreateNew(this.MegaSdk, this.AppInformation, inSharesList.get(i), ContainerType.InShares, InShares.ChildNodes);
                            _inSharedFolder.DefaultImagePathData = VisualResources.FolderTypePath_shared;
                            InShares.ChildNodes.Add(_inSharedFolder);
                        }

                        OnPropertyChanged("NumberOfInSharedFolders");
                        OnPropertyChanged("NumberOfInSharedFoldersText");
                    });
                }
                catch (OperationCanceledException)
                {
                    // Do nothing. Just exit this background process because a cancellation exception has been thrown
                }
            }, LoadingCancelToken, TaskCreationOptions.PreferFairness, TaskScheduler.Current);
        }
Пример #4
0
        private async Task RecursiveSaveForOffline(String sfoPath, NodeViewModel node)
        {
            if (!FolderService.FolderExists(sfoPath))
            {
                FolderService.CreateFolder(sfoPath);
            }

            String newSfoPath = Path.Combine(sfoPath, node.Name);

            if (!FolderService.FolderExists(newSfoPath))
            {
                FolderService.CreateFolder(newSfoPath);
            }

            if (!SavedForOffline.ExistsNodeByLocalPath(newSfoPath))
            {
                SavedForOffline.Insert(node.OriginalMNode, true);
            }
            else
            {
                SavedForOffline.UpdateNode(node.OriginalMNode, true);
            }

            MNodeList childList = MegaSdk.getChildren(node.OriginalMNode);

            for (int i = 0; i < childList.size(); i++)
            {
                // To avoid pass null values to CreateNew
                if (childList.get(i) == null)
                {
                    continue;
                }

                var childNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, childList.get(i), this.ParentContainerType);

                // If node creation failed for some reason, continue with the rest and leave this one
                if (childNode == null)
                {
                    continue;
                }

                if (childNode.IsFolder)
                {
                    await RecursiveSaveForOffline(newSfoPath, childNode);
                }
                else
                {
                    await SaveFileForOffline(newSfoPath, childNode);
                }
            }
        }
Пример #5
0
        public void LoadFolders()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (this.CameraUploads.FolderRootNode == null)
                {
                    this.CameraUploads.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation,
                                                                              NodeService.FindCameraUploadNode(this.MegaSdk, this.MegaSdk.getRootNode()),
                                                                              ContainerType.CloudDrive);
                }

                this.CameraUploads.LoadChildNodes();
            });
        }
Пример #6
0
        public void onTransferStart(MegaSDK api, MTransfer transfer)
        {
            TransferObjectModel megaTransfer = null;

            if (transfer.getType() == MTransferType.TYPE_DOWNLOAD)
            {
                // If is a public node
                MNode node = transfer.getPublicMegaNode();
                if (node == null) // If not
                {
                    node = api.getNodeByHandle(transfer.getNodeHandle());
                }

                if (node != null)
                {
                    megaTransfer = new TransferObjectModel(api,
                                                           NodeService.CreateNew(api, App.AppInformation, node, ContainerType.CloudDrive),
                                                           TransferType.Download, transfer.getPath());
                }
            }
            else
            {
                megaTransfer = new TransferObjectModel(api, App.MainPageViewModel.CloudDrive.FolderRootNode,
                                                       TransferType.Upload, transfer.getPath());
            }

            if (megaTransfer != null)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    TransfersService.GetTransferAppData(transfer, megaTransfer);

                    megaTransfer.Transfer                      = transfer;
                    megaTransfer.Status                        = TransferStatus.Queued;
                    megaTransfer.CancelButtonState             = true;
                    megaTransfer.TransferButtonIcon            = new Uri("/Assets/Images/cancel transfers.Screen-WXGA.png", UriKind.Relative);
                    megaTransfer.TransferButtonForegroundColor = new SolidColorBrush(Colors.White);
                    megaTransfer.IsBusy                        = true;
                    megaTransfer.TotalBytes                    = transfer.getTotalBytes();
                    megaTransfer.TransferedBytes               = transfer.getTransferredBytes();
                    megaTransfer.TransferSpeed                 = transfer.getSpeed().ToStringAndSuffixPerSecond();

                    App.MegaTransfers.Add(megaTransfer);
                    Transfers.Add(megaTransfer);
                });
            }
        }
Пример #7
0
        private void LoadFolder()
        {
            if (this.FolderLink.FolderRootNode == null)
            {
                this.FolderLink.FolderRootNode = NodeService.CreateNew(
                    this.MegaSdk, App.AppInformation,
                    this.MegaSdk.getRootNode(), this.FolderLink);
            }

            // Store the absolute root node of the folder link
            if (this.FolderLinkRootNode == null)
            {
                this.FolderLinkRootNode = this.FolderLink.FolderRootNode as FolderNodeViewModel;
            }

            this.FolderLink.LoadChildNodes();
        }
Пример #8
0
        /// <summary>
        /// Load folders of the view model
        /// </summary>
        public async void LoadFolders()
        {
            if (this.CloudDrive?.FolderRootNode == null)
            {
                this.CloudDrive.FolderRootNode =
                    NodeService.CreateNew(this.MegaSdk, App.AppInformation,
                                          this.MegaSdk.getRootNode(), this.CloudDrive);
            }

            if (this.ActiveFolderView.Equals(this.CloudDrive))
            {
                this.CloudDrive.LoadChildNodes();
            }

            if (this.RubbishBin?.FolderRootNode == null)
            {
                this.RubbishBin.FolderRootNode =
                    NodeService.CreateNew(this.MegaSdk, App.AppInformation,
                                          this.MegaSdk.getRubbishNode(), this.RubbishBin);
            }

            if (this.ActiveFolderView.Equals(this.RubbishBin))
            {
                this.RubbishBin.LoadChildNodes();
            }

            if (this.CameraUploads?.FolderRootNode == null)
            {
                var cameraUploadsNode = await SdkService.GetCameraUploadRootNodeAsync();

                this.CameraUploads.FolderRootNode =
                    NodeService.CreateNew(this.MegaSdk, App.AppInformation,
                                          cameraUploadsNode, this.CameraUploads);
            }

            if (this.ActiveFolderView.Equals(this.CameraUploads))
            {
                if (!TaskService.IsBackGroundTaskActive(CameraUploadService.TaskEntryPoint, CameraUploadService.TaskName) &&
                    this.CameraUploads?.FolderRootNode == null)
                {
                    return;
                }

                this.CameraUploads.LoadChildNodes();
            }
        }
        public override void BrowseToHome()
        {
            if (this.FolderRootNode == null)
            {
                return;
            }

            MNode homeNode = NodeService.FindCameraUploadNode(this.MegaSdk, this.MegaSdk.getRootNode());

            if (homeNode == null)
            {
                return;
            }

            this.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, homeNode, _containerType, ChildNodes);

            LoadChildNodes();
        }
Пример #10
0
        private void FetchNodesFolderLink(MegaSDK api, MRequest request)
        {
            App.LinkInformation.HasFetchedNodesFolderLink = true;

            var folderLinkRootNode = _folderLinkViewModel.FolderLink.FolderRootNode ??
                                     NodeService.CreateNew(api, App.AppInformation, api.getRootNode(), ContainerType.FolderLink);

            var autoResetEvent = new AutoResetEvent(false);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _folderLinkViewModel.FolderLink.FolderRootNode = folderLinkRootNode;
                autoResetEvent.Set();
            });
            autoResetEvent.WaitOne();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                      _folderLinkViewModel.LoadFolders());
        }
Пример #11
0
        public void LoadFolders()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (this.FolderLink.FolderRootNode == null)
                {
                    this.FolderLink.FolderRootNode = NodeService.CreateNew(this.MegaSdk,
                                                                           App.AppInformation, this.MegaSdk.getRootNode(), ContainerType.FolderLink);
                }

                // Store the absolute root node of the folder link
                if (this.FolderLinkRootNode == null)
                {
                    this.FolderLinkRootNode = this.FolderLink.FolderRootNode;
                }

                this.FolderLink.LoadChildNodes();
            });
        }
Пример #12
0
        public void LoadFolders()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (this.CloudDrive.FolderRootNode == null)
                {
                    this.CloudDrive.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, this.MegaSdk.getRootNode(), ContainerType.CloudDrive);
                }

                this.CloudDrive.LoadChildNodes();

                if (this.RubbishBin.FolderRootNode == null)
                {
                    this.RubbishBin.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, this.MegaSdk.getRubbishNode(), ContainerType.RubbishBin);
                }

                this.RubbishBin.LoadChildNodes();
            });
        }
        public override bool GoFolderUp()
        {
            if (this.FolderRootNode == null)
            {
                return(false);
            }

            MNode parentNode = this.MegaSdk.getParentNode(this.FolderRootNode.OriginalMNode);

            if (parentNode == null || parentNode.getType() == MNodeType.TYPE_UNKNOWN || parentNode.getType() == MNodeType.TYPE_ROOT)
            {
                return(false);
            }

            this.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, parentNode, _containerType, ChildNodes);

            LoadChildNodes();

            return(true);
        }
Пример #14
0
        private void FetchNodesCameraUploadsPage(MegaSDK api, MRequest request)
        {
            App.AppInformation.HasFetchedNodes = true;

            var cameraUploadsRootNode = _cameraUploadsPageViewModel.CameraUploads.FolderRootNode ??
                                        NodeService.CreateNew(api, _cameraUploadsPageViewModel.AppInformation,
                                                              NodeService.FindCameraUploadNode(api, api.getRootNode()), ContainerType.CloudDrive);

            var autoResetEvent = new AutoResetEvent(false);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _cameraUploadsPageViewModel.CameraUploads.FolderRootNode = cameraUploadsRootNode;
                autoResetEvent.Set();
            });
            autoResetEvent.WaitOne();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                      _cameraUploadsPageViewModel.LoadFolders());
        }
Пример #15
0
        private void ViewDetails(object obj)
        {
            NodeViewModel node = NodeService.CreateNew(this.MegaSdk, App.AppInformation,
                                                       this.MegaSdk.getNodeByBase64Handle(FocusedNode.Base64Handle), this.Type);

            OnUiThread(() =>
            {
                if (node != null)
                {
                    NavigateService.NavigateTo(typeof(NodeDetailsPage), NavigationParameter.Normal, node);
                }
                else
                {
                    new CustomMessageDialog(
                        AppMessages.AM_GetNodeDetailsFailed_Title,
                        AppMessages.AM_GetNodeDetailsFailed,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                }
            });
        }
Пример #16
0
        private void FetchNodesFolderLink(MegaSDK api, MRequest request)
        {
            App.LinkInformation.HasFetchedNodesFolderLink = true;

            var folderLinkRootNode = _folderLinkViewModel.FolderLink.FolderRootNode ??
                                     NodeService.CreateNew(api, App.AppInformation, api.getRootNode(), ContainerType.FolderLink);

            // Save the handle of the last public node accessed (Task #10800)
            SettingsService.SaveLastPublicNodeHandle(folderLinkRootNode.Handle);

            var autoResetEvent = new AutoResetEvent(false);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _folderLinkViewModel.FolderLink.FolderRootNode = folderLinkRootNode;
                autoResetEvent.Set();
            });
            autoResetEvent.WaitOne();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                      _folderLinkViewModel.LoadFolders());
        }
Пример #17
0
        public void BuildBreadCrumbs()
        {
            this.BreadCrumbs.Clear();

            // Top root nodes have no breadcrumbs
            if (this.FolderRootNode == null ||
                this.FolderRootNode.Type == MNodeType.TYPE_ROOT ||
                FolderRootNode.Type == MNodeType.TYPE_RUBBISH)
            {
                return;
            }

            this.BreadCrumbs.Add((IBaseNode)this.FolderRootNode);

            MNode parentNode = FolderRootNode.OriginalMNode;

            parentNode = this.MegaSdk.getParentNode(parentNode);
            while ((parentNode != null) && (parentNode.getType() != MNodeType.TYPE_ROOT) &&
                   (parentNode.getType() != MNodeType.TYPE_RUBBISH))
            {
                this.BreadCrumbs.Insert(0, (IBaseNode)NodeService.CreateNew(this.MegaSdk, this.AppInformation, parentNode, this.Type));
                parentNode = this.MegaSdk.getParentNode(parentNode);
            }
        }
Пример #18
0
        /// <summary>
        /// Refresh the current folder. Delete cached thumbnails and reload the nodes
        /// </summary>
        public void Refresh()
        {
            FileService.ClearFiles(
                NodeService.GetFiles(this.ChildNodes,
                                     Path.Combine(ApplicationData.Current.LocalFolder.Path,
                                                  AppResources.ThumbnailsDirectory)));

            if (this.FolderRootNode == null)
            {
                switch (this.Type)
                {
                case ContainerType.RubbishBin:
                    this.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, this.MegaSdk.getRubbishNode(), this.Type);
                    break;

                case ContainerType.CloudDrive:
                case ContainerType.FolderLink:
                    this.FolderRootNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, this.MegaSdk.getRootNode(), this.Type);
                    break;
                }
            }

            this.LoadChildNodes();
        }
Пример #19
0
        public void Create(FolderViewModel folder)
        {
            this.Items.Clear();

            // Top root nodes have no breadcrumbs
            if (folder.FolderRootNode == null ||
                folder.FolderRootNode.Type == MNodeType.TYPE_ROOT ||
                folder.FolderRootNode.Type == MNodeType.TYPE_RUBBISH)
            {
                return;
            }

            this.Items.Add(folder.FolderRootNode);

            MNode parentNode = this.MegaSdk.getParentNode(folder.FolderRootNode.OriginalMNode);

            while (parentNode != null &&
                   parentNode.getType() != MNodeType.TYPE_ROOT &&
                   parentNode.getType() != MNodeType.TYPE_RUBBISH)
            {
                this.Items.Insert(0, NodeService.CreateNew(this.MegaSdk, App.AppInformation, parentNode, folder));
                parentNode = this.MegaSdk.getParentNode(parentNode);
            }
        }
Пример #20
0
        public async void GetPublicNode(string link)
        {
            if (string.IsNullOrWhiteSpace(link))
            {
                return;
            }

            PublicLinkService.Link = link;

            if (_getPublicNode == null)
            {
                _getPublicNode = new GetPublicNodeRequestListenerAsync();
            }

            this.ControlState = false;
            this.IsBusy       = true;

            var result = await _getPublicNode.ExecuteAsync(() =>
                                                           this.MegaSdk.getPublicNode(PublicLinkService.Link, _getPublicNode));

            bool navigateBack = true;

            switch (result)
            {
            case GetPublicNodeResult.Success:
                LinkInformationService.PublicNode = _getPublicNode.PublicNode;

                // Save the handle of the last public node accessed (Task #10801)
                SettingsService.SaveLastPublicNodeHandle(_getPublicNode.PublicNode.getHandle());

                this.Node = NodeService.CreateNew(this.MegaSdk, App.AppInformation,
                                                  LinkInformationService.PublicNode, null);
                if (this.Node is ImageNodeViewModel)
                {
                    (this.Node as ImageNodeViewModel).SetThumbnailImage();
                    (this.Node as ImageNodeViewModel).SetPreviewImage();
                }
                navigateBack = false;
                break;

            case GetPublicNodeResult.InvalidHandleOrDecryptionKey:
                LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Get public node failed. Invalid handle or decryption key.");
                PublicLinkService.ShowLinkNoValidAlert();
                break;

            case GetPublicNodeResult.InvalidDecryptionKey:
                PublicLinkService.Link = await PublicLinkService.ShowDecryptionKeyNotValidAlertAsync();

                if (PublicLinkService.Link != null)
                {
                    this.GetPublicNode(PublicLinkService.Link);
                    return;
                }
                break;

            case GetPublicNodeResult.NoDecryptionKey:
                PublicLinkService.Link = await PublicLinkService.ShowDecryptionAlertAsync();

                this._getPublicNode.DecryptionAlert = true;
                if (PublicLinkService.Link != null)
                {
                    this.GetPublicNode(PublicLinkService.Link);
                    return;
                }
                break;

            case GetPublicNodeResult.UnavailableLink:
                this.ShowUnavailableFileLinkAlert();
                break;

            case GetPublicNodeResult.AssociatedUserAccountTerminated:
                PublicLinkService.ShowAssociatedUserAccountTerminatedAlert();
                break;

            case GetPublicNodeResult.Unknown:
                LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Get public node failed.");
                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_GetPublicNodeFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_GetPublicNodeFailed"));

                break;
            }

            this.ControlState = true;
            this.IsBusy       = false;

            if (!navigateBack)
            {
                return;
            }

            OnUiThread(() =>
            {
                // Navigate to the Cloud Drive page
                NavigateService.Instance.Navigate(typeof(CloudDrivePage), false,
                                                  NavigationObject.Create(this.GetType()));
            });
        }
Пример #21
0
        private void FetchNodesMainPage(MegaSDK api, MRequest request)
        {
            App.AppInformation.HasFetchedNodes = true;

            // If the user is trying to open a shortcut
            if (App.ShortCutBase64Handle != null)
            {
                bool shortCutError = false;

                MNode shortCutMegaNode = api.getNodeByBase64Handle(App.ShortCutBase64Handle);
                App.ShortCutBase64Handle = null;

                if (_mainPageViewModel != null && shortCutMegaNode != null)
                {
                    // Looking for the absolute parent of the shortcut node to see the type
                    MNode parentNode;
                    MNode absoluteParentNode = shortCutMegaNode;
                    while ((parentNode = api.getParentNode(absoluteParentNode)) != null)
                    {
                        absoluteParentNode = parentNode;
                    }

                    if (absoluteParentNode.getType() == MNodeType.TYPE_ROOT)
                    {
                        var newRootNode    = NodeService.CreateNew(api, _mainPageViewModel.AppInformation, shortCutMegaNode, ContainerType.CloudDrive);
                        var autoResetEvent = new AutoResetEvent(false);
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            _mainPageViewModel.ActiveFolderView.FolderRootNode = newRootNode;
                            autoResetEvent.Set();
                        });
                        autoResetEvent.WaitOne();
                    }
                    else
                    {
                        shortCutError = true;
                    }
                }
                else
                {
                    shortCutError = true;
                }

                if (shortCutError)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(AppMessages.ShortCutFailed_Title,
                                                AppMessages.ShortCutFailed, App.AppInformation,
                                                MessageDialogButtons.Ok).ShowDialog();
                    });
                }
            }
            // If the user is trying to open a MEGA link
            else if (App.LinkInformation.ActiveLink != null)
            {
                // Only need to check if is a "file link" or an "internal node link".
                // The "folder links" are checked in the "SpecialNavigation" method
                if (!App.LinkInformation.ActiveLink.Contains("https://mega.nz/#F!"))
                {
                    // Public file link
                    if (App.LinkInformation.ActiveLink.Contains("https://mega.nz/#!"))
                    {
                        SdkService.MegaSdk.getPublicNode(App.LinkInformation.ActiveLink,
                                                         new GetPublicNodeRequestListener(_mainPageViewModel.CloudDrive));
                    }
                    // Internal file/folder link
                    else if (App.LinkInformation.ActiveLink.Contains("https://mega.nz/#"))
                    {
                        var nodeHandle = App.LinkInformation.ActiveLink.Split("#".ToCharArray())[1];
                        var megaNode   = SdkService.MegaSdk.getNodeByBase64Handle(nodeHandle);
                        if (megaNode != null)
                        {
                            ContainerType containerType = (SdkService.MegaSdk.isInRubbish(megaNode)) ?
                                                          containerType = ContainerType.RubbishBin : containerType = ContainerType.CloudDrive;

                            var node = NodeService.CreateNew(SdkService.MegaSdk, App.AppInformation, megaNode, containerType);

                            Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                if (node != null)
                                {
                                    if (node.IsFolder)
                                    {
                                        _mainPageViewModel.ActiveFolderView.BrowseToFolder(node);
                                    }
                                    else
                                    {
                                        node.Download(TransfersService.MegaTransfers);
                                    }
                                }
                                else
                                {
                                    new CustomMessageDialog(
                                        AppMessages.AM_InternalNodeNotFound_Title,
                                        AppMessages.AM_InternalNodeNotFound,
                                        App.AppInformation,
                                        MessageDialogButtons.Ok).ShowDialog();
                                }
                            });
                        }
                        else
                        {
                            Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                new CustomMessageDialog(
                                    AppMessages.AM_InternalNodeNotFound_Title,
                                    AppMessages.AM_InternalNodeNotFound,
                                    App.AppInformation,
                                    MessageDialogButtons.Ok).ShowDialog();
                            });
                        }
                    }
                }
            }
            else
            {
                var cloudDriveRootNode = _mainPageViewModel.CloudDrive.FolderRootNode ??
                                         NodeService.CreateNew(api, _mainPageViewModel.AppInformation, api.getRootNode(), ContainerType.CloudDrive);
                var rubbishBinRootNode = _mainPageViewModel.RubbishBin.FolderRootNode ??
                                         NodeService.CreateNew(api, _mainPageViewModel.AppInformation, api.getRubbishNode(), ContainerType.RubbishBin);

                var autoResetEvent = new AutoResetEvent(false);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _mainPageViewModel.CloudDrive.FolderRootNode = cloudDriveRootNode;
                    _mainPageViewModel.RubbishBin.FolderRootNode = rubbishBinRootNode;
                    autoResetEvent.Set();
                });
                autoResetEvent.WaitOne();
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _mainPageViewModel.LoadFolders();
                _mainPageViewModel.GetAccountDetails();

                // Enable MainPage appbar buttons
                _mainPageViewModel.SetCommandStatus(true);

                if (_mainPageViewModel.SpecialNavigation())
                {
                    return;
                }
            });

            // KEEP ALWAYS AT THE END OF THE METHOD, AFTER THE "LoadForlders" call
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // If is a newly activated account, navigates to the upgrade account page
                if (App.AppInformation.IsNewlyActivatedAccount)
                {
                    NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal, new Dictionary <string, string> {
                        { "Pivot", "1" }
                    });
                }
                // If is the first login, navigates to the camera upload service config page
                else if (SettingsService.LoadSetting <bool>(SettingsResources.CameraUploadsFirstInit, true))
                {
                    NavigateService.NavigateTo(typeof(InitCameraUploadsPage), NavigationParameter.Normal);
                }
                else if (App.AppInformation.IsStartedAsAutoUpload)
                {
                    NavigateService.NavigateTo(typeof(SettingsPage), NavigationParameter.AutoCameraUpload);
                }
            });
        }
        private void FetchNodesMainPage(MegaSDK api, MRequest request)
        {
            App.AppInformation.HasFetchedNodes = true;

            // If the user is trying to open a shortcut
            if (App.ShortCutBase64Handle != null)
            {
                bool shortCutError = false;

                MNode shortCutMegaNode = api.getNodeByBase64Handle(App.ShortCutBase64Handle);
                App.ShortCutBase64Handle = null;

                if (_mainPageViewModel != null && shortCutMegaNode != null)
                {
                    // Looking for the absolute parent of the shortcut node to see the type
                    MNode parentNode;
                    MNode absoluteParentNode = shortCutMegaNode;
                    while ((parentNode = api.getParentNode(absoluteParentNode)) != null)
                    {
                        absoluteParentNode = parentNode;
                    }

                    if (absoluteParentNode.getType() == MNodeType.TYPE_ROOT)
                    {
                        var newRootNode    = NodeService.CreateNew(api, _mainPageViewModel.AppInformation, shortCutMegaNode, ContainerType.CloudDrive);
                        var autoResetEvent = new AutoResetEvent(false);
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            _mainPageViewModel.ActiveFolderView.FolderRootNode = newRootNode;
                            autoResetEvent.Set();
                        });
                        autoResetEvent.WaitOne();
                    }
                    else
                    {
                        shortCutError = true;
                    }
                }
                else
                {
                    shortCutError = true;
                }

                if (shortCutError)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(AppMessages.ShortCutFailed_Title,
                                                AppMessages.ShortCutFailed, App.AppInformation,
                                                MessageDialogButtons.Ok).ShowDialog();
                    });
                }
            }
            else
            {
                var cloudDriveRootNode = _mainPageViewModel.CloudDrive.FolderRootNode ??
                                         NodeService.CreateNew(api, _mainPageViewModel.AppInformation, api.getRootNode(), ContainerType.CloudDrive);
                var rubbishBinRootNode = _mainPageViewModel.RubbishBin.FolderRootNode ??
                                         NodeService.CreateNew(api, _mainPageViewModel.AppInformation, api.getRubbishNode(), ContainerType.RubbishBin);

                var autoResetEvent = new AutoResetEvent(false);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _mainPageViewModel.CloudDrive.FolderRootNode = cloudDriveRootNode;
                    _mainPageViewModel.RubbishBin.FolderRootNode = rubbishBinRootNode;
                    autoResetEvent.Set();
                });
                autoResetEvent.WaitOne();
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _mainPageViewModel.LoadFolders();
                _mainPageViewModel.GetAccountDetails();

                // Enable MainPage appbar buttons
                _mainPageViewModel.SetCommandStatus(true);

                if (_mainPageViewModel.SpecialNavigation())
                {
                    return;
                }
            });

            // KEEP ALWAYS AT THE END OF THE METHOD, AFTER THE "LoadForlders" call
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // If is a newly activated account, navigates to the upgrade account page
                if (App.AppInformation.IsNewlyActivatedAccount)
                {
                    NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal, new Dictionary <string, string> {
                        { "Pivot", "1" }
                    });
                }
                // If is the first login, navigates to the camera upload service config page
                else if (SettingsService.LoadSetting <bool>(SettingsResources.CameraUploadsFirstInit, true))
                {
                    NavigateService.NavigateTo(typeof(InitCameraUploadsPage), NavigationParameter.Normal);
                }
                else if (App.AppInformation.IsStartedAsAutoUpload)
                {
                    NavigateService.NavigateTo(typeof(SettingsPage), NavigationParameter.AutoCameraUpload);
                }
            });
        }
Пример #23
0
        /// <summary>
        /// Gets the incoming shared folders and fills the list.
        /// </summary>
        public void GetIncomingSharedFolders()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            // First cancel any other loading task that is busy
            CancelLoad();

            // Create the option to cancel
            CreateLoadCancelOption();

            InShares.SetProgressIndication(true);

            // Process is started so we can set the empty content template to loading already
            InShares.SetEmptyContentTemplate(true);

            MNodeList inSharesList = MegaSdk.getInShares();

            if (inSharesList == null)
            {
                OnUiThread(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.AM_LoadFailed_Title,
                        AppMessages.AM_LoadInSharesFailed,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();

                    InShares.SetEmptyContentTemplate(false);
                });

                return;
            }

            OnUiThread(() => InShares.ChildNodes.Clear());

            Task.Factory.StartNew(() =>
            {
                try
                {
                    int inSharesListSize = inSharesList.size();
                    for (int i = 0; i < inSharesListSize; i++)
                    {
                        // If the task has been cancelled, stop processing
                        if (LoadingCancelToken.IsCancellationRequested)
                        {
                            LoadingCancelToken.ThrowIfCancellationRequested();
                        }

                        MNode inSharedFolder = inSharesList.get(i);
                        if (inSharedFolder != null)
                        {
                            var _inSharedFolder = NodeService.CreateNew(this.MegaSdk, this.AppInformation,
                                                                        inSharedFolder, ContainerType.InShares, InShares.ChildNodes);

                            if (_inSharedFolder != null)
                            {
                                _inSharedFolder.DefaultImagePathData = VisualResources.FolderTypePath_shared;
                                OnUiThread(() => InShares.ChildNodes.Add(_inSharedFolder));
                            }
                        }
                    }

                    OnUiThread(() =>
                    {
                        OnPropertyChanged("HasInSharedFolders");
                        OnPropertyChanged("NumberOfInSharedFolders");
                        OnPropertyChanged("NumberOfInSharedFoldersText");
                    });
                }
                catch (OperationCanceledException)
                {
                    // Do nothing. Just exit this background process because a cancellation exception has been thrown
                }
                finally
                {
                    // Show the user that processing the childnodes is done
                    InShares.SetProgressIndication(false);

                    // Set empty content to folder instead of loading view
                    InShares.SetEmptyContentTemplate(false);
                }
            }, LoadingCancelToken, TaskCreationOptions.PreferFairness, TaskScheduler.Current);
        }
Пример #24
0
        public void onNodesUpdate(MegaSDK api, MNodeList nodes)
        {
            // exit methods when node list is incorrect
            if (nodes == null || nodes.size() < 1)
            {
                return;
            }

            try
            {
                // Retrieve the listsize for performance reasons and store local
                int listSize = nodes.size();

                for (int i = 0; i < listSize; i++)
                {
                    bool isProcessed = false;

                    // Get the specific node that has an update. If null exit the method
                    // and process no notification
                    MNode megaNode = nodes.get(i);
                    if (megaNode == null)
                    {
                        return;
                    }

                    // PROCESS THE FOLDERS LISTENERS
                    if (megaNode.isRemoved())
                    {
                        // REMOVED Scenario

                        foreach (var folder in Folders)
                        {
                            IMegaNode nodeToRemoveFromView = folder.ChildNodes.FirstOrDefault(
                                node => node.Base64Handle.Equals(megaNode.getBase64Handle()));

                            // If node is found in current view, process the remove action
                            if (nodeToRemoveFromView != null)
                            {
                                // Needed because we are in a foreach loop to prevent the use of the wrong
                                // local variable in the dispatcher code.
                                var currentFolder = folder;
                                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                {
                                    try
                                    {
                                        currentFolder.ChildNodes.Remove(nodeToRemoveFromView);
                                        ((FolderNodeViewModel)currentFolder.FolderRootNode).SetFolderInfo();
                                    }
                                    catch (Exception)
                                    {
                                        // Dummy catch, surpress possible exception
                                    }
                                });

                                isProcessed = true;
                                break;
                            }
                        }

                        if (!isProcessed)
                        {
                            // REMOVED in subfolder scenario

                            MNode parentNode = api.getParentNode(megaNode);

                            if (parentNode != null)
                            {
                                foreach (var folder in Folders)
                                {
                                    IMegaNode nodeToUpdateInView = folder.ChildNodes.FirstOrDefault(
                                        node => node.Base64Handle.Equals(parentNode.getBase64Handle()));

                                    // If parent folder is found, process the update action
                                    if (nodeToUpdateInView != null)
                                    {
                                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                                        {
                                            try
                                            {
                                                nodeToUpdateInView.Update(parentNode, folder.Type);
                                                var folderNode = nodeToUpdateInView as FolderNodeViewModel;
                                                if (folderNode != null)
                                                {
                                                    folderNode.SetFolderInfo();
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                // Dummy catch, surpress possible exception
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    }
                    // UPDATE / ADDED scenarions
                    else
                    {
                        // UPDATE Scenario

                        // PROCESS THE SINGLE NODE(S) LISTENER(S) (NodeDetailsPage live updates)
                        foreach (var node in Nodes)
                        {
                            if (megaNode.getBase64Handle() == node.getNodeBase64Handle())
                            {
                                Deployment.Current.Dispatcher.BeginInvoke(() => node.updateNode(megaNode));
                            }
                        }

                        // Used in different scenario's
                        MNode parentNode = api.getParentNode(megaNode);

                        foreach (var folder in Folders)
                        {
                            IMegaNode nodeToUpdateInView = folder.ChildNodes.FirstOrDefault(
                                node => node.Base64Handle.Equals(megaNode.getBase64Handle()));

                            // If node is found, process the update action
                            if (nodeToUpdateInView != null)
                            {
                                bool isMoved = !folder.FolderRootNode.Base64Handle.Equals(parentNode.getBase64Handle());

                                // Is node is move to different folder. Remove from current folder view
                                if (isMoved)
                                {
                                    // Needed because we are in a foreach loop to prevent the use of the wrong
                                    // local variable in the dispatcher code.
                                    var currentFolder = folder;
                                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                    {
                                        try
                                        {
                                            currentFolder.ChildNodes.Remove(nodeToUpdateInView);
                                            ((FolderNodeViewModel)currentFolder.FolderRootNode).SetFolderInfo();
                                            UpdateFolders(currentFolder);
                                        }
                                        catch (Exception)
                                        {
                                            // Dummy catch, surpress possible exception
                                        }
                                    });
                                }
                                // Node is updated with new data. Update node in current view
                                else
                                {
                                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                    {
                                        try
                                        {
                                            nodeToUpdateInView.Update(megaNode, folder.Type);
                                        }
                                        catch (Exception)
                                        {
                                            // Dummy catch, surpress possible exception
                                        }
                                    });
                                    isProcessed = true;
                                    break;
                                }
                            }
                        }

                        // ADDED scenario

                        if (parentNode != null && !isProcessed)
                        {
                            foreach (var folder in Folders)
                            {
                                bool isAddedInFolder = folder.FolderRootNode.Base64Handle.Equals(parentNode.getBase64Handle());

                                // If node is added in current folder, process the add action
                                if (isAddedInFolder)
                                {
                                    // Retrieve the index from the SDK
                                    // Substract -1 to get a valid list index
                                    int insertIndex = api.getIndex(megaNode,
                                                                   UiService.GetSortOrder(parentNode.getBase64Handle(),
                                                                                          parentNode.getName())) - 1;

                                    // If the insert position is higher than the ChilNodes size insert in the last position
                                    if (insertIndex >= folder.ChildNodes.Count())
                                    {
                                        // Needed because we are in a foreach loop to prevent the use of the wrong
                                        // local variable in the dispatcher code.
                                        var currentFolder = folder;
                                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                                        {
                                            try
                                            {
                                                currentFolder.ChildNodes.Add(NodeService.CreateNew(api,
                                                                                                   _appInformation, megaNode, currentFolder.Type));

                                                ((FolderNodeViewModel)currentFolder.FolderRootNode).SetFolderInfo();
                                                UpdateFolders(currentFolder);
                                            }
                                            catch (Exception)
                                            {
                                                // Dummy catch, surpress possible exception
                                            }
                                        });
                                    }
                                    // Insert the node at a specific position
                                    else
                                    {
                                        // Insert position can never be less then zero
                                        // Replace negative index with first possible index zero
                                        if (insertIndex < 0)
                                        {
                                            insertIndex = 0;
                                        }

                                        // Needed because we are in a foreach loop to prevent the use of the wrong
                                        // local variable in the dispatcher code.
                                        var currentFolder = folder;
                                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                                        {
                                            try
                                            {
                                                currentFolder.ChildNodes.Insert(insertIndex,
                                                                                NodeService.CreateNew(api, _appInformation, megaNode, currentFolder.Type));

                                                ((FolderNodeViewModel)currentFolder.FolderRootNode).SetFolderInfo();
                                                UpdateFolders(currentFolder);
                                            }
                                            catch (Exception)
                                            {
                                                // Dummy catch, surpress possible exception
                                            }
                                        });
                                    }

                                    break;
                                }

                                // ADDED in subfolder scenario
                                IMegaNode nodeToUpdateInView = folder.ChildNodes.FirstOrDefault(
                                    node => node.Base64Handle.Equals(parentNode.getBase64Handle()));

                                if (nodeToUpdateInView != null)
                                {
                                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                    {
                                        try
                                        {
                                            nodeToUpdateInView.Update(parentNode, folder.Type);
                                            var folderNode = nodeToUpdateInView as FolderNodeViewModel;
                                            if (folderNode != null)
                                            {
                                                folderNode.SetFolderInfo();
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            // Dummy catch, surpress possible exception
                                        }
                                    });
                                    break;
                                }

                                // Unconditional scenarios
                                // Move/delete/add actions in subfolders
                                var localFolder = folder;
                                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                {
                                    try
                                    {
                                        UpdateFolders(localFolder);
                                    }
                                    catch (Exception)
                                    {
                                        // Dummy catch, surpress possible exception
                                    }
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                // Dummy catch, surpress possible exception
            }
        }
Пример #25
0
        /// <summary>
        /// Gets the outgoing shared folders and fills the list.
        /// </summary>
        public void GetOutgoingSharedFolders()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            // First cancel any other loading task that is busy
            CancelLoad();

            // Create the option to cancel
            CreateLoadCancelOption();

            OutShares.SetProgressIndication(true);

            // Process is started so we can set the empty content template to loading already
            OutShares.SetEmptyContentTemplate(true);

            MShareList outSharesList = MegaSdk.getOutShares();

            if (outSharesList == null)
            {
                OnUiThread(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.AM_LoadFailed_Title,
                        AppMessages.AM_LoadOutSharesFailed,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();

                    OutShares.SetEmptyContentTemplate(false);
                });

                return;
            }

            OnUiThread(() => OutShares.ChildNodes.Clear());

            Task.Factory.StartNew(() =>
            {
                try
                {
                    ulong lastFolderHandle = 0;
                    int outSharesListSize  = outSharesList.size();
                    for (int i = 0; i < outSharesListSize; i++)
                    {
                        // If the task has been cancelled, stop processing
                        if (LoadingCancelToken.IsCancellationRequested)
                        {
                            LoadingCancelToken.ThrowIfCancellationRequested();
                        }

                        MShare outSharedFolder = outSharesList.get(i);

                        // To avoid null values and public links
                        if ((outSharedFolder != null) && MegaSdk.isOutShare(MegaSdk.getNodeByHandle(outSharedFolder.getNodeHandle())))
                        {
                            // To avoid repeated values, folders shared with more than one user
                            if (lastFolderHandle != outSharedFolder.getNodeHandle())
                            {
                                lastFolderHandle = outSharedFolder.getNodeHandle();

                                var _outSharedFolder = NodeService.CreateNew(this.MegaSdk, this.AppInformation,
                                                                             MegaSdk.getNodeByHandle(lastFolderHandle), ContainerType.OutShares, OutShares.ChildNodes);

                                if (_outSharedFolder != null)
                                {
                                    _outSharedFolder.DefaultImagePathData = VisualResources.FolderTypePath_shared;
                                    OnUiThread(() => OutShares.ChildNodes.Add(_outSharedFolder));
                                }
                            }
                        }
                    }

                    OnUiThread(() =>
                    {
                        OnPropertyChanged("HasOutSharedFolders");
                        OnPropertyChanged("NumberOfOutSharedFolders");
                        OnPropertyChanged("NumberOfOutSharedFoldersText");
                    });
                }
                catch (OperationCanceledException)
                {
                    // Do nothing. Just exit this background process because a cancellation exception has been thrown
                }
                finally
                {
                    // Show the user that processing the childnodes is done
                    OutShares.SetProgressIndication(false);

                    // Set empty content to folder instead of loading view
                    OutShares.SetEmptyContentTemplate(false);
                }
            }, LoadingCancelToken, TaskCreationOptions.PreferFairness, TaskScheduler.Current);
        }
Пример #26
0
        private void CreateChildren(MNodeList childList, int listSize)
        {
            // Set the parameters for the performance for the different view types of a folder
            int viewportItemCount, backgroundItemCount;

            InitializePerformanceParameters(out viewportItemCount, out backgroundItemCount);

            // We will not add nodes one by one in the dispatcher but in groups
            List <IMegaNode> helperList;

            try { helperList = new List <IMegaNode>(1024); }
            catch (ArgumentOutOfRangeException) { helperList = new List <IMegaNode>(); }

            for (int i = 0; i < listSize; i++)
            {
                // If the task has been cancelled, stop processing
                if (LoadingCancelToken.IsCancellationRequested)
                {
                    LoadingCancelToken.ThrowIfCancellationRequested();
                }

                // To avoid pass null values to CreateNew
                if (childList.get(i) == null)
                {
                    continue;
                }

                var node = NodeService.CreateNew(this.MegaSdk, this.AppInformation, childList.get(i), this.Type, ChildNodes);

                // If node creation failed for some reason, continue with the rest and leave this one
                if (node == null)
                {
                    continue;
                }

                // If the user is moving nodes, check if the node had been selected to move
                // and establish the corresponding display mode
                if (CurrentDisplayMode == DriveDisplayMode.CopyOrMoveItem)
                {
                    // Check if it is the only focused node
                    if ((FocusedNode != null) && (node.OriginalMNode.getBase64Handle() == FocusedNode.OriginalMNode.getBase64Handle()))
                    {
                        node.DisplayMode = NodeDisplayMode.SelectedForCopyOrMove;
                        FocusedNode      = node;
                    }

                    // Check if it is one of the multiple selected nodes
                    IsSelectedNode(node);
                }

                helperList.Add(node);

                // First add the viewport items to show some data to the user will still loading
                if (i == viewportItemCount)
                {
                    var waitHandleViewportNodes = new AutoResetEvent(false);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        // If the task has been cancelled, stop processing
                        foreach (var megaNode in helperList.TakeWhile(megaNode => !LoadingCancelToken.IsCancellationRequested))
                        {
                            ChildNodes.Add(megaNode);
                        }
                        waitHandleViewportNodes.Set();
                    });
                    waitHandleViewportNodes.WaitOne();

                    helperList.Clear();
                    continue;
                }

                if (helperList.Count != backgroundItemCount || i <= viewportItemCount)
                {
                    continue;
                }

                // Add the rest of the items in the background to the list
                var waitHandleBackgroundNodes = new AutoResetEvent(false);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    // If the task has been cancelled, stop processing
                    foreach (var megaNode in helperList.TakeWhile(megaNode => !LoadingCancelToken.IsCancellationRequested))
                    {
                        ChildNodes.Add(megaNode);
                    }
                    waitHandleBackgroundNodes.Set();
                });
                waitHandleBackgroundNodes.WaitOne();

                helperList.Clear();
            }

            // Add any nodes that are left over
            var waitHandleRestNodes = new AutoResetEvent(false);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // Show the user that processing the childnodes is done
                SetProgressIndication(false);

                // Set empty content to folder instead of loading view
                SetEmptyContentTemplate(false);

                // If the task has been cancelled, stop processing
                foreach (var megaNode in helperList.TakeWhile(megaNode => !LoadingCancelToken.IsCancellationRequested))
                {
                    ChildNodes.Add(megaNode);
                }
                waitHandleRestNodes.Set();
            });
            waitHandleRestNodes.WaitOne();

            OnUiThread(() => OnPropertyChanged("HasChildNodesBinding"));
        }
Пример #27
0
        private async Task <bool> RecursiveDownloadFolder(String downloadPath, NodeViewModel folderNode)
        {
            if (String.IsNullOrWhiteSpace(folderNode.Name))
            {
                await new CustomMessageDialog(AppMessages.DownloadNodeFailed_Title,
                                              AppMessages.AM_DownloadNodeFailedNoErrorCode, this.AppInformation).ShowDialogAsync();
                return(false);
            }

            // Check for illegal characters in the folder name
            if (FolderService.HasIllegalChars(folderNode.Name))
            {
                await new CustomMessageDialog(AppMessages.DownloadNodeFailed_Title,
                                              String.Format(AppMessages.InvalidFolderNameOrPath, folderNode.Name),
                                              this.AppInformation).ShowDialogAsync();
                return(false);
            }

            try
            {
                String newDownloadPath = Path.Combine(downloadPath, folderNode.Name);
                if (!await CheckDownloadPath(newDownloadPath))
                {
                    return(false);
                }

                MNodeList childList = MegaSdk.getChildren(folderNode.OriginalMNode);

                bool result = true; // Default value in case that the folder is empty
                for (int i = 0; i < childList.size(); i++)
                {
                    // To avoid pass null values to CreateNew
                    if (childList.get(i) == null)
                    {
                        continue;
                    }

                    var childNode = NodeService.CreateNew(this.MegaSdk, this.AppInformation, childList.get(i), ContainerType.CloudDrive);

                    // If node creation failed for some reason, continue with the rest and leave this one
                    if (childNode == null)
                    {
                        continue;
                    }

                    bool partialResult;
                    if (childNode.IsFolder)
                    {
                        partialResult = await RecursiveDownloadFolder(newDownloadPath, childNode);
                    }
                    else
                    {
                        partialResult = await DownloadFile(newDownloadPath, childNode);
                    }

                    // Only change the global result if the partial result indicates an error
                    if (!partialResult)
                    {
                        result = partialResult;
                    }
                }

                return(result);
            }
            catch (Exception e)
            {
                OnUiThread(() =>
                {
                    new CustomMessageDialog(AppMessages.DownloadNodeFailed_Title,
                                            String.Format(AppMessages.DownloadNodeFailed, e.Message),
                                            App.AppInformation).ShowDialog();
                });

                return(false);
            }
        }