}//button register private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { RegisterLoginForm register = new RegisterLoginForm(); register.Show(); Close(); }
private void Form1_Load(object sender, EventArgs e) { if (!File.Exists(PathMS + "/Settings/chat.dat")) { MessageBox.Show("Login or register to continue.", "Not logged in"); RegisterLoginForm frm = new RegisterLoginForm(); frm.Show(); } else { SaveWriter save = new SaveWriter(PathMS + "/Settings/chat.dat"); save.Load(); string usr = save.GetItem("Username"); string pass = encryptpass.DecryptString(save.GetItem("Password"), "1cPOnaLrV2MusS4Cq3aU6dja"); Administrator = save.GetItemBool("Admin"); if (Administrator) { label1.Visible = true; } if (Administrator) { ReceiverJID = usr + "@" + XmppConnection.Server; usr = "******" + usr; } else { ReceiverJID = "Admin_" + usr + "@" + XmppConnection.Server; } //connection.Login(usr, pass); //connection.Connect(); connection.ConnectToXMPPIM(usr, pass); /* * XmppIm xmppim = new XmppIm("", "", ""); * xmppim;*/ //Debug.WriteLine(connection.GetXmppClient().Authenticated); //Debug.WriteLine(connection.IsConnected()); Debug.WriteLine("Connected as " + connection.GetXmppIm().Jid); connection.GetXmppIm().Message += Connection_Message; Debug.WriteLine("Size: " + connection.Rostersize()); connection.AddToRoster(ReceiverJID); connection.GetXmppIm().RequestSubscription(ReceiverJID); connection.ApproveRequest(ReceiverJID); connection.GetXmppIm().Status += Connection_Status; Debug.WriteLine("ReceiverJID: " + ReceiverJID); } /* * RegisterLoginForm frm = new RegisterLoginForm(); * frm.Show(); */ }
//register private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textBoxpass.Text)) { if (textBoxpass.Text.Equals(textBoxpassrepeat.Text)) { if (!string.IsNullOrWhiteSpace(textBoxuser.Text)) { try { pictureBoxLoading.Visible = true; panel1.Enabled = false; //zaregistruje sa klasicky pouzivatel Username = AppPrefix + textBoxuser.Text; Password = encrypt.EncryptText(textBoxpass.Text, "ZuhajoLafyNAYjCAw2VZfaYo"); XmppClient xmpp = new XmppClient(Server); xmpp.Connect(); Debug.WriteLine("Connected: " + xmpp.Connected + " Auth: " + xmpp.Authenticated + " JID: " + xmpp.Jid); xmpp.Register(RegistrationCallback); xmpp.Close(); xmpp.Dispose(); new Thread(() => { Thread.CurrentThread.IsBackground = true; Thread.Sleep(3000); try { XmppClient xmppa = new XmppClient(Server); xmppa.Connect(); Username = "******" + AppPrefix + textBoxuser.Text; Password = encrypt.EncryptText(textBoxpass.Text, "ZuhajoLafyNAYjCAw2VZfaYo"); xmppa.Register(RegistrationCallback); xmppa.Close(); this.Invoke((MethodInvoker) delegate { panel1.Enabled = true; pictureBoxLoading.Visible = false; MessageBox.Show("Registered! Login to continue"); RegisterLoginForm register = new RegisterLoginForm(); register.Show(); Close(); }); }catch (Exception ex) { Debug.WriteLine("" + ex); this.Invoke((MethodInvoker) delegate { panel1.Enabled = true; pictureBoxLoading.Visible = false; MessageBox.Show("Account exist or something is bad!", "Error to register a new account"); }); } }).Start(); } catch (Exception ex) { Debug.WriteLine("" + ex); MessageBox.Show("Account exist or something is bad!", "Error to register a new account"); panel1.Enabled = true; pictureBoxLoading.Visible = false; } } else { MessageBox.Show("Bad username"); } } else { MessageBox.Show("Passwords not equal", "Bad password"); } } else { MessageBox.Show("Bad Password"); } }//button register