From 5911a413b0159fa8a73f65f4718e39e4a4417354 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 28 Sep 2007 11:54:19 +0000 Subject: [PATCH] adds default application config, which will be executed if no app explicitely selected git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@463 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmConfig.cpp | 3 +++ core/AmConfig.h | 4 ++++ core/AmSessionContainer.cpp | 7 +++++-- core/sems.conf.sample | 8 ++++++++ core/sems.cpp | 5 ++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 199ebd3a..f2864559 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -59,6 +59,7 @@ string AmConfig::Signature = ""; bool AmConfig::SingleCodecInOK = false; unsigned int AmConfig::DeadRtpTime = DEAD_RTP_TIME; bool AmConfig::IgnoreRTPXHdrs = false; +string AmConfig::DefaultApplication = ""; vector AmConfig::CodecOrder; @@ -210,6 +211,8 @@ int AmConfig::readConfiguration() } } + DefaultApplication = cfg.getParameter("default_application"); + // fork if(cfg.hasParameter("fork")){ if(!setFork(cfg.getParameter("fork"))){ diff --git a/core/AmConfig.h b/core/AmConfig.h index 49b5451f..f6e656f0 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -88,6 +88,10 @@ struct AmConfig /** If 200 OK reply should be limited to preferred codec only */ static bool SingleCodecInOK; static vector CodecOrder; + + /** this application is executed on incoming calls if there is no + * app/P-App-Name header present */ + static string DefaultApplication; /** Time of no RTP after which Session is regarded as dead, 0 for no Timeout */ static unsigned int DeadRtpTime; diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index bcc11eb1..3a52addd 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -322,9 +322,12 @@ AmSession* AmSessionContainer::createSession(AmSipRequest& req, plugin_name = getHeader(req.hdrs,APPNAME_HDR); if(plugin_name.empty()) { - string ex = "AmSessionContainer::createSession: missing '" APPNAME_HDR "' header."; - throw ex; + plugin_name = AmConfig::DefaultApplication; } + if (plugin_name.empty()) { + string ex = "Unknown Application"; + throw ex; + } } AmSessionFactory* state_factory = AmPlugIn::instance()->getFactory4App(plugin_name); diff --git a/core/sems.conf.sample b/core/sems.conf.sample index 22d243f8..216a0f2c 100644 --- a/core/sems.conf.sample +++ b/core/sems.conf.sample @@ -37,6 +37,14 @@ stderr=no # (same as -D) loglevel=2 +# optional parameter: default_application +# - this application is executed if the application is +# not explicitely set with P-App-Name header/appname +# parameter of unix command. +# +# example: +# default_application = conference + # optional parameter: socket_name= # # - path and file name of our unix socket diff --git a/core/sems.cpp b/core/sems.cpp index f19ddaca..545caf7e 100644 --- a/core/sems.cpp +++ b/core/sems.cpp @@ -256,6 +256,7 @@ int main(int argc, char* argv[]) " plug-in path: %s\n" " daemon mode: %i\n" " local IP: %s\n" + " default application: %s\n" "\n", AmConfig::ConfigurationFile.c_str(), AmConfig::SerSocketName.c_str(), @@ -263,7 +264,9 @@ int main(int argc, char* argv[]) AmConfig::ReplySocketName.c_str(), AmConfig::PlugInPath.c_str(), AmConfig::DaemonMode, - AmConfig::LocalIP.c_str() + AmConfig::LocalIP.c_str(), + AmConfig::DefaultApplication.empty()? + "":AmConfig::DefaultApplication.c_str() ); if(AmConfig::DaemonMode){