2
* Copyright 2014 Canonical Ltd.
4
* This file is part of webbrowser-app.
6
* webbrowser-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* webbrowser-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include <QStringList>
29
* Simple optional type wrapper
35
explicit Fallible<T>(const T& data, bool is_valid = true)
36
: _data(data), _is_valid(is_valid) {}
38
bool is_valid() const { return _is_valid; }
39
const T& value() const
43
throw std::exception();
54
* @brief The WebappHookParser class
56
class WebappHookParser {
61
: shouldDeleteCacheOnUninstall(false)
62
, shouldDeleteCookiesOnUninstall(false) {}
63
bool shouldDeleteCacheOnUninstall;
64
bool shouldDeleteCookiesOnUninstall;
66
typedef Fallible<Data> OptionalData;
69
OptionalData parseContent(const QString& filename);
71
OptionalData parseDocument(const QJsonArray &array);
75
* @brief Simple POD for click hook files & their parent folders.
77
struct WebappClickHookInstallDescription
79
WebappClickHookInstallDescription(
80
const QString& folder,
81
const QHash<QString, QString>& files)
82
: parentFolder(folder), hookFiles(files) {}
85
QHash<QString, QString> hookFiles;
89
* @brief listWebappClickHookFilesIn
93
WebappClickHookInstallDescription listWebappClickHookFilesIn(const QDir& dir);
96
* @brief getProcessedClickHooksFolder
99
QString getProcessedClickHooksFolder();
102
* @brief getClickHooksInstallFolder
105
QString getClickHooksInstallFolder();
108
* @brief removeVersionFrom
112
QString removeVersionFrom(const QString &appId);
115
* @brief handleInstalls Detects click package uninstalls and handled what's needed
116
* @param alreadyProcessedClickHooks
117
* @param currentClickHooks
119
void handleInstalls(const WebappClickHookInstallDescription& alreadyProcessedClickHooks
120
, const WebappClickHookInstallDescription& currentClickHooks);
123
* @brief handleUninstall Detects click package uninstalls and handled what's needed
124
* @param alreadyProcessedClickHooks
125
* @param currentClickHooks
127
void handleUninstall(const WebappClickHookInstallDescription& alreadyProcessedClickHooks
128
, const WebappClickHookInstallDescription& currentClickHooks);
131
* @brief handleUpdates
132
* @param alreadyProcessedClickHooks
133
* @param currentClickHooks
135
void handleUpdates(const WebappClickHookInstallDescription& alreadyProcessedClickHooks
136
, const WebappClickHookInstallDescription& installedClickHooks);
138
} // namespace HookUtils