| 1 | /* |
| 2 | * Copyright (C) 2003-2008 Justin Karneges <justin@affinix.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "gpgop.h" |
| 22 | #include "qcaprovider.h" |
| 23 | |
| 24 | namespace gpgQCAPlugin { |
| 25 | |
| 26 | class MyOpenPGPContext; |
| 27 | |
| 28 | class MyMessageContext : public QCA::MessageContext |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | MyOpenPGPContext *sms; |
| 33 | |
| 34 | QString signerId; |
| 35 | QStringList recipIds; |
| 36 | QCA::MessageContext::Operation op; |
| 37 | QCA::SecureMessage::SignMode signMode; |
| 38 | QCA::SecureMessage::Format format; |
| 39 | QByteArray in, out, sig; |
| 40 | int wrote; |
| 41 | bool ok, wasSigned; |
| 42 | GpgOp::Error op_err; |
| 43 | QCA::SecureMessageSignature signer; |
| 44 | GpgOp gpg; |
| 45 | bool _finished; |
| 46 | QString dtext; |
| 47 | |
| 48 | QCA::PasswordAsker asker; |
| 49 | QCA::TokenAsker tokenAsker; |
| 50 | |
| 51 | MyMessageContext(MyOpenPGPContext *_sms, QCA::Provider *p); |
| 52 | |
| 53 | // reimplemented Provider::Context |
| 54 | QCA::Provider::Context *clone() const override; |
| 55 | |
| 56 | // reimplemented MessageContext |
| 57 | bool canSignMultiple() const override; |
| 58 | QCA::SecureMessage::Type type() const override; |
| 59 | void reset() override; |
| 60 | void setupEncrypt(const QCA::SecureMessageKeyList &keys) override; |
| 61 | void setupSign(const QCA::SecureMessageKeyList &keys, QCA::SecureMessage::SignMode m, bool, bool) override; |
| 62 | void setupVerify(const QByteArray &detachedSig) override; |
| 63 | void start(QCA::SecureMessage::Format f, QCA::MessageContext::Operation op) override; |
| 64 | void update(const QByteArray &in) override; |
| 65 | QByteArray read() override; |
| 66 | int written() override; |
| 67 | void end() override; |
| 68 | bool finished() const override; |
| 69 | bool waitForFinished(int msecs) override; |
| 70 | bool success() const override; |
| 71 | QCA::SecureMessage::Error errorCode() const override; |
| 72 | QByteArray signature() const override; |
| 73 | QString hashName() const override; |
| 74 | QCA::SecureMessageSignatureList signers() const override; |
| 75 | QString diagnosticText() const override; |
| 76 | |
| 77 | void seterror(); |
| 78 | void complete(); |
| 79 | |
| 80 | private Q_SLOTS: |
| 81 | void gpg_readyRead(); |
| 82 | void gpg_bytesWritten(int bytes); |
| 83 | void gpg_finished(); |
| 84 | void gpg_needPassphrase(const QString &in_keyId); |
| 85 | void gpg_needCard(); |
| 86 | void gpg_readyReadDiagnosticText(); |
| 87 | void asker_responseReady(); |
| 88 | void tokenAsker_responseReady(); |
| 89 | }; |
| 90 | |
| 91 | } // end namespace gpgQCAPlugin |
| 92 | |