/// <summary>
        /// Enable the Multi-Factor Authentication
        /// </summary>
        private async Task <bool> EnableMultiFactorAuthAsync(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return(false);
            }

            var enableMultiFactorAuth = new MultiFactorAuthEnableRequestListenerAsync();
            var result = await enableMultiFactorAuth.ExecuteAsync(() =>
                                                                  SdkService.MegaSdk.multiFactorAuthEnable(code, enableMultiFactorAuth));

            if (!result)
            {
                DialogService.SetMultiFactorAuthCodeInputDialogWarningMessage();
                return(result);
            }

            OnUiThread(() =>
            {
                NavigateService.NavigateTo(typeof(SettingsPage),
                                           NavigationParameter.MFA_Enabled);
            });

            return(result);
        }
Esempio n. 2
0
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgessService.SetProgressIndicator(false);

                //this.ControlState = true;

                if (e.getErrorCode() == MErrorType.API_OK)
                {
                    if (ShowSuccesMessage)
                    {
                        MessageBox.Show(SuccessMessage, SuccessMessageTitle, MessageBoxButton.OK);
                    }

                    if (ActionOnSucces)
                    {
                        OnSuccesAction(request);
                    }

                    if (NavigateOnSucces)
                    {
                        NavigateService.NavigateTo(NavigateToPage, NavigationParameter);
                    }
                }
                else
                {
                    MessageBox.Show(String.Format(ErrorMessage, e.getErrorString()), ErrorMessageTitle, MessageBoxButton.OK);
                }
            });
        }
Esempio n. 3
0
        private void UpdateGUI(bool isNetworkConnected = true)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (isNetworkConnected)
                {
                    if (!Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()))
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.None);
                        return;
                    }

                    _sharedItemsViewModel.IsInSharedItemsRootListView  = true;
                    _sharedItemsViewModel.IsOutSharedItemsRootListView = true;

                    _sharedItemsViewModel.GetIncomingSharedFolders();
                    _sharedItemsViewModel.GetOutgoingSharedFolders();
                }
                else
                {
                    _sharedItemsViewModel.IsInSharedItemsRootListView  = false;
                    _sharedItemsViewModel.IsOutSharedItemsRootListView = false;

                    _sharedItemsViewModel.ClearIncomingSharedFolders();
                    _sharedItemsViewModel.InShares.BreadCrumbs.Clear();
                    _sharedItemsViewModel.InShares.SetOfflineContentTemplate();

                    _sharedItemsViewModel.ClearOutgoingSharedFolders();
                    _sharedItemsViewModel.OutShares.BreadCrumbs.Clear();
                    _sharedItemsViewModel.OutShares.SetOfflineContentTemplate();
                }

                SetApplicationBarData(isNetworkConnected);
            });
        }
        private void UpdateGUI(bool isNetworkConnected = true)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (isNetworkConnected)
                {
                    if (!Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()))
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.None);
                        return;
                    }

                    _cameraUploadsPageViewModel.CameraUploads.SetEmptyContentTemplate(true);
                    _cameraUploadsPageViewModel.LoadFolders();
                }
                else
                {
                    _cameraUploadsPageViewModel.CameraUploads.ClearChildNodes();
                    _cameraUploadsPageViewModel.CameraUploads.BreadCrumbs.Clear();
                    _cameraUploadsPageViewModel.CameraUploads.SetOfflineContentTemplate();
                }

                SetApplicationBarData(isNetworkConnected);
            });
        }
        private void OnSkipClick(object sender, EventArgs e)
        {
            SetApplicationBar(false);

            try
            {
                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                SetApplicationBar(true);
            }
        }
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            try
            {
                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                e.Cancel = true;
            }
        }
Esempio n. 7
0
        private void ImportItem(object obj)
        {
            App.LinkInformation.SelectedNodes.Add(FocusedNode);
            App.LinkInformation.LinkAction = LinkAction.Import;

            OnUiThread(() => NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink));
        }
Esempio n. 8
0
        private async void OnRemoveClick(object sender, EventArgs e)
        {
            NodeActionResult result = await _nodeDetailsViewModel.Remove();

            if (result == NodeActionResult.Cancelled)
            {
                return;
            }

            try
            {
                if (NavigateService.CanGoBack())
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
        }
Esempio n. 9
0
        private void UpdateGUI(bool isNetworkConnected = true)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (isNetworkConnected)
                {
                    if (!Convert.ToBoolean(App.MegaSdk.isLoggedIn()))
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.None);
                        return;
                    }

                    _contactsViewModel.SetEmptyContentTemplate(true);

                    _contactsViewModel.GetMegaContacts();
                    _contactsViewModel.GetReceivedContactRequests();
                    _contactsViewModel.GetSentContactRequests();
                }
                else
                {
                    _contactsViewModel.MegaContactsList.Clear();
                    _contactsViewModel.ReceivedContactRequests.Clear();
                    _contactsViewModel.SentContactRequests.Clear();

                    _contactsViewModel.SetOfflineContentTemplate();
                }

                SetApplicationBarData(isNetworkConnected);
            });
        }
        private void OnOkClick(object sender, EventArgs e)
        {
            SetApplicationBar(false);

            try
            {
                // Enable or turn on the "Camera Uploads" service
                SettingsService.SaveSetting <bool>(SettingsResources.CameraUploadsIsEnabled, true);
                MediaService.SetAutoCameraUpload(true);

                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                SetApplicationBar(true);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.AppInformation.IsStartupModeActivate)
            {
                // Needed on every UI interaction
                SdkService.MegaSdk.retryPendingConnections();

                if (!App.AppInformation.HasPinLockIntroduced && SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled))
                {
                    NavigateService.NavigateTo(typeof(PasswordPage), NavigationParameter.Normal, this.GetType());
                    return;
                }

                App.AppInformation.IsStartupModeActivate = false;

                #if WINDOWS_PHONE_81
                // Check to see if any files have been picked
                var app = Application.Current as App;
                if (app != null && app.FolderPickerContinuationArgs != null)
                {
                    FolderService.ContinueFolderOpenPicker(app.FolderPickerContinuationArgs,
                                                           this._folderViewModel);
                }
                return;
                #endif
            }

            base.OnNavigatedTo(e);
        }
Esempio n. 12
0
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            switch (e.getErrorCode())
            {
            // SSL Key error management
            case MErrorType.API_EINCOMPLETE:
                if (request.getType() == MRequestType.TYPE_LOGOUT &&
                    request.getParamType() == (int)MErrorType.API_ESSL)
                {
                    if (SSLCertificateAlertDisplayed)
                    {
                        break;
                    }

                    SSLCertificateAlertDisplayed = true;
                    Deployment.Current.Dispatcher.BeginInvoke(async() =>
                    {
                        await DialogService.ShowSSLKeyErrorAlertAsync(api);
                        SSLCertificateAlertDisplayed = false;
                    });
                }
                break;

            // Bad session ID error management
            case MErrorType.API_ESID:
                AppService.LogoutActions();
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                          NavigateService.NavigateTo(typeof(InitTourPage), NavigationParameter.API_ESID));
                break;
            }
        }
Esempio n. 13
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            // Check if multi select is active on current view and disable it if so
            e.Cancel = CheckMultiSelectActive(e.Cancel);

            // Check if we can go a folder up in the selected pivot view
            e.Cancel = CheckAndGoFolderUp(e.Cancel);

            if (e.Cancel)
            {
                return;
            }

            if (ContactDetailsPivot.SelectedItem.Equals(SharedItemsPivotItem))
            {
                if (!_contactDetailsViewModel.IsInSharedItemsRootListView)
                {
                    _contactDetailsViewModel.GetContactSharedFolders();
                    _contactDetailsViewModel.IsInSharedItemsRootListView = true;
                    e.Cancel = true; return;
                }
            }

            NavigateService.NavigateTo(typeof(ContactsPage), NavigationParameter.Normal);

            e.Cancel = true;
        }
Esempio n. 14
0
        private void OnImportFolderLinkClick(object sender, EventArgs e)
        {
            // Needed on every UI interaction
            SdkService.MegaSdkFolderLinks.retryPendingConnections();

            // Extra check to avoid NullReferenceException
            if (_folderLinkViewModel == null || _folderLinkViewModel.FolderLinkRootNode == null)
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.AM_ImportFailed_Title,
                    AppMessages.AM_ImportFolderLinkFailed,
                    App.AppInformation,
                    MessageDialogButtons.Ok);

                customMessageDialog.OkOrYesButtonTapped += (new_sender, args) => CancelAction();

                customMessageDialog.ShowDialog();
                return;
            }

            App.LinkInformation.SelectedNodes.Add(_folderLinkViewModel.FolderLinkRootNode);
            App.LinkInformation.LinkAction = LinkAction.Import;

            NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink);
        }
Esempio n. 15
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            // If a product has been selected, deselect it
            if (_paymentViewModel.CreditCardPaymentIsEnabled)
            {
                PageSubtitle.Text = UiResources.ChoosePaymentMethod;
                _paymentViewModel.ProductSelectionIsEnabled       = false;
                _paymentViewModel.PaymentMethodSelectionIsEnabled = true;
            }
            else if (_paymentViewModel.PaymentMethodSelectionIsEnabled)
            {
                PageSubtitle.Text = UiResources.ChooseRenewalPeriod;
                _paymentViewModel.SelectedProduct                 = null;
                _paymentViewModel.ProductSelectionIsEnabled       = true;
                _paymentViewModel.PaymentMethodSelectionIsEnabled = false;
            }
            // If not, come back to the update account pivot
            else if (_paymentViewModel.ProductSelectionIsEnabled)
            {
                ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal, new Dictionary <string, string> {
                    { "Pivot", "1" }
                });
            }

            _paymentViewModel.CreditCardPaymentIsEnabled = false;
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false;

            e.Cancel = true;
        }
        private void OnItemTap(object sender, ListBoxItemTapEventArgs e)
        {
            // In case that it is an account newly activated, the list of available plans shows the "Free" option.
            // If the user selects it, we only need to redirect it to the cloud drive
            if (((ProductBase)LstPlans.SelectedItem).AccountType == MAccountType.ACCOUNT_TYPE_FREE)
            {
                NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                return;
            }

            // Else we need to identify the selected plan and send it along the Monthly and Annual plans of this type to the PaymentPage
            for (int i = 0; i < _myAccountPageViewModel.UpgradeAccount.Products.Count; i++)
            {
                if (_myAccountPageViewModel.UpgradeAccount.Products.ElementAt(i).AccountType == ((ProductBase)LstPlans.SelectedItem).AccountType)
                {
                    switch (_myAccountPageViewModel.UpgradeAccount.Products.ElementAt(i).Months)
                    {
                    case 1:
                        PhoneApplicationService.Current.State["SelectedPlanMonthly"] = _myAccountPageViewModel.UpgradeAccount.Products.ElementAt(i);
                        break;

                    case 12:
                        PhoneApplicationService.Current.State["SelectedPlanAnnualy"] = _myAccountPageViewModel.UpgradeAccount.Products.ElementAt(i);
                        break;

                    default:
                        break;
                    }
                }
            }

            PhoneApplicationService.Current.State["SelectedPlan"] = LstPlans.SelectedItem;
            NavigateService.NavigateTo(typeof(PaymentPage), NavigationParameter.Normal);
        }
Esempio n. 17
0
        private void UpdateGUI(bool isNetworkConnected = true)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (isNetworkConnected)
                {
                    if (!Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()))
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.None);
                        return;
                    }

                    _transfersViewModel.Uploads.SetEmptyContentTemplate();
                    _transfersViewModel.Downloads.SetEmptyContentTemplate();
                    LstUploads.ItemsSource   = _transfersViewModel.Uploads.Items;
                    LstDownloads.ItemsSource = _transfersViewModel.Downloads.Items;
                }
                else
                {
                    _transfersViewModel.Uploads.SetOfflineContentTemplate();
                    _transfersViewModel.Downloads.SetOfflineContentTemplate();
                    LstUploads.ItemsSource   = null;
                    LstDownloads.ItemsSource = null;
                }

                SetApplicationBarData(isNetworkConnected);
            });
        }
Esempio n. 18
0
 public void SelectFolder(NodeViewModel selectedNode)
 {
     this.CurrentRootNode = selectedNode;
     // Create unique uri string to navigate
     NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Browsing, new Dictionary <string, string> {
         { "Id", Guid.NewGuid().ToString("N") }
     });
 }
Esempio n. 19
0
 public void ViewContactDetails()
 {
     if (FocusedContact != null)
     {
         PhoneApplicationService.Current.State["SelectedContact"] = FocusedContact;
         NavigateService.NavigateTo(typeof(ContactDetailsPage), NavigationParameter.Normal);
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Captures a photo. Photo data is stored to DataContext.ImageStream, and application
        /// is navigated to the preview page after capturing.
        /// </summary>
        private async Task Capture()
        {
            try
            {
                bool goToPreview = false;

                var selfieBitmap = new BitmapImage();

                if (!_capturing)
                {
                    _capturing = true;

                    var stream = new MemoryStream();

                    CameraCaptureSequence sequence = PhotoCaptureDevice.CreateCaptureSequence(1);
                    sequence.Frames[0].CaptureStream = stream.AsOutputStream();

                    await PhotoCaptureDevice.PrepareCaptureSequenceAsync(sequence);

                    await sequence.StartCaptureAsync();

                    selfieBitmap = new BitmapImage();
                    selfieBitmap.SetSource(stream);

                    _capturing = false;

                    // Defer navigation as it will release the camera device and the
                    // following Device calls must still work.
                    goToPreview = true;
                }

                _manuallyFocused = false;

                if (PhotoCaptureDevice.IsFocusRegionSupported(PhotoCaptureDevice.SensorLocation))
                {
                    PhotoCaptureDevice.FocusRegion = null;
                }

                FocusIndicator.SetValue(VisibilityProperty, Visibility.Collapsed);
                PhotoCaptureDevice.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None);

                if (goToPreview)
                {
                    NavigateService.NavigateTo(typeof(PreviewSelfiePage), NavigationParameter.Normal, selfieBitmap);
                }
            }
            catch (Exception e)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.CapturePhotoVideoFailed_Title,
                        String.Format(AppMessages.CapturePhotoVideoFailed, e.Message),
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });
            }
        }
        private void SetupMultiFactorAuth(object obj = null)
        {
            this.DialogResult = true;

            base.CloseDialog();

            NavigateService.NavigateTo(typeof(MultiFactorAuthAppSetupPage),
                                       NavigationParameter.Normal);
        }
Esempio n. 22
0
        private void OnImportClick(object sender, EventArgs e)
        {
            if (_nodeViewModel.ParentContainerType == ContainerType.FolderLink)
            {
                App.LinkInformation.SelectedNodes.Add(_nodeViewModel);
                App.LinkInformation.LinkAction = LinkAction.Import;

                NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink);
            }
        }
Esempio n. 23
0
        private void OnDoneClick(object sender, System.EventArgs e)
        {
            if (!_passwordViewModel.CheckPassword())
            {
                return;
            }

            App.AppInformation.HasPinLockIntroduced = true;
            NavigateService.NavigateTo(_originPage, NavigationParameter.PasswordLogin);
        }
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            if (e.Cancel) return;

            NavigateService.NavigateTo(typeof(InitTourPage), NavigationParameter.Normal);

            e.Cancel = true;
        }
Esempio n. 25
0
        private void ShowErrorMesageAndNavigate(String title, String message)
        {
            var customMessageDialog = new CustomMessageDialog(
                title, message, App.AppInformation, MessageDialogButtons.Ok);

            customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                       NavigateService.NavigateTo(NavigateToPage, NavigationParameter);

            customMessageDialog.ShowDialog();
        }
Esempio n. 26
0
        private void OnMultiSelectImportClick(object sender, EventArgs e)
        {
            // Needed on every UI interaction
            SdkService.MegaSdkFolderLinks.retryPendingConnections();

            App.LinkInformation.SelectedNodes = _folderLinkViewModel.FolderLink.ChildNodes.Where(n => n.IsMultiSelected).ToList();
            App.LinkInformation.LinkAction    = LinkAction.Import;

            NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink);
        }
Esempio n. 27
0
        public virtual void Download(TransferQueu transferQueu, string downloadPath = null)
        {
            if (!IsUserOnline())
            {
                return;
            }
            //NavigateService.NavigateTo(typeof(DownloadPage), NavigationParameter.Normal, this);

            SaveForOffline(transferQueu);

            NavigateService.NavigateTo(typeof(TransferPage), NavigationParameter.Downloads);
        }
Esempio n. 28
0
        private void OnCancelClick(object sender, EventArgs e)
        {
            PageSubtitle.Text = UiResources.ChooseRenewalPeriod;

            _paymentViewModel.ProductSelectionIsEnabled       = true;
            _paymentViewModel.PaymentMethodSelectionIsEnabled = false;
            _paymentViewModel.CreditCardPaymentIsEnabled      = false;

            NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal, new Dictionary <string, string> {
                { "Pivot", "1" }
            });
        }
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);
            });

            if (e.getErrorCode() == MErrorType.API_OK)
            {
                if (this._waitEventRequest != null)
                {
                    this._waitEventRequest.Set();
                }

                if (ShowSuccesMessage && !_isMultiRemove)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            SuccessMessageTitle,
                            SuccessMessage,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });
                }

                if (ActionOnSucces)
                {
                    OnSuccesAction(api, request);
                }

                if (NavigateOnSucces)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => NavigateService.NavigateTo(NavigateToPage, NavigationParameter));
                }
            }
            else if (e.getErrorCode() != MErrorType.API_EINCOMPLETE)
            {
                if (ShowErrorMessage)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            ErrorMessageTitle,
                            String.Format(ErrorMessage, e.getErrorString()),
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });
                }
            }
        }
Esempio n. 30
0
        private void UpgradeAccount(object obj)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _mainPage.ChangeGetProAccountBorderVisibility(Visibility.Collapsed);
                _mainPage.ChangeWarningOutOfSpaceBorderVisibility(Visibility.Collapsed);
            });

            var extraParams = new Dictionary <string, string>(1);

            extraParams.Add("Pivot", "1");
            NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal, extraParams);
        }