コード例 #1
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;
                            }
                        });
                    }
                }
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: vrosnet/windowsphone
        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;
            }
        }
コード例 #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_GET_ATTR_USER &&
                request.getParamType() == (int)MUserAttrType.USER_ATTR_PWD_REMINDER)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull get user attribute process
                    Tcs?.TrySetResult(request.getAccess() == 1);
                    break;

                case MErrorType.API_ENOENT: // User attribute is not set yet
                default:                    // Default error processing
                    Tcs?.TrySetResult(false);
                    break;
                }
            }
        }
コード例 #4
0
        public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            switch (e.getErrorCode())
            {
            case MErrorType.API_EINCOMPLETE:
                if (request.getType() == MRequestType.TYPE_LOGOUT &&
                    request.getParamType() == (int)MErrorType.API_ESSL)
                {
                    if (SSLCertificateAlertDisplayed)
                    {
                        break;
                    }

                    SSLCertificateAlertDisplayed = true;
                    UiService.OnUiThread(async() =>
                    {
                        var result = await DialogService.ShowSSLCertificateAlert();
                        SSLCertificateAlertDisplayed = false;
                        switch (result)
                        {
                        // "Retry" button
                        case ContentDialogResult.Primary:
                            api.reconnect();
                            break;

                        // "Open browser" button
                        case ContentDialogResult.Secondary:
                            await Launcher.LaunchUriAsync(
                                new Uri(ResourceService.AppResources.GetString("AR_MegaUrl"),
                                        UriKind.RelativeOrAbsolute));
                            break;

                        // "Ignore" or "Close" button
                        case ContentDialogResult.None:
                        default:
                            api.setPublicKeyPinning(false);
                            api.reconnect();
                            break;
                        }
                    });
                }
                break;

            case MErrorType.API_ESID:
                AppService.LogoutActions();

                // Show the login page with the corresponding navigation parameter
                UiService.OnUiThread(() =>
                {
                    NavigateService.Instance.Navigate(typeof(LoginAndCreateAccountPage), true,
                                                      NavigationObject.Create(typeof(MainViewModel), NavigationActionType.API_ESID));
                });
                break;
            }
        }
コード例 #5
0
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            if (request.getType() == MRequestType.TYPE_GET_ATTR_USER)
            {
                switch (request.getParamType())
                {
                case (int)MUserAttrType.USER_ATTR_FIRSTNAME:
                    Deployment.Current.Dispatcher.BeginInvoke(() => _megaContact.FirstName = request.getText());
                    break;

                case (int)MUserAttrType.USER_ATTR_LASTNAME:
                    Deployment.Current.Dispatcher.BeginInvoke(() => _megaContact.LastName = request.getText());
                    break;
                }
            }
        }
コード例 #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_GET_ATTR_USER &&
                request.getParamType() == (int)MUserAttrType.USER_ATTR_AVATAR)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull get user avatar process
                    Tcs?.TrySetResult(true);
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(false);
                    break;
                }
            }
        }