From 8bf91c61fb7f70a6f053df2e1cd4959f466f006e Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 20 Jun 2006 22:01:30 +0000 Subject: [PATCH] Added channel ID filter, updated sample file. git-svn-id: http://yate.null.ro/svn/yate/trunk@892 acf43c95-373e-0410-b603-e72c3f656dc1 --- conf.d/pbxassist.conf.sample | 10 +++++++-- modules/pbxassist.cpp | 39 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/conf.d/pbxassist.conf.sample b/conf.d/pbxassist.conf.sample index 227c59b0..2e4ca56a 100644 --- a/conf.d/pbxassist.conf.sample +++ b/conf.d/pbxassist.conf.sample @@ -7,6 +7,12 @@ ; priority: int: Priority to install message handlers into engine ;priority=15 +; default: bool: Assist channels by default +;default=yes + +; filter: regexp: Expression matching assisted channel IDs, default all +;filter= + ; minlen: int: Minimum length of command sequences ;minlen=2 @@ -33,8 +39,8 @@ ; message: string: Message to emit for this operation ;message=chan.operation -; remember: bool: Remember peer's ID just before performing the operation -;remember=yes +; pbxstates: regexp: Expression matching states allowing operation, default all +;pbxstates= ; All other parameters are copied in the generated message after having ; the \0 .. \9 placeholders replaced with matches from the trigger diff --git a/modules/pbxassist.cpp b/modules/pbxassist.cpp index 43237a7a..4c63e5c1 100644 --- a/modules/pbxassist.cpp +++ b/modules/pbxassist.cpp @@ -65,17 +65,28 @@ public: virtual bool received(Message& msg, int id, ChanAssist* assist); }; +// assist all channels by default? +static bool s_assist = true; +// filter for channel names to enable assistance +static Regexp s_filter; + +// interdigit timeout, clear collected digits if last was older than this static unsigned int s_timeout = 30000000; +// minimum length of collected digits before we start interpreting static int s_minlen = 2; +// maximum length of collected digits, drop old if longer static int s_maxlen = 20; +// command to take back from DTMF pass-through mode static String s_retake; +// on-hold (music) source name static String s_onhold; +// error beep override source name static String s_error; static Configuration s_cfg; @@ -83,8 +94,14 @@ static Configuration s_cfg; ChanAssist* PBXList::create(Message& msg, const String& id) { Debug(this,DebugCall,"Asked to create assistant for '%s'",id.c_str()); - if (msg == "chan.startup" || msg.userObject("Channel")) - return new PBXAssist(this,id); + if (msg == "chan.startup" || msg.userObject("Channel")) { + // if a filter is set try to match it + if (s_filter && !s_filter.matches(id)) + return 0; + // allow routing to enable/disable assistance + if (msg.getBoolValue("pbxassist",s_assist)) + return new PBXAssist(this,id); + } return 0; } @@ -102,6 +119,8 @@ void PBXList::initialize() lock(); s_cfg = Engine::configFile(name()); s_cfg.load(); + s_assist = s_cfg.getBoolValue("general","default",true); + s_filter = s_cfg.getValue("general","filter"); s_minlen = s_cfg.getIntValue("general","minlen",2); if (s_minlen < 1) s_minlen = 1; @@ -122,6 +141,7 @@ void PBXList::initialize() ChanAssistList::initialize(); } +// Handler for relayed messages, call corresponding assistant method bool PBXList::received(Message& msg, int id, ChanAssist* assist) { switch (id) { @@ -269,10 +289,17 @@ bool PBXAssist::msgOperation(Message& msg, const String& operation) return true; } + else if (operation == "setstate") { + // just set the current state and conference room + m_state = msg.getValue("state"); + m_room = msg.getValue("room"); + return true; + } + else if (operation == "conference") { // turn the call into a conference or connect back to one it left if (m_state=="conference") - return errorBeep(); + return errorBeep(); RefPointer c = locate(); if (!c) return errorBeep(); @@ -317,12 +344,6 @@ bool PBXAssist::msgOperation(Message& msg, const String& operation) return true; } - else if (operation == "setstate") { - // just set the current state and conference room - m_state = msg.getValue("state"); - m_room = msg.getValue("room"); - } - else if (operation == "secondcall") { // make another call, disconnect peer Message m("call.preroute");