diff --git a/engine/Channel.cpp b/engine/Channel.cpp index 63223389..61df7127 100644 --- a/engine/Channel.cpp +++ b/engine/Channel.cpp @@ -1107,31 +1107,37 @@ void* Module::getObject(const String& name) const return Plugin::getObject(name); } -bool Module::installRelay(int id, const char* name, unsigned priority) +bool Module::installRelay(int id, const char* name, unsigned priority, NamedString* filter) { - if (!(id && name && priority)) + if (!(id && name && priority)) { + TelEngine::destruct(filter); return false; + } TempObjectCounter cnt(objectsCounter(),true); Lock lock(this); - if (m_relays & id) + if (m_relays & id) { + TelEngine::destruct(filter); return true; + } m_relays |= id; MessageRelay* relay = new MessageRelay(name,this,id,priority,Module::name()); + if (filter) + relay->setFilter(filter); m_relayList.append(relay)->setDelete(false); Engine::install(relay); return true; } -bool Module::installRelay(int id, unsigned priority) +bool Module::installRelay(int id, unsigned priority, NamedString* filter) { - return installRelay(id,messageName(id),priority); + return installRelay(id,messageName(id),priority,filter); } -bool Module::installRelay(const char* name, unsigned priority) +bool Module::installRelay(const char* name, unsigned priority, NamedString* filter) { - return installRelay(lookup(name,s_messages),name,priority); + return installRelay(lookup(name,s_messages),name,priority,filter); } bool Module::installRelay(MessageRelay* relay) diff --git a/yatephone.h b/yatephone.h index c8e1da2d..ca2f7a44 100644 --- a/yatephone.h +++ b/yatephone.h @@ -1509,26 +1509,29 @@ protected: * Install a standard message relay * @param id RelayID of the new relay to create * @param priority Priority of the handler, 0 = top + * @param filter Optional filter for relay. It will be consumed * @return True if installed or already was one installed */ - bool installRelay(int id, unsigned priority = 100); + bool installRelay(int id, unsigned priority = 100, NamedString* filter = 0); /** * Install a standard message relay * @param name Name of the relay to create, must match a RelayID * @param priority Priority of the handler, 0 = top + * @param filter Optional filter for relay. It will be consumed * @return True if installed or already was one installed */ - bool installRelay(const char* name, unsigned priority = 100); + bool installRelay(const char* name, unsigned priority = 100, NamedString* filter = 0); /** * Install a custom message relay * @param id RelayID of the new relay to create * @param name Name of the custom relay to create * @param priority Priority of the handler, 0 = top + * @param filter Optional filter for relay. It will be consumed * @return True if installed or already was one installed */ - bool installRelay(int id, const char* name, unsigned priority = 100); + bool installRelay(int id, const char* name, unsigned priority = 100, NamedString* filter = 0); /** * Install a custom message relay