File indexing completed on 2024-06-02 05:12:11

0001 /*
0002     SPDX-FileCopyrightText: 2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0003     SPDX-FileCopyrightText: 2021 Dawid Wróbel <me@dawidwrobel.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef XMLSTORAGE_H
0008 #define XMLSTORAGE_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // KDE Includes
0012 
0013 // ----------------------------------------------------------------------------
0014 // QT Includes
0015 
0016 #include <QUrl>
0017 
0018 // Project Includes
0019 
0020 #include "kmymoneyplugin.h"
0021 
0022 class QIODevice;
0023 
0024 class MyMoneyStorageMgr;
0025 class MyMoneyXmlWriter;
0026 
0027 class XMLStorage : public KMyMoneyPlugin::Plugin, public KMyMoneyPlugin::StoragePlugin
0028 {
0029     Q_OBJECT
0030     Q_INTERFACES(KMyMoneyPlugin::StoragePlugin)
0031 
0032 public:
0033     explicit XMLStorage(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
0034     ~XMLStorage() override;
0035 
0036     bool open(const QUrl &url) override;
0037     bool save(const QUrl &url) override;
0038     bool saveAs() override;
0039     eKMyMoney::StorageType storageType() const override;
0040     QString fileExtension() const override;
0041     QUrl openUrl() const override;
0042 
0043 private:
0044     void createActions();
0045     void ungetString(QIODevice *qfile, char *buf, int len);
0046 
0047     /**
0048       * This method is used by saveFile() to store the data
0049       * either directly in the destination file if it is on
0050       * the local file system or in a temporary file when
0051       * the final destination is reached over a network
0052       * protocol (e.g. FTP)
0053       *
0054       * @param localFile the name of the local file
0055       * @param writer pointer to the formatter
0056       * @param plaintext whether to override any compression & encryption settings
0057       * @param keyList QString containing a comma separated list of keys to be used for encryption
0058       *            If @p keyList is empty, the file will be saved unencrypted
0059       *
0060       * @note This method will close the file when it is written.
0061       */
0062     void saveToLocalFile(const QString& localFile, MyMoneyXmlWriter* pWriter, bool plaintext, const QString& keyList);
0063 
0064     void checkRecoveryKeyValidity();
0065 
0066     QString m_encryptionKeys;
0067 
0068     QUrl fileUrl;
0069 };
0070 
0071 #endif