mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
refs #467 Only send a log message via DBus if it matches a pattern to which another process has subscribed.
This commit is contained in:
@@ -111,6 +111,17 @@ namespace BlackCore
|
|||||||
CInputManager::instance()->setForwarding(true);
|
CInputManager::instance()->setForwarding(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CIdentifierList IContextApplication::subscribersOf(const CStatusMessage &message) const
|
||||||
|
{
|
||||||
|
CIdentifierList result;
|
||||||
|
for (auto it = m_logSubscriptions.begin(); it != m_logSubscriptions.end(); ++it)
|
||||||
|
{
|
||||||
|
bool match = std::any_of(it->begin(), it->end(), [&message](const CLogPattern &pattern) { return pattern.match(message); });
|
||||||
|
if (match) { result.push_back(it.key()); }
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void IContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
void IContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ namespace BlackCore
|
|||||||
void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms);
|
void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//! Compute which process' subscriptions match a given log message.
|
||||||
|
BlackMisc::CIdentifierList subscribersOf(const BlackMisc::CStatusMessage &message) const;
|
||||||
|
|
||||||
//! Tracks which processes are subscribed to which patterns of log messages.
|
//! Tracks which processes are subscribed to which patterns of log messages.
|
||||||
CLogSubscriptionHash m_logSubscriptions;
|
CLogSubscriptionHash m_logSubscriptions;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
CLogHandler::instance()->logRemoteMessage(message);
|
CLogHandler::instance()->logRemoteMessage(message);
|
||||||
}
|
}
|
||||||
emit this->messageLogged(message, origin);
|
if (subscribersOf(message).containsAnyNotIn(CIdentifierList({ origin, {} })))
|
||||||
|
{
|
||||||
|
emit this->messageLogged(message, origin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextApplication::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
void CContextApplication::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
|||||||
@@ -65,7 +65,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextApplicationProxy::logMessage(const CStatusMessage &message, const CIdentifier &origin)
|
void CContextApplicationProxy::logMessage(const CStatusMessage &message, const CIdentifier &origin)
|
||||||
{
|
{
|
||||||
this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin);
|
if (subscribersOf(message).containsAnyNotIn(CIdentifierList({ origin, {} })))
|
||||||
|
{
|
||||||
|
this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextApplicationProxy::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
void CContextApplicationProxy::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
|||||||
Reference in New Issue
Block a user