[prev in list] [next in list] [prev in thread] [next in thread] 

List:       semsdev
Subject:    [Semsdev] r336 - trunk/core
From:       sayer () mail ! berlios ! de
Date:       2007-05-28 21:33:53
Message-ID: 200705282133.l4SLXrZg016019 () sheep ! berlios ! de
[Download RAW message or body]

Author: sayer
Date: 2007-05-28 23:33:49 +0200 (Mon, 28 May 2007)
New Revision: 336

Modified:
   trunk/core/AmApi.cpp
   trunk/core/AmApi.h
   trunk/core/AmSessionContainer.cpp
   trunk/core/AmSessionContainer.h
   trunk/core/AmUAC.cpp
   trunk/core/AmUAC.h
Log:
allows to give dialout sessions a variant parameter with the call to AmUAC::dialout. 
Plugin interface stays backward compatible by overloading the AmSessionFactory::onInvite 
- applications that want to use this feature need to implement the onInvite function with 
second parameter.


Modified: trunk/core/AmApi.cpp
===================================================================
--- trunk/core/AmApi.cpp	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmApi.cpp	2007-05-28 21:33:49 UTC (rev 336)
@@ -48,11 +48,24 @@
 {
 }
 
+AmSession* AmSessionFactory::onInvite(const AmSipRequest& req, 
+				      AmArg& session_params) {
+  WARN(" discarding session parameters to new session.\n");
+  return onInvite(req);
+}
+
 AmSession* AmSessionFactory::onRefer(const AmSipRequest& req)
 {
   throw AmSession::Exception(488,"Not accepted here");
 }
 
+AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, 
+				     AmArg& session_params)
+{
+  WARN(" discarding session parameters to new session.\n");
+  return onRefer(req);
+}
+
 int AmSessionFactory::configureModule(AmConfigReader& cfg) {
   return mod_conf.readFromConfig(cfg);
 }
@@ -71,6 +84,12 @@
 {
 }
 
+bool AmSessionEventHandlerFactory::onInvite(const AmSipRequest& req, 
+						  AmArg& session_params) {
+  WARN("discarding session parameters for new session.\n");
+  return onInvite(req);
+}
+
 AmSIPEventHandler::AmSIPEventHandler(const string& name) 
   : AmPluginFactory(name) 
 {

Modified: trunk/core/AmApi.h
===================================================================
--- trunk/core/AmApi.h	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmApi.h	2007-05-28 21:33:49 UTC (rev 336)
@@ -113,6 +113,7 @@
    * @return true if session creation should be stopped
    */
   virtual bool onInvite(const AmSipRequest& req)=0;
+  virtual bool onInvite(const AmSipRequest& req, AmArg& session_params);
 };
 
 /** \brief Interface for plugins to create sessions */
