qca
gpgproc.h
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00017 * 00018 */ 00019 00020 #ifndef GPGPROC_H 00021 #define GPGPROC_H 00022 00023 #include "qpipe.h" 00024 00025 class QTimer; 00026 00027 namespace gpgQCAPlugin { 00028 00029 // FIXME: Even though deleting an object during a metacall event is supposed 00030 // to be legal with Qt, it is unfortunately buggy (at least before Qt 4.4). 00031 // This function performs the following steps: 00032 // obj->disconnect(owner); // to prevent future signals to owner 00033 // obj->setParent(0); // to prevent delete if parent is deleted 00034 // obj->deleteLater(); // now we can forget about the object 00035 void releaseAndDeleteLater(QObject *owner, QObject *obj); 00036 00037 class SafeTimer : public QObject 00038 { 00039 Q_OBJECT 00040 public: 00041 SafeTimer(QObject *parent = 0); 00042 ~SafeTimer(); 00043 00044 int interval() const; 00045 bool isActive() const; 00046 bool isSingleShot() const; 00047 void setInterval(int msec); 00048 void setSingleShot(bool singleShot); 00049 int timerId() const; 00050 00051 public slots: 00052 void start(int msec); 00053 void start(); 00054 void stop(); 00055 00056 signals: 00057 void timeout(); 00058 00059 private: 00060 QTimer *timer; 00061 }; 00062 00063 // GPGProc - executes gpg and provides access to all 6 channels. NormalMode 00064 // enables stdout, stderr, and stdin. ExtendedMode has those 3 plus status 00065 // aux, and command. The aux channel is connected to the '-&?' argument. 00066 // The debug() signal, as well as stderr, can be used for diagnostic text. 00067 class GPGProc : public QObject 00068 { 00069 Q_OBJECT 00070 public: 00071 enum Error { FailedToStart, UnexpectedExit, ErrorWrite }; 00072 enum Mode { NormalMode, ExtendedMode }; 00073 GPGProc(QObject *parent = 0); 00074 ~GPGProc(); 00075 00076 void reset(); 00077 00078 bool isActive() const; 00079 void start(const QString &bin, const QStringList &args, Mode m = ExtendedMode); 00080 00081 QByteArray readStdout(); 00082 QByteArray readStderr(); 00083 QStringList readStatusLines(); 00084 void writeStdin(const QByteArray &a); 00085 void writeAux(const QByteArray &a); 00086 #ifdef QPIPE_SECURE 00087 void writeCommand(const QCA::SecureArray &a); 00088 #else 00089 void writeCommand(const QByteArray &a); 00090 #endif 00091 void closeStdin(); 00092 void closeAux(); 00093 void closeCommand(); 00094 00095 Q_SIGNALS: 00096 void error(gpgQCAPlugin::GPGProc::Error error); 00097 void finished(int exitCode); 00098 void readyReadStdout(); 00099 void readyReadStderr(); 00100 void readyReadStatusLines(); 00101 void bytesWrittenStdin(int bytes); 00102 void bytesWrittenAux(int bytes); 00103 void bytesWrittenCommand(int bytes); 00104 void debug(const QString &str); // not signal-safe 00105 00106 private: 00107 class Private; 00108 friend class Private; 00109 Private *d; 00110 }; 00111 00112 } 00113 00114 #endif
KDE 4.4 API Reference