MCPcopy Create free account
hub / github.com/blizzard4591/openMittsu / openDatabaseFile

Method openDatabaseFile

src/Client.cpp:515–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515void Client::openDatabaseFile(QString const& fileName) {
516 if (!QFile::exists(fileName)) {
517 QMessageBox::warning(this, tr("Database file does not exist"), tr("The selected database file \"%1\" does not exist. Please check the access permissions!").arg(fileName));
518 return;
519 }
520
521 QString password;
522 while (true) {
523 QString password;
524 bool ok = false;
525 if (m_optionTryEmptyPassword) {
526 password = "";
527 ok = true;
528 } else if (m_optionUsePasswordFile) {
529 password = m_optionPasswordFromFile;
530 ok = true;
531 } else {
532 password = QInputDialog::getText(this, tr("Database password"), tr("Please enter the database password for file \"%1\":").arg(fileName), QLineEdit::Password, QString(), &ok);
533 if (password.isNull()) {
534 password = QString("");
535 }
536 }
537 if (ok) {
538 QDir location(fileName);
539 location.cdUp();
540
541 int databaseOpenSuccess = -1;
542
543 if (!QMetaObject::invokeMethod(m_databaseThread.getQObjectPtr(), "openDatabase", Qt::BlockingQueuedConnection, Q_RETURN_ARG(int, databaseOpenSuccess), Q_ARG(QString const&, fileName), Q_ARG(QString const&, password), Q_ARG(QDir const&, location), Q_ARG(bool, false))) {
544 throw openmittsu::exceptions::InternalErrorException() << "Could not invoke Database open, terminating.";
545 } else if (databaseOpenSuccess != 0) {
546 if (databaseOpenSuccess == 1) {
547 // Try compat options
548 if (!QMetaObject::invokeMethod(m_databaseThread.getQObjectPtr(), "openDatabase", Qt::BlockingQueuedConnection, Q_RETURN_ARG(int, databaseOpenSuccess), Q_ARG(QString const&, fileName), Q_ARG(QString const&, password), Q_ARG(QDir const&, location), Q_ARG(bool, true))) {
549 throw openmittsu::exceptions::InternalErrorException() << "Could not invoke Database open, terminating.";
550 } else if (databaseOpenSuccess != 0) {
551 if (databaseOpenSuccess == 1) {
552 if (m_optionTryEmptyPassword) {
553 QMessageBox::information(this, tr("Invalid password"), tr("Tried the empty password for opening the database (commandline option set), but it was rejected."));
554 m_optionTryEmptyPassword = false;
555 } else if (m_optionUsePasswordFile) {
556 QMessageBox::information(this, tr("Invalid password"), tr("Tried the password from the given file for opening the database (commandline option set), but it was rejected."));
557 m_optionUsePasswordFile = false;
558 } else {
559 QMessageBox::information(this, tr("Invalid password"), tr("The entered database password was invalid."));
560 }
561 } else {
562 askForDatabaseRemovalFromConfig(fileName);
563 break;
564 }
565 }
566 } else {
567 askForDatabaseRemovalFromConfig(fileName);
568 break;
569 }
570 }
571
572 if (databaseOpenSuccess == 0) {

Callers

nothing calls this directly

Calls 6

getQObjectPtrMethod · 0.80
setOptionMethod · 0.80
setDatabaseMethod · 0.80
hasDatabaseMethod · 0.80
isNullMethod · 0.45
getDatabaseMethod · 0.45

Tested by

no test coverage detected