Exemple #1
0
        /// <summary>
        /// Gets the offline path of the parent of a <see cref="MNode"/>
        /// </summary>
        /// <param name="node">Node to get the parent node path</param>
        /// <returns>The offline path of the parent node</returns>
        public static string GetOfflineParentNodePath(MNode node)
        {
            if (node == null)
            {
                return(null);
            }

            var parentNode = SdkService.MegaSdk.getParentNode(node);

            if (parentNode == null)
            {
                if (node.isInShare())
                {
                    return(Path.Combine(AppService.GetOfflineDirectoryPath(),
                                        SdkService.MegaSdk.getUserFromInShare(node).getHandle().ToString()));
                }

                return(AppService.GetOfflineDirectoryPath());
            }

            var parentNodePath = SdkService.MegaSdk.getNodePath(parentNode);

            if (string.IsNullOrWhiteSpace(parentNodePath))
            {
                return(AppService.GetOfflineDirectoryPath());
            }

            var rootNode = SdkService.MegaSdk.getRootNode(node);

            if (rootNode.isInShare())
            {
                return(Path.Combine(AppService.GetOfflineDirectoryPath(),
                                    SdkService.MegaSdk.getUserFromInShare(rootNode).getHandle().ToString(),
                                    parentNodePath.Split(':')[1]).Replace("/", "\\"));
            }

            return(Path.Combine(AppService.GetOfflineDirectoryPath(),
                                parentNodePath.Remove(0, 1).Replace("/", "\\")));
        }
        /// <summary>
        /// Update core data associated with the SDK MNode object
        /// </summary>
        /// <param name="megaNode">Node to update</param>
        /// <param name="externalUpdate">Indicates if is an update external to the app. For example from an `onNodesUpdate`</param>
        public override void Update(MNode megaNode, bool externalUpdate = false)
        {
            base.Update(megaNode, externalUpdate);
            SetFolderInfo();

            if (megaNode.isInShare())
            {
                return;
            }

            OnPropertyChanged(nameof(this.IsOutShare), nameof(this.SharingText));

            if (megaNode.isOutShare())
            {
                if (this.ContactsList == null)
                {
                    this.ContactsList = new ContactsListOutgoingSharedFolderViewModel(megaNode);
                    this.GetContactsList();
                }
            }
            else
            {
                if (this.ContactsList != null)
                {
                    OnUiThread(() => this.ContactsList.ItemCollection.Clear());
                }
            }

            this.DefaultImagePathData = megaNode.isOutShare() ?
                                        ResourceService.VisualResources.GetString("VR_OutgoingSharedFolderPathData") :
                                        ResourceService.VisualResources.GetString("VR_FolderTypePath_default");

            if (!megaNode.getName().ToLower().Equals("camera uploads"))
            {
                return;
            }
            this.DefaultImagePathData = ResourceService.VisualResources.GetString("VR_FolderTypePath_photo");
        }
Exemple #3
0
        public void onNodesUpdate(MegaSDK api, MNodeList nodes)
        {
            // Exit methods when node list is incorrect
            if (nodes == null || nodes.size() < 1)
            {
                return;
            }

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

            for (int i = 0; i < listSize; i++)
            {
                try
                {
                    // 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;
                    }

                    // Incoming shared folder
                    if (megaNode.isInShare())
                    {
                        if (megaNode.isRemoved()) // REMOVED Scenario
                        {
                            OnInSharedFolderRemoved(megaNode);
                        }
                        else // ADDED/UPDATED scenarios
                        {
                            OnInSharedFolderAdded(megaNode);
                        }
                    }
                    // Outgoing shared folder - ADDED/UPDATED scenarios
                    else if (megaNode.isOutShare())
                    {
                        OnOutSharedFolderAdded(megaNode);
                    }
                    else
                    {
                        // Outgoing shared folder - REMOVED Scenario
                        if (megaNode.hasChanged((int)MNodeChangeType.CHANGE_TYPE_OUTSHARE))
                        {
                            OnOutSharedFolderRemoved(megaNode);
                        }

                        // Normal node
                        if (megaNode.isRemoved()) // REMOVED Scenario
                        {
                            OnNodeRemoved(megaNode);
                        }
                        else // ADDED/UPDATED scenarions
                        {
                            OnNodeAdded(megaNode);
                        }
                    }
                }
                catch (Exception) { /* Dummy catch, suppress possible exception */ }
            }
        }