2017-12-12 08:15:23 +00:00
|
|
|
/*
|
2018-11-01 03:27:38 +00:00
|
|
|
* Copyright (C) 2013 Francois Ferrand
|
|
|
|
|
* Copyright (C) 2017 Sami Vänttinen <sami.vanttinen@protonmail.com>
|
|
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2017-12-12 08:15:23 +00:00
|
|
|
|
|
|
|
|
#include "BrowserSettings.h"
|
|
|
|
|
#include "core/Config.h"
|
2020-02-01 13:42:34 +00:00
|
|
|
#include "core/PasswordHealth.h"
|
2017-12-12 08:15:23 +00:00
|
|
|
|
2018-09-05 20:21:59 +00:00
|
|
|
BrowserSettings* BrowserSettings::m_instance(nullptr);
|
|
|
|
|
|
|
|
|
|
BrowserSettings* BrowserSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
if (!m_instance) {
|
|
|
|
|
m_instance = new BrowserSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
2017-12-12 08:15:23 +00:00
|
|
|
|
|
|
|
|
bool BrowserSettings::isEnabled()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_Enabled).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setEnabled(bool enabled)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_Enabled, enabled);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::showNotification()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_ShowNotification).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setShowNotification(bool showNotification)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_ShowNotification, showNotification);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::bestMatchOnly()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_BestMatchOnly).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setBestMatchOnly(bool bestMatchOnly)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_BestMatchOnly, bestMatchOnly);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::unlockDatabase()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_UnlockDatabase).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setUnlockDatabase(bool unlockDatabase)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_UnlockDatabase, unlockDatabase);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::matchUrlScheme()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_MatchUrlScheme).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setMatchUrlScheme(bool matchUrlScheme)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_MatchUrlScheme, matchUrlScheme);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::alwaysAllowAccess()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_AlwaysAllowAccess).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setAlwaysAllowAccess(bool alwaysAllowAccess)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_AlwaysAllowAccess, alwaysAllowAccess);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::alwaysAllowUpdate()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_AlwaysAllowUpdate).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setAlwaysAllowUpdate(bool alwaysAllowUpdate)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_AlwaysAllowUpdate, alwaysAllowUpdate);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-12-08 10:12:52 +00:00
|
|
|
bool BrowserSettings::httpAuthPermission()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_HttpAuthPermission).toBool();
|
2018-12-08 10:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setHttpAuthPermission(bool httpAuthPermission)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_HttpAuthPermission, httpAuthPermission);
|
2018-12-08 10:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
bool BrowserSettings::searchInAllDatabases()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_SearchInAllDatabases).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setSearchInAllDatabases(bool searchInAllDatabases)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_SearchInAllDatabases, searchInAllDatabases);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::supportKphFields()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_SupportKphFields).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setSupportKphFields(bool supportKphFields)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_SupportKphFields, supportKphFields);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2019-07-02 08:55:15 +00:00
|
|
|
bool BrowserSettings::noMigrationPrompt()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_NoMigrationPrompt).toBool();
|
2019-07-02 08:55:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setNoMigrationPrompt(bool prompt)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_NoMigrationPrompt, prompt);
|
2019-07-02 08:55:15 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
bool BrowserSettings::useCustomProxy()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_UseCustomProxy).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setUseCustomProxy(bool enabled)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_UseCustomProxy, enabled);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BrowserSettings::customProxyLocation()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_CustomProxyLocation).toString();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-28 11:49:32 +00:00
|
|
|
void BrowserSettings::setCustomProxyLocation(const QString& location)
|
2017-12-12 08:15:23 +00:00
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_CustomProxyLocation, location);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-17 19:44:52 +00:00
|
|
|
bool BrowserSettings::customBrowserSupport()
|
|
|
|
|
{
|
|
|
|
|
return config()->get(Config::Browser_UseCustomBrowser).toBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setCustomBrowserSupport(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
config()->set(Config::Browser_UseCustomBrowser, enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BrowserSettings::customBrowserType()
|
|
|
|
|
{
|
|
|
|
|
return config()->get(Config::Browser_CustomBrowserType).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setCustomBrowserType(int type)
|
|
|
|
|
{
|
|
|
|
|
config()->set(Config::Browser_CustomBrowserType, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BrowserSettings::customBrowserLocation()
|
|
|
|
|
{
|
|
|
|
|
return config()->get(Config::Browser_CustomBrowserLocation).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setCustomBrowserLocation(const QString& location)
|
|
|
|
|
{
|
|
|
|
|
config()->set(Config::Browser_CustomBrowserLocation, location);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-11 01:20:00 +00:00
|
|
|
QString BrowserSettings::proxyLocation()
|
|
|
|
|
{
|
|
|
|
|
return m_nativeMessageInstaller.getProxyPath();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 15:51:46 +00:00
|
|
|
#ifdef QT_DEBUG
|
|
|
|
|
QString BrowserSettings::customExtensionId()
|
|
|
|
|
{
|
|
|
|
|
return config()->get(Config::Browser_CustomExtensionId).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setCustomExtensionId(const QString& id)
|
|
|
|
|
{
|
|
|
|
|
config()->set(Config::Browser_CustomExtensionId, id);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
bool BrowserSettings::updateBinaryPath()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_UpdateBinaryPath).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setUpdateBinaryPath(bool enabled)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_UpdateBinaryPath, enabled);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-09 05:46:16 +00:00
|
|
|
bool BrowserSettings::allowExpiredCredentials()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::Browser_AllowExpiredCredentials).toBool();
|
2019-05-09 05:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setAllowExpiredCredentials(bool enabled)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::Browser_AllowExpiredCredentials, enabled);
|
2019-05-09 05:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-11 01:20:00 +00:00
|
|
|
bool BrowserSettings::browserSupport(BrowserShared::SupportedBrowsers browser)
|
2018-03-31 20:01:30 +00:00
|
|
|
{
|
2020-05-11 01:20:00 +00:00
|
|
|
return m_nativeMessageInstaller.isBrowserEnabled(browser);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-11 01:20:00 +00:00
|
|
|
void BrowserSettings::setBrowserSupport(BrowserShared::SupportedBrowsers browser, bool enabled)
|
2018-03-31 20:01:30 +00:00
|
|
|
{
|
2020-05-11 01:20:00 +00:00
|
|
|
m_nativeMessageInstaller.setBrowserEnabled(browser, enabled);
|
2020-01-15 20:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
bool BrowserSettings::passwordUseNumbers()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Numbers).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseNumbers(bool useNumbers)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Numbers, useNumbers);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseLowercase()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_LowerCase).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseLowercase(bool useLowercase)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_LowerCase, useLowercase);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseUppercase()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_UpperCase).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseUppercase(bool useUppercase)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_UpperCase, useUppercase);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseSpecial()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_SpecialChars).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseSpecial(bool useSpecial)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_SpecialChars, useSpecial);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 02:37:09 +00:00
|
|
|
bool BrowserSettings::passwordUseBraces()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Braces).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseBraces(bool useBraces)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Braces, useBraces);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUsePunctuation()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Punctuation).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUsePunctuation(bool usePunctuation)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Punctuation, usePunctuation);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseQuotes()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Quotes).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseQuotes(bool useQuotes)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Quotes, useQuotes);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseDashes()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Dashes).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseDashes(bool useDashes)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Dashes, useDashes);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseMath()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Math).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseMath(bool useMath)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Math, useMath);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordUseLogograms()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Logograms).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseLogograms(bool useLogograms)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Logograms, useLogograms);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
bool BrowserSettings::passwordUseEASCII()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_EASCII).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordUseEASCII(bool useEASCII)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_EASCII, useEASCII);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 02:37:09 +00:00
|
|
|
bool BrowserSettings::advancedMode()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_AdvancedMode).toBool();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setAdvancedMode(bool advancedMode)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_AdvancedMode, advancedMode);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-16 16:51:56 +00:00
|
|
|
QString BrowserSettings::passwordAdditionalChars()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_AdditionalChars).toString();
|
2019-11-16 16:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordAdditionalChars(const QString& chars)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_AdditionalChars, chars);
|
2019-11-16 16:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 02:37:09 +00:00
|
|
|
QString BrowserSettings::passwordExcludedChars()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_ExcludedChars).toString();
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-28 11:49:32 +00:00
|
|
|
void BrowserSettings::setPasswordExcludedChars(const QString& chars)
|
2018-06-11 02:37:09 +00:00
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_ExcludedChars, chars);
|
2018-06-11 02:37:09 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:15:23 +00:00
|
|
|
int BrowserSettings::passPhraseWordCount()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_WordCount).toInt();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPassPhraseWordCount(int wordCount)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_WordCount, wordCount);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BrowserSettings::passPhraseWordSeparator()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_WordSeparator).toString();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-28 11:49:32 +00:00
|
|
|
void BrowserSettings::setPassPhraseWordSeparator(const QString& separator)
|
2017-12-12 08:15:23 +00:00
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_WordSeparator, separator);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BrowserSettings::generatorType()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Type).toInt();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setGeneratorType(int type)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Type, type);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordEveryGroup()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_EnsureEvery).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordEveryGroup(bool everyGroup)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_EnsureEvery, everyGroup);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BrowserSettings::passwordExcludeAlike()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_ExcludeAlike).toBool();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordExcludeAlike(bool excludeAlike)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_ExcludeAlike, excludeAlike);
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BrowserSettings::passwordLength()
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
return config()->get(Config::PasswordGenerator_Length).toInt();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrowserSettings::setPasswordLength(int length)
|
|
|
|
|
{
|
2020-04-25 23:31:38 +00:00
|
|
|
config()->set(Config::PasswordGenerator_Length, length);
|
2017-12-12 08:15:23 +00:00
|
|
|
m_passwordGenerator.setLength(length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PasswordGenerator::CharClasses BrowserSettings::passwordCharClasses()
|
|
|
|
|
{
|
|
|
|
|
PasswordGenerator::CharClasses classes;
|
|
|
|
|
if (passwordUseLowercase()) {
|
|
|
|
|
classes |= PasswordGenerator::LowerLetters;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseUppercase()) {
|
|
|
|
|
classes |= PasswordGenerator::UpperLetters;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseNumbers()) {
|
|
|
|
|
classes |= PasswordGenerator::Numbers;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseSpecial()) {
|
|
|
|
|
classes |= PasswordGenerator::SpecialCharacters;
|
|
|
|
|
}
|
2018-06-11 02:37:09 +00:00
|
|
|
if (passwordUseBraces()) {
|
|
|
|
|
classes |= PasswordGenerator::Braces;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUsePunctuation()) {
|
|
|
|
|
classes |= PasswordGenerator::Punctuation;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseQuotes()) {
|
|
|
|
|
classes |= PasswordGenerator::Quotes;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseDashes()) {
|
|
|
|
|
classes |= PasswordGenerator::Dashes;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseMath()) {
|
|
|
|
|
classes |= PasswordGenerator::Math;
|
|
|
|
|
}
|
|
|
|
|
if (passwordUseLogograms()) {
|
|
|
|
|
classes |= PasswordGenerator::Logograms;
|
|
|
|
|
}
|
2017-12-12 08:15:23 +00:00
|
|
|
if (passwordUseEASCII()) {
|
|
|
|
|
classes |= PasswordGenerator::EASCII;
|
|
|
|
|
}
|
|
|
|
|
return classes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PasswordGenerator::GeneratorFlags BrowserSettings::passwordGeneratorFlags()
|
|
|
|
|
{
|
|
|
|
|
PasswordGenerator::GeneratorFlags flags;
|
|
|
|
|
if (passwordExcludeAlike()) {
|
|
|
|
|
flags |= PasswordGenerator::ExcludeLookAlike;
|
|
|
|
|
}
|
|
|
|
|
if (passwordEveryGroup()) {
|
|
|
|
|
flags |= PasswordGenerator::CharFromEveryGroup;
|
|
|
|
|
}
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 00:40:41 +00:00
|
|
|
QJsonObject BrowserSettings::generatePassword()
|
2017-12-12 08:15:23 +00:00
|
|
|
{
|
2019-06-20 00:40:41 +00:00
|
|
|
QJsonObject password;
|
2017-12-12 08:15:23 +00:00
|
|
|
if (generatorType() == 0) {
|
|
|
|
|
m_passwordGenerator.setLength(passwordLength());
|
|
|
|
|
m_passwordGenerator.setCharClasses(passwordCharClasses());
|
|
|
|
|
m_passwordGenerator.setFlags(passwordGeneratorFlags());
|
2019-06-20 00:40:41 +00:00
|
|
|
const QString pw = m_passwordGenerator.generatePassword();
|
2020-02-01 13:42:34 +00:00
|
|
|
password["entropy"] = PasswordHealth(pw).entropy();
|
2019-06-20 00:40:41 +00:00
|
|
|
password["password"] = pw;
|
2017-12-12 08:15:23 +00:00
|
|
|
} else {
|
|
|
|
|
m_passPhraseGenerator.setWordCount(passPhraseWordCount());
|
|
|
|
|
m_passPhraseGenerator.setWordSeparator(passPhraseWordSeparator());
|
2019-06-20 00:40:41 +00:00
|
|
|
password["entropy"] = m_passPhraseGenerator.estimateEntropy();
|
|
|
|
|
password["password"] = m_passPhraseGenerator.generatePassphrase();
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
2019-06-20 00:40:41 +00:00
|
|
|
return password;
|
2017-12-12 08:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-11 01:20:00 +00:00
|
|
|
void BrowserSettings::updateBinaryPaths()
|
2018-10-23 13:03:18 +00:00
|
|
|
{
|
2020-05-11 01:20:00 +00:00
|
|
|
m_nativeMessageInstaller.updateBinaryPaths();
|
2018-10-23 13:03:18 +00:00
|
|
|
}
|