public PhoneNumberViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _passwordBase = stateService.Password; stateService.Password = null; _authorizationForm = stateService.AuthorizationForm; stateService.AuthorizationForm = null; _secureValues = stateService.SecureValues; stateService.SecureValues = null; _secureType = stateService.SecureType; stateService.SecureType = null; _secureRequiredType = stateService.SecureRequiredType; stateService.SecureRequiredType = null; var user = CacheService.GetUser(new TLInt(StateService.CurrentUserId)); if (user != null && user.HasPhone) { CurrentPhone = user.Phone.ToString(); } _phoneNumberValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null; }
public EmailViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _passwordBase = stateService.Password; stateService.Password = null; _authorizationForm = stateService.AuthorizationForm; stateService.AuthorizationForm = null; _secureValues = stateService.SecureValues; stateService.SecureValues = null; _secureType = stateService.SecureType; stateService.SecureType = null; _secureRequiredType = stateService.SecureRequiredType; stateService.SecureRequiredType = null; var password = _passwordBase as TLPassword81; if (password != null) { var passwordSettings = password.Settings as TLPasswordSettings83; if (passwordSettings != null) { CurrentEmail = TLString.IsNullOrEmpty(passwordSettings.Email)? string.Empty : passwordSettings.Email.ToString(); } } _emailValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null; }
public EmailCodeViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _passwordBase = stateService.Password; stateService.Password = null; _authorizationForm = stateService.AuthorizationForm; stateService.AuthorizationForm = null; _secureValues = stateService.SecureValues; stateService.SecureValues = null; _secureType = stateService.SecureType; stateService.SecureType = null; _secureRequiredType = stateService.SecureRequiredType; stateService.SecureRequiredType = null; CurrentEmail = stateService.CurrentEmail; stateService.CurrentEmail = null; _emailValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null; _sentCode = stateService.SentEmailCode; stateService.SentEmailCode = null; Subtitle = GetSubtitle(); var length = _sentCode as ILength; CodeLength = length != null ? length.Length.Value : Constants.DefaultCodeLength; }
public PhoneNumberCodeViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _passwordBase = stateService.Password; stateService.Password = null; _authorizationForm = stateService.AuthorizationForm; stateService.AuthorizationForm = null; _secureValues = stateService.SecureValues; stateService.SecureValues = null; _secureType = stateService.SecureType; stateService.SecureType = null; _secureRequiredType = stateService.SecureRequiredType; stateService.SecureRequiredType = null; _phoneNumberValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null; _type = stateService.Type; stateService.Type = null; _nextType = stateService.NextType; stateService.NextType = null; Subtitle = GetSubtitle(); var length = _type as ILength; CodeLength = length != null ? length.Length.Value : Constants.DefaultCodeLength; Timeout = stateService.SendCallTimeout; ResendCodeVisibility = stateService.SendCallTimeout != null && stateService.SendCallTimeout.Value > 0 ? Visibility.Collapsed : Visibility.Visible; SuppressUpdateStatus = true; EventAggregator.Subscribe(this); PropertyChanged += (sender, args) => { if (Property.NameEquals(args.PropertyName, () => Code)) { NotifyOfPropertyChange(() => CanConfirm); if (!string.IsNullOrEmpty(Code) && Code.Length == CodeLength) { Confirm(); } } }; _callTimer.Tick += (sender, args) => { _timeCounter = Timeout == null? 0 : (int)(Timeout.Value - (DateTime.Now - _startTime).TotalSeconds); if (_timeCounter > 0) { #if DEBUG TimeCounterString = _timeCounter.ToString(CultureInfo.InvariantCulture); #endif if (_nextType is TLCodeTypeCall) { TimeCounterString = string.Format(AppResources.WeWillCallYou, TimeSpan.FromSeconds(TimeCounter).ToString(@"m\:ss")); } } else { _timeCounter = 0; if (_nextType is TLCodeTypeCall) { TimeCounterString = AppResources.TelegramDialedYourNumber; } HelpVisibility = Visibility.Visible; ResendCodeVisibility = Visibility.Visible; _callTimer.Stop(); } NotifyOfPropertyChange(() => TimeCounter); }; }
public override void DeserializeResponse(BinaryReader br) { Response = (TLSecureValue)ObjectUtils.DeserializeObject(br); }
public static string Convert(TLSecureValue secureValue) { var personalDetails = secureValue.Type as TLSecureValueTypePersonalDetails; if (personalDetails != null) { var rootObject = secureValue.Data.DecryptedData as PersonalDetailsRootObject; if (rootObject != null) { return(rootObject.ToString( GenderToStringConverter.Convert, x => { var country = CountryUtils.GetCountryByCode(x); return country != null ? country.Name : null; })); } } var passport = secureValue.Type as TLSecureValueTypePassport; if (passport != null) { if (secureValue.Data.DecryptedData != null) { return(secureValue.Data.DecryptedData.ToString()); } } var driverLicence = secureValue.Type as TLSecureValueTypeDriverLicense; if (driverLicence != null) { if (secureValue.Data.DecryptedData != null) { return(secureValue.Data.DecryptedData.ToString()); } } var identityCard = secureValue.Type as TLSecureValueTypeIdentityCard; if (identityCard != null) { if (secureValue.Data.DecryptedData != null) { return(secureValue.Data.DecryptedData.ToString()); } } var internalPassport = secureValue.Type as TLSecureValueTypeInternalPassport; if (internalPassport != null) { if (secureValue.Data.DecryptedData != null) { return(secureValue.Data.DecryptedData.ToString()); } } var address = secureValue.Type as TLSecureValueTypeAddress; if (address != null) { var rootObject = secureValue.Data.DecryptedData as ResidentialAddressRootObject; if (rootObject != null) { return(rootObject.ToString(x => { var country = CountryUtils.GetCountryByCode(x); return country != null ? country.Name : null; })); } } var utilityBill = secureValue.Type as TLSecureValueTypeUtilityBill; if (utilityBill != null) { return(AppResources.PassportDocuments); } var bankStatement = secureValue.Type as TLSecureValueTypeBankStatement; if (bankStatement != null) { return(AppResources.PassportDocuments); } var rentalAgreement = secureValue.Type as TLSecureValueTypeRentalAgreement; if (rentalAgreement != null) { return(AppResources.PassportDocuments); } var passportRegistration = secureValue.Type as TLSecureValueTypePassportRegistration; if (passportRegistration != null) { return(AppResources.PassportDocuments); } var temporaryRegistration = secureValue.Type as TLSecureValueTypeTemporaryRegistration; if (temporaryRegistration != null) { return(AppResources.PassportDocuments); } var phone = secureValue.Type as TLSecureValueTypePhone; if (phone != null) { var plainData = secureValue.PlainData as TLSecurePlainPhone; if (plainData != null && !TLString.IsNullOrEmpty(plainData.Phone)) { return(plainData.Phone.ToString().StartsWith("+") ? plainData.Phone.ToString() : "+" + plainData.Phone); } } var email = secureValue.Type as TLSecureValueTypeEmail; if (email != null) { var plainData = secureValue.PlainData as TLSecurePlainEmail; if (plainData != null && !TLString.IsNullOrEmpty(plainData.Email)) { return(plainData.Email.ToString()); } } return(null); }