public override void onRequestStart(MegaSDK api, MRequest request)
        {
            //Get if transfers were paused (true) or resumed (false)
            _pause = request.getFlag();

            base.onRequestStart(api, request);
        }
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_MULTI_FACTOR_AUTH_CHECK)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull check multi-factor authentication process
                    if (Tcs != null)
                    {
                        Tcs.TrySetResult(request.getFlag() ?
                                         MultiFactorAuthStatus.Enabled :
                                         MultiFactorAuthStatus.Disabled);
                    }
                    break;

                default:     // Default error processing
                    if (Tcs != null)
                    {
                        Tcs.TrySetResult(MultiFactorAuthStatus.Unknown);
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_QUERY_RECOVERY_LINK)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successful reset
                    Tcs?.TrySetResult(request.getFlag() ? RecoverLinkType.Recovery : RecoverLinkType.ParkAccount);
                    break;

                case MErrorType.API_EEXPIRED:
                    Tcs?.TrySetResult(RecoverLinkType.Expired);
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(RecoverLinkType.Unknown);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_GET_ATTR_USER)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:         // Successfull get user attribute process
                case MErrorType.API_ENOENT:     // Attribute not exists yet but the value still be valid
                    if (Tcs != null)
                    {
                        Tcs.TrySetResult(request.getFlag());
                    }
                    break;

                default:     // Default error processing
                    if (Tcs != null)
                    {
                        Tcs.TrySetResult(false);
                    }
                    break;
                }
            }
        }
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            //Get if transfers were paused (true) or resumed (false)
            _pause = request.getFlag();

            if (this.PauseTransfersFinished != null)
            {
                this.PauseTransfersFinished.Invoke(this, EventArgs.Empty);
            }
        }
Exemplo n.º 6
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_FETCH_NODES)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull fetch nodes process
                    //If getFlag() returns true, the folder link key is invalid.
                    if (request.getFlag())
                    {
                        Tcs?.TrySetResult(DecryptionAlert ?
                                          FetchNodesResult.InvalidDecryptionKey :         // No valid decryption key
                                          FetchNodesResult.InvalidHandleOrDecryptionKey); // Handle length or Key length no valid
                    }

                    AccountService.GetUserData();
                    AccountService.GetAccountDetails();
                    AccountService.GetAccountAchievements();
                    Tcs?.TrySetResult(FetchNodesResult.Success);
                    break;

                case MErrorType.API_ETOOMANY:     // Taken down link and the link owner's account is blocked
                    Tcs?.TrySetResult(FetchNodesResult.AssociatedUserAccountTerminated);
                    return;

                case MErrorType.API_ENOENT:     // Link not exists or has been deleted by user
                case MErrorType.API_EBLOCKED:   // Taken down link
                    Tcs?.TrySetResult(FetchNodesResult.UnavailableLink);
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(FetchNodesResult.Unknown);
                    break;
                }
            }
        }
Exemplo n.º 7
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_QUERY_SIGNUP_LINK)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Valid and operative confirmation link.
                    this.EmailAddress = request.getEmail();
                    Tcs?.TrySetResult(request.getFlag() ?
                                      SignUpLinkType.AutoConfirmed : SignUpLinkType.Valid);
                    break;

                case MErrorType.API_EEXPIRED:     // Expired confirmation link.
                    Tcs?.TrySetResult(SignUpLinkType.Expired);
                    break;

                case MErrorType.API_ENOENT:     // Already confirmed account
                    Tcs?.TrySetResult(SignUpLinkType.AlreadyConfirmed);
                    break;

                case MErrorType.API_EINCOMPLETE:     // Incomplete confirmation link
                    Tcs?.TrySetResult(SignUpLinkType.Invalid);
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(SignUpLinkType.Unknown);
                    break;
                }
            }
        }
        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;
                }
            }
        }
