Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        private void Btn_login_Click(object sender, EventArgs e)
        {
            //Toast.MakeText(this.Context, "æÑæÏ  ÇäÌÇã ÔÏ", ToastLength.Short).Show();
            var formIsValid = true;

            if (txt_email.Text == "")
            {
                formIsValid     = false;
                txt_email.Error = Resources.GetString(Resource.String.txt_email_error);
            }

            if (txt_pass.Text == "")
            {
                formIsValid    = false;
                txt_pass.Error = Resources.GetString(Resource.String.txt_pass_error);
            }


            if (formIsValid)
            {
                if (_userInfo != null)
                {
                    if (_userInfo.Email == txt_email.Text && _userInfo.Pass == txt_pass.Text)
                    {
                        _userInfo.IsLogin = true;

                        OnLoginComplete.Invoke(this, _userInfo);
                        Dialog.Dismiss();
                    }
                }

                txt_pass_error.Visibility = ViewStates.Visible;
                txt_pass_error.Text       = Resources.GetString(Resource.String.pass_or_email_invalid);
            }
        }
Exemple #2
0
        public void HandleMessage(string messageFromServer)
        {
            var messages = messageFromServer.Split(new[] { "<<EOFS>>" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var message in messages)
            {
                if (message.Length < 7)
                {
                    continue;
                }
                XDocument xDoc = null;
                try
                {
                    xDoc = XDocument.Parse(message);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                var rootName = xDoc?.Root?.Name.ToString();
                switch (rootName)
                {
                case "stroke":
                    OnStrokeRecieved?.Invoke(XmlConverter.GetStroke(xDoc));
                    break;

                case "message":
                    OnMessageRecieved?.Invoke(XmlConverter.GetMessage(xDoc));
                    break;

                case "new_user":
                    OnUserConnected?.Invoke(XmlConverter.GetUser(xDoc));
                    break;

                case "user_logout":
                    OnUserLogout?.Invoke(XmlConverter.GetUser(xDoc));
                    break;

                case "users_list":
                    OnUsersListReceived?.Invoke(XmlConverter.GetUsers(xDoc));
                    break;

                case "login_response":
                    var user = XmlConverter.GetAuthResult(xDoc);
                    if (string.IsNullOrEmpty(user))
                    {
                        OnLoginFailure?.Invoke();
                    }
                    else
                    {
                        OnLoginComplete?.Invoke(user);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemple #3
0
        private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            string json = Encoding.UTF8.GetString(e.Result);

            statusReader            = JsonConvert.DeserializeObject <List <StatusReader> >(json);
            StatusReader.log_status = statusReader[0].u_status;
            OnLoginComplete.Invoke(this, new OnLoginDialogEventArgs(etlogin.Text, etpassword.Text));
        }
Exemple #4
0
 private void XmppOnOnAuthError(object sender, Element element)
 {
     if (OnLoginComplete != null)
     {
         OnLoginComplete.Invoke(this, LoginResults.Failure);
     }
     Trace.WriteLine("[XMPP]AuthError: Closing...");
     Xmpp.Close();
 }
Exemple #5
0
    public void Login(OnLoginComplete oLC)
    {
        if (loginStatus != IdentityStatus.NOT_STARTED)
        {
            return;
        }

        onLoginComplete = oLC;

        Login();
    }
 public void OnAuthCompleted(GoogleSignInResult result)
 {
     if (result.IsSuccess)
     {
         GoogleSignInAccount accountt = result.SignInAccount;
         OnLoginComplete?.Invoke(new User()
         {
             Email   = accountt.Email,
             Picture = accountt.PhotoUrl?.ToString()
         }, string.Empty);
     }
     else
     {
         OnLoginComplete?.Invoke(null, "An error occured!");
     }
 }
Exemple #7
0
        public async void DoLogin(object sender, EventArgs args)
        {
            if (BindingContext is MediaContent)
            {
                var context = BindingContext as MediaContent;
                context.ChannelLogin.Execute(context.SelectedChannel);
                OnLoginComplete?.Invoke(this, true);
            }
            else if (BindingContext is ViewModel.Account)
            {
                var context = BindingContext as ViewModel.Account;
                var success = await context.PerformChannelLogin(context.SelectedChannel);

                OnLoginComplete?.Invoke(this, success);
            }
        }
Exemple #8
0
        private void XmppOnOnLogin(object sender)
        {
            myPresence.Type = PresenceType.available;
            myPresence.Show = ShowType.chat;
            MucManager      = new MucManager(Xmpp);
            Jid room = new Jid("lobby@conference." + Host);

            MucManager.AcceptDefaultConfiguration(room);
            //MucManager.JoinRoom(room,Username,Password,false);
            Me = new NewUser(Xmpp.MyJID);
            Me.SetStatus(UserStatus.Online);
            Xmpp.PresenceManager.Subscribe(Xmpp.MyJID);
            if (OnLoginComplete != null)
            {
                OnLoginComplete.Invoke(this, LoginResults.Success);
            }
        }
        /// <summary>
        /// Method for invoking login event
        /// </summary>
        /// <param name="context"></param>
        /// <param name="username"></param>
        /// <param name="firstname"></param>
        /// <param name="pic"></param>
        /// <param name="isLogged"></param>
        public static void Trigger(Context context, string username, string firstname, byte[] pic, bool isLogged)
        {
            // Set a timer to delay the execution til the flip is triggered
            Timer delayedTimer = new Timer
            {
                Interval = 1500,
                Enabled  = true
            };

            delayedTimer.Start();

            delayedTimer.Elapsed += (object sender, ElapsedEventArgs e) =>
            {
                delayedTimer.Stop();
                OnLoginComplete.Invoke(context, new OnLoginEventArgs(username, firstname, pic, isLogged));
                // Dispose time since it will no longer be used.
                delayedTimer.Dispose();
            };
        }
        private void Btnlogin_Click(object sender, EventArgs e)
        {
            WebClient           webClient  = new WebClient();
            Uri                 uri        = new Uri(URLAddresses.LOGIN_PHP);
            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("Login", etlogin.Text);
            parameters.Add("Password", etpassword.Text);

            byte[] response   = webClient.UploadValues(uri, parameters);
            string userStatus = Encoding.UTF8.GetString(response);

            if (userStatus.Contains(Help.TRUE))
            {
                UserAuthority.isLogged = true;
            }
            else
            {
                UserAuthority.isLogged = false;
            }

            if (UserAuthority.isLogged)
            {
                string id      = "";
                int    index   = userStatus.IndexOf(Help.TRUE);
                int    bracket = userStatus.IndexOf(Help.SQUARE_BRACKET);

                for (int i = 0; i < index; i++)
                {
                    UserAuthority.nick += userStatus[i];
                }
                for (int i = index + Help.TRUE.Length; i < bracket; i++)
                {
                    id += userStatus[i];
                }
                UserAuthority.id = Convert.ToInt16(id);
                Help.JSON        = userStatus.Remove(0, 12);
            }
            OnLoginComplete.Invoke(this, new OnLoginDialogEventArgs());
            this.Dismiss();
        }
Exemple #11
0
        /// <summary>
        /// The xmpp on on iq.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="iq">
        /// The iq.
        /// </param>
        private void XmppOnOnIq(object sender, IQ iq)
        {
            if (iq.Error != null && iq.Error.Code == ErrorCode.NotAllowed)
            {
                if (OnLoginComplete != null)
                {
                    OnLoginComplete.Invoke(this, LoginResults.Failure);
                }
            }
            if (iq.Type == IqType.result)
            {
                if (iq.Vcard != null)
                {
                    //var f = this.Friends.AsParallel().FirstOrDefault(x => x.FullUserName == iq.From.Bare);
                    //if (f != null)
                    //{
                    //    var email = DatabaseHandler.GetUser(f.FullUserName);
                    //    if (string.IsNullOrWhiteSpace(email))
                    //    {
                    //        var s =
                    //            iq.Vcard.GetEmailAddresses().FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.UserId));
                    //        if (s != null)
                    //        {
                    //            f.Email = s.UserId;
                    //            DatabaseHandler.AddUser(f.FullUserName, f.Email);
                    //        }
                    //    }
                    //    else
                    //    {
                    //        f.Email = email;
                    //    }
                    //}

                    if (this.OnDataReceived != null)
                    {
                        this.OnDataReceived.Invoke(this, DataRecType.FriendList, this.Friends);
                    }
                }
            }
        }
Exemple #12
0
        private void XmppOnOnIq(object sender, IQ iq)
        {
            if (iq.Error != null && iq.Error.Code == ErrorCode.NotAllowed)
            {
                if (OnLoginComplete != null)
                {
                    OnLoginComplete.Invoke(this, LoginResults.Failure);
                }
            }
            if (iq.Type == IqType.result)
            {
                if (iq.Vcard != null)
                {
                    var f = Friends.AsParallel().SingleOrDefault(x => x.User.Bare == iq.From.Bare);
                    if (f != null)
                    {
                        var email = DatabaseHandler.GetUser(f.User.Bare);
                        if (String.IsNullOrWhiteSpace(email))
                        {
                            var s = iq.Vcard.GetEmailAddresses().SingleOrDefault(x => !String.IsNullOrWhiteSpace(x.UserId));
                            if (s != null)
                            {
                                f.Email = s.UserId;
                                DatabaseHandler.AddUser(f.User.Bare, f.Email);
                            }
                        }
                        else
                        {
                            f.Email = email;
                        }
                    }

                    if (OnDataRecieved != null)
                    {
                        OnDataRecieved.Invoke(this, DataRecType.FriendList, Friends);
                    }
                }
            }
        }