File indexing completed on 2024-05-12 05:22:53

0001 /*
0002     test_keyformailbox.cpp
0003 
0004     This file is part of libkleopatra's test suite.
0005     SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik
0006     SPDX-FileContributor: Intevation GmbH
0007 
0008     SPDX-License-Identifier: GPL-2.0-only
0009 */
0010 
0011 #include <qgpgme/keyformailboxjob.h>
0012 #include <qgpgme/protocol.h>
0013 
0014 #include <gpgme++/key.h>
0015 #include <gpgme++/keylistresult.h>
0016 
0017 #include <QDebug>
0018 
0019 int main(int argc, char **argv)
0020 {
0021     QString mailbox;
0022     if (argc == 2) {
0023         mailbox = QString::fromLocal8Bit(argv[1]);
0024     }
0025 
0026     const auto proto = QGpgME::openpgp();
0027     auto *job = proto->keyForMailboxJob();
0028     GpgME::Key k;
0029     GpgME::UserID uid;
0030     job->exec(mailbox, true, k, uid);
0031     qDebug() << "UID Name: " << uid.name() << " Mail: " << uid.email() << " id: " << uid.id();
0032     qDebug() << "Key fpr: " << k.primaryFingerprint();
0033     return 0;
0034 }