예제 #1
0
void MainWindow::on_action_EditPassword_triggered()
{
    int row = ui->listWidget->currentRow();
    QListWidgetItem *widgetItem = ui->listWidget->currentItem();

    if(row >= 0 && widgetItem && widgetItem->isSelected())
    {
        QList<PasswordItem> list = this->accountFile->getPasswordList();
        PasswordDialog dialog;

        dialog.setWindowTitle("编辑密码项");
        dialog.setPasswordItem(list.at(row));
        if(dialog.exec() == QDialog::Accepted)
        {
            PasswordItem item = dialog.getPasswordItem();
            bool ok;

            list[row].name = item.name;
            list[row].password = item.password;
            this->accountFile->setPasswordList(list);
            ok = this->accountFile->save(this->accountFileName);
            if(ok)
                ui->listWidget->item(row)->setText(item.name);
        }
    }
}
예제 #2
0
//==============================================================================
// Connect As Root Button Clicked Slot
//==============================================================================
void TestDialog::on_connectAsRootButton_clicked()
{
    // Check Model
    if (clientListModel) {

        // Init Root Pass
        QString rootPass = "";

        // Check If Remote File Server Running
        if (!checkRemoteFileServerRunning(DEFAULT_ROOT)) {
            // Init Password Dialog
            PasswordDialog passwordDialog;
            // Exec Password Dialog
            if (passwordDialog.exec()) {
                // Get Root Pass
                rootPass = passwordDialog.getPass().trimmed();

            } else {
                return;
            }
        }

        // Connect As Admin
        clientListModel->connectClientAsAdmin(currentIndex, rootPass);
    }
}
예제 #3
0
void QuetzalAccount::onPasswordRejected()
{
	PasswordDialog *dialog = qobject_cast<PasswordDialog *>(sender());
	QuetzalAccountPasswordInfo info = dialog->property("info").value<QuetzalAccountPasswordInfo>();
	info.cancelCb(info.userData, info.fields);
	purple_request_fields_destroy(info.fields);
	dialog->deleteLater();
}
예제 #4
0
void EditDialog::on_generateButton_clicked()
{
    PasswordDialog *dialog = new PasswordDialog(this);
    dialog->setModal(true);
    connect(dialog, &PasswordDialog::finished, [=](int state) {
        dialog->deleteLater();
    });
    connect(dialog, &PasswordDialog::generatePassword, this, &EditDialog::generate_password);
    dialog->show();
}
예제 #5
0
int PasswordDialog::getNameAndPassword( QString& user, QString& pass, bool* keep,
                                        const QString& prompt, bool readOnly,
                                        const QString& caption,
                                        const QString& comment,
                                        const QString& label )
{
    PasswordDialog* dlg;
    if( keep )
        dlg = new PasswordDialog( prompt, user, (*keep) );
    else
        dlg = new PasswordDialog( prompt, user );

    if ( !caption.isEmpty() )
        dlg->setPlainCaption( caption );
    else
        dlg->setPlainCaption( i18n("Authorization Dialog") );

    if ( !comment.isEmpty() )
        dlg->addCommentLine( label, comment );

    if ( readOnly )
        dlg->setUserReadOnly( readOnly );

    int ret = dlg->exec();
    if ( ret == Accepted )
    {
        user = dlg->username();
        pass = dlg->password();
        if ( keep ) { (*keep) = dlg->keepPassword(); }
    }
    delete dlg;
    return ret;
 }
