File indexing completed on 2024-05-19 04:46:24
0001 /* 0002 * Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public 0015 * License along with this library; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 0017 * 0018 */ 0019 0020 #ifndef GPGPROC_H 0021 #define GPGPROC_H 0022 0023 #include "qpipe.h" 0024 0025 namespace gpgQCAPlugin { 0026 0027 // GPGProc - executes gpg and provides access to all 6 channels. NormalMode 0028 // enables stdout, stderr, and stdin. ExtendedMode has those 3 plus status 0029 // aux, and command. The aux channel is connected to the '-&?' argument. 0030 // The debug() signal, as well as stderr, can be used for diagnostic text. 0031 class GPGProc : public QObject 0032 { 0033 Q_OBJECT 0034 public: 0035 enum Error 0036 { 0037 FailedToStart, 0038 UnexpectedExit, 0039 ErrorWrite 0040 }; 0041 enum Mode 0042 { 0043 NormalMode, 0044 ExtendedMode 0045 }; 0046 GPGProc(QObject *parent = nullptr); 0047 ~GPGProc() override; 0048 0049 void reset(); 0050 0051 bool isActive() const; 0052 void start(const QString &bin, const QStringList &args, Mode m = ExtendedMode); 0053 0054 QByteArray readStdout(); 0055 QByteArray readStderr(); 0056 QStringList readStatusLines(); 0057 void writeStdin(const QByteArray &a); 0058 void writeAux(const QByteArray &a); 0059 #ifdef QPIPE_SECURE 0060 void writeCommand(const QCA::SecureArray &a); 0061 #else 0062 void writeCommand(const QByteArray &a); 0063 #endif 0064 void closeStdin(); 0065 void closeAux(); 0066 void closeCommand(); 0067 0068 Q_SIGNALS: 0069 void error(gpgQCAPlugin::GPGProc::Error error); 0070 void finished(int exitCode); 0071 void readyReadStdout(); 0072 void readyReadStderr(); 0073 void readyReadStatusLines(); 0074 void bytesWrittenStdin(int bytes); 0075 void bytesWrittenAux(int bytes); 0076 void bytesWrittenCommand(int bytes); 0077 void debug(const QString &str); // not signal-safe 0078 0079 private: 0080 class Private; 0081 friend class Private; 0082 Private *d; 0083 }; 0084 0085 } 0086 0087 #endif