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
00020
00021 #ifndef KNEWSTUFF2_SECURITY_H
00022 #define KNEWSTUFF2_SECURITY_H
00023
00024
00025 #include <QtCore/QMap>
00026 #include <QtCore/QObject>
00027 #include <QtCore/QProcess>
00028
00029 struct KeyStruct {
00030 QString id;
00031 QString name;
00032 QString mail;
00033 bool trusted;
00034 bool secret;
00035 };
00036
00037 class KProcess;
00038 namespace KNS
00039 {
00040
00049 class Security : public QObject
00050 {
00051 Q_OBJECT
00052 public:
00053 static Security* ref() {
00054 static Security *m_ref;
00055 if (!m_ref) m_ref = new Security();
00056 return m_ref;
00057 }
00058 ~Security();
00059
00060
00066 void checkValidity(const QString &fileName);
00067
00074 void signFile(const QString &fileName);
00075
00082 KeyStruct signatureKey() {
00083 return m_signatureKey;
00084 }
00085
00086 enum Results {
00087 MD5_OK = 1,
00088 SIGNED_OK = 2,
00089 SIGNED_BAD = 4,
00090 TRUSTED = 8,
00091 UNKNOWN = 16,
00092 SIGNED_BAD_CLEAR = 27,
00093 BAD_PASSPHRASE = 32
00094 };
00095
00096 public Q_SLOTS:
00097
00099 void readKeys();
00100
00102 void readSecretKeys();
00103
00106 void slotCheckValidity();
00107
00111 void slotSignFile();
00112
00113 private:
00114 Security();
00115
00116 enum RunMode {
00117 List = 0,
00118 ListSecret,
00119 Verify,
00120 Sign
00121 };
00122
00123 KeyStruct m_signatureKey;
00124 int m_result;
00125 int m_runMode;
00126 bool m_gpgRunning;
00127 bool m_keysRead;
00128 QMap<QString, KeyStruct> m_keys;
00129 QString m_fileName;
00130 QString m_secretKey;
00131 KProcess *m_process;
00132
00133 private Q_SLOTS:
00134 void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
00135 void slotReadyReadStandardOutput();
00136
00137 Q_SIGNALS:
00142 void validityResult(int result);
00143
00148 void fileSigned(int result);
00149 };
00150
00151 }
00152
00153 #endif