private async void AddContactToFolder() { var shareFolderToDialog = new ShareFolderToDialog(this._sharedFolder.getName()); var dialogResult = await shareFolderToDialog.ShowAsync(); if (dialogResult != ContentDialogResult.Primary) { return; } var share = new ShareRequestListenerAsync(); var result = await share.ExecuteAsync(() => { SdkService.MegaSdk.shareByEmail(this._sharedFolder, shareFolderToDialog.ViewModel.ContactEmail, (int)shareFolderToDialog.ViewModel.AccessLevel, share); }); if (!result) { OnUiThread(async() => { await DialogService.ShowAlertAsync( ResourceService.AppMessages.GetString("AM_ShareFolderFailed_Title"), ResourceService.AppMessages.GetString("AM_ShareFolderFailed")); }); } }
/// <summary> /// Modify the contact permissions over an outgoing shared folder /// </summary> /// <param name="newAccessLevel">New access level</param> /// <returns>Result of the action</returns> public async Task <bool> ChangePermissionsAsync(MShareType newAccessLevel) { var changePermissions = new ShareRequestListenerAsync(); var result = await changePermissions.ExecuteAsync(() => { SdkService.MegaSdk.shareByEmail( SdkService.MegaSdk.getNodeByHandle(this._outShare.getNodeHandle()), this.Email, (int)newAccessLevel, changePermissions); }); return(result); }
/// <summary> /// Stop sharing a folder in MEGA /// </summary> /// <returns>Result of the action</returns> public async Task <bool> RemoveSharedAccessAsync() { var removeSharedAccess = new ShareRequestListenerAsync(); var outShares = SdkService.MegaSdk.getOutShares(this.OriginalMNode); var outSharesSize = outShares.size(); bool result = true; for (int i = 0; i < outSharesSize; i++) { result = result & await removeSharedAccess.ExecuteAsync(() => { this.MegaSdk.shareByEmail(this.OriginalMNode, outShares.get(i).getUser(), (int)MShareType.ACCESS_UNKNOWN, removeSharedAccess); }); } return(result); }
private async void ConfirmShare() { if (!MegaContacts.ItemCollection.HasSelectedItems) { return; } // Ask user for the access level var shareFolderToDialog = new SetSharedFolderPermissionDialog(); var dialogResult = await shareFolderToDialog.ShowAsync(); if (dialogResult != ContentDialogResult.Primary) { return; } // Use a temp variable to avoid "InvalidOperationException" tracing the selected items var selectedItems = this.MegaContacts.ItemCollection.SelectedItems.ToList(); this.OnClosePanelEvent(); bool result = true; foreach (var contact in selectedItems) { var share = new ShareRequestListenerAsync(); result = result & await share.ExecuteAsync(() => { SdkService.MegaSdk.share(this.Node.OriginalMNode, contact.MegaUser, (int)shareFolderToDialog.ViewModel.AccessLevel, share); }); } if (!result) { OnUiThread(async() => { await DialogService.ShowAlertAsync( ResourceService.AppMessages.GetString("AM_ShareFolderFailed_Title"), ResourceService.AppMessages.GetString("AM_ShareFolderFailed")); }); } }