Exemplo n.º 9
0
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            //Get if transfers were paused (true) or resumed (false)
            _pause = request.getFlag();

            ObservableCollection <TransferObjectModel> transfersList;

            switch (request.getNumber())
            {
            case (int)MTransferType.TYPE_DOWNLOAD:
                transfersList = App.MegaTransfers.Downloads;
                break;

            case (int)MTransferType.TYPE_UPLOAD:
                transfersList = App.MegaTransfers.Uploads;
                break;

            default:
                transfersList = App.MegaTransfers;
                break;
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var numTransfers = transfersList.Count;
                for (int i = 0; i < numTransfers; i++)
                {
                    var item = transfersList.ElementAt(i);
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.TransferedBytes < item.TotalBytes || item.TransferedBytes == 0)
                    {
                        switch (item.Status)
                        {
                        case TransferStatus.Downloading:
                        case TransferStatus.Uploading:
                        case TransferStatus.Queued:
                            {
                                if (_pause)
                                {
                                    item.Status = TransferStatus.Paused;
                                }
                                break;
                            }

                        case TransferStatus.Paused:
                            {
                                if (!_pause)
                                {
                                    item.Status = TransferStatus.Queued;
                                }
                                break;
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 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);
                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;
                    }
                }
            });
        }
        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 getFlag() returns true, the file link key is invalid.
                if (request.getFlag())
                {
                    if (_decryptionAlert)
                    {
                        ShowDecryptionKeyNotValidAlert(api, request);
                    }
                    else
                    {
                        ShowFileLinkNoValidAlert();
                    }
                }
                else
                {
                    OnSuccesAction(api, request);
                }
            }
            else
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_EARGS:
                    if (_decryptionAlert)
                    {
                        ShowDecryptionKeyNotValidAlert(api, request);
                    }
                    else
                    {
                        ShowFileLinkNoValidAlert();
                    }
                    break;

                case MErrorType.API_ETOOMANY:           // Taken down link and the link owner's account is blocked
                    ShowAssociatedUserAccountTerminatedFileLinkAlert();
                    break;

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

                case MErrorType.API_EINCOMPLETE:        // Link has not decryption key
                    ShowDecryptionAlert(api, request);
                    break;

                default:
                    ShowFileLinkNoValidAlert();
                    break;
                }
            }
        }
Exemplo n.º 12
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_GET_PUBLIC_NODE)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:
                    //If getFlag() returns true, the file link key is invalid.
                    if (request.getFlag())
                    {
                        if (DecryptionAlert)     // No valid decryption key
                        {
                            Tcs?.TrySetResult(GetPublicNodeResult.InvalidDecryptionKey);
                        }
                        else     // Handle length or Key length no valid
                        {
                            Tcs?.TrySetResult(GetPublicNodeResult.InvalidHandleOrDecryptionKey);
                        }
                    }

                    // Get public node was successfull
                    this.PublicNode = request.getPublicMegaNode();
                    Tcs?.TrySetResult(GetPublicNodeResult.Success);
                    return;

                case MErrorType.API_EARGS:
                    if (DecryptionAlert)     // No valid decryption key
                    {
                        Tcs?.TrySetResult(GetPublicNodeResult.InvalidDecryptionKey);
                    }
                    else     // Handle length or Key length no valid
                    {
                        Tcs?.TrySetResult(GetPublicNodeResult.InvalidHandleOrDecryptionKey);
                    }
                    return;

                case MErrorType.API_ETOOMANY:     // Taken down link and the link owner's account is blocked
                    Tcs?.TrySetResult(GetPublicNodeResult.AssociatedUserAccountTerminated);
                    return;

                case MErrorType.API_ENOENT:     // Link not exists or has been deleted by user
                case MErrorType.API_EBLOCKED:   // Taken down link
                    Tcs?.TrySetResult(GetPublicNodeResult.UnavailableLink);
                    break;

                case MErrorType.API_EINCOMPLETE:     // Link has not decryption key
                    Tcs?.TrySetResult(GetPublicNodeResult.NoDecryptionKey);
                    return;

                default:     // Unknown result, but not successful
                    Tcs?.TrySetResult(GetPublicNodeResult.Unknown);
                    return;
                }
            }
        }