예제 #6
0
void YandexNarodAuthorizator::onDialogFinished(int dialogResult)
{
	PasswordDialog *dialog = qobject_cast<PasswordDialog*>(sender());
	Q_ASSERT(dialog);
	dialog->deleteLater();

	if (dialogResult == PasswordDialog::Accepted)
		requestAuthorization(dialog->login(), dialog->password());
	else
		emit result(Failure, tr("Has no login or password"));
}
예제 #7
0
void MainWindow::showPasswordDialog() {
    QString pass;
    PasswordDialog *pDialog = new PasswordDialog();
    if (pDialog->exec()==QDialog::Accepted) {
        pDialog->getText(pass);
    } else { return; }
    pDialog->close();
    /* Check password and save log.
     * .........
     * */
    return;
}
예제 #8
0
void QuetzalAccount::onPasswordEntered(const QString &password, bool remember)
{
	PasswordDialog *dialog = qobject_cast<PasswordDialog *>(sender());
	QuetzalAccountPasswordInfo info = dialog->property("info").value<QuetzalAccountPasswordInfo>();
	PurpleRequestField *passwordField = purple_request_fields_get_field(info.fields, "password");
	PurpleRequestField *rememberField = purple_request_fields_get_field(info.fields, "remember");
	purple_request_field_string_set_value(passwordField, password.toUtf8().constData());
	purple_request_field_bool_set_value(rememberField, remember);
	info.okCb(info.userData, info.fields);
	purple_request_fields_destroy(info.fields);
	dialog->deleteLater();
//	if (remember) {
//		purple_account_set_password(password);
//	}
//		config("general").setValue("passwd", password, Config::Crypted);
}
예제 #9
0
void MainWindow::on_action_NewPassword_triggered()
{
    PasswordDialog dialog;

    dialog.setWindowTitle("新增密码项");
    if(dialog.exec() == QDialog::Accepted)
    {
        PasswordItem item = dialog.getPasswordItem();
        QList<PasswordItem> list = this->accountFile->getPasswordList();
        bool ok;

        list.append(item);
        this->accountFile->setPasswordList(list);
        ok = this->accountFile->save(this->accountFileName);
        if(ok)
            ui->listWidget->addItem(item.name);
    }
}
void BrowserAuthenticationListener::OnAuthenticationRequired(OpAuthenticationCallback* callback, OpWindowCommander *commander, DesktopWindow* parent_window)
{
	// Check if there already exists an authentication request with same authentication
	for (unsigned i = 0; i < m_open_dialogs.GetCount(); i++)
	{
		PasswordDialog* dialog_current = m_open_dialogs.Get(i);
		OpAuthenticationCallback* callback_current = dialog_current->GetCallback();

		// if same authentication don't launch another password dialog (on the same page)
		if (callback && callback->IsSameAuth(callback_current) && dialog_current->GetParentDesktopWindow() == parent_window)
			return;
	}

	PasswordDialog *dialog = OP_NEW(PasswordDialog, (callback, commander));
	if (!dialog)
	{
		callback->CancelAuthentication();
		return; //FALSE;
	}

	RETURN_VOID_IF_ERROR(dialog->Init(parent_window));

	if (OpStatus::IsError(m_open_dialogs.Add(dialog)))
	{
		dialog->CloseDialog(TRUE, TRUE);
		return;
	}

	dialog->SetDialogListener(this);

	// Inform OpPage about pending authentication 
	if (parent_window && parent_window->GetBrowserView())
	{	
		OpPage *page = parent_window->GetBrowserView()->GetOpPage();
		if (page)
			page->SetAuthIsPending(true);
	
		// Update document icon
		parent_window->GetBrowserView()->UpdateWindowImage(TRUE);
		parent_window->SetWidgetImage(parent_window->GetBrowserView()->GetFavIcon(FALSE));
	}

	return;
}
예제 #11
0
void YandexNarodAuthorizator::requestAuthorization()
{
	if (m_stage > Need) {
		if (m_stage == Already)
			emit result(Success);
		return;
	}
	ConfigGroup group = Config().group("yandex");
	QString login = group.value("login", QString());
	QString password = group.value("passwd", QString(), Config::Crypted);
	if (login.isEmpty() || password.isEmpty()) {
		PasswordDialog *dialog = PasswordDialog::request(
									 tr("Yandex.Disk authorizarion"),
									 tr("Enter your Yandex login and password"));
		dialog->setLoginEditVisible(true);
		dialog->setSaveButtonVisible(false);
		connect(dialog, SIGNAL(finished(int)), SLOT(onDialogFinished(int)));
		return;
	}
	return requestAuthorization(login, password);
}
void BrowserAuthenticationListener::ClosePasswordDialogs(const URL_ID authid, PasswordDialog* request_from)
{
	OpVector<PasswordDialog> still_opened_dialogs;

	// will close all passworddialogs with the supplied id, except the one that request was from
	for (unsigned i = 0; i < m_open_dialogs.GetCount(); i++)
	{
		PasswordDialog* dialog = m_open_dialogs.Get(i);
		if (dialog->GetAuthID() == authid && dialog != request_from)
		{
			dialog->CloseDialog(FALSE);
		}
		else 
		{
			still_opened_dialogs.Add(dialog);
		}
	}

	// This code updates m_open_dialogs list to contain only opened dialogs.
	// Relying on 'OnClose()' to call 'm_open_dialogs.RemoveByItem()' is not enough,
	// because some events (like OnAuthenticationRequired) may be called before 'OnClose()' gets called,
	// and we may want to access the good version of m_open_dialogs.
	m_open_dialogs.Swap(still_opened_dialogs);
}
예제 #13
0
QObject *QuetzalAccount::requestPassword(PurpleRequestFields *fields, PurpleRequestFieldsCb okCb,
										 PurpleRequestFieldsCb cancelCb, void *userData)
{
//	QByteArray password = config("general").value("passwd", QString(), Config::Crypted).toUtf8();
//	if (!password.isEmpty()) {
//		PurpleRequestField *passwordField = purple_request_fields_get_field(fields, "password");
//		purple_request_field_string_set_value(passwordField, password.constData());
//	}
//	if (password != purple_account_get_password(m_account)) {
//		quetzal_password_build(okCb, password.constData(), false, userData);
//		return;
//	}
	QuetzalAccountPasswordInfo info = {fields, okCb, cancelCb, userData};
//	QString password = config("general").value("passwd", QString(), Config::Crypted);
//	if (!password.isEmpty()) {
//		fillPassword(info, password);
//		return;
//	}
	PasswordDialog *dialog = PasswordDialog::request(this);
	dialog->setProperty("info", qVariantFromValue(info));
	connect(dialog, SIGNAL(entered(QString,bool)), this, SLOT(onPasswordEntered(QString,bool)));
	connect(dialog, SIGNAL(rejected()), this, SLOT(onPasswordRejected()));
	return dialog;
}
예제 #14
0
int main(int argc, char *argv[])
{
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
	QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
	
	julyTranslator=new JulyTranslator;
	appDataDir_=new QByteArray();
	appVerIsBeta_=new bool(false);
	appVerStr_=new QByteArray("1.0707");
	appVerReal_=new double(appVerStr.toDouble());
	if(appVerStr.size()>4)
	{ 
		appVerStr.insert(4,".");
		if(appVerStr.at(appVerStr.size()-1)!='0')appVerIsBeta=true;
	}
	appVerLastReal_=new double(appVerReal);
	currencyBStr_=new QByteArray("USD");
	currencyBStrLow_=new QByteArray("usd");
	currencyBSign_=new QByteArray("USD");
	validKeySign_=new bool(false);
	currencyASign_=new QByteArray("BTC");
	currencyAStr_=new QByteArray("BTC");
	currencyAStrLow_=new QByteArray("btc");
	currencyRequest_=new QByteArray("BTCUSD");
	defaultLangFile_=new QString();pickDefaultLangFile();
	currencySignMap=new QMap<QByteArray,QByteArray>;
	currencyNamesMap=new QMap<QByteArray,QByteArray>;
	dateTimeFormat_=new QString(QLocale().dateTimeFormat(QLocale::ShortFormat));
	timeFormat_=new QString(QLocale().timeFormat(QLocale::ShortFormat));
	exchangeName_=new QString("Mt.Gox");
	btcDecimals_=new int(8);
	usdDecimals_=new int(5);
	priceDecimals_=new int(5);

	minTradePrice_=new double(0.01);
	minTradeVolume_=new double(0.01);
	currentTimeStamp_=new qint32(QDateTime::currentDateTime().toTime_t());
	httpRequestInterval_=new int(400);
	httpRequestTimeout_=new int(5);

	QString globalStyleSheet="QGroupBox {background: rgba(255,255,255,190); border: 1px solid gray;border-radius: 3px;margin-top: 7px;} QGroupBox:title {background: qradialgradient(cx: 0.5, cy: 0.5, fx: 0.5, fy: 0.5, radius: 0.7, stop: 0 #fff, stop: 1 transparent); border-radius: 2px; padding: 1 4px; top: -7; left: 7px;} QLabel {color: black;} QDoubleSpinBox {background: white;} QTextEdit {background: white;} QPlainTextEdit {background: white;} QCheckBox {color: black;} QLineEdit {color: black; background: white; border: 1px solid gray;}";

#ifdef Q_OS_WIN
	if(QFile::exists("./QtBitcoinTrader"))
	{
		appDataDir="./QtBitcoinTrader/";
		QDir().mkpath(appDataDir+"Language");
		if(!QFile::exists(appDataDir+"Language"))appDataDir.clear();
	}
	if(appDataDir.isEmpty())
	{
	appDataDir=QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace("\\","/").toAscii()+"/QtBitcoinTrader/";
	if(!QFile::exists(appDataDir))QDir().mkpath(appDataDir);
	}
#else
	appDataDir=QDesktopServices::storageLocation(QDesktopServices::HomeLocation).toAscii()+"/.config/QtBitcoinTrader/";
	if(!QFile::exists(appDataDir))QDir().mkpath(appDataDir);
#endif
	
    if(argc>1)
	{
		QApplication a(argc,argv);
        if(a.arguments().last().startsWith("/checkupdate"))
		{
#ifndef Q_OS_WIN
			a.setStyle(new QPlastiqueStyle);
#endif
			a.setStyleSheet(globalStyleSheet);

			QSettings settings(appDataDir+"/Settings.set",QSettings::IniFormat);
			QString langFile=settings.value("LanguageFile","").toString();
			if(langFile.isEmpty()||!langFile.isEmpty()&&!QFile::exists(langFile))langFile=defaultLangFile;
			julyTranslator->loadFromFile(langFile);

			UpdaterDialog updater(a.arguments().last()!="/checkupdate");
			return a.exec();
		}
	}

	QApplication a(argc,argv);
#ifndef Q_OS_WIN
	a.setStyle(new QPlastiqueStyle);
#endif

#ifdef  Q_OS_WIN
	if(QFile::exists(a.applicationFilePath()+".upd"))QFile::remove(a.applicationFilePath()+".upd");
	if(QFile::exists(a.applicationFilePath()+".bkp"))QFile::remove(a.applicationFilePath()+".bkp");
#endif

#ifdef  Q_OS_MAC
	if(QFile::exists(a.applicationFilePath()+".upd"))QFile::remove(a.applicationFilePath()+".upd");
	if(QFile::exists(a.applicationFilePath()+".bkp"))QFile::remove(a.applicationFilePath()+".bkp");
#endif

	a.setWindowIcon(QIcon(":/Resources/QtBitcoinTrader.png"));
	QFile *lockFile=0;

	{
		QNetworkProxy proxy;
		QList<QNetworkProxy> proxyList=QNetworkProxyFactory::systemProxyForQuery(QNetworkProxyQuery(QUrl("https://")));
		if(proxyList.count())proxy=proxyList.first();
		QNetworkProxy::setApplicationProxy(proxy);

	logEnabled_=new bool(false);

	a.setStyleSheet(globalStyleSheet);

	logFileName_=new QString("QtBitcoinTrader.log");
	iniFileName_=new QString("QtBitcoinTrader.ini");

	restKey_=new QByteArray;
	restSign_=new QByteArray;
	{
		QFile currencyFile("://Resources/Currencies.map");
		currencyFile.open(QIODevice::ReadOnly);
		QStringList currencyList=QString(currencyFile.readAll().replace("\r","")).split("\n");
		currencyFile.close();
		for(int n=0;n<currencyList.count();n++)
		{
			QStringList currencyName=currencyList.at(n).split("=");
			if(currencyName.count()!=3)continue;
			currencyNamesMap->insert(currencyName.at(0).toAscii(),currencyName.at(1).toAscii());
			currencySignMap->insert(currencyName.at(0).toAscii(),currencyName.at(2).toAscii());
		}
		if(!QFile::exists(appDataDir+"Language"))QDir().mkpath(appDataDir+"Language");
		QSettings settings(appDataDir+"/Settings.set",QSettings::IniFormat);
		QString langFile=settings.value("LanguageFile","").toString();
		appVerLastReal=settings.value("Version",1.0).toDouble();
		settings.setValue("Version",appVerReal);
		if(langFile.isEmpty()||!langFile.isEmpty()&&!QFile::exists(langFile))langFile=defaultLangFile;
			julyTranslator->loadFromFile(langFile);
	}

	bool tryDecrypt=true;
	bool showNewPasswordDialog=false;
	while(tryDecrypt)
	{
		QString tryPassword;
		restKey.clear();
		restSign.clear();

		if(QDir(appDataDir,"*.ini").entryList().isEmpty()||showNewPasswordDialog)
		{
			NewPasswordDialog newPassword;
			if(newPassword.exec()==QDialog::Accepted)
			{
			tryPassword=newPassword.getPassword();
			newPassword.updateIniFileName();
			restKey=newPassword.getRestKey().toAscii();
			QSettings settings(iniFileName,QSettings::IniFormat);
			settings.setValue("ExchangeId",newPassword.getExchangeId());
			QByteArray cryptedData;
			if(newPassword.getExchangeId()==0)
			{
			restSign=QByteArray::fromBase64(newPassword.getRestSign().toAscii());
			cryptedData=JulyAES256::encrypt("Qt Bitcoin Trader\r\n"+restKey+"\r\n"+restSign.toBase64(),tryPassword.toAscii());
			}
			else
			if(newPassword.getExchangeId()==1)
			{
				restSign=newPassword.getRestSign().toAscii();
				cryptedData=JulyAES256::encrypt("Qt Bitcoin Trader\r\n"+restKey+"\r\n"+restSign.toBase64(),tryPassword.toAscii());
			}
			settings.setValue("CryptedData",QString(cryptedData.toBase64()));
			settings.setValue("ProfileName",newPassword.selectedProfileName());
			settings.remove("RestSign");
			settings.remove("RestKey");
			settings.sync();

			showNewPasswordDialog=false;
			}
		}
			PasswordDialog enterPassword;
			if(enterPassword.exec()==QDialog::Rejected)return 0;
			if(enterPassword.resetData)
			{
				if(QFile::exists(enterPassword.getIniFilePath()))
					QFile::remove(enterPassword.getIniFilePath());
				continue;
			}
			if(enterPassword.newProfile){showNewPasswordDialog=true;continue;}
			tryPassword=enterPassword.getPassword();

		if(!tryPassword.isEmpty())
		{
			iniFileName=enterPassword.getIniFilePath();
			bool profileLocked=enterPassword.isProfileLocked(iniFileName);
			if(profileLocked)
			{
				QMessageBox msgBox(0);
				msgBox.setIcon(QMessageBox::Question);
				msgBox.setWindowTitle("Qt Bitcoin Trader");
				msgBox.setText(julyTr("THIS_PROFILE_ALREADY_USED","This profile is already used by another instance.<br>API does not allow to run two instances with same key sign pair.<br>Please create new profile if you want to use two instances."));
#ifdef Q_OS_WIN
				msgBox.setStandardButtons(QMessageBox::Ok);
				msgBox.setDefaultButton(QMessageBox::Ok);
				msgBox.exec();
#else
				msgBox.setStandardButtons(QMessageBox::Ignore|QMessageBox::Ok);
				msgBox.setDefaultButton(QMessageBox::Ok);
				if(msgBox.exec()==QMessageBox::Ignore)profileLocked=false;
#endif
				if(profileLocked)tryPassword.clear();
			}
			if(!profileLocked)
			{
				QSettings settings(iniFileName,QSettings::IniFormat);
				QStringList decryptedList=QString(JulyAES256::decrypt(QByteArray::fromBase64(settings.value("CryptedData","").toString().toAscii()),tryPassword.toAscii())).split("\r\n");

				if(decryptedList.count()==3&&decryptedList.first()=="Qt Bitcoin Trader")
				{
					restKey=decryptedList.at(1).toAscii();
					restSign=QByteArray::fromBase64(decryptedList.last().toAscii());
                    tryDecrypt=false;
					lockFile=new QFile(enterPassword.lockFilePath(iniFileName));
                    lockFile->open(QIODevice::WriteOnly|QIODevice::Truncate);
					lockFile->write("Qt Bitcoin Trader Lock File");
				}
			}
		}
	}

	QSettings settings(iniFileName,QSettings::IniFormat);
	isLogEnabled=settings.value("LogEnabled",false).toBool();
	settings.setValue("LogEnabled",isLogEnabled);
	currencyASign=currencySignMap->value("BTC","BTC");
	currencyBStr=settings.value("Currency","USD").toString().toAscii();
	currencyBSign=currencySignMap->value(currencyBStr,"$");

	if(isLogEnabled)logThread=new LogThread;

	mainWindow_=new QtBitcoinTrader;
	QObject::connect(mainWindow_,SIGNAL(quit()),&a,SLOT(quit()));
	}
	mainWindow.loadUiSettings();
	a.exec();
	if(lockFile)
	{
		lockFile->close();
		lockFile->remove();
		delete lockFile;
	}
	return 0;
}
예제 #15
0
void LauncherWindow::showChangePasswordDialog() {
    PasswordDialog* d = new PasswordDialog(this);
    d->exec();
}