File indexing completed on 2024-05-12 04:58:21

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2014 Franz Fellner <alpine.art.de@googlemail.com>
0004 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
0005 *
0006 * This program is free software: you can redistribute it and/or modify
0007 * it under the terms of the GNU General Public License as published by
0008 * the Free Software Foundation, either version 3 of the License, or
0009 * (at your option) any later version.
0010 *
0011 * This program is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 * ============================================================ */
0019 #ifndef RESTOREMANAGER_H
0020 #define RESTOREMANAGER_H
0021 
0022 #include "qzcommon.h"
0023 #include "browserwindow.h"
0024 
0025 class WebPage;
0026 class RecoveryJsObject;
0027 
0028 struct FALKON_EXPORT RestoreData
0029 {
0030     QVector<BrowserWindow::SavedWindow> windows;
0031     QByteArray crashedSession;
0032     QByteArray closedWindows;
0033 
0034     bool isValid() const;
0035     void clear();
0036 
0037     friend FALKON_EXPORT QDataStream &operator<<(QDataStream &stream, const RestoreData &data);
0038     friend FALKON_EXPORT QDataStream &operator>>(QDataStream &stream, RestoreData &data);
0039 };
0040 
0041 class FALKON_EXPORT RestoreManager
0042 {
0043 public:
0044     explicit RestoreManager(const QString &file);
0045     virtual ~RestoreManager();
0046 
0047     bool isValid() const;
0048     RestoreData restoreData() const;
0049     void clearRestoreData();
0050 
0051     QObject *recoveryObject(WebPage *page);
0052 
0053     static bool validateFile(const QString &file);
0054     static void createFromFile(const QString &file, RestoreData &data);
0055 
0056 private:
0057     void createFromFile(const QString &file);
0058 
0059     RecoveryJsObject *m_recoveryObject;
0060     RestoreData m_data;
0061 };
0062 
0063 #endif // RESTOREMANAGER_H