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;
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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 override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            _flags = GetObject <TLInt>(bytes, ref position);
            Type   = GetObject <TLSecureValueTypeBase>(bytes, ref position);

            return(this);
        }
        public static string Convert(TLSecureValueTypeBase value)
        {
            string caption;

            if (value != null && _dict.TryGetValue(value.GetType(), out caption))
            {
                return(caption);
            }

            return(null);
        }
Beispiel #6
0
        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 static bool IsValidType(TLSecureValueTypeBase type)
 {
     return(type is TLSecureValueTypePhone);
 }