1 /* 2 SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org> 3 SPDX-FileCopyrightText: 2008, 2009, 2010, 2011 Rolf Eike Beer <kde@opensource.sf-tec.de> 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef _KGPGEXTERNALACTIONS_H 8 #define _KGPGEXTERNALACTIONS_H 9 10 #include <QObject> 11 #include <QPointer> 12 #include <QStringList> 13 14 #include <QUrl> 15 16 class KeysManager; 17 class KGpgFirstAssistant; 18 class KGpgItemModel; 19 class KJob; 20 class QKeySequence; 21 class QTemporaryFile; 22 class QString; 23 24 /** 25 * @brief handle actions called from outside the application 26 * 27 * This class takes care about everything sent to us from outside the 28 * application, e.g. command line arguments given on startup. 29 */ 30 class KGpgExternalActions : public QObject 31 { 32 Q_OBJECT 33 34 public: 35 KGpgExternalActions(KeysManager *parent, KGpgItemModel *model); 36 ~KGpgExternalActions() override; 37 38 void showDroppedFile(const QUrl &file); 39 void verifyFile(QUrl url); 40 41 /** 42 * @brief create a detached signature for the given files 43 */ 44 static void signFiles(KeysManager* parent, const QList<QUrl> &urls); 45 46 static void decryptFiles(KeysManager* parent, const QList<QUrl>& urls); 47 static void encryptFolders(KeysManager* parent, const QList<QUrl> &urls); 48 49 /** 50 * @brief create a new object, encrypt the given files, and destroy the object 51 */ 52 static void encryptFiles(KeysManager* parent, const QList<QUrl>& urls); 53 54 void readOptions(); 55 Q_SIGNALS: 56 void createNewKey(); 57 void updateDefault(QString); 58 59 private: 60 QStringList customDecrypt; 61 QPointer<KGpgFirstAssistant> m_assistant; 62 int compressionScheme; 63 KGpgItemModel *m_model; 64 QTemporaryFile *m_kgpgfoldertmp; 65 66 void startAssistant(); 67 void firstRun(); 68 69 QList<QUrl> m_decryptionFailed; 70 KeysManager *m_keysmanager; 71 QList<QUrl> droppedUrls; 72 73 QKeySequence goDefaultKey() const; 74 void decryptFile(QList<QUrl> urls); 75 76 private Q_SLOTS: 77 void startFolderEncode(); 78 void slotSaveOptionsPath(); 79 void slotVerificationDone(int result); 80 void help(); 81 void slotSetCompression(int cp); 82 void slotDecryptionDone(int status); 83 void slotFolderFinished(KJob *job); 84 void slotSignFiles(); 85 void slotEncryptionKeySelected(); 86 }; 87 88 #endif /* _KGPGEXTERNALACTIONS_H */ 89