mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
SiteSettings: Store more details about url
Store protocol, port, host. Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
061672798b
commit
bbe03cf9c2
|
@ -413,7 +413,9 @@ void ProfileManager::updateDatabase()
|
|||
for (auto [feature, settingName] : html5SettingPairs.asKeyValueRange()) {
|
||||
auto const serverList = settings.value(settingName + suflix, QStringList()).toStringList();
|
||||
|
||||
for (const auto &server : serverList) {
|
||||
for (const auto &serverUrl : serverList) {
|
||||
const auto server = SiteSettingsManager::adjustUrl(QUrl(serverUrl));
|
||||
|
||||
if (!siteSettings.contains(server)) {
|
||||
siteSettings[server] = SiteSettingsManager::SiteSettings();
|
||||
for (auto [f, nameUnused] : html5SettingPairs.asKeyValueRange()) {
|
||||
|
@ -438,7 +440,8 @@ void ProfileManager::updateDatabase()
|
|||
auto loadCookiesSettings = [&](const QString &listName, const SiteSettingsManager::Permission permission) {
|
||||
auto const serverList = settings.value(listName, QStringList()).toStringList();
|
||||
|
||||
for (const auto &server : serverList) {
|
||||
for (const auto &serverUrl : serverList) {
|
||||
const auto server = SiteSettingsManager::adjustUrl(QUrl(serverUrl));
|
||||
if (!siteSettings.contains(server)) {
|
||||
siteSettings[server] = SiteSettingsManager::SiteSettings();
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ void SiteInfo::saveSiteSettings()
|
|||
siteSettings.AllowCookies = item->permission();
|
||||
siteSettings.ZoomLevel = -1;
|
||||
|
||||
siteSettings.server = m_baseUrl.host();
|
||||
siteSettings.server = mApp->siteSettingsManager()->adjustUrl(m_baseUrl);
|
||||
|
||||
auto storedSiteSettings = mApp->siteSettingsManager()->getSiteSettings(m_baseUrl);
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void SiteSettingsManager::saveSettings()
|
|||
QHash<QWebEngineSettings::WebAttribute, bool> SiteSettingsManager::getWebAttributes(const QUrl& url)
|
||||
{
|
||||
QHash<QWebEngineSettings::WebAttribute, bool> attributes;
|
||||
QString host = url.host();
|
||||
QString host = adjustUrl(url);
|
||||
|
||||
if (host.isEmpty()) {
|
||||
for (int i = 0; i < supportedAttribute.size(); ++i) {
|
||||
|
@ -133,7 +133,7 @@ QHash<QWebEngineSettings::WebAttribute, bool> SiteSettingsManager::getWebAttribu
|
|||
|
||||
void SiteSettingsManager::setOption(const QString& column, const QUrl& url, const int value)
|
||||
{
|
||||
QString host = url.host();
|
||||
QString host = adjustUrl(url);
|
||||
|
||||
if (column.isEmpty() || host.isEmpty()) {
|
||||
return;
|
||||
|
@ -208,22 +208,22 @@ SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEng
|
|||
|
||||
SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QString &column, const QUrl& url)
|
||||
{
|
||||
return getPermission(column, url.host());
|
||||
return getPermission(column, adjustUrl(url));
|
||||
}
|
||||
|
||||
SiteSettingsManager::Permission SiteSettingsManager::getPermission(const SiteSettingsManager::PageOptions option, const QUrl& url)
|
||||
{
|
||||
return getPermission(optionToSqlColumn(option), url.host());
|
||||
return getPermission(optionToSqlColumn(option), adjustUrl(url));
|
||||
}
|
||||
|
||||
SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEnginePage::Feature feature, const QUrl& url)
|
||||
{
|
||||
return getPermission(featureToSqlColumn(feature), url.host());
|
||||
return getPermission(featureToSqlColumn(feature), adjustUrl(url));
|
||||
}
|
||||
|
||||
SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEngineSettings::WebAttribute attribute, const QUrl& url)
|
||||
{
|
||||
return getPermission(webAttributeToSqlColumn(attribute), url.host());
|
||||
return getPermission(webAttributeToSqlColumn(attribute), adjustUrl(url));
|
||||
}
|
||||
|
||||
SiteSettingsManager::Permission SiteSettingsManager::getDefaultPermission(const SiteSettingsManager::PageOptions option)
|
||||
|
@ -464,9 +464,9 @@ QList<QWebEnginePage::Feature> SiteSettingsManager::getSupportedFeatures() const
|
|||
SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url)
|
||||
{
|
||||
SiteSettings siteSettings;
|
||||
siteSettings.server = url.host();
|
||||
siteSettings.server = adjustUrl(url);
|
||||
|
||||
if (url.isEmpty()) {
|
||||
if (url.isEmpty() || siteSettings.server.isEmpty()) {
|
||||
return siteSettings;
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url
|
|||
|
||||
QSqlQuery query(SqlDatabase::instance()->database());
|
||||
query.prepare(everythingSql.arg(sqlTable()));
|
||||
query.addBindValue(url.host());
|
||||
query.addBindValue(siteSettings.server);
|
||||
query.exec();
|
||||
|
||||
if (query.next()) {
|
||||
|
@ -624,3 +624,16 @@ void SiteSettingsManager::prepareSqls() {
|
|||
|
||||
everythingUpdateSql.append(QSL(" WHERE server=?"));
|
||||
}
|
||||
|
||||
QString SiteSettingsManager::adjustUrl(const QUrl url)
|
||||
{
|
||||
QUrl urlAdjusted = url.adjusted(
|
||||
QUrl::RemoveUserInfo
|
||||
| QUrl::RemovePath
|
||||
| QUrl::RemoveQuery
|
||||
| QUrl::RemoveFragment
|
||||
| QUrl::StripTrailingSlash
|
||||
);
|
||||
|
||||
return urlAdjusted.toString();
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ public:
|
|||
QString sqlTable();
|
||||
Permission intToPermission(const int permission) const;
|
||||
|
||||
static QString adjustUrl(const QUrl url);
|
||||
|
||||
private:
|
||||
void prepareSqls();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user