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_PAYMENT_METHODS)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull get payment methods process
                    Tcs?.TrySetResult(request.getNumber());
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(0);
                    break;
                }
            }
        }
Exemplo n.º 2
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.º 3
0
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            switch (request.getType())
            {
            case MRequestType.TYPE_ACCOUNT_DETAILS:

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    accountDetails.TotalSpace      = request.getMAccountDetails().getStorageMax();
                    accountDetails.TotalSpaceSize  = accountDetails.TotalSpace.ToReadableSize();
                    accountDetails.TotalSpaceUnits = accountDetails.TotalSpace.ToReadableUnits();
                    accountDetails.UsedSpace       = request.getMAccountDetails().getStorageUsed();
                    accountDetails.CreateDataPoints();
                    accountDetails.AccountType = request.getMAccountDetails().getProLevel();

                    if (accountDetails.AccountType == MAccountType.ACCOUNT_TYPE_FREE)
                    {
                        accountDetails.IsFreeAccount   = true;
                        accountDetails.AccountTypeText = AppResources.AccountTypeFree;
                        accountDetails.AccountTypeUri  = new Uri("/Assets/Images/small_free" + ImageService.GetResolutionExtension() + ".png", UriKind.Relative);
                    }
                    else
                    {
                        switch (accountDetails.AccountType)
                        {
                        case MAccountType.ACCOUNT_TYPE_LITE:
                            accountDetails.AccountTypeText = AppResources.AccountTypeLite;
                            //accountDetails.AccountTypeUri = new Uri("/Assets/Images/small_free" + ImageService.GetResolutionExtension() + ".png", UriKind.Relative);
                            break;

                        case MAccountType.ACCOUNT_TYPE_PROI:
                            accountDetails.AccountTypeText = AppResources.AccountTypePro1;
                            accountDetails.AccountTypeUri  = new Uri("/Assets/Images/small_pro1" + ImageService.GetResolutionExtension() + ".png", UriKind.Relative);
                            break;

                        case MAccountType.ACCOUNT_TYPE_PROII:
                            accountDetails.AccountTypeText = AppResources.AccountTypePro2;
                            accountDetails.AccountTypeUri  = new Uri("/Assets/Images/small_pro2" + ImageService.GetResolutionExtension() + ".png", UriKind.Relative);
                            break;

                        case MAccountType.ACCOUNT_TYPE_PROIII:
                            accountDetails.AccountTypeText = AppResources.AccountTypePro3;
                            accountDetails.AccountTypeUri  = new Uri("/Assets/Images/small_pro3" + ImageService.GetResolutionExtension() + ".png", UriKind.Relative);
                            break;
                        }

                        accountDetails.IsFreeAccount = false;

                        DateTime date;
                        DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, 0);

                        // If there is a valid subscription get the renew time
                        if (request.getMAccountDetails().getSubscriptionStatus() == MSubscriptionStatus.SUBSCRIPTION_STATUS_VALID)
                        {
                            try
                            {
                                if (request.getMAccountDetails().getSubscriptionRenewTime() != 0)
                                {
                                    date = start.AddSeconds(Convert.ToDouble(request.getMAccountDetails().getSubscriptionRenewTime()));
                                }
                                else
                                {
                                    date = start.AddSeconds(Convert.ToDouble(request.getMAccountDetails().getProExpiration()));
                                }

                                accountDetails.SubscriptionRenewDate = date.ToString("dd-MM-yyyy");
                            }
                            catch (ArgumentOutOfRangeException) { /* Do nothing*/ }

                            accountDetails.SubscriptionCycle   = request.getMAccountDetails().getSubscriptionCycle();
                            accountDetails.IsValidSubscription = true;
                        }
                        // Else get the expiration time for the current PRO status
                        else
                        {
                            try
                            {
                                date = start.AddSeconds(Convert.ToDouble(request.getMAccountDetails().getProExpiration()));
                                accountDetails.ProExpirationDate = date.ToString("dd-MM-yyyy");
                            }
                            catch (ArgumentOutOfRangeException) { /* Do nothing*/ }

                            accountDetails.IsValidSubscription = false;
                        }
                    }

                    if (_getAccountDetailsFinish != null)
                    {
                        _getAccountDetailsFinish.Invoke(this, EventArgs.Empty);
                    }
                });

                break;

            case MRequestType.TYPE_CREDIT_CARD_QUERY_SUBSCRIPTIONS:
                accountDetails.CreditCardSubscriptions = request.getNumber();
                break;
            }
        }
Exemplo n.º 4
0
 public override void onRequestStart(MegaSDK api, MRequest request)
 {
     inviteActionType = (MContactRequestInviteActionType)request.getNumber();
     contactEmail     = request.getEmail();
     base.onRequestStart(api, request);
 }
Exemplo n.º 5
0
 public override void onRequestStart(MegaSDK api, MRequest request)
 {
     replyActionType = (MContactRequestReplyActionType)request.getNumber();
     base.onRequestStart(api, request);
 }