void OtrInternal::create_privkey(const char *accountname, const char *protocol) { Q_ASSERT(m_userstate); if(!m_mutex.tryLock(10)) return; QMessageBox infoMb(QMessageBox::Information, tr("qutim-otr"), tr("Generating keys for account %1\nThis may take a while.\nPlease, move mouse and use keyoard to decrease generation time.").arg(QString(accountname)), QMessageBox::Ok, NULL, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); infoMb.button(QMessageBox::Ok)->setEnabled(false); infoMb.button(QMessageBox::Ok)->setText(tr("please wait...")); infoMb.setWindowModality(Qt::NonModal); infoMb.setModal(false); infoMb.show(); Protocol *protocolObject = Protocol::all().value(QString::fromUtf8(protocol)); Account *account = protocolObject->account(QString::fromUtf8(accountname)); OTRCrypt::instance()->disableAccount(account); { QByteArray keysFile = m_keysFile.toLocal8Bit(); QEventLoop loop; QFutureWatcher<gcry_error_t> watcher; connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); QFuture<gcry_error_t> future = QtConcurrent::run(otrl_privkey_generate, m_userstate, keysFile.constData(), accountname, protocol); watcher.setFuture(future); loop.exec(); } OTRCrypt::instance()->enableAccount(account); m_mutex.unlock(); infoMb.button(QMessageBox::Ok)->setEnabled(true); infoMb.button(QMessageBox::Ok)->setText("Ok"); char fingerprint[45]; if (otrl_privkey_fingerprint(m_userstate, fingerprint, accountname, protocol) == NULL) { QMessageBox failMb(QMessageBox::Critical, tr("qutim-otr"), tr("Failed to generate key for account %1\nThe OTR Plugin will not work.").arg(QString(accountname)), QMessageBox::Ok, NULL, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); failMb.exec(); } else { infoMb.setText(tr("The fingerprint for account %1 is\n").arg(QString(accountname)) + QString(fingerprint)); } infoMb.exec(); }