2022-03-14 13:42:33 +02:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KGPG_H
|
|
|
|
#define KGPG_H
|
|
|
|
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <kmainwindow.h>
|
|
|
|
|
|
|
|
#include <gpgme.h>
|
|
|
|
|
|
|
|
#include "ui_kgpgwidget.h"
|
|
|
|
|
2022-03-14 15:11:34 +02:00
|
|
|
struct KGPGKey
|
|
|
|
{
|
|
|
|
QByteArray name;
|
|
|
|
QByteArray email;
|
|
|
|
QByteArray comment;
|
2022-03-14 15:56:34 +02:00
|
|
|
QByteArray uidhash;
|
|
|
|
QByteArray fpr;
|
|
|
|
bool disabled;
|
2022-03-14 15:11:34 +02:00
|
|
|
bool revoked;
|
|
|
|
bool expired;
|
|
|
|
bool canencrypt;
|
|
|
|
bool cansign;
|
|
|
|
};
|
|
|
|
|
2022-03-14 13:42:33 +02:00
|
|
|
class KGPG : public KMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-03-14 15:11:34 +02:00
|
|
|
enum KGPGMode {
|
|
|
|
EncryptMode = 0,
|
|
|
|
DecryptMode = 1,
|
|
|
|
SignMode = 2,
|
|
|
|
VerifyMode = 3
|
|
|
|
};
|
|
|
|
|
2022-03-14 13:42:33 +02:00
|
|
|
explicit KGPG(QWidget *parent = 0);
|
|
|
|
~KGPG();
|
|
|
|
|
2022-03-14 15:11:34 +02:00
|
|
|
void setMode(const KGPGMode mode);
|
|
|
|
void setSource(const QString &source);
|
|
|
|
void setError(const char* const error);
|
2022-03-14 15:56:34 +02:00
|
|
|
void setError(const QString &error);
|
2022-03-14 18:45:31 +02:00
|
|
|
void setProgress(const int gpgcurrent, const int gpgtotal);
|
2022-03-14 15:11:34 +02:00
|
|
|
|
|
|
|
void start();
|
|
|
|
|
2022-03-14 18:17:45 +02:00
|
|
|
static gpgme_error_t gpgPasswordCallback(void *opaque, const char *uid_hint,
|
|
|
|
const char *passphrase_info,
|
|
|
|
int prev_was_bad, int fd);
|
|
|
|
static void gpgProgressCallback(void *opaque, const char *what,
|
|
|
|
int type, int current, int total);
|
|
|
|
|
2022-03-14 17:19:33 +02:00
|
|
|
private Q_SLOTS:
|
2022-03-14 19:19:52 +02:00
|
|
|
void slotKeysBox(const int index);
|
|
|
|
void slotGenerateKey();
|
2022-03-14 17:19:33 +02:00
|
|
|
void slotStart();
|
|
|
|
|
2022-03-14 13:42:33 +02:00
|
|
|
private:
|
2022-03-14 15:56:34 +02:00
|
|
|
void updateKeys(const gpgme_keylist_mode_t gpgmode, const bool secret);
|
|
|
|
|
2022-03-14 13:42:33 +02:00
|
|
|
Ui_KGPGWindow m_ui;
|
2022-03-14 15:11:34 +02:00
|
|
|
KGPGMode m_mode;
|
|
|
|
|
2022-03-14 13:42:33 +02:00
|
|
|
bool m_release;
|
|
|
|
gpgme_ctx_t m_gpgctx;
|
2022-03-14 15:11:34 +02:00
|
|
|
|
|
|
|
QList<KGPGKey> m_keys;
|
2022-03-14 13:42:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KGPG_H
|