Exemplo n.º 1
0
        private void on_saveAccountButton_clicked()
        {
            JID jid = null;

            if (String.IsNullOrEmpty(m_LoginLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login may not be empty.");
            }
            else if (!JID.TryParse(m_LoginLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(new JID(m_LoginLineEdit.Text).User))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(m_PasswordLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Password may not be empty");
            }
            else
            {
                var            accountInfo = new AccountInfo(jid.User, jid.Server, m_PasswordLineEdit.Text, "Synapse");
                AccountService service     = ServiceManager.Get <AccountService>();
                service.AddAccount(accountInfo);
            }
        }
Exemplo n.º 2
0
        void on_m_JoinChatButton_clicked()
        {
            Account selectedAccount = Gui.ShowAccountSelectMenu(m_JoinChatButton);

            if (selectedAccount != null)
            {
                JID    jid  = null;
                string nick = (!String.IsNullOrEmpty(mucNicknameLineEdit.Text)) ? mucNicknameLineEdit.Text : selectedAccount.ConferenceManager.DefaultNick;
                if (JID.TryParse(String.Format("{0}@{1}/{2}", mucRoomLineEdit.Text, mucServerLineEdit.Text, nick), out jid))
                {
                    if (!String.IsNullOrEmpty(jid.User) && !String.IsNullOrEmpty(jid.Server))
                    {
                        try {
                            selectedAccount.JoinMuc(jid, mucPasswordLineEdit.Text);
                        } catch (UserException ex) {
                            QMessageBox.Critical(this.TopLevelWidget(), "Synapse Error", ex.Message);
                        }
                    }
                    else
                    {
                        QMessageBox.Critical(null, "Synapse", "Invalid JID");
                    }
                }
                else
                {
                    QMessageBox.Critical(this.TopLevelWidget(), "Synapse Error", "Invalid conference room");
                }
            }
        }
Exemplo n.º 3
0
        void HandleAddAccountButtonClicked()
        {
            bool error = false;
            JID  jid   = null;

            if (!JID.TryParse(jidLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID is invalid");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.User))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a username");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.Server))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a server");
                error = true;
            }
            else if (passwordLineEdit.Text.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Password may not be blank");
                error = true;
            }
            else if (resourceComboBox.CurrentText.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Resource may not be blank");
                error = true;
            }

            if (error)
            {
                return;
            }

            var accountInfo = new AccountInfo(jid.User, jid.Server, passwordLineEdit.Text, resourceComboBox.CurrentText);

            accountInfo.AutoConnect = autoConnectCheckBox.Checked;
            ServiceManager.Get <AccountService>().AddAccount(accountInfo);

            base.Accept();
        }
Exemplo n.º 4
0
        public override void Accept()
        {
            bool error = false;
            JID  jid   = null;

            if (!JID.TryParse(jidLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID is invalid");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.User))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a username");
                error = true;
            }
            else if (String.IsNullOrEmpty(jid.Server))
            {
                QMessageBox.Critical(this, "Problem saving account", "JID must have a server");
                error = true;
            }
            else if (passwordLineEdit.Text.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Password may not be blank");
                error = true;
            }
            else if (resourceCombo.CurrentText.Trim() == String.Empty)
            {
                QMessageBox.Critical(this, "Problem saving account", "Resource may not be blank");
                error = true;
            }

            if (error)
            {
                return;
            }

            m_AccountInfo.User     = jid.User;
            m_AccountInfo.Domain   = jid.Server;
            m_AccountInfo.Password = passwordLineEdit.Text;
            m_AccountInfo.Resource = resourceCombo.CurrentText;

            m_AccountInfo.ConnectServer = serverLineEdit.Text;
            m_AccountInfo.ConnectPort   = portSpinBox.Value;

            m_AccountInfo.AutoConnect = autoConnectCheckBox.Checked;

            switch (comboBox.CurrentIndex)
            {
            case 0:
                m_AccountInfo.ProxyType = ProxyType.System;
                break;

            case 1:
                m_AccountInfo.ProxyType = ProxyType.None;
                break;

            case 2:
                m_AccountInfo.ProxyType = ProxyType.HTTP;
                break;

            case 3:
                m_AccountInfo.ProxyType = ProxyType.SOCKS4;
                break;

            case 4:
                m_AccountInfo.ProxyType = ProxyType.SOCKS5;
                break;
            }
            m_AccountInfo.ProxyHost     = proxyHostLineEdit.Text;
            m_AccountInfo.ProxyPort     = proxyPortSpinBox.Value;
            m_AccountInfo.ProxyUsername = proxyUserLineEdit.Text;
            m_AccountInfo.ProxyPassword = proxyPassLineEdit.Text;

            ServiceManager.Get <AccountService>().SaveAccounts();

            base.Accept();
        }