예제 #1
0
파일: gnupg.cpp 프로젝트: psi-plus/plugins
void GnuPG::sendPublicKey()
{
    QAction *action = qobject_cast<QAction*>(sender());
    QString fingerprint = "0x" + action->data().toString();

    GpgProcess gpg;
    QStringList arguments;
    arguments << "--armor"
              << "--export"
              << fingerprint;

    gpg.start(arguments);
    gpg.waitForFinished();

    // do nothing if error is occurred
    if (gpg.exitCode()) {
        return;
    }

    QString key = QString::fromUtf8(gpg.readAllStandardOutput());

    QString jid = _activeTab->getYourJid();
    QString jidToSend = _activeTab->getJid();
    int account = 0;
    QString tmpJid;
    while (jid != (tmpJid = _accountInfo->getJid(account))) {
        ++account;
        if (tmpJid == "-1") {
            return;
        }
    }

    _stanzaSending->sendMessage(account, jidToSend, key, "", "chat");
    _accountHost->appendSysMsg(account, jidToSend, _stanzaSending->escape(QString(tr("Public key %1 sent")).arg(action->text())));
}