Exemplo n.º 1
0
void ChangePasswordDlg::apply()
{
	// sanity check
	if(ui_.le_pwcur->text().isEmpty() || ui_.le_pwnew->text().isEmpty() || ui_.le_pwver->text().isEmpty()) {
		QMessageBox::information(this, tr("Error"), tr("You must fill out the fields properly before you can proceed."));
		return;
	}

	if(ui_.le_pwcur->text() != pa->userAccount().pass) {
		QMessageBox::information(this, tr("Error"), tr("You entered your old password incorrectly.  Try again."));
		ui_.le_pwcur->setText("");
		ui_.le_pwcur->setFocus();
		return;
	}

	if(ui_.le_pwnew->text() != ui_.le_pwver->text()) {
		QMessageBox::information(this, tr("Error"), tr("New password and confirmation do not match.  Please enter them again."));
		ui_.le_pwnew->setText("");
		ui_.le_pwver->setText("");
		ui_.le_pwnew->setFocus();
		return;
	}

	ui_.busy->start();
	blockWidgets();

	JT_Register *reg = new JT_Register(pa->client()->rootTask());
	connect(reg, SIGNAL(finished()), SLOT(finished()));
	Jid j = pa->userAccount().jid;
	reg->reg(j.node(), ui_.le_pwnew->text());
	reg->go(true);
}
Exemplo n.º 2
0
void ChangePasswordDlg::finished()
{
	ui_.busy->stop();

	JT_Register *reg = (JT_Register *)sender();
	QString err = reg->statusString();
	int code = reg->statusCode();
	bool ok = reg->success();
	if(ok) {
		UserAccount acc = pa->userAccount();
		acc.pass = ui_.le_pwnew->text();
		pa->setUserAccount(acc);
		AccountModifyDlg *amd = pa->findDialog<AccountModifyDlg*>();
		if(amd)
			amd->setPassword(acc.pass);

		QMessageBox::information(this, tr("Success"), tr("Successfully changed password."));
		close();
	}
	else {
		// ignore task disconnect error
		if(code == Task::ErrDisc)
			return;

		QMessageBox::critical(this, tr("Error"), QString(tr("There was an error when trying to set the password.\nReason: %1")).arg(QString(err).replace('\n', "<br>")));
		restoreWidgets();
	}
}
void TransportRegistrationManager::unregisterTransport (void)
{
	JT_Register *registrationTask = new JT_Register(_client->rootTask());
	
	connect(registrationTask, SIGNAL(finished()), SLOT(transportUnRegistrationFinished()));
	
	registrationTask->unreg(Jid(_transportHost));
	registrationTask->go(true);
}
void TransportRegistrationManager::transportUnRegistrationFinished()
{
	JT_Register *task = (JT_Register *)sender();
	
	if (task->success()) {
		_registered = false;
		emit registrationStatusChanged(_registered, "");
		emit unregistrationFinished();
	}
}
void TransportRegistrationManager::registerTransport (const QString &username, const QString &password)
{
	JT_Register *registrationTask = new JT_Register(_client->rootTask());
	
	connect(registrationTask, SIGNAL(finished()), SLOT(transportRegistrationFinished()));
	
	registrationTask->reg(Jid(_transportHost), username, password);
	registrationTask->go(true);
	
	_usernamesForTasks[registrationTask] = username;
}
void TransportRegistrationManager::transportRegistrationFinished()
{
	JT_Register *task = (JT_Register *)sender();
	
	if (task->success()) {
		_registered = true;
		emit registrationStatusChanged(_registered, _usernamesForTasks[task]);
		emit registrationFinished();
	}
	
	_usernamesForTasks.remove(task);
}