Module: sems
Branch: master
Commit: 91ee676feb4f028652a631b223d02451d6079db1
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=91ee676feb4f028652a631b223d02451d6079db1

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Tue Sep 27 13:45:20 2011 +0200

sbc: cc: added getMandatoryValues DI function

with getMandatoryValues the call control modules can assure that the
configuration contains the values that are necessary for proper
functioning of the call control module.

E.g. the parallel calls module has 'uuid' as mandatory parameter; if
that is not configured, the sbc profile will not load.

---

 apps/sbc/SBCCallProfile.cpp                        |   31 ++++++++++++++++----
 apps/sbc/SBCCallProfile.h                          |    2 +
 .../parallel_calls/CCParallelCalls.cpp             |    2 +
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp
index f75edbc..b8dc293 100644
--- a/apps/sbc/SBCCallProfile.cpp
+++ b/apps/sbc/SBCCallProfile.cpp
@@ -182,12 +182,21 @@ bool SBCCallProfile::readFromConfiguration(const string& 
name,
 
       cc_if.cc_module = cfg.getParameter(*it + "_module");
 
-      // check if module is loaded
-      if ((cc_if.cc_module.find('$') == string::npos) &&
-         (NULL == AmPlugIn::instance()->getFactory4Di(cc_if.cc_module))) {
-       ERROR("Call control module '%s' used in call profile "
-             "'%s' is not loaded\n", cc_if.cc_module.c_str(), name.c_str());
-       return false;
+      AmArg mandatory_values;
+
+      // check if module is loaded and if, get mandatory config values
+      if (cc_if.cc_module.find('$') == string::npos) {
+       AmDynInvokeFactory* df = 
AmPlugIn::instance()->getFactory4Di(cc_if.cc_module);
+       if (NULL == df) {
+         ERROR("Call control module '%s' used in call profile "
+               "'%s' is not loaded\n", cc_if.cc_module.c_str(), name.c_str());
+         return false;
+       }
+       AmDynInvoke* di = df->getInstance();
+       AmArg args;
+       try {
+         di->invoke(CC_INTERFACE_MAND_VALUES_METHOD, args, mandatory_values);
+       } catch (AmDynInvoke::NotImplemented& ni) { }
       }
 
       size_t cc_name_prefix_len = it->length()+1;
@@ -204,6 +213,16 @@ bool SBCCallProfile::readFromConfiguration(const string& 
name,
 
        cc_if.cc_values[cfg_it->first.substr(cc_name_prefix_len)] = 
cfg_it->second;
       }
+
+      for (size_t i=0;i<mandatory_values.size();i++) {
+       if (!isArgCStr(mandatory_values[i])) continue;
+       if (cc_if.cc_values.find(mandatory_values[i].asCStr()) == 
cc_if.cc_values.end()) {
+         ERROR("value '%s' for SBC profile '%s' in '%s' not defined. set 
%s_%s=...\n",
+               mandatory_values[i].asCStr(), name.c_str(), 
profile_file_name.c_str(),
+               it->c_str(), mandatory_values[i].asCStr());
+         return false;
+       }
+      }
     }
   }
 
diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h
index b9ed2b4..1b8e75e 100644
--- a/apps/sbc/SBCCallProfile.h
+++ b/apps/sbc/SBCCallProfile.h
@@ -41,6 +41,8 @@ using std::set;
 typedef map<string, AmArg>   SBCVarMapT;
 typedef SBCVarMapT::iterator SBCVarMapIteratorT;
 
+#define CC_INTERFACE_MAND_VALUES_METHOD "getMandatoryValues"
+
 struct CCInterface {
   string cc_name;
   string cc_module;
diff --git a/apps/sbc/call_control/parallel_calls/CCParallelCalls.cpp 
b/apps/sbc/call_control/parallel_calls/CCParallelCalls.cpp
index 7da6613..8e04af6 100644
--- a/apps/sbc/call_control/parallel_calls/CCParallelCalls.cpp
+++ b/apps/sbc/call_control/parallel_calls/CCParallelCalls.cpp
@@ -93,6 +93,8 @@ void CCParallelCalls::invoke(const string& method, const 
AmArg& args, AmArg& ret
       SBCCallProfile* call_profile = 
dynamic_cast<SBCCallProfile*>(args[1].asObject());
 
       end(args.get(0).asCStr(), call_profile, args.get(2).asInt(), 
args.get(3).asInt());
+    } else if(method == CC_INTERFACE_MAND_VALUES_METHOD){
+      ret.push("uuid");
     } else if(method == "_list"){
       ret.push("start");
       ret.push("connect");

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to