@@ -147,6 +148,19 @@
   virtual AmSession* onInvite(const AmSipRequest& req)=0;
 
   /**
+   * Creates a dialog state on new request. Passes with 
+   * parameters to the new session.
+   * 
+   * @return 0 if the request is not acceptable.
+   *
+   * Warning:
+   *   This method should not make any expensive
+   *   processing as it would block the server.
+   */
+  virtual AmSession* onInvite(const AmSipRequest& req, 
+			      AmArg& session_params);
+
+  /**
    * Creates a dialog state on new REFER with local-tag.
    * @return 0 if the request is not acceptable.
    *
@@ -157,6 +171,18 @@
   virtual AmSession* onRefer(const AmSipRequest& req);
 
   /**
+   * Creates a dialog state on new REFER with local-tag.
+   * Passes session_params to the new session.
+   * @return 0 if the request is not acceptable.
+   *
+   * Warning:
+   *   This method should not make any expensive
+   *   processing as it would block the server.
+   */
+  virtual AmSession* onRefer(const AmSipRequest& req, 
+			     AmArg& session_params);
+
+  /**
    * method to receive an Event that is posted
    * to  the factory
    *

Modified: trunk/core/AmSessionContainer.cpp
===================================================================
--- trunk/core/AmSessionContainer.cpp	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmSessionContainer.cpp	2007-05-28 21:33:49 UTC (rev 336)
@@ -177,11 +177,11 @@
   return it->second;
 }
 
-AmSession* AmSessionContainer::startSessionUAC(AmSipRequest& req) {
+AmSession* AmSessionContainer::startSessionUAC(AmSipRequest& req, AmArg* session_params) {
   AmSession* session = NULL;
   as_mut.lock();
   try {
-    if((session = createSession(req)) != 0){
+    if((session = createSession(req, session_params)) != 0){
       session->dlg.updateStatusFromLocalRequest(req); // sets local tag as well
       session->setCallgroup(req.from_tag);
 
@@ -303,7 +303,8 @@
   return false;
 }
 
-AmSession* AmSessionContainer::createSession(AmSipRequest& req)
+AmSession* AmSessionContainer::createSession(AmSipRequest& req, 
+					     AmArg* session_params)
 {
   string& plugin_name = req.cmd;
 
@@ -328,13 +329,18 @@
   }
 	    
   AmSession* session = 0;
-  if (req.method == "INVITE")
-    session = state_factory->onInvite(req);
-  else if (req.method == "REFER")
-    session = state_factory->onRefer(req);
+  if (req.method == "INVITE") {
+    if (NULL != session_params) 
+      session = state_factory->onInvite(req, *session_params);
+    else 
+      session = state_factory->onInvite(req);
+  }  else if (req.method == "REFER") {
+    if (NULL != session_params) 
+      session = state_factory->onRefer(req, *session_params);
+    else 
+      session = state_factory->onRefer(req);
+  }
 
-
-
   if(!session) {
     //  State creation failed:
     //   application denied session creation

Modified: trunk/core/AmSessionContainer.h
===================================================================
--- trunk/core/AmSessionContainer.h	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmSessionContainer.h	2007-05-28 21:33:49 UTC (rev 336)
@@ -141,7 +141,8 @@
    * @param req local request
    * @return a new session or NULL on error.
    */
-  AmSession* createSession(AmSipRequest& req);
+  AmSession* createSession(AmSipRequest& req, 
+			   AmArg* session_params = NULL);
 
   /**
    * Adds a session to the container (UAS only).
@@ -169,7 +170,8 @@
    * Constructs a new session and adds it to the active session container. 
    * @param req client's request
    */
-  AmSession* startSessionUAC(AmSipRequest& req);
+  AmSession* startSessionUAC(AmSipRequest& req, 
+			     AmArg* session_params = NULL);
 
   /**
    * Detroys a session.

Modified: trunk/core/AmUAC.cpp
===================================================================
--- trunk/core/AmUAC.cpp	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmUAC.cpp	2007-05-28 21:33:49 UTC (rev 336)
@@ -37,7 +37,8 @@
 			  const string& from,
 			  const string& from_uri,
 			  const string& to,
-			  const string& local_tag) {
+			  const string& local_tag,
+			  AmArg*  session_params) {
  
   AmSipRequest req;
 
@@ -56,6 +57,6 @@
   req.to_tag   = "";
   req.callid   = AmSession::getNewId() + "@" + AmConfig::LocalIP;
     
-  return AmSessionContainer::instance()->startSessionUAC(req);
+  return AmSessionContainer::instance()->startSessionUAC(req, session_params);
 }
 

Modified: trunk/core/AmUAC.h
===================================================================
--- trunk/core/AmUAC.h	2007-05-23 16:04:40 UTC (rev 335)
+++ trunk/core/AmUAC.h	2007-05-28 21:33:49 UTC (rev 336)
@@ -30,6 +30,7 @@
 
 #include "AmThread.h"
 #include "AmSession.h"
+#include "AmArg.h"
 
 #include <string>
 using std::string; 
@@ -43,7 +44,9 @@
 			    const string& from,
 			    const string& from_uri,
 			    const string& to,
-			    const string& local_tag = "");
+			    const string& local_tag = "",
+			    AmArg*  session_params = NULL);
+
 };
 
 #endif

_______________________________________________
Semsdev mailing list
Semsdev@lists.iptel.org
http://lists.iptel.org/mailman/listinfo/semsdev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic