Example #1
0
        // Method which is called when the timer event is triggered
        private void ApiErrorTimerOnTick(object sender, object e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (apiErrorTimer != null)
                    apiErrorTimer.Stop();
            });

            if (this.api == null) return;

            string message = string.Empty;
            switch ((MRetryReason)this.api.isWaiting())
            {
                case MRetryReason.RETRY_CONNECTIVITY:
                    message = ProgressMessages.PM_ConnectivityIssue;
                    break;

                case MRetryReason.RETRY_SERVERS_BUSY:
                    message = ProgressMessages.PM_ServersBusy;
                    break;

                case MRetryReason.RETRY_API_LOCK:
                    message = ProgressMessages.PM_ApiLocked;
                    break;

                case MRetryReason.RETRY_RATE_LIMIT:
                    message = ProgressMessages.PM_ApiRateLimit;
                    break;

                default: return;
            }

            Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, message));
        }
        public override void onRequestUpdate(MegaSDK api, MRequest request)
        {
            base.onRequestUpdate(api, request);

            if (request.getType() != MRequestType.TYPE_FETCH_NODES)
            {
                return;
            }

            if (request.getTotalBytes() > 0)
            {
                double progressValue = 100.0 * request.getTransferredBytes() / request.getTotalBytes();
                if ((progressValue > 99) || (progressValue < 0))
                {
                    UiService.OnUiThread(() =>
                                         ProgressService.SetProgressIndicator(true, ProgressMessages.PM_DecryptNodes));
                }
            }

            if (AppMemoryController.IsThresholdExceeded(75UL.FromMBToBytes()))
            {
                UiService.OnUiThread(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.MemoryLimitError_Title,
                        AppMessages.MemoryLimitError,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                    Application.Current.Terminate();
                });
            }
        }
Example #3
0
        private async void OnAcceptClick(object sender, System.EventArgs e)
        {
            if (LstMediaItems.CheckedItems == null || LstMediaItems.CheckedItems.Count < 1)
            {
                new CustomMessageDialog(
                    AppMessages.MinimalPictureSelection_Title,
                    AppMessages.MinimalPictureSelection,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                return;
            }

            ProgressService.SetProgressIndicator(true, ProgressMessages.PrepareUploads);
            SetControlState(false);

            // Set upload directory only once for speed improvement and if not exists, create dir
            var uploadDir = AppService.GetUploadDirectoryPath(true);

            foreach (var checkedItem in LstMediaItems.CheckedItems)
            {
                var item = (BaseMediaViewModel <Picture>)checkedItem;
                if (item == null)
                {
                    continue;
                }

                try
                {
                    string fileName = Path.GetFileName(item.Name);
                    if (fileName != null)
                    {
                        string newFilePath = Path.Combine(uploadDir, fileName);
                        using (var fs = new FileStream(newFilePath, FileMode.Create))
                        {
                            await item.BaseObject.GetImage().CopyToAsync(fs);

                            await fs.FlushAsync();

                            fs.Close();
                        }
                        var uploadTransfer = new TransferObjectModel(SdkService.MegaSdk, App.CloudDrive.CurrentRootNode, MTransferType.TYPE_UPLOAD, newFilePath);
                        TransfersService.MegaTransfers.Add(uploadTransfer);
                        uploadTransfer.StartTransfer();
                    }
                }
                catch (Exception)
                {
                    new CustomMessageDialog(
                        AppMessages.PrepareImageForUploadFailed_Title,
                        String.Format(AppMessages.PrepareImageForUploadFailed, item.Name),
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                }
            }

            ProgressService.SetProgressIndicator(false);
            SetControlState(true);

            App.CloudDrive.NoFolderUpAction = true;
        }
Example #4
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);
            });

            switch (e.getErrorCode())
            {
            case MErrorType.API_OK:
                OnSuccesAction(api, request);
                break;

            case MErrorType.API_EEXIST:
                OnSuccesAction(api, request);
                break;

            default:
                if (ShowErrorMessage)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            ErrorMessageTitle,
                            ErrorMessage,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });
                }
                break;
            }
        }
        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)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    AccountService.AccountDetails.HasAvatarImage = true;

                    var img           = new BitmapImage();
                    img.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                    img.UriSource     = new Uri(request.getFile());
                    AccountService.AccountDetails.AvatarUri = img.UriSource;
                });
            }
            else
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    AccountService.AccountDetails.HasAvatarImage = false;
                    AccountService.AccountDetails.AvatarUri      = null;
                });
            }
        }
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            this.api = api;

            this.ErrorString = e.getErrorString();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);

                if (apiErrorTimer != null)
                {
                    apiErrorTimer.Stop();
                }
            });

            switch (e.getErrorCode())
            {
            case MErrorType.API_EGOINGOVERQUOTA:     // Not enough storage quota
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               string.Format("Not enough storage quota ({0})", e.getErrorCode().ToString()));
                UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(true));
                break;

            case MErrorType.API_EOVERQUOTA:     // Storage overquota error
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               string.Format("Storage quota exceeded ({0})", e.getErrorCode().ToString()));
                UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(false));
                break;
            }
        }
Example #7
0
        public async Task <bool> MultipleDeleteContacts()
        {
            int count = MegaContactsList.Count(n => n.IsMultiSelected);

            if (count < 1)
            {
                return(false);
            }

            var customMessageDialog = new CustomMessageDialog(
                AppMessages.DeleteMultipleContactsQuestion_Title,
                String.Format(AppMessages.DeleteMultipleContactsQuestion, count),
                App.AppInformation,
                MessageDialogButtons.OkCancel);

            customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveContact));

                var helperList = new List <Contact>(count);
                helperList.AddRange(MegaContactsList.Where(n => n.IsMultiSelected));

                foreach (var contact in helperList)
                {
                    MegaSdk.removeContact(MegaSdk.getContact(contact.Email), new RemoveContactRequestListener(this, contact));
                }

                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false));
                this.IsMultiSelectActive = false;
            };

            return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
        }
Example #8
0
 // Method which is call when the timer event is triggered
 private void timerTickAPI_EAGAIN(object sender, object e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         timerAPI_EAGAIN.Stop();
         ProgressService.SetProgressIndicator(true, ProgressMessages.ServersTooBusy);
     });
 }
Example #9
0
        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)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        SuccessMessageTitle,
                        SuccessMessage,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });

                try
                {
                    SaveUniqueReceiptId(GetUniqueReceiptId(_receipt));
                }
                catch
                {
                    // On error do nothing. The app will just retry to validate the receipt on app start and
                    // add it to the settings if succeeded or -12 (already exists) error code returns
                }
            }
            else if (e.getErrorCode() == MErrorType.API_EEXIST)
            {
                // Current receipt is already validate on MEGA license server
                // Add receipt id to the saved list in the settings
                try
                {
                    SaveUniqueReceiptId(GetUniqueReceiptId(_receipt));
                }
                catch
                {
                    // On error do nothing. The app will just retry to validate the receipt on app start and
                    // Add it to settings if succeeded or -12 (already exists) error code returns
                }
            }
            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();
                    });
                }
            }
        }
Example #10
0
        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 (request.getType() == MRequestType.TYPE_GET_ATTR_USER)
                {
                    switch (request.getParamType())
                    {
                    case (int)MUserAttrType.USER_ATTR_FIRSTNAME:
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            _userData.Firstname = request.getText();
                            if (App.UserData != null)
                            {
                                App.UserData.Firstname = _userData.Firstname;
                            }
                        });
                        break;

                    case (int)MUserAttrType.USER_ATTR_LASTNAME:
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            _userData.Lastname = request.getText();
                            if (App.UserData != null)
                            {
                                App.UserData.Lastname = _userData.Lastname;
                            }
                        });
                        break;
                    }
                }
            }
            else
            {
                if (request.getType() == MRequestType.TYPE_GET_ATTR_USER)
                {
                    if (request.getParamType() == (int)MUserAttrType.USER_ATTR_FIRSTNAME)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            _userData.Firstname = UiResources.MyAccount;
                            if (App.UserData != null)
                            {
                                App.UserData.Firstname = _userData.Firstname;
                            }
                        });
                    }
                }
            }
        }
        public override void onRequestStart(MegaSDK api, MRequest request)
        {
            base.onRequestStart(api, request);

            if (request.getType() != MRequestType.TYPE_LOGIN)
            {
                return;
            }

            UiService.OnUiThread(() =>
                                 ProgressService.SetProgressIndicator(true, ProgressMessages.FastLogin));
        }
        public override void onRequestStart(MegaSDK api, MRequest request)
        {
            base.onRequestStart(api, request);

            if (request.getType() != MRequestType.TYPE_CHANGE_PW)
            {
                return;
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                      ProgressService.SetProgressIndicator(true, ProgressMessages.PM_ChangePassword));
        }
        public override void onRequestStart(MegaSDK api, MRequest request)
        {
            base.onRequestStart(api, request);

            if (request.getType() != MRequestType.TYPE_FETCH_NODES)
            {
                return;
            }

            UiService.OnUiThread(() =>
                                 ProgressService.SetProgressIndicator(true, ProgressMessages.PM_FetchNodes));
        }
Example #14
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);

                _loginViewModel.ControlState = true;

                timerAPI_EAGAIN.Stop();
            });

            if (e.getErrorCode() == MErrorType.API_OK)
            {
                _loginViewModel.SessionKey = api.dumpSession();
            }
            else
            {
                if (_loginPage != null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => _loginPage.SetApplicationBar(true));
                }

                switch (e.getErrorCode())
                {
                case MErrorType.API_ENOENT:     // E-mail unassociated with a MEGA account or Wrong password
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle, AppMessages.WrongEmailPasswordLogin,
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;

                case MErrorType.API_ETOOMANY:     // Too many failed login attempts. Wait one hour.
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle,
                                                                                      String.Format(AppMessages.AM_TooManyFailedLoginAttempts, DateTime.Now.AddHours(1).ToString("HH:mm:ss")),
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;

                case MErrorType.API_EINCOMPLETE:     // Account not confirmed
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle, AppMessages.AM_AccountNotConfirmed,
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;

                case MErrorType.API_EBLOCKED:     // Account blocked
                    base.onRequestFinish(api, request, e);
                    return;
                }
            }

            base.onRequestFinish(api, request, e);
        }
        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();
                    });
                }
            }
        }
Example #16
0
        public virtual void onRequestStart(MegaSDK api, MRequest request)
        {
            this.api = api;

            if (!ShowProgressMessage) return;
            var autoReset = new AutoResetEvent(true);
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.SetProgressIndicator(true, ProgressMessage);
                autoReset.Set();
            });
            autoReset.WaitOne();
        }
        public override void onRequestStart(MegaSDK api, MRequest request)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // Disable MainPage appbar buttons
                if (_mainPageViewModel != null)
                {
                    _mainPageViewModel.SetCommandStatus(false);
                }

                ProgressService.SetProgressIndicator(true,
                                                     String.Format(ProgressMessages.FetchingNodes, request.getTransferredBytes().ToStringAndSuffix(2)));
            });
        }
        protected override async void OnNavigatedTo(System.Windows.Navigation.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;
            }

            try
            {
                ProgressService.SetProgressIndicator(true, "Loading camera...");
                if (Camera.IsCameraTypeSupported(CameraType.FrontFacing))
                {
                    await InitializeCamera(CameraSensorLocation.Front);
                }
                else
                {
                    MessageBox.Show("Your phone does not have a front facing camera for selfies. Back Camera is used");
                    await InitializeCamera(CameraSensorLocation.Back);
                }
                ProgressService.SetProgressIndicator(false);

                videoBrush.RelativeTransform = new CompositeTransform()
                {
                    CenterX  = 0.5,
                    CenterY  = 0.5,
                    Rotation = PhotoCaptureDevice.SensorLocation == CameraSensorLocation.Back
                        ? PhotoCaptureDevice.SensorRotationInDegrees
                        : -PhotoCaptureDevice.SensorRotationInDegrees,
                };

                videoBrush.SetSource(PhotoCaptureDevice);

                SetScreenButtonsEnabled(true);
                SetCameraButtonsEnabled(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("There was an error during the camera initialization. Please, try again: [{0}]", ex.Message));
            }
        }
Example #19
0
        private void RemoveOrRubbish(int count)
        {
            var helperList = new List <IMegaNode>(count);

            helperList.AddRange(ChildNodes.Where(n => n.IsMultiSelected));

            Task.Run(async() =>
            {
                WaitHandle[] waitEventRequests = new WaitHandle[count];

                int index = 0;

                foreach (var node in helperList)
                {
                    waitEventRequests[index] = new AutoResetEvent(false);
                    await node.RemoveAsync(true, (AutoResetEvent)waitEventRequests[index]);
                    index++;
                }

                WaitHandle.WaitAll(waitEventRequests);

                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false));

                if (this.CurrentDisplayMode == DriveDisplayMode.RubbishBin)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.MultiRemoveSucces_Title,
                            String.Format(AppMessages.MultiRemoveSucces, count),
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });
                }
                else
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.MultiMoveToRubbishBinSucces_Title,
                            String.Format(AppMessages.MultiMoveToRubbishBinSucces, count),
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });
                }
            });

            this.IsMultiSelectActive = false;
        }
Example #20
0
        private void MultipleRemoveItems(int count)
        {
            var helperList = new List <IOfflineNode>(count);

            helperList.AddRange(ChildNodes.Where(n => n.IsMultiSelected));

            Task.Run(async() =>
            {
                WaitHandle[] waitEventRequests = new WaitHandle[count];

                int index = 0;

                foreach (var node in helperList)
                {
                    waitEventRequests[index] = new AutoResetEvent(false);
                    await node.RemoveAsync(true, (AutoResetEvent)waitEventRequests[index]);
                    index++;
                }

                WaitHandle.WaitAll(waitEventRequests);

                String parentNodePath = Path.GetDirectoryName(this.FolderRootNode.NodePath);

                String sfoRootPath = Path.Combine(ApplicationData.Current.LocalFolder.Path,
                                                  AppResources.DownloadsDirectory.Replace("\\", ""));

                // Check if the previous folders of the path are empty and
                // remove from the offline and the DB on this case
                while (String.Compare(parentNodePath, sfoRootPath) != 0)
                {
                    var folderPathToRemove = parentNodePath;
                    parentNodePath         = ((new DirectoryInfo(parentNodePath)).Parent).FullName;

                    if (FolderService.IsEmptyFolder(folderPathToRemove))
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() => GoFolderUp());
                        FolderService.DeleteFolder(folderPathToRemove);
                        SavedForOffline.DeleteNodeByLocalPath(folderPathToRemove);
                    }
                }

                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false));

                Refresh();
            });

            this.IsMultiSelectActive = false;
        }
Example #21
0
        public async Task <bool> MultipleRemoveItems()
        {
            int count = ChildNodes.Count(n => n.IsMultiSelected);

            if (count < 1)
            {
                return(false);
            }

            if (this.CurrentDisplayMode == DriveDisplayMode.RubbishBin ||
                (this.CurrentDisplayMode == DriveDisplayMode.MultiSelect &&
                 this.PreviousDisplayMode == DriveDisplayMode.RubbishBin))
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.MultiSelectRemoveQuestion_Title,
                    String.Format(AppMessages.MultiSelectRemoveQuestion, count),
                    App.AppInformation,
                    MessageDialogButtons.OkCancel,
                    MessageDialogImage.RubbishBin);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveNode));
                    RemoveOrRubbish(count);
                };

                return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
            }
            else
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.MultiMoveToRubbishBinQuestion_Title,
                    String.Format(AppMessages.MultiMoveToRubbishBinQuestion, count),
                    App.AppInformation,
                    MessageDialogButtons.OkCancel,
                    MessageDialogImage.RubbishBin);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.NodeToTrash));
                    RemoveOrRubbish(count);
                };

                return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
            }
        }
Example #22
0
        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 folder link is well structured
            if (e.getErrorCode() == MErrorType.API_OK)
            {
                OnSuccesAction(api, request);
            }
            else
            {
                // Set the empty state and disable the app bar buttons
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false);
                    _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false);
                });

                switch (e.getErrorCode())
                {
                case MErrorType.API_EARGS:
                    if (_decryptionAlert)
                    {
                        ShowDecryptionKeyNotValidAlert(api, request);     //If the user have written the key
                    }
                    else
                    {
                        ShowFolderLinkNoValidAlert();     //Handle length or Key length no valid
                    }
                    break;

                case MErrorType.API_EINCOMPLETE:     //Link has not decryption key
                    ShowDecryptionAlert(api, request);
                    break;
                }
            }
        }
Example #23
0
        public async Task SaveForOffline(bool newStatus)
        {
            if (newStatus)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                          ProgressService.SetProgressIndicator(true, ProgressMessages.SaveForOffline));

                _node.IsSelectedForOffline = true;
                await _node.SaveForOffline();
            }
            else
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                          ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveFromOffline));

                _node.IsSelectedForOffline = false;
                await _node.RemoveForOffline();
            }

            Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false));
        }
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            this.api = api;

            this.ErrorString = e.getErrorString();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);

                if (apiErrorTimer != null)
                {
                    apiErrorTimer.Stop();
                }
            });

            switch (e.getErrorCode())
            {
            case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota
            case MErrorType.API_EOVERQUOTA:      // Storage overquota error
                Deployment.Current.Dispatcher.BeginInvoke(DialogService.ShowOverquotaAlert);

                // Stop all upload transfers
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               string.Format("Storage quota exceeded ({0}) - Canceling uploads", e.getErrorCode().ToString()));
                api.cancelTransfers((int)MTransferType.TYPE_UPLOAD);

                // Disable the "Camera Uploads" service if is enabled
                if (MediaService.GetAutoCameraUploadStatus())
                {
                    LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                                   string.Format("Storage quota exceeded ({0}) - Disabling CAMERA UPLOADS service", e.getErrorCode().ToString()));
                    MediaService.SetAutoCameraUpload(false);
                    SettingsService.SaveSetting(SettingsResources.CameraUploadsIsEnabled, false);
                }
                break;
            }
        }
Example #25
0
        public override void onRequestUpdate(MegaSDK api, MRequest request)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(true, String.Format(ProgressMessages.FetchingNodes,
                                                                         request.getTransferredBytes().ToStringAndSuffix(2)));
            });

            if (AppMemoryController.IsThresholdExceeded(75UL.FromMBToBytes()))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.MemoryLimitError_Title,
                        AppMessages.MemoryLimitError,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                    Application.Current.Terminate();
                });
            }
        }
Example #26
0
        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 (apiErrorTimer != null)
                {
                    apiErrorTimer.Stop();
                }
            });

            if (e.getErrorCode() != MErrorType.API_OK)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_ENOENT:     // E-mail unassociated with a MEGA account or Wrong password
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle, AppMessages.WrongEmailPasswordLogin,
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;

                case MErrorType.API_ETOOMANY:     // Too many failed login attempts
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle, AppMessages.AM_TooManyFailedLoginAttempts,
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;

                case MErrorType.API_EINCOMPLETE:     // Account not confirmed
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              new CustomMessageDialog(ErrorMessageTitle, AppMessages.AM_AccountNotConfirmed,
                                                                                      App.AppInformation, MessageDialogButtons.Ok).ShowDialog());
                    return;
                }
            }

            base.onRequestFinish(api, request, e);
        }
        private void onRequestFinishFolderLink(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);

                if (apiErrorTimer != null)
                {
                    apiErrorTimer.Stop();
                }
            });

            if (e.getErrorCode() == MErrorType.API_OK)
            {
                //If getFlag() returns true, the folder link key is invalid.
                if (request.getFlag())
                {
                    // First logout from the folder
                    api.logout();

                    // Set the empty state and disable the app bar buttons
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false);
                        _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false);
                    });

                    //If the user have written the key
                    if (_decryptionAlert)
                    {
                        ShowDecryptionKeyNotValidAlert(api, request);
                    }
                    else
                    {
                        ShowFolderLinkNoValidAlert();
                    }
                }
                else
                {
                    OnSuccesAction(api, request);
                }
            }
            else
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false);
                    _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false);
                });

                switch (e.getErrorCode())
                {
                case MErrorType.API_ETOOMANY:       // Taken down link and the link owner's account is blocked
                    ShowAssociatedUserAccountTerminatedFolderLinkAlert();
                    break;

                case MErrorType.API_ENOENT:         // Link not exists or has been deleted by user
                case MErrorType.API_EBLOCKED:       // Taken down link
                    ShowUnavailableFolderLinkAlert();
                    break;

                default:
                    ShowFolderLinkNoValidAlert();
                    break;
                }
            }
        }
Example #28
0
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            this.api = api;

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);
            });

            switch (e.getErrorCode())
            {
            case MErrorType.API_OK:
                if (ShowSuccesMessage)
                {
                    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));
                }
                break;

            case MErrorType.API_EGOINGOVERQUOTA:     // Not enough storage quota
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               string.Format("Not enough storage quota ({0})", e.getErrorCode().ToString()));
                UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(true));
                break;

            case MErrorType.API_EOVERQUOTA:     //Storage overquota error
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               string.Format("Storage quota exceeded ({0})", e.getErrorCode().ToString()));
                UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(false));
                break;

            default:
                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();
                        });
                    }
                }
                break;
            }
        }
Example #29
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);
                this._confirmAccountViewModel.ControlState = true;

                if (request.getType() == MRequestType.TYPE_QUERY_SIGNUP_LINK)
                {
                    switch (e.getErrorCode())
                    {
                    case MErrorType.API_OK:     // Valid and operative confirmation link
                        if (request.getFlag())  // Auto confirmed account.
                        {
                            ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title,
                                                       AppMessages.AlreadyConfirmedAccount);
                            break;
                        }
                        this._confirmAccountViewModel.Email = request.getEmail();
                        break;

                    case MErrorType.API_ENOENT:     // Already confirmed account
                        ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title,
                                                   AppMessages.AlreadyConfirmedAccount);
                        break;

                    case MErrorType.API_EINCOMPLETE:     // Incomplete confirmation link
                        ShowErrorMesageAndNavigate(AppMessages.ConfirmAccountFailed_Title,
                                                   AppMessages.AM_IncompleteConfirmationLink);
                        break;

                    case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota
                    case MErrorType.API_EOVERQUOTA:      // Storage overquota error
                        base.onRequestFinish(api, request, e);
                        break;

                    default:     // Other error
                        ShowDefaultErrorMessage(e);
                        break;
                    }
                }
                else if (request.getType() == MRequestType.TYPE_CONFIRM_ACCOUNT)
                {
                    switch (e.getErrorCode())
                    {
                    case MErrorType.API_OK:     // Successfull confirmation process
                        var customMessageDialog = new CustomMessageDialog(
                            SuccessMessageTitle, SuccessMessage,
                            App.AppInformation, MessageDialogButtons.Ok);

                        customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                                   OnSuccesAction(api, request);

                        customMessageDialog.ShowDialog();
                        break;

                    case MErrorType.API_ENOENT:     // Wrong password
                    case MErrorType.API_EKEY:       // Wrong password
                        new CustomMessageDialog(
                            AppMessages.WrongPassword_Title,
                            AppMessages.WrongPassword,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                        break;

                    case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota
                    case MErrorType.API_EOVERQUOTA:      // Storage overquota error
                        base.onRequestFinish(api, request, e);
                        break;

                    default:     // Other error
                        ShowDefaultErrorMessage(e);
                        break;
                    }
                }
            });
        }
Example #30
0
        public async void Download(TransferQueue transferQueue, string downloadPath = null)
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            if (AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return;
            }

            if (downloadPath == null)
            {
                if (!await FolderService.SelectDownloadFolder(this))
                {
                    return;
                }
                else
                {
                    downloadPath = AppService.GetSelectedDownloadDirectoryPath();
                }
            }

            OnUiThread(() => ProgressService.SetProgressIndicator(true, ProgressMessages.PrepareDownloads));

            // Extra check to try avoid null values
            if (String.IsNullOrWhiteSpace(downloadPath))
            {
                OnUiThread(() => ProgressService.SetProgressIndicator(false));
                await new CustomMessageDialog(AppMessages.SelectFolderFailed_Title,
                                              AppMessages.SelectFolderFailed, App.AppInformation,
                                              MessageDialogButtons.Ok).ShowDialogAsync();
                return;
            }

            // Check for illegal characters in the download path
            if (FolderService.HasIllegalChars(downloadPath))
            {
                OnUiThread(() => ProgressService.SetProgressIndicator(false));
                await new CustomMessageDialog(AppMessages.SelectFolderFailed_Title,
                                              String.Format(AppMessages.InvalidFolderNameOrPath, downloadPath),
                                              this.AppInformation).ShowDialogAsync();
                return;
            }

            if (!await CheckDownloadPath(downloadPath))
            {
                OnUiThread(() => ProgressService.SetProgressIndicator(false));
                return;
            }

            // If selected file is a folder then also select it childnodes to download
            if (this.IsFolder)
            {
                await RecursiveDownloadFolder(downloadPath, this);
            }
            else
            {
                await DownloadFile(downloadPath, this);
            }

            OnUiThread(() => ProgressService.SetProgressIndicator(false));

            // TODO Remove this global declaration in method
            App.CloudDrive.NoFolderUpAction = true;
        }