Esempio n. 1
0
LoginForm::LoginForm( QGraphicsItem* parent, Qt::WindowFlags wFlags )
    : Overlay( parent, wFlags )
    , m_usernameEdit( new Plasma::LineEdit( this ) )
    , m_passwordEdit( new Plasma::LineEdit( this ) )
    , m_loginButton( new Plasma::PushButton( this ) )
    , m_busyWidget( new Plasma::BusyWidget( this ) )
    , m_usernameLabel( new Plasma::Label( this ) )
{
    m_usernameEdit->nativeWidget()->setClickMessage( i18nc( "The name of the user", "Username" ) );
    m_passwordEdit->nativeWidget()->setClickMessage( i18n( "Password" ) );
    m_passwordEdit->nativeWidget()->setPasswordMode( true );
    m_loginButton->setIcon( KIcon( "network-connect" ) );
    m_loginButton->setText( i18n( "Login" ) );
    m_loginButton->setEnabled( false );

    m_busyWidget->hide();
    m_usernameLabel->setText( i18n( "Not Logged In" ) );

    QGraphicsLinearLayout* layout1 = new QGraphicsLinearLayout( m_contentLayout );
    layout1->addItem( m_busyWidget );
    layout1->addItem( m_usernameLabel );

    m_contentLayout->addItem( layout1 );
    m_contentLayout->addItem( m_usernameEdit );
    m_contentLayout->addItem( m_passwordEdit );
    m_contentLayout->addItem( m_loginButton );

    connect( m_loginButton, SIGNAL( clicked() ), SLOT( doLogin() ) );
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(providerInitialized()), SLOT(initDone()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(failedToInitialize()), SLOT(initFailed()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(loggedIn()), SLOT(loginDone()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(loginFailed()), SLOT(loginFailed()));

    initialize();
}
Esempio n. 2
0
CLogin::CLogin(QWidget *parent) :
    QDialog(parent)
{
    QGridLayout* grid = new QGridLayout;
    grid->addWidget(new QLabel("用户名:"), 0, 0);
    grid->addWidget(_username = new QLineEdit, 0, 1);
    grid->addWidget(new QLabel("密码:"), 1, 0);
    grid->addWidget(_password = new QLineEdit, 1, 1);

    QPushButton* buttonOK = new QPushButton("登录");
    QPushButton* buttonClose = new QPushButton("关闭");
    QHBoxLayout* hBox = new QHBoxLayout;
    hBox->addStretch(1);
    hBox->addWidget(buttonOK);
    hBox->addWidget(buttonClose);

    QVBoxLayout* vLayout = new QVBoxLayout;
    vLayout->addLayout(grid);
    vLayout->addLayout(hBox);

    QGridLayout* layout = new QGridLayout;
    layout->addLayout(vLayout, 1, 1);
    layout->setColumnStretch(0, 1);
    layout->setColumnStretch(2, 1);
    layout->setRowStretch(0, 1);
    layout->setRowStretch(2, 1);

    setLayout(layout);

    _password->setEchoMode(QLineEdit::Password);

    connect(buttonOK, SIGNAL(clicked()), this, SLOT(doLogin()));
    connect(buttonClose, SIGNAL(clicked()), this, SLOT(reject()));
}
Esempio n. 3
0
void LoginForm::newAccountLoginCB(std::pair<gcString, gcString> &info)
{
	ASSERT_UITHREAD();

	gcString username = info.first;
	gcString cookie = info.second;

	if (cookie.empty())
		return;

	if (username.size() == 0 || cookie.size() == 0)
	{
		newAccountLoginError("Invalid data returned from auto login.");
		return;
	}

	if (m_pNewAccount)
		m_pNewAccount->EndModal(0);

	m_tbUsername->SetValue(username);
	m_tbPassword->SetValue(cookie);

	m_tbPasswordDisp->Show(false);
	m_tbPassword->Show();
	Layout();

	doLogin(username, cookie);
}
Esempio n. 4
0
void LoginForm::onChar(wxKeyEvent& event)
{
	if (event.m_keyCode == WXK_TAB)
	{
		processTab(!event.ShiftDown(), event.GetId());
	}
	else
	{
		if (event.GetId() == m_cbRemPass->GetId())
		{
			if (event.m_keyCode == WXK_RETURN)
				doLogin();
			else if (event.m_keyCode == ' ')
				m_cbRemPass->SetValue(!m_cbRemPass->GetValue());
		}

		if (event.GetKeyCode() == WXK_CONTROL_A)
		{
			if (event.GetId() == m_tbPassword->GetId())
				m_tbPassword->SelectAll();
			else if (event.GetId() == m_tbUsername->GetId())
				m_tbUsername->SelectAll();
		}

		event.Skip();
	}
}
Esempio n. 5
0
int LoginForm::exec()
{
	if(isAutoLogin->checkState() == Qt::Checked)
		return doLogin();
	else
		return QDialog::exec();
}
Esempio n. 6
0
void LoginForm::autoLogin()
{
	char* user = nullptr;
	char* pass = nullptr;

	try
	{
		UserCoreGetLoginFN* getLogin = (UserCoreGetLoginFN*)UserCore::FactoryBuilderUC(USERCORE_GETLOGIN);

		if (!getLogin)
			throw gcException();

		getLogin(&user, &pass);

		if (user && pass)
		{
			m_tbUsername->SetValue(user);
			m_tbPassword->SetValue(pass);

			m_tbPasswordDisp->Show(false);
			m_tbPassword->Show();
			Layout();

			m_bAutoLogin = true;
			doLogin();
		}
	}
	catch (gcException &except)
	{
		Msg(gcString("Auto Login Failed: {0}\n", except));
	}

	safe_delete(user);
	safe_delete(pass);
}
Esempio n. 7
0
void LoginForm::doLogin()
{
	gcString user((const wchar_t*)m_tbUsername->GetValue().c_str());
	gcString pass((const wchar_t*)m_tbPassword->GetValue().c_str());

	doLogin(user, pass);
}
Esempio n. 8
0
void MainWindow::instanceActivated ( QModelIndex index )
{
	if(!index.isValid())
		return;
	Instance * inst = (Instance *) index.data(InstanceModel::InstancePointerRole).value<void *>();
	doLogin(inst->id());
}
Esempio n. 9
0
	Private(LastFmSettings* p) :
		page_(p),
		widget_(new QWidget),
		ui(new Ui::LastFmSettings)
	{
		ui->setupUi(widget_);
		QObject::connect(ui->pb_authentication, SIGNAL(clicked()), page_, SIGNAL(doLogin()));
	}
Esempio n. 10
0
int main(int argc, char **argv) {
    UdiRootConfig udiConfig;
    struct options config;
    ImageGwState *imgGw = NULL;

    memset(&udiConfig, 0, sizeof(UdiRootConfig));
    memset(&config, 0, sizeof(struct options));
    curl_global_init(CURL_GLOBAL_ALL);

    if (parse_UdiRootConfig(CONFIG_FILE, &udiConfig, UDIROOT_VAL_ALL) != 0) {
        fprintf(stderr, "FAILED to parse udiRoot configuration.\n");
        exit(1);
    }

    if (parse_options(argc, argv, &config, &udiConfig) != 0) {
        fprintf(stderr, "FAILED to parse command line options.\n");
        exit(1);
    }

    if (config.mode == MODE_LOGIN) {
        return doLogin();
    }

    /* get local copy of gateway urls */
    size_t nGateways = udiConfig.gwUrl_size;
    char **gateways = (char **) malloc(sizeof(char *) * nGateways);
    size_t idx = 0;
    for (idx = 0 ; idx < nGateways; idx++) {
        gateways[idx] = strdup(udiConfig.gwUrl[idx]);
    }

    /* seed our shuffle */
    srand(getpid() ^ time(NULL));

    /* shuffle the list in random order */
    for (idx = 0; idx < nGateways && nGateways - idx - 1 > 0; idx++) {
        size_t r = rand() % (nGateways - idx);
        char *tmp = gateways[idx];
        gateways[idx] = gateways[idx + r];
        gateways[idx + r] = tmp;
    }

    for (idx = 0; idx < nGateways; idx++) {
        imgGw = queryGateway(gateways[idx], config.type, config.tag, &config, &udiConfig);
        if (imgGw != NULL) {
            break;
        }
    }

    for (idx = 0; idx < nGateways; idx++) {
        free(gateways[idx]);
    }
    free(gateways);

    curl_global_cleanup();
    if (imgGw == NULL) return 1;
    return 0;
}
Esempio n. 11
0
void MainWindow::on_actionLaunchInstance_triggered()
{
	QModelIndex index = view->currentIndex();
	if(index.isValid())
	{
		Instance * inst = (Instance *) index.data(InstanceModel::InstancePointerRole).value<void *>();
		doLogin(inst->id());
	}
}
Esempio n. 12
0
LoginForm::LoginForm(QWidget* parent) : QDialog(parent)
{
	login = new QLineEdit;
	password = new QLineEdit;
	password->setEchoMode(QLineEdit::Password);
	nick = new QLineEdit;
	loginStatus = new QLabel;
	startLogin = new QPushButton(tr("Login"));
	isAutoLogin = new QCheckBox(tr("Auto-login?"));
	isForumLogin = new QCheckBox(tr("Uruchie account?"));
	
	QVBoxLayout* main = new QVBoxLayout;
	QHBoxLayout* loginLine = new QHBoxLayout;
	QHBoxLayout* passwordLine = new QHBoxLayout;
	QHBoxLayout* nickLine = new QHBoxLayout;
	QHBoxLayout* checkLink = new QHBoxLayout;
	
	loginLine->addWidget(new QLabel(tr("Login:"******"Password:"******"Your nickname:")));
	nickLine->addWidget(nick);
	checkLink->addWidget(isAutoLogin);
	checkLink->addWidget(isForumLogin);
	
	main->addLayout(loginLine);
	main->addLayout(passwordLine);
	main->addLayout(nickLine);
	main->addLayout(checkLink);
	main->addWidget(loginStatus);
	main->addWidget(startLogin);
	
	setLayout(main);
	setModal(true);
	setWindowTitle(tr("Enter your forum login"));
	connect(startLogin, SIGNAL(pressed()), this, SLOT(doLogin()));
	
	QSettings settings("eNoise", "UeNclient");
	login->setText(settings.value("LastSessionLogin").toString());
	password->setText(settings.value("LastSessionPassword").toString());
	nick->setText(settings.value("LastSessionNick").toString());
	isAutoLogin->setCheckState((settings.value("IsAutoLogin").toBool()) ? Qt::Checked : Qt::Unchecked);
	if(settings.value("IsForumLogin").isNull())
		isForumLogin->setCheckState(Qt::Checked);
	else
		isForumLogin->setCheckState((settings.value("IsForumLogin").toBool()) ? Qt::Checked : Qt::Unchecked);
	
	connect(this, SIGNAL(closeSignal()), (uenclient*)parent, SLOT(closeThroughtTray()));
	connect(&manager, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinish(QNetworkReply*)));
	((uenclient*)parent)->autoLogin->setChecked(isAutoLogin->checkState() == Qt::Checked);
	connect(isAutoLogin, SIGNAL(toggled(bool)), ((uenclient*)parent)->autoLogin, SLOT(setChecked(bool)));
#ifndef NDEBUG
    qDebug() << "[UENDEBUG] " << "Init login form finished"; 
#endif
}
Esempio n. 13
0
void RemoteClient::activateResponse(const Response &response)
{
    if (response.response_code() == Response::RespActivationAccepted) {
        emit activateAccepted();

        doLogin();
    } else {
        emit activateError();
    }
}
Esempio n. 14
0
void *key_thread( void *arg ) {
	struct termios t;

	tcgetattr(STDIN_FILENO, &t); //get the current terminal I/O structure
	t.c_lflag &= ~ICANON; //Manipulate the flag bits to do what you want it to do
	tcsetattr(STDIN_FILENO, TCSANOW, &t); //Apply the new settings

	char key = ' ';
	while( !exit_bot ) {
		key = getchar();
		switch( key ) {
			case 49: // '1'
				finished_quest = true;
				missing_quest  = true;
				printf( "[%s] Restarting loop as requested\n", currentDateTime().c_str());
				break;
			case 50: // '2'
				printf( "[%s] X/Y: %i,%i - HP: %i - Current Quest: %i - Kills/Req: %i of %i\n", currentDateTime().c_str(), player_x, player_y, player_health, lastQL.curquest, lastQL.curkills, lastQL.reqkills );
				break;
			case 51: // '3'
				requestLog( player_id );
				break;
			case 52: // '4'
				printf( "[%s] Dumping Unit Map to File\n", currentDateTime().c_str());
				dumpUnitMap();
				break;
			case 53: // '5'
				printf( "[%s] Sending logout\n", currentDateTime().c_str());
				finished_quest = true;
				missing_quest  = true;
				logout( player_id );
				break;
			case 54: // '6'
				ping_success = false;
				doLogin();
				break;
			case 55: // '7'
				have_quest = false;
				finished_quest = true;
				missing_quest  = true;
				Say( player_id, (char*)"-quitquest", 10 );
				printf( "[%s] Forcing player to abandon quest and start over\n", currentDateTime().c_str());
				break;
			case 48:
				printf( "[%s] Logging off and exiting\n", currentDateTime().c_str());
				finished_quest = true;
				missing_quest  = true;
				logout( player_id );
				SLEEP( 200 );
				exit_bot = true;
				break;
		}
	}
}
Esempio n. 15
0
void RemoteClient::registerResponse(const Response &response)
{
    const Response_Register &resp = response.GetExtension(Response_Register::ext);
    switch(response.response_code())
    {
        case Response::RespRegistrationAccepted:
            emit registerAccepted();
            doLogin();
            break;
        case Response::RespRegistrationAcceptedNeedsActivation:
            emit registerAcceptedNeedsActivate();
            doLogin();
            break;
        default:
            emit registerError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), resp.denied_end_time());
            setStatus(StatusDisconnecting);
            doDisconnectFromServer();
            break;
    }
}
Esempio n. 16
0
void LoginForm::onButtonClick(wxCommandEvent& event)
{
	if (event.GetId() == m_butCancel->GetId())
	{
		Close();
	}
	else if (event.GetId() == m_butSignin->GetId())
	{
		doLogin();
	}
}
Esempio n. 17
0
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent)
{
    setupUi(this);
    setWindowTitle(tr("Add an account"));

    request_ = NULL;

    mStatusText->setText("");

    connect(mSubmitBtn, SIGNAL(clicked()), this, SLOT(doLogin()));
}
Esempio n. 18
0
static void command_loop(void)
{
	char c, more = FALSE, help = FALSE;
    int i;

    while (!ExitToMsdos) {
		
        if (sysReq && !loggedIn && !haveCarrier) {
            sysReq = FALSE;
			if (cfg.offhook) {
                offhook();
            } else {
                drop_dtr();
            }
            ringSystemREQ();
        }
		
		if (parm.door) {
			if (!loggedIn && cfg.forcelogin) {
				for (i = 0; !loggedIn && i < 4; ++i)
					doLogin(2);
				if (!loggedIn) {
					ExitToMsdos = 1;
					break;
				}
			}
		}
		
		more = getCommand(&c);
		
		outFlag = IMPERVIOUS;

		if (chatkey)
			chat();
		
		if (eventkey && !haveCarrier) {
			do_cron(CRON_TIMEOUT);
			eventkey = FALSE;
		}
		
		if (sysopkey)
			help = doSysop();
		else
			help = doRegular(more, c);

		if (help) {
			if (!gl_user.expert)
				mPrintf("\n '?' for menu, 'H' for help.\n \n");
			else
				mPrintf(" ?\n \n");
		}
    }
}
GoogleChat::GoogleChat(): QWidget() {
    form.setupUi(this);
    setFixedSize(320, 480);

    form.userNameEdit->setFocus();
    connect(form.userNameEdit, SIGNAL(textChanged(QString)), SLOT(adjustLoginButton()));
    connect(form.userNameEdit, SIGNAL(returnPressed()), SLOT(inputPassword()));

    connect(form.passwordEdit, SIGNAL(textChanged(QString)), SLOT(adjustLoginButton()));
    connect(form.passwordEdit, SIGNAL(returnPressed()), SLOT(doLogin()));

    form.loginButton->setEnabled(false);
    connect(form.loginButton, SIGNAL(clicked()), SLOT(doLogin()));

    connect(form.webView, SIGNAL(loadFinished(bool)), SLOT(initialPage(bool)));
    connect(form.webView, SIGNAL(loadProgress(int)),
            form.progressBar, SLOT(setValue(int)));
    form.webView->setUrl((QUrl(GOOGLECHAT_URL)));
    form.webView->setContextMenuPolicy(Qt::PreventContextMenu);

    showStatus("Wait...");
}
Esempio n. 20
0
AP_MSG_HANDLER_METHOD(GmModule, Gm_Start)
{
  if (!bActive_) { pMsg->apStatus = ApMessage::Ok; return;}

  int ok = 0;

  ok = doLogin();
  if (!ok) {
    apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "doLogin() failed"));
  }

  pMsg->apStatus = ok ? ApMessage::Ok : ApMessage::Error;
}
void GGoogleChat::EventSucceededLogin()
{
	qDebug() << "Loaded" << m_nLoaded;
	m_nLoaded = 0;
	m_LastLoginSuccessful = true;

//return;

	// TRICK ///////////////////////////////////
	// Try to find a trick to load another chat so that the contact appears in the first one (Bug at Google)
	GoogleChatWidget* pobj = new GoogleChatWidget(this, 0);
	pobj->UpdateUrl();
	QTimer::singleShot(5000, pobj, SLOT(doLogin()));
	// TRICK ///////////////////////////////////
}
Esempio n. 22
0
AP_MSG_HANDLER_METHOD(GmModule, Timer_Event)
{
  if (pMsg->hTimer == hRegisterTimer_) {
    hRegisterTimer_ = ApNoHandle;
    if (!doRegister()) {
      apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "doRegister() failed"));
    }
  }

  if (pMsg->hTimer == hLoginTimer_) {
    hLoginTimer_ = ApNoHandle;
    if (!doLogin()) {
      apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "doLogin() failed"));
    }
  }
}
Esempio n. 23
0
void LoginForm::newAccountLogin(const char* username, const char* cookie)
{
	if (!cookie)
		return;

	if (m_pNewAccount)
		m_pNewAccount->EndModal(0);

	m_tbUsername->SetValue(username);
	m_tbPassword->SetValue(cookie);

	m_tbPasswordDisp->Show(false);
	m_tbPassword->Show();
	Layout();

	doLogin();
}
Esempio n. 24
0
void GmModule::onRegisterResult(SrpcMessage& srpc)
{
  String sUser = srpc.getString("User");
  String sPassword = srpc.getString("Password");

  apLog_Verbose((LOG_CHANNEL, LOG_CONTEXT, "Success user=%s", _sz(sUser)));

  Apollo::setModuleConfig(MODULE_NAME, "User", sUser);
  Apollo::setModuleConfig(MODULE_NAME, "EncryptedPassword", encrypt(sPassword));

  if (bLoginOnRegister_) {
    if (!doLogin()) {
      apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "doLogin() failed"));
    } else {
      bLoginOnRegister_ = 0;
    }
  }
}
Esempio n. 25
0
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent)
{
    setupUi(this);
    setWindowTitle(tr("Add an account"));
    setWindowIcon(QIcon(":/images/seafile.png"));

    request_ = NULL;

    mStatusText->setText("");
    mLogo->setPixmap(QPixmap(":/images/seafile-32.png"));
    mServerAddr->addItem(kDefaultServerAddr1);
    mServerAddr->addItem(kDefaultServerAddr2);
    mServerAddr->clearEditText();

    connect(mSubmitBtn, SIGNAL(clicked()), this, SLOT(doLogin()));

    const QRect screen = QApplication::desktop()->screenGeometry();
    move(screen.center() - this->rect().center());
}
Esempio n. 26
0
void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentification &event)
{
    if (event.protocol_version() != protocolVersion) {
        emit protocolVersionMismatch(protocolVersion, event.protocol_version());
        setStatus(StatusDisconnecting);
        return;
    }

    if(getStatus() == StatusRegistering)
    {
        Command_Register cmdRegister;
        cmdRegister.set_user_name(userName.toStdString());
        cmdRegister.set_password(password.toStdString());
        cmdRegister.set_email(email.toStdString());
        cmdRegister.set_gender((ServerInfo_User_Gender) gender);
        cmdRegister.set_country(country.toStdString());
        cmdRegister.set_real_name(realName.toStdString());
        cmdRegister.set_clientid(settingsCache->getClientID().toStdString());

        PendingCommand *pend = prepareSessionCommand(cmdRegister);
        connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(registerResponse(Response)));
        sendCommand(pend);

        return;
    }

    if(getStatus() == StatusActivating)
    {
        Command_Activate cmdActivate;
        cmdActivate.set_user_name(userName.toStdString());
        cmdActivate.set_token(token.toStdString());

        PendingCommand *pend = prepareSessionCommand(cmdActivate);
        connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(activateResponse(Response)));
        sendCommand(pend);

        return;
    }

    doLogin();
}
Esempio n. 27
0
void LoginForm::onChar(wxKeyEvent& event)
{ 
	if (event.m_keyCode == WXK_TAB)
	{
		processTab(!event.ShiftDown(), event.GetId());
	}
	else
	{
#ifndef UI_HIDE_AUTOLOGIN
		if (event.GetId() == m_cbRemPass->GetId())
		{
			if (event.m_keyCode == WXK_RETURN)
				doLogin();
			else if (event.m_keyCode == ' ')
				m_cbRemPass->SetValue(!m_cbRemPass->GetValue());
		}
#endif

		event.Skip(); 
	}
}
Esempio n. 28
0
LoginForm::LoginForm( QWidget* parent, Qt::WindowFlags wFlags )
    : Overlay( parent, wFlags )
    , m_usernameLineEdit( new QLineEdit( this ) )
    , m_passwordLineEdit( new QLineEdit( this ) )
    , m_loginButton( new QPushButton( this ) )
    , m_busyWidget( new QProgressBar( this ) )
    , m_usernameLabel( new QLabel( this ) )
    , m_passwordLabel( new QLabel( this ) )
    , m_rememberMeCheckBox( new QCheckBox( this ) )
{
    m_usernameLabel->setText( tr( "Username" ) );
    m_passwordLabel->setText( tr( "Password" ) );
    m_loginButton->setIcon( QIcon( "network-connect" ) );
    m_loginButton->setText( tr( "Login" ) );
    m_loginButton->setEnabled( false );

    m_busyWidget->hide();

    QGridLayout* layout1 = static_cast<QGridLayout*>(layout());
    layout1->addWidget( m_usernameLabel, 0, 0 );
    layout1->addWidget( m_passwordLabel, 0, 1);
    layout1->addWidget( m_usernameLineEdit, 1, 0 );
    layout1->addWidget( m_passwordLineEdit, 1, 1 );
    layout1->addWidget( m_loginButton, 2, 0 );
    layout1->addWidget( m_rememberMeCheckBox, 2, 1 );
    // layout1->addWidget( m_busyWidget );

    // m_contentLayout->addItem( layout1 );
    // m_contentLayout->addItem( m_usernameLineEdit );
    // m_contentLayout->addItem( m_passwordLineEdit );
    // m_contentLayout->addItem( m_loginButton );

    connect( m_loginButton, SIGNAL( clicked() ), SLOT( doLogin() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( initialized() ), SLOT( initDone() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( initFailed() ), SLOT( initFailed() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( loggedIn() ), SLOT( loginDone() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( loginFailed() ), SLOT( loginFailed() ) );

    initialize();
}
Esempio n. 29
0
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent)
{
    setupUi(this);
    setWindowTitle(tr("Add an account"));
    setWindowIcon(QIcon(":/images/seafile.png"));
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    request_ = NULL;
    account_info_req_ = NULL;

    mStatusText->setText("");
    mLogo->setPixmap(QPixmap(":/images/seafile-32.png"));
    QString preconfigure_addr = seafApplet->readPreconfigureExpandedString(kPreconfigureServerAddr);
    if (seafApplet->readPreconfigureEntry(kPreconfigureServerAddrOnly).toBool() && !preconfigure_addr.isEmpty()) {
        mServerAddr->setMaxCount(1);
        mServerAddr->insertItem(0, preconfigure_addr);
        mServerAddr->setCurrentIndex(0);
        mServerAddr->setEditable(false);
    } else {
        mServerAddr->addItems(getUsedServerAddresses());
        mServerAddr->clearEditText();
    }
    mServerAddr->setAutoCompletion(false);

    QString computerName = seafApplet->settingsManager()->getComputerName();

    mComputerName->setText(computerName);

    connect(mSubmitBtn, SIGNAL(clicked()), this, SLOT(doLogin()));

    const QRect screen = QApplication::desktop()->screenGeometry();
    move(screen.center() - this->rect().center());

#ifdef HAVE_SHIBBOLETH_SUPPORT
    setupShibLoginLink();
#else
    mShibLoginLink->hide();
#endif
}
Esempio n. 30
0
void LoginDialog::onHttpError(int code)
{
    const QNetworkReply* reply = request_->reply();
    if (reply->hasRawHeader(kSeafileOTPHeader) &&
        QString(reply->rawHeader(kSeafileOTPHeader)) == "required") {
        two_factor_auth_token_ = seafApplet->getText(
            this,
            tr("Two Factor Authentication"),
            tr("Enter the two factor authentication token"),
            QLineEdit::Normal,
            "");
        if (!two_factor_auth_token_.isEmpty()) {
            doLogin();
            return;
        }
    } else {
        QString err_msg, reason;
        if (code == 400) {
            reason = tr("Incorrect email or password");
        } else if (code == 429) {
            reason = tr("Logging in too frequently, please wait a minute");
        } else if (code == 500) {
            reason = tr("Internal Server Error");
        }

        if (reason.length() > 0) {
            err_msg = tr("Failed to login: %1").arg(reason);
        } else {
            err_msg = tr("Failed to login");
        }

        showWarning(err_msg);
    }

    enableInputs();

    mStatusText->setText("");
}