mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #494 Using CValueCachePacket, cache values are given timestamps.
This commit is contained in:
@@ -63,12 +63,12 @@ namespace BlackCore
|
||||
this->m_logSubscriptions[subscriber].removeAll(pattern);
|
||||
});
|
||||
|
||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CVariantMap &settings)
|
||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CValueCachePacket &settings)
|
||||
{
|
||||
this->changeSettings(settings, {});
|
||||
});
|
||||
|
||||
connect(this, &IContextApplication::settingsChanged, [](const CVariantMap &settings, const CIdentifier &origin)
|
||||
connect(this, &IContextApplication::settingsChanged, [](const CValueCachePacket &settings, const CIdentifier &origin)
|
||||
{
|
||||
// Intentionally don't check for round trip here
|
||||
CSettingsCache::instance()->changeValuesFromRemote(settings, origin);
|
||||
@@ -120,7 +120,7 @@ namespace BlackCore
|
||||
return result;
|
||||
}
|
||||
|
||||
void IContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||
void IContextApplication::changeSettings(const CValueCachePacket &settings, const CIdentifier &origin)
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(origin);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace BlackCore
|
||||
|
||||
//! One or more settings were changed
|
||||
//! \note Used for cache relay, do not use directly
|
||||
void settingsChanged(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin);
|
||||
void settingsChanged(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin);
|
||||
|
||||
//! New action was registered
|
||||
//! \note Used to register hotkey action, do not use directly
|
||||
@@ -138,10 +138,10 @@ namespace BlackCore
|
||||
//! Ratify some settings changed by another process
|
||||
//! \note Not pure because it can be called from the base class constructor.
|
||||
//! \note This is the function which relays cache changes via DBus.
|
||||
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin);
|
||||
virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin);
|
||||
|
||||
//! Get all settings currently in core settings cache
|
||||
virtual BlackMisc::CVariantMap getAllSettings() const = 0;
|
||||
virtual BlackMisc::CValueCachePacket getAllSettings() const = 0;
|
||||
|
||||
//! Update local settings with settings from core
|
||||
virtual void synchronizeLocalSettings() = 0;
|
||||
|
||||
@@ -66,16 +66,16 @@ namespace BlackCore
|
||||
// no-op: proxy implements this method by calling getAllLogSubscriptions
|
||||
}
|
||||
|
||||
void CContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||
void CContextApplication::changeSettings(const CValueCachePacket &settings, const CIdentifier &origin)
|
||||
{
|
||||
// Intentionally don't check for round trip here
|
||||
emit this->settingsChanged(settings, origin);
|
||||
}
|
||||
|
||||
BlackMisc::CVariantMap CContextApplication::getAllSettings() const
|
||||
BlackMisc::CValueCachePacket CContextApplication::getAllSettings() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return CSettingsCache::instance()->getAllValues();
|
||||
return CSettingsCache::instance()->getAllValuesWithTimestamps();
|
||||
}
|
||||
|
||||
void CContextApplication::synchronizeLocalSettings()
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace BlackCore
|
||||
virtual void synchronizeLogSubscriptions();
|
||||
|
||||
//! \copydoc IContextApplication::changeSettings
|
||||
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
||||
virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin) override;
|
||||
|
||||
//! \copydoc IContextApplication::getAllSettings
|
||||
virtual BlackMisc::CVariantMap getAllSettings() const override;
|
||||
virtual BlackMisc::CValueCachePacket getAllSettings() const override;
|
||||
|
||||
//! \copydoc IContextApplication::synchronizeLocalSettings
|
||||
virtual void synchronizeLocalSettings() override;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BlackCore
|
||||
"logSubscriptionRemoved", this, SIGNAL(logSubscriptionRemoved(BlackMisc::CIdentifier, BlackMisc::CLogPattern)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"settingsChanged", this, SIGNAL(settingsChanged(BlackMisc::CVariantMap, BlackMisc::CIdentifier)));
|
||||
"settingsChanged", this, SIGNAL(settingsChanged(BlackMisc::CValueCachePacket, BlackMisc::CIdentifier)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||
"registrationChanged", this, SIGNAL(registrationChanged()));
|
||||
@@ -93,14 +93,14 @@ namespace BlackCore
|
||||
for (const auto &pattern : CLogHandler::instance()->getAllSubscriptions()) { this->addLogSubscription({}, pattern); }
|
||||
}
|
||||
|
||||
void CContextApplicationProxy::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||
void CContextApplicationProxy::changeSettings(const CValueCachePacket &settings, const CIdentifier &origin)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("changeSettings"), settings, origin);
|
||||
}
|
||||
|
||||
BlackMisc::CVariantMap CContextApplicationProxy::getAllSettings() const
|
||||
BlackMisc::CValueCachePacket CContextApplicationProxy::getAllSettings() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CVariantMap>(QLatin1Literal("getAllSettings"));
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CValueCachePacket>(QLatin1Literal("getAllSettings"));
|
||||
}
|
||||
|
||||
void CContextApplicationProxy::synchronizeLocalSettings()
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace BlackCore
|
||||
virtual void synchronizeLogSubscriptions();
|
||||
|
||||
//! \copydoc IContextApplication::changeSettings
|
||||
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
||||
virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin) override;
|
||||
|
||||
//! \copydoc IContextApplication::getAllSettings
|
||||
virtual BlackMisc::CVariantMap getAllSettings() const override;
|
||||
virtual BlackMisc::CValueCachePacket getAllSettings() const override;
|
||||
|
||||
//! \copydoc IContextApplication::synchronizeLocalSettings
|
||||
virtual void synchronizeLocalSettings() override;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackCore
|
||||
CLogMessage(this).error("Failed to create directory %1") << persistentStore();
|
||||
}
|
||||
|
||||
connect(this, &CValueCache::valuesChangedByLocal, this, &CDataCache::saveToStore);
|
||||
connect(this, &CValueCache::valuesChangedByLocal, this, [this](const CValueCachePacket &values) { saveToStore(values.toVariantMap()); });
|
||||
connect(&m_watcher, &QFileSystemWatcher::fileChanged, this, [this] { loadFromStore(); });
|
||||
|
||||
if (! QFile::exists(m_revisionFileName)) { QFile(m_revisionFileName).open(QFile::WriteOnly); }
|
||||
@@ -116,7 +116,7 @@ namespace BlackCore
|
||||
if (m_revision != newRevision)
|
||||
{
|
||||
m_revision = newRevision;
|
||||
CVariantMap newValues;
|
||||
CValueCachePacket newValues;
|
||||
loadFromFiles(persistentStore(), newValues);
|
||||
m_deferredChanges.insert(newValues);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackCore
|
||||
QFileSystemWatcher m_watcher;
|
||||
QUuid m_revision;
|
||||
const QString m_revisionFileName { persistentStore() + "/.rev" };
|
||||
BlackMisc::CVariantMap m_deferredChanges;
|
||||
BlackMisc::CValueCachePacket m_deferredChanges;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user