private async Task <Response <T> > ProcessCaptcha <T>(Response <T> errorResponse) { var response = errorResponse; while (true) { var enterCaptcha = new EnterCaptcha(errorResponse.Error.CaptchaImg); if (await enterCaptcha.ShowAsync() == ContentDialogResult.Primary) { string captcha = String.IsNullOrWhiteSpace(enterCaptcha.Captcha) ? "empty" : enterCaptcha.Captcha; response = await _inTouch.SendCaptcha <T>(captcha, response.Error); if (response.IsError && response.Error.Code == 14) { return(await ProcessCaptcha(response)); } else { return(response); } } else { return(response); } } }
public async Task <string> GetCaptchaUserInput(string captchaImg) { #if WINDOWS_UWP return(null); #else var enterCaptcha = new EnterCaptcha(captchaImg); if (await enterCaptcha.ShowAsync() == ContentDialogResult.Primary) { return(String.IsNullOrWhiteSpace(enterCaptcha.Captcha) ? "empty" : enterCaptcha.Captcha); } else { return(null); } #endif }
private void InitializeServices() { if (!_isInitialized) { Helpers.CoreHelper.LockOrientation(); Helpers.VKHelper.CaptchaHandler = async(request, callback) => { await rootVisual.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var captcha = new EnterCaptcha(request.CaptchaURL); if (await captcha.ShowAsync() == ContentDialogResult.Primary) { callback(new VKCaptchaResponse(request) { IsCanceled = false, UserResponse = captcha.Captcha }); } else { callback(new VKCaptchaResponse(request) { IsCanceled = true, UserResponse = "" }); } }); }; Messenger.Default.Register <NavigateToPageMessage>(this, async message => { await rootVisual.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { rootVisual.CommonState = ChromeFrame.CommonStates.Normal; if (message.Operation == NavigationType.New) { var targerType = GetPageTypeFromName(message.Page); if (targerType == rootVisual.CurrentSourcePageType && message.Parameter == null) { return; } NavigationService.Navigate(targerType.Name, message.Parameter); } else if (message.Operation == NavigationType.GoBack && rootVisual.CanGoBack) { NavigationService.GoBack(); } else if (message.Operation == NavigationType.GoForward && rootVisual.CanGoForward) { NavigationService.GoForward(); } else if (message.Operation == NavigationType.NewClear) { var targerType = GetPageTypeFromName(message.Page); if (targerType == rootVisual.CurrentSourcePageType && message.Parameter == null) { return; } NavigationService.Navigate(targerType.Name, message.Parameter); NavigationService.ClearHistory(); } }); }); HardwareButtons.BackPressed += (s, args) => { if (CancelGoBack) { return; } if (rootVisual.CommonState == ChromeFrame.CommonStates.MenuOpened) { rootVisual.CommonState = ChromeFrame.CommonStates.Normal; args.Handled = true; } else if (rootVisual.CanGoBack) { args.Handled = true; rootVisual.GoBack(); } }; Helpers.ServiceHelper.PlayerService.Initialize(); _isInitialized = true; } }