Changeset View
Changeset View
Standalone View
Standalone View
krusader/Archive/krarchandler.h
Show All 18 Lines | |||||
19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
20 | *****************************************************************************/ | 20 | *****************************************************************************/ | ||
21 | #ifndef KRARCHANDLER_H | 21 | #ifndef KRARCHANDLER_H | ||
22 | #define KRARCHANDLER_H | 22 | #define KRARCHANDLER_H | ||
23 | 23 | | |||
24 | // QtCore | 24 | // QtCore | ||
25 | #include <QStringList> | 25 | #include <QStringList> | ||
26 | #include <QObject> | 26 | #include <QObject> | ||
27 | #include <QSet> | ||||
27 | #include <QUrl> | 28 | #include <QUrl> | ||
28 | 29 | | |||
29 | #include <KCoreAddons/KProcess> | 30 | #include <KCoreAddons/KProcess> | ||
30 | 31 | | |||
31 | #include "../../krArc/krarcbasemanager.h" | 32 | #include "../../krArc/krarcbasemanager.h" | ||
32 | 33 | | |||
33 | namespace KWallet { | 34 | namespace KWallet { | ||
34 | class Wallet; | 35 | class Wallet; | ||
Show All 15 Lines | |||||
50 | public slots: | 51 | public slots: | ||
51 | virtual void incrementProgress(int) = 0; | 52 | virtual void incrementProgress(int) = 0; | ||
52 | }; | 53 | }; | ||
53 | 54 | | |||
54 | class KRarcHandler: public QObject, public KrArcBaseManager | 55 | class KRarcHandler: public QObject, public KrArcBaseManager | ||
55 | { | 56 | { | ||
56 | Q_OBJECT | 57 | Q_OBJECT | ||
57 | public: | 58 | public: | ||
59 | explicit KRarcHandler(QObject *parent = nullptr); | ||||
60 | | ||||
58 | // return the number of files in the archive | 61 | // return the number of files in the archive | ||
59 | static long arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer); | 62 | static long arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer); | ||
60 | // unpack an archive to destination directory | 63 | // unpack an archive to destination directory | ||
61 | static bool unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer ); | 64 | static bool unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer ); | ||
62 | // pack an archive to destination directory | 65 | // pack an archive to destination directory | ||
63 | static bool pack(QStringList fileNames, QString type, const QString& dest, long count, QMap<QString, QString> extraProps, KRarcObserver *observer ); | 66 | static bool pack(QStringList fileNames, QString type, const QString& dest, long count, QMap<QString, QString> extraProps, KRarcObserver *observer ); | ||
64 | // test an archive | 67 | // test an archive | ||
65 | static bool test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count = 0L ); | 68 | static bool test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count = 0L ); | ||
66 | // returns `true` if the right unpacker exist in the system | 69 | // returns `true` if the right unpacker exist in the system | ||
67 | static bool arcSupported(QString type); | 70 | static bool arcSupported(QString type); | ||
68 | // return the list of supported packers | 71 | // return the list of supported packers | ||
69 | static QStringList supportedPackers(); | 72 | static QStringList supportedPackers(); | ||
70 | // returns `true` if the url is an archive (ie: tar:/home/test/file.tar.bz2) | 73 | // returns `true` if the url is an archive (ie: tar:/home/test/file.tar.bz2) | ||
71 | static bool isArchive(const QUrl &url); | 74 | static bool isArchive(const QUrl &url); | ||
72 | // used to determine the type of the archive | 75 | // used to determine the type of the archive | ||
73 | QString getType(bool &encrypted, QString fileName, const QString& mime, bool checkEncrypted = true, bool fast = false); | 76 | QString getType(bool &encrypted, QString fileName, const QString& mime, bool checkEncrypted = true, bool fast = false); | ||
74 | // queries the password from the user | 77 | // queries the password from the user | ||
75 | static QString getPassword(const QString& path); | 78 | static QString getPassword(const QString& path); | ||
76 | // detects the archive type | 79 | // detects the archive type | ||
77 | void checkIf7zIsEncrypted(bool &, QString) override; | 80 | void checkIf7zIsEncrypted(bool &, QString) override; | ||
81 | // returns the registered protocol associated with the mimetype | ||||
82 | QString registeredProtocol(const QString& mimetype); | ||||
83 | // clear the cache of handled protocols | ||||
84 | static void clearProtocolCache(); | ||||
85 | | ||||
78 | private: | 86 | private: | ||
79 | //! checks if a returned status ("exit code") of an archiving-related process is OK | 87 | //! checks if a returned status ("exit code") of an archiving-related process is OK | ||
80 | static bool checkStatus(const QString& type, int exitCode); | 88 | static bool checkStatus(const QString& type, int exitCode); | ||
81 | 89 | | |||
82 | static bool openWallet(); | 90 | static bool openWallet(); | ||
83 | 91 | | |||
92 | //! the list of archive mimetypes that are openable by the krarc protocol | ||||
93 | QSet<QString> krarcArchiveMimetypes; | ||||
94 | | ||||
95 | //! the cache of handled protocols | ||||
96 | static QMap<QString, QString>* slaveMap; | ||||
97 | | ||||
84 | static KWallet::Wallet * wallet; | 98 | static KWallet::Wallet * wallet; | ||
85 | }; | 99 | }; | ||
86 | 100 | | |||
87 | #endif | 101 | #endif |