File indexing completed on 2024-04-14 05:43:35

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org>
0003     SPDX-FileCopyrightText: 2008, 2009, 2010, 2011 Rolf Eike Beer <kde@opensource.sf-tec.de>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef _KGPGEXTERNALACTIONS_H
0008 #define _KGPGEXTERNALACTIONS_H
0009 
0010 #include <QObject>
0011 #include <QPointer>
0012 #include <QStringList>
0013 
0014 #include <QUrl>
0015 
0016 class KeysManager;
0017 class KGpgFirstAssistant;
0018 class KGpgItemModel;
0019 class KJob;
0020 class QKeySequence;
0021 class QTemporaryFile;
0022 class QString;
0023 
0024 /**
0025  * @brief handle actions called from outside the application
0026  *
0027  * This class takes care about everything sent to us from outside the
0028  * application, e.g. command line arguments given on startup.
0029  */
0030 class KGpgExternalActions : public QObject
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     KGpgExternalActions(KeysManager *parent, KGpgItemModel *model);
0036     ~KGpgExternalActions() override;
0037 
0038     void showDroppedFile(const QUrl &file);
0039     void verifyFile(QUrl url);
0040 
0041     /**
0042      * @brief create a detached signature for the given files
0043      */
0044     static void signFiles(KeysManager* parent, const QList<QUrl> &urls);
0045 
0046     static void decryptFiles(KeysManager* parent, const QList<QUrl>& urls);
0047     static void encryptFolders(KeysManager* parent, const QList<QUrl> &urls);
0048 
0049     /**
0050      * @brief create a new object, encrypt the given files, and destroy the object
0051      */
0052     static void encryptFiles(KeysManager* parent, const QList<QUrl>& urls);
0053 
0054     void readOptions();
0055 Q_SIGNALS:
0056     void createNewKey();
0057     void updateDefault(QString);
0058 
0059 private:
0060     QStringList customDecrypt;
0061     QPointer<KGpgFirstAssistant> m_assistant;
0062     int compressionScheme;
0063     KGpgItemModel *m_model;
0064     QTemporaryFile *m_kgpgfoldertmp;
0065 
0066     void startAssistant();
0067     void firstRun();
0068 
0069     QList<QUrl> m_decryptionFailed;
0070     KeysManager *m_keysmanager;
0071     QList<QUrl> droppedUrls;
0072 
0073     QKeySequence goDefaultKey() const;
0074     void decryptFile(QList<QUrl> urls);
0075 
0076 private Q_SLOTS:
0077     void startFolderEncode();
0078     void slotSaveOptionsPath();
0079     void slotVerificationDone(int result);
0080     void help();
0081     void slotSetCompression(int cp);
0082     void slotDecryptionDone(int status);
0083     void slotFolderFinished(KJob *job);
0084     void slotSignFiles();
0085     void slotEncryptionKeySelected();
0086 };
0087 
0088 #endif /* _KGPGEXTERNALACTIONS_H */