<!-- Version 0.4. -->
<sect1 id="version_0.4">
- <title>0.4 -
- 13 June 2023</title>
+ <title><ulink url="https://www.stoutner.com/privacy-browser-pc-0-4/">0.4</ulink> -
+ <ulink url="https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff;h=b4c8c8d02113d14c2a07751eb3b0c1bdeec7abb4">13 June 2023</ulink></title>
<itemizedlist>
<listitem><para>Add a setting to <ulink url="https://redmine.stoutner.com/issues/1002">control spatial navigation</ulink>.</para></listitem>
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// Define the private static schema constants.
const int CookiesDatabase::SCHEMA_VERSION = 0;
-// Define the public static database constants.
+// Define the public static constants.
const QString CookiesDatabase::CONNECTION_NAME = "cookies_database";
const QString CookiesDatabase::COOKIES_TABLE = "cookies";
-
-// Define the public static database field names.
-const QString CookiesDatabase::_ID = "_id";
const QString CookiesDatabase::DOMAIN = "domain";
-const QString CookiesDatabase::NAME = "name";
-const QString CookiesDatabase::PATH = "path";
const QString CookiesDatabase::EXPIRATION_DATE = "expiration_date";
const QString CookiesDatabase::HTTP_ONLY = "http_only";
+const QString CookiesDatabase::ID = "_id";
+const QString CookiesDatabase::NAME = "name";
+const QString CookiesDatabase::PATH = "path";
const QString CookiesDatabase::SECURE = "secure";
const QString CookiesDatabase::VALUE = "value";
// Prepare the create table query.
createTableQuery.prepare("CREATE TABLE " + COOKIES_TABLE + "(" +
- _ID + " INTEGER PRIMARY KEY, " +
- DOMAIN + " TEXT NOT NULL, " +
- NAME + " TEXT NOT NULL, " +
- PATH + " TEXT NOT NULL, " +
- EXPIRATION_DATE + " TEXT, " +
- HTTP_ONLY + " INTEGER NOT NULL DEFAULT 0, " +
- SECURE + " INTEGER NOT NULL DEFAULT 0, " +
- VALUE + " TEXT NOT NULL)"
- );
+ ID + " INTEGER PRIMARY KEY, " +
+ DOMAIN + " TEXT NOT NULL, " +
+ NAME + " TEXT NOT NULL, " +
+ PATH + " TEXT NOT NULL, " +
+ EXPIRATION_DATE + " TEXT, " +
+ HTTP_ONLY + " INTEGER NOT NULL DEFAULT 0, " +
+ SECURE + " INTEGER NOT NULL DEFAULT 0, " +
+ VALUE + " TEXT NOT NULL)");
// Execute the query.
if (!createTableQuery.exec())
QSqlQuery addCookieQuery(cookiesDatabase);
// Prepare the add cookie query.
- addCookieQuery.prepare("INSERT INTO " + COOKIES_TABLE + " (" + DOMAIN + ", " + NAME + ", " + PATH + ", " + EXPIRATION_DATE + ", " + HTTP_ONLY + ", " + SECURE + ", " + VALUE + ") "
- "VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"
+ addCookieQuery.prepare("INSERT INTO " + COOKIES_TABLE + " (" +
+ DOMAIN + ", " +
+ NAME + ", " +
+ PATH + ", " +
+ EXPIRATION_DATE + ", " +
+ HTTP_ONLY + ", " +
+ SECURE + ", " +
+ VALUE + ") "
+ "VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"
);
// Bind the values.
countCookiesQuery.setForwardOnly(true);
// Prepare the query.
- countCookiesQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE);
+ countCookiesQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE);
// Execute the query.
countCookiesQuery.exec();
QSqlQuery deleteCookieQuery(cookiesDatabase);
// Prepare the delete cookie query.
- deleteCookieQuery.prepare("DELETE FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+ deleteCookieQuery.prepare("DELETE FROM " + COOKIES_TABLE + " WHERE " +
+ DOMAIN + " = :domain AND " +
+ NAME + " = :name AND " +
+ PATH + " = :path");
// Bind the values.
deleteCookieQuery.bindValue(":domain", cookie.domain());
cookieQuery.setForwardOnly(true);
// Prepare the cookies query.
- cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + _ID + " = :id");
+ cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + ID + " = :id");
// Bind the values.
cookieQuery.bindValue(":id", id);
isDurableQuery.setForwardOnly(true);
// Prepare the is durable query.
- isDurableQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+ isDurableQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE + " WHERE " +
+ DOMAIN + " = :domain AND " +
+ NAME + " = :name AND " +
+ PATH + " = :path");
// Bind the values.
isDurableQuery.bindValue(":domain", cookie.domain());
QSqlQuery isUpdateQuery(cookiesDatabase);
// Prepare the is update query.
- isUpdateQuery.prepare("SELECT " + EXPIRATION_DATE + " , " + HTTP_ONLY + " , " + SECURE + " , " + VALUE + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " +
- NAME + " = :name AND " + PATH + " = :path");
+ isUpdateQuery.prepare("SELECT " + EXPIRATION_DATE + " , " +
+ HTTP_ONLY + " , " +
+ SECURE + " , " +
+ VALUE +
+ " FROM " + COOKIES_TABLE +
+ " WHERE " + DOMAIN + " = :domain AND " +
+ NAME + " = :name AND " +
+ PATH + " = :path");
// Bind the values.
isUpdateQuery.bindValue(":domain", cookie.domain());
if (isUpdateQuery.isValid()) // The cookie exists in the database.
{
// Check to see if the cookie data has changed.
- if ((QDateTime::fromString(isUpdateQuery.value(0).toString(), Qt::ISODate) != cookie.expirationDate()) ||
- (isUpdateQuery.value(1).toBool() != cookie.isHttpOnly()) ||
- (isUpdateQuery.value(2).toBool() != cookie.isSecure()) ||
- (isUpdateQuery.value(3).toString().toUtf8() != cookie.value())) // The cookies data has changed.
+ if ((QDateTime::fromString(isUpdateQuery.value(EXPIRATION_DATE).toString(), Qt::ISODate) != cookie.expirationDate()) ||
+ (isUpdateQuery.value(HTTP_ONLY).toBool() != cookie.isHttpOnly()) ||
+ (isUpdateQuery.value(SECURE).toBool() != cookie.isSecure()) ||
+ (isUpdateQuery.value(VALUE).toString().toUtf8() != cookie.value())) // The cookies data has changed.
{
//qDebug() << "The durable cookie data has changed.";
QSqlQuery updateCookieQuery(cookiesDatabase);
// Prepare the edit cookie query.
- updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE + " SET " + EXPIRATION_DATE + " = :expiration_date , " + HTTP_ONLY + " = :http_only , " + SECURE + " = :secure , " +
- VALUE + " = :value WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+ updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
+ " SET " + EXPIRATION_DATE + " = :expiration_date , " +
+ HTTP_ONLY + " = :http_only , " +
+ SECURE + " = :secure , " +
+ VALUE + " = :value " +
+ "WHERE " + DOMAIN + " = :domain AND " +
+ NAME + " = :name AND " +
+ PATH + " = :path");
// Bind the values.
updateCookieQuery.bindValue(":domain", cookie.domain());
oldCookieQuery.setForwardOnly(true);
// Prepare the old cookie query.
- oldCookieQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+ oldCookieQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE +
+ " WHERE " + DOMAIN + " = :domain AND " +
+ NAME + " = :name AND " +
+ PATH + " = :path");
// Bind the values.
oldCookieQuery.bindValue(":domain", oldCookie.domain());
QSqlQuery updateCookieQuery(cookiesDatabase);
// Prepare the update cookie query.
- updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE + " SET " + DOMAIN + " = :domain , " + NAME + " = :name , " + PATH + " = :path , " + EXPIRATION_DATE + " = :expiration_date , " +
- HTTP_ONLY + " = :http_only , " + SECURE + " = :secure , " + VALUE + " = :value WHERE " + _ID + " = :id");
+ updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
+ " SET " + DOMAIN + " = :domain , " +
+ NAME + " = :name , " +
+ PATH + " = :path , " +
+ EXPIRATION_DATE + " = :expiration_date , " +
+ HTTP_ONLY + " = :http_only , " +
+ SECURE + " = :secure , " +
+ VALUE + " = :value " +
+ "WHERE " + ID + " = :id");
// Bind the values.
updateCookieQuery.bindValue(":id", oldCookieQuery.value(0).toLongLong());
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
static void updateCookie(const QNetworkCookie &oldCookie, const QNetworkCookie &newCookie);
// The public constants.
- static const QString _ID;
static const QString CONNECTION_NAME;
static const QString COOKIES_TABLE;
static const QString DOMAIN;
static const QString EXPIRATION_DATE;
static const QString HTTP_ONLY;
+ static const QString ID;
static const QString NAME;
static const QString PATH;
static const QString SECURE;
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
#include "helpers/UserAgentHelper.h"
// Define the private static schema constants.
-const int DomainsDatabase::SCHEMA_VERSION = 5;
+const int DomainsDatabase::SCHEMA_VERSION = 6;
-// Define the public static database constants.
+// Define the public static constants.
const QString DomainsDatabase::CONNECTION_NAME = "domains_database";
-const QString DomainsDatabase::DOMAINS_TABLE = "domains";
-
-// Define the public static database field names.
-const QString DomainsDatabase::_ID = "_id";
+const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
+const QString DomainsDatabase::DOM_STORAGE = "dom_storage";
const QString DomainsDatabase::DOMAIN_NAME = "domain_name";
+const QString DomainsDatabase::DOMAINS_TABLE = "domains";
+const QString DomainsDatabase::ID = "_id";
const QString DomainsDatabase::JAVASCRIPT = "javascript";
const QString DomainsDatabase::LOCAL_STORAGE = "local_storage";
-const QString DomainsDatabase::DOM_STORAGE = "dom_storage";
const QString DomainsDatabase::USER_AGENT = "user_agent";
const QString DomainsDatabase::ZOOM_FACTOR = "zoom_factor";
-const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
// Construct the class.
DomainsDatabase::DomainsDatabase() {}
// Add the JavaScript column.
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + JAVASCRIPT + " INTEGER DEFAULT 0");
- // Fallthrough to the next case.
+ // Fall through to the next case.
[[fallthrough]];
}
// Add the User Agent column.
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "'");
- // Fallthrough to the next case.
+ // Fall through to the next case.
[[fallthrough]];
}
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ZOOM_FACTOR + " INTEGER DEFAULT 0");
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0");
- // Fallthrough to the next case.
+ // Fall through to the next case.
[[fallthrough]];
}
// Add the DOM Storage column.
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + DOM_STORAGE + " INTEGER DEFAULT 0");
- // Fallthrough to the next case.
+ // Fall through to the next case.
[[fallthrough]];
}
// Add the Local Storage column.
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + LOCAL_STORAGE + " INTEGER DEFAULT 0");
- // Fallthrough to the next case.
+ // Fall through to the next case.
+ [[fallthrough]];
+ }
+
+ // Upgrade from schema version 5 to schema version 6.
+ case 5:
+ {
+ // Instantiate a spinner query.
+ QSqlQuery spinnerQuery(domainsDatabase);
+
+ // Set the query to be forward only (increases performance while iterating over the query).
+ spinnerQuery.setForwardOnly(true);
+
+ // Prepare the query.
+ spinnerQuery.prepare("SELECT " + ID + "," + JAVASCRIPT + "," + LOCAL_STORAGE + "," + DOM_STORAGE + " FROM " + DOMAINS_TABLE);
+
+ // Execute the query.
+ spinnerQuery.exec();
+
+ // Update the spinner values so that enabled is 1 and disabled is 2.
+ while (spinnerQuery.next())
+ {
+ // Initialize the new spinner values.
+ int newJavaScriptValue = SYSTEM_DEFAULT;
+ int newLocalStorageValue = SYSTEM_DEFAULT;
+ int newDomStorageValue = SYSTEM_DEFAULT;
+
+ // Update the new JavaScript value if needed.
+ switch (spinnerQuery.value(JAVASCRIPT).toInt())
+ {
+ // Disabled used to be 1.
+ case 1:
+ {
+ // Update the value to be 2.
+ newJavaScriptValue = DISABLED;
+
+ break;
+ }
+
+ // Enabled used to be 2.
+ case 2:
+ {
+ // Update the new value to be 1.
+ newJavaScriptValue = ENABLED;
+
+ break;
+ }
+ }
+
+ // Update the new local storage value if needed.
+ switch (spinnerQuery.value(LOCAL_STORAGE).toInt())
+ {
+ // Disabled used to be 1.
+ case 1:
+ {
+ // Update the new value to be 2.
+ newLocalStorageValue = DISABLED;
+
+ break;
+ }
+
+ // Enabled used to be 2.
+ case 2:
+ {
+ // Update the new value to be 1.
+ newLocalStorageValue = ENABLED;
+
+ break;
+ }
+ }
+
+ // Update the new DOM storage value if needed.
+ switch (spinnerQuery.value(DOM_STORAGE).toInt())
+ {
+ // Disabled used to be 1.
+ case 1:
+ {
+ // Update the new value to be 2.
+ newDomStorageValue = DISABLED;
+
+ break;
+ }
+
+ // Enabled used to be 2.
+ case 2:
+ {
+ // Update the new value to be 1.
+ newDomStorageValue = ENABLED;
+
+ break;
+ }
+ }
+
+ // Create an update spinner query.
+ QSqlQuery updateSpinnerQuery(domainsDatabase);
+
+ // Prepare the update spinner query.
+ updateSpinnerQuery.prepare("UPDATE " + DOMAINS_TABLE + " SET " +
+ JAVASCRIPT + " = :javascript , " +
+ LOCAL_STORAGE + " = :local_storage , " +
+ DOM_STORAGE + " = :dom_storage " +
+ " WHERE " + ID + " = :id");
+
+ // Bind the values.
+ updateSpinnerQuery.bindValue(":javascript", newJavaScriptValue);
+ updateSpinnerQuery.bindValue(":local_storage", newLocalStorageValue);
+ updateSpinnerQuery.bindValue(":dom_storage", newDomStorageValue);
+ updateSpinnerQuery.bindValue(":id", spinnerQuery.value(ID));
+
+ // Execute the query.
+ updateSpinnerQuery.exec();
+ }
+
+ // Fall through to the next case.
// [[fallthrough]];
}
}
// Prepare the create table query.
createTableQuery.prepare("CREATE TABLE " + DOMAINS_TABLE + "(" +
- _ID + " INTEGER PRIMARY KEY, " +
- DOMAIN_NAME + " TEXT, " +
- JAVASCRIPT + " INTEGER DEFAULT 0, " +
- LOCAL_STORAGE + " INTEGER DEFAULT 0, " +
- DOM_STORAGE + " INTEGER DEFAULT 0, " +
- USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
- ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
- CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)"
- );
+ ID + " INTEGER PRIMARY KEY, " +
+ DOMAIN_NAME + " TEXT, " +
+ JAVASCRIPT + " INTEGER DEFAULT 0, " +
+ LOCAL_STORAGE + " INTEGER DEFAULT 0, " +
+ DOM_STORAGE + " INTEGER DEFAULT 0, " +
+ USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
+ ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
+ CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)");
// Execute the query.
if (!createTableQuery.exec())
allDomainNamesQuery.setForwardOnly(true);
// Prepare the query.
- allDomainNamesQuery.prepare("SELECT " + _ID + "," + DOMAIN_NAME + " FROM " + DOMAINS_TABLE);
+ allDomainNamesQuery.prepare("SELECT " + ID + "," + DOMAIN_NAME + " FROM " + DOMAINS_TABLE);
// Execute the query.
allDomainNamesQuery.exec();
while (allDomainNamesQuery.next())
{
// Add the domain name and database ID to the map.
- domainSettingsMap.insert(allDomainNamesQuery.record().field(DOMAIN_NAME).value().toString(), allDomainNamesQuery.record().field(_ID).value().toInt());
+ domainSettingsMap.insert(allDomainNamesQuery.value(DOMAIN_NAME).toString(), allDomainNamesQuery.value(ID).toInt());
}
// Initialize the database ID tracker.
QSqlQuery domainLookupQuery(domainsDatabase);
// Prepare the domain lookup query.
- domainLookupQuery.prepare("SELECT * FROM " + DOMAINS_TABLE + " WHERE " + _ID + " = " + QString::number(databaseId));
+ domainLookupQuery.prepare("SELECT * FROM " + DOMAINS_TABLE + " WHERE " + ID + " = " + QString::number(databaseId));
// Execute the query.
domainLookupQuery.exec();
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// The public int constants.
static const int SYSTEM_DEFAULT = 0;
- static const int DISABLED = 1;
- static const int ENABLED = 2;
+ static const int ENABLED = 1;
+ static const int DISABLED = 2;
static const int CUSTOM = 1;
// The public constants.
- static const QString _ID;
static const QString CONNECTION_NAME;
static const QString CUSTOM_ZOOM_FACTOR;
static const QString DOM_STORAGE;
static const QString DOMAIN_NAME;
static const QString DOMAINS_TABLE;
+ static const QString ID;
static const QString JAVASCRIPT;
static const QString LOCAL_STORAGE;
static const QString USER_AGENT;
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
QModelIndex currentIndex = domainsListViewPointer->currentIndex();
// Get the ID of the current index row.
- QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)).data();
+ QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)).data();
// Submit all pending changes.
domainsTableModelPointer->submitAll();
// Find the new index for the selected id. The `1` keeps searching after the first match.
- QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)), Qt::DisplayRole, currentId,
+ QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)), Qt::DisplayRole, currentId,
1, Qt::MatchWrap);
// Select the new index.
break;
}
- case (DomainsDatabase::DISABLED):
+ case (DomainsDatabase::ENABLED):
{
- // Set the disabled text in bold.
- domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
+ // Set the enabled text in bold.
+ domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
// Set the palette.
domStorageWidgetPointer->setPalette(highlightedPalette);
break;
}
- case (DomainsDatabase::ENABLED):
+ case (DomainsDatabase::DISABLED):
{
- // Set the enabled text in bold.
- domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
+ // Set the disabled text in bold.
+ domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
// Set the palette.
domStorageWidgetPointer->setPalette(highlightedPalette);
break;
}
- case (DomainsDatabase::DISABLED):
+ case (DomainsDatabase::ENABLED):
{
- // Set the disabled text in bold.
- javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
+ // Set the enabled text in bold.
+ javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
// Set the palette.
javaScriptWidgetPointer->setPalette(highlightedPalette);
break;
}
- case (DomainsDatabase::ENABLED):
+ case (DomainsDatabase::DISABLED):
{
- // Set the enabled text in bold.
- javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
+ // Set the disabled text in bold.
+ javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
// Set the palette.
javaScriptWidgetPointer->setPalette(highlightedPalette);
break;
}
- case (DomainsDatabase::DISABLED):
+ case (DomainsDatabase::ENABLED):
{
- // Set the disabled text in bold.
- localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The <b> tags should be retained.", "<b>Local storage disabled</b>"));
+ // Set the enabled text in bold.
+ localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
// Set the palette.
localStorageWidgetPointer->setPalette(highlightedPalette);
break;
}
- case (DomainsDatabase::ENABLED):
+ case (DomainsDatabase::DISABLED):
{
- // Set the enabled text in bold.
- localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
+ // Set the disabled text in bold.
+ localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The <b> tags should be retained.", "<b>Local storage disabled</b>"));
// Set the palette.
localStorageWidgetPointer->setPalette(highlightedPalette);
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
if (sqlRecord.isGenerated(CookiesDatabase::DOMAIN) || sqlRecord.isGenerated(CookiesDatabase::NAME) || sqlRecord.isGenerated(CookiesDatabase::PATH))
{
// Get the ID of the cookie
- int id = sqlRecord.value(CookiesDatabase::_ID).toInt();
+ int id = sqlRecord.value(CookiesDatabase::ID).toInt();
// Get the cookie.
QNetworkCookie *cookiePointer = CookiesDatabase::getCookieById(id);
<item>
<property name="text">
- <string>JavaScript disabled</string>
+ <string>JavaScript enabled</string>
</property>
</item>
<item>
<property name="text">
- <string>JavaScript enabled</string>
+ <string>JavaScript disabled</string>
</property>
</item>
</widget>
<item>
<property name="text">
- <string>Local storage disabled</string>
+ <string>Local storage enabled</string>
</property>
</item>
<item>
<property name="text">
- <string>Local storage enabled</string>
+ <string>Local storage disabled</string>
</property>
</item>
</widget>
<item>
<property name="text">
- <string>DOM storage disabled</string>
+ <string>DOM storage enabled</string>
</property>
</item>
<item>
<property name="text">
- <string>DOM storage enabled</string>
+ <string>DOM storage disabled</string>
</property>
</item>
</widget>
// Check if the hostname has domain settings.
if (domainQuery.isValid()) // The hostname has domain settings.
{
- // Get the domain record.
- QSqlRecord domainRecord = domainQuery.record();
-
// Store the domain settings name.
- domainSettingsName = domainRecord.field(DomainsDatabase::DOMAIN_NAME).value().toString();
+ domainSettingsName = domainQuery.value(DomainsDatabase::DOMAIN_NAME).toString();
// Set the JavaScript status.
- switch (domainRecord.field(DomainsDatabase::JAVASCRIPT).value().toInt())
+ switch (domainQuery.value(DomainsDatabase::JAVASCRIPT).toInt())
{
// Set the default JavaScript status.
case (DomainsDatabase::SYSTEM_DEFAULT):
break;
}
- // Disable JavaScript.
- case (DomainsDatabase::DISABLED):
+ // Enable JavaScript.
+ case (DomainsDatabase::ENABLED):
{
- webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
break;
}
- // Enable JavaScript.
- case (DomainsDatabase::ENABLED):
+ // Disable JavaScript.
+ case (DomainsDatabase::DISABLED):
{
- webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
break;
}
}
// Set the local storage status.
- switch (domainRecord.field(DomainsDatabase::LOCAL_STORAGE).value().toInt())
+ switch (domainQuery.value(DomainsDatabase::LOCAL_STORAGE).toInt())
{
// Set the default local storage status.
case (DomainsDatabase::SYSTEM_DEFAULT):
break;
}
- // Disable local storage.
- case (DomainsDatabase::DISABLED):
+ // Enable local storage.
+ case (DomainsDatabase::ENABLED):
{
- localStorageEnabled = false;
+ localStorageEnabled = true;
break;
}
- // Enable local storage.
- case (DomainsDatabase::ENABLED):
+ // Disable local storage.
+ case (DomainsDatabase::DISABLED):
{
- localStorageEnabled = true;
+ localStorageEnabled = false;
break;
}
}
// Set the DOM storage status.
- switch (domainRecord.field(DomainsDatabase::DOM_STORAGE).value().toInt())
+ switch (domainQuery.value(DomainsDatabase::DOM_STORAGE).toInt())
{
// Set the default DOM storage status. QWebEngineSettings confusingly calls this local storage.
case (DomainsDatabase::SYSTEM_DEFAULT):
break;
}
- // Disable DOM storage. QWebEngineSettings confusingly calls this local storage.
- case (DomainsDatabase::DISABLED):
+ // Enable DOM storage. QWebEngineSettings confusingly calls this local storage.
+ case (DomainsDatabase::ENABLED):
{
- webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
break;
}
- // Enable DOM storage. QWebEngineSettings confusingly calls this local storage.
- case (DomainsDatabase::ENABLED):
+ // Disable DOM storage. QWebEngineSettings confusingly calls this local storage.
+ case (DomainsDatabase::DISABLED):
{
- webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
break;
}
}
// Set the user agent.
- webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabase::USER_AGENT).value().toString()));
+ webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainQuery.value(DomainsDatabase::USER_AGENT).toString()));
// Check if a custom zoom factor is set.
- if (domainRecord.field(DomainsDatabase::ZOOM_FACTOR).value().toInt())
+ if (domainQuery.value(DomainsDatabase::ZOOM_FACTOR).toInt())
{
// Store the current zoom factor.
- setZoomFactor(domainRecord.field(DomainsDatabase::CUSTOM_ZOOM_FACTOR).value().toDouble());
+ setZoomFactor(domainQuery.value(DomainsDatabase::CUSTOM_ZOOM_FACTOR).toDouble());
}
else
{