Module: sems Branch: kubartv/cc_rest Commit: 51bccb25d341f1d59c80c4943148fd1d1a82428d URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=51bccb25d341f1d59c80c4943148fd1d1a82428d
Author: Václav Kubart <[email protected]> Committer: Václav Kubart <[email protected]> Date: Thu Feb 2 09:40:51 2012 +0100 base_url parameter renamed to url and few more call profile params are replaced --- apps/sbc/call_control/rest/RestModule.cpp | 25 +++++++++++++++++++------ apps/sbc/call_control/rest/RestParams.cpp | 15 +++++++++++++++ apps/sbc/call_control/rest/RestParams.h | 1 + 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/apps/sbc/call_control/rest/RestModule.cpp b/apps/sbc/call_control/rest/RestModule.cpp index f24930a..33fd1ac 100644 --- a/apps/sbc/call_control/rest/RestModule.cpp +++ b/apps/sbc/call_control/rest/RestModule.cpp @@ -184,11 +184,11 @@ void RestModule::start(const string& cc_name, const string& ltag, string url; bool ignore_errors = true; - if (!values.hasMember("base_url")) - throw string("configuration error: base_url must be configured for REST queries\n"); + if (!values.hasMember("url")) + throw string("configuration error: url must be configured for REST queries\n"); - if (!isArgCStr(values["base_url"]) || !strlen(values["base_url"].asCStr())) { - throw string("configuration error: invalid value of base_url\n"); + if (!isArgCStr(values["url"]) || !strlen(values["url"].asCStr())) { + throw string("configuration error: invalid value of url\n"); } /*FIXME @@ -201,12 +201,25 @@ void RestModule::start(const string& cc_name, const string& ltag, ignore_errors = values["ignore_errors"].asBool(); }*/ - url = values["base_url"].asCStr(); - DBG("REST: base_url = %s\n", url.c_str()); + url = values["url"].asCStr(); + DBG("REST: url = %s\n", url.c_str()); RestParams params(url, ignore_errors); params.getIfSet("ruri", call_profile->ruri); + params.getIfSet("from", call_profile->from); + params.getIfSet("to", call_profile->to); + params.getIfSet("contact", call_profile->contact); + params.getIfSet("call-id", call_profile->callid); + params.getIfSet("outbound_proxy", call_profile->outbound_proxy); + params.getIfSet("force_outbound_proxy", call_profile->force_outbound_proxy); + params.getIfSet("next_hop_ip", call_profile->next_hop_ip); + params.getIfSet("next_hop_port", call_profile->next_hop_port); + params.getIfSet("next_hop_for_replies", call_profile->next_hop_for_replies); + + // TODO: headerfilter, messagefilter + // TODO: other params + } catch (string &err) { ERROR(err.c_str()); diff --git a/apps/sbc/call_control/rest/RestParams.cpp b/apps/sbc/call_control/rest/RestParams.cpp index 84d4337..d2e827a 100644 --- a/apps/sbc/call_control/rest/RestParams.cpp +++ b/apps/sbc/call_control/rest/RestParams.cpp @@ -16,12 +16,27 @@ static void trim_spaces(string &s) else s.erase(s.begin(), s.end()); } +static bool str2bool(const string &s) +{ + if (s.empty()) return true; // understand as just bool option which should be true + if ((s == "yes") || (s == "1") || (s == "true")) return true; + else return false; +} + +//////////////////////////////////////////////////////////////////////////////// + void RestParams::getIfSet(const char *param_name, string &dst) { map<string, string>::iterator i = params.find(param_name); if (i != params.end()) dst = i->second; } +void RestParams::getIfSet(const char *param_name, bool &dst) +{ + map<string, string>::iterator i = params.find(param_name); + if (i != params.end()) dst = str2bool(i->second); +} + void RestParams::handleParamLine(const string &line, size_t begin, size_t end) { size_t pos; diff --git a/apps/sbc/call_control/rest/RestParams.h b/apps/sbc/call_control/rest/RestParams.h index 8f47ac0..8b89860 100644 --- a/apps/sbc/call_control/rest/RestParams.h +++ b/apps/sbc/call_control/rest/RestParams.h @@ -23,6 +23,7 @@ class RestParams { // sets dst to value of given parameter if the parameter is set void getIfSet(const char *param_name, string &dst); + void getIfSet(const char *param_name, bool &dst); }; #endif _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
