Reduce use of static vars in browser plugin

* Convert BrowserSettings into instanced class
* Moved HostInstaller init into class constructor
This commit is contained in:
Jonathan White 2018-09-05 16:21:59 -04:00
parent 57e60681f2
commit 53a17c2355
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
11 changed files with 209 additions and 203 deletions

View file

@ -30,14 +30,14 @@
NativeMessagingHost::NativeMessagingHost(DatabaseTabWidget* parent, const bool enabled)
: NativeMessagingBase(enabled)
, m_mutex(QMutex::Recursive)
, m_browserClients(m_browserService)
, m_browserService(parent)
, m_browserClients(m_browserService)
{
m_localServer.reset(new QLocalServer(this));
m_localServer->setSocketOptions(QLocalServer::UserAccessOption);
m_running.store(false);
if (BrowserSettings::isEnabled() && !m_running) {
if (browserSettings()->isEnabled() && !m_running) {
run();
}
@ -64,8 +64,8 @@ void NativeMessagingHost::run()
}
// Update KeePassXC/keepassxc-proxy binary paths to Native Messaging scripts
if (BrowserSettings::updateBinaryPath()) {
BrowserSettings::updateBinaryPaths(BrowserSettings::useCustomProxy() ? BrowserSettings::customProxyLocation()
if (browserSettings()->updateBinaryPath()) {
browserSettings()->updateBinaryPaths(browserSettings()->useCustomProxy() ? browserSettings()->customProxyLocation()
: "");
}
@ -75,7 +75,7 @@ void NativeMessagingHost::run()
QtConcurrent::run(this, static_cast<void (NativeMessagingHost::*)()>(&NativeMessagingHost::readNativeMessages));
#endif
if (BrowserSettings::supportBrowserProxy()) {
if (browserSettings()->supportBrowserProxy()) {
QString serverPath = getLocalServerPath();
QFile::remove(serverPath);