KNewStuff
security.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KNEWSTUFF2_SECURITY_H
00020 #define KNEWSTUFF2_SECURITY_H
00021
00022
00023 #include <QtCore/QMap>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QProcess>
00026
00027 struct KeyStruct {
00028 QString id;
00029 QString name;
00030 QString mail;
00031 bool trusted;
00032 bool secret;
00033 };
00034
00035 class KProcess;
00036 namespace KNS
00037 {
00038
00047 class Security : public QObject
00048 {
00049 Q_OBJECT
00050 public:
00051 static Security* ref() {
00052 static Security *m_ref;
00053 if (!m_ref) m_ref = new Security();
00054 return m_ref;
00055 }
00056 ~Security();
00057
00058
00064 void checkValidity(const QString &fileName);
00065
00072 void signFile(const QString &fileName);
00073
00080 KeyStruct signatureKey() {
00081 return m_signatureKey;
00082 }
00083
00084 enum Results {
00085 MD5_OK = 1,
00086 SIGNED_OK = 2,
00087 SIGNED_BAD = 4,
00088 TRUSTED = 8,
00089 UNKNOWN = 16,
00090 SIGNED_BAD_CLEAR = 27,
00091 BAD_PASSPHRASE = 32
00092 };
00093
00094 public Q_SLOTS:
00095
00097 void readKeys();
00098
00100 void readSecretKeys();
00101
00104 void slotCheckValidity();
00105
00109 void slotSignFile();
00110
00111 private:
00112 Security();
00113
00114 enum RunMode {
00115 List = 0,
00116 ListSecret,
00117 Verify,
00118 Sign
00119 };
00120
00121 KeyStruct m_signatureKey;
00122 int m_result;
00123 int m_runMode;
00124 bool m_gpgRunning;
00125 bool m_keysRead;
00126 QMap<QString, KeyStruct> m_keys;
00127 QString m_fileName;
00128 QString m_secretKey;
00129 KProcess *m_process;
00130
00131 private Q_SLOTS:
00132 void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
00133 void slotReadyReadStandardOutput();
00134
00135 Q_SIGNALS:
00140 void validityResult(int result);
00141
00146 void fileSigned(int result);
00147 };
00148
00149 }
00150
00151 #endif