Author: sayer
Date: 2010-04-21 02:26:00 +0200 (Wed, 21 Apr 2010)
New Revision: 1814

Modified:
   trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp
   trunk/apps/dsm/mods/mod_dlg/ModDlg.h
   trunk/apps/dsm/mods/mod_dlg/Readme.mod_dlg.txt
Log:
dialout function

Modified: trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp      2010-04-21 00:03:29 UTC (rev 
1813)
+++ trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp      2010-04-21 00:26:00 UTC (rev 
1814)
@@ -34,6 +34,9 @@
 #include <string.h>
 #include "AmSipHeaders.h"
 
+#include "AmUAC.h"
+#include "ampi/UACAuthAPI.h"
+
 SC_EXPORT(MOD_CLS_NAME);
 
 
@@ -43,6 +46,7 @@
   DEF_CMD("dlg.acceptInvite", DLGAcceptInviteAction);
   DEF_CMD("dlg.bye", DLGByeAction);
   DEF_CMD("dlg.connectCalleeRelayed", DLGConnectCalleeRelayedAction);
+  DEF_CMD("dlg.dialout", DLGDialoutAction);
 
 } MOD_ACTIONEXPORT_END;
 
@@ -159,3 +163,82 @@
 
   sc_sess->B2BconnectCallee(remote_party, remote_uri, true);
 } EXEC_ACTION_END;
+
+EXEC_ACTION_START(DLGDialoutAction) {  
+  string arrayname = resolveVars(arg, sess, sc_sess, event_params);
+
+#define GET_VARIABLE_MANDATORY(varname_suffix, outvar)                 \
+  it = sc_sess->var.find(arrayname+varname_suffix); \
+  if (it == sc_sess->var.end()) {                                      \
+    WARN("%s", std::string("need " + arrayname + varname_suffix " set for 
dlg.dialoutSimple("+arrayname+")").c_str()); \
+    sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);                         \
+    return false;                                                      \
+  }                                                                    \
+  outvar = it->second;
+
+#define GET_VARIABLE_OPTIONAL(varname_suffix, outvar) \
+  it = sc_sess->var.find(arrayname+varname_suffix);  \
+  if (it != sc_sess->var.end())                      \
+    outvar = it->second;
+
+  map<string, string>::iterator it; 
+
+  string v_from;
+  GET_VARIABLE_MANDATORY("_caller", v_from);
+  string v_to;
+  GET_VARIABLE_MANDATORY("_callee", v_to);
+  string v_domain;
+  GET_VARIABLE_MANDATORY("_domain", v_domain);
+  string app_name;
+  GET_VARIABLE_MANDATORY("_app", app_name);
+
+  string user = v_from;
+  string r_uri = "sip:"+v_to+"@"+v_domain;
+
+  GET_VARIABLE_OPTIONAL("_r_uri", r_uri);
+
+  string from = "<sip:"+v_from+"@"+v_domain+">"; 
+  GET_VARIABLE_OPTIONAL("_from", from);
+
+  string from_uri = "sip:"+v_from+"@"+v_domain; 
+  GET_VARIABLE_OPTIONAL("_from_uri", from_uri);
+
+  string to = "<sip:"+v_to+"@"+v_domain+">";
+  GET_VARIABLE_OPTIONAL("_to", to);
+
+  string auth_user; 
+  GET_VARIABLE_OPTIONAL("_auth_user", auth_user);
+
+  string auth_pwd; 
+  GET_VARIABLE_OPTIONAL("_auth_pwd", auth_pwd);
+   
+  string ltag; 
+  GET_VARIABLE_OPTIONAL("_ltag", ltag);
+
+  string hdrs; 
+  GET_VARIABLE_OPTIONAL("_hdrs", hdrs);
+  
+#undef GET_VARIABLE_MANDATORY
+#undef GET_VARIABLE_OPTIONAL
+
+  DBG("placing UAC call: user <%s>, app <%s>, ruri <%s>, from <%s> "
+      "from_uri <%s>, to <%s>, ltag <%s>, hdrs <%s>, auth_user <%s>, auth_pwd 
<not shown>\n",
+      user.c_str(), app_name.c_str(), r_uri.c_str(), from.c_str(),
+      from_uri.c_str(), to.c_str(), ltag.c_str(), hdrs.c_str(), 
auth_user.c_str());
+
+  AmArg* sess_params = NULL;
+  if (!auth_user.empty() && !auth_pwd.empty()) {
+    sess_params = new AmArg();
+    sess_params->setBorrowedPointer(new UACAuthCred("", auth_user,auth_pwd));
+  }
+ 
+ AmSession* new_sess = AmUAC::dialout(user, app_name, r_uri, from, from_uri, 
to, ltag, hdrs, sess_params);
+
+ if (NULL != new_sess) {
+   sc_sess->var[arrayname + "_ltag"] = new_sess->getLocalTag();
+ } else {
+   sc_sess->var[arrayname + "_ltag"] = "";
+   sc_sess->SET_ERRNO(DSM_ERRNO_GENERAL);
+ }
+
+} EXEC_ACTION_END;

Modified: trunk/apps/dsm/mods/mod_dlg/ModDlg.h
===================================================================
--- trunk/apps/dsm/mods/mod_dlg/ModDlg.h        2010-04-21 00:03:29 UTC (rev 
1813)
+++ trunk/apps/dsm/mods/mod_dlg/ModDlg.h        2010-04-21 00:26:00 UTC (rev 
1814)
@@ -38,4 +38,5 @@
 DEF_ACTION_2P(DLGAcceptInviteAction);
 DEF_ACTION_2P(DLGConnectCalleeRelayedAction);
 DEF_ACTION_1P(DLGByeAction);
+DEF_ACTION_1P(DLGDialoutAction);
 #endif

Modified: trunk/apps/dsm/mods/mod_dlg/Readme.mod_dlg.txt
===================================================================
--- trunk/apps/dsm/mods/mod_dlg/Readme.mod_dlg.txt      2010-04-21 00:03:29 UTC 
(rev 1813)
+++ trunk/apps/dsm/mods/mod_dlg/Readme.mod_dlg.txt      2010-04-21 00:26:00 UTC 
(rev 1814)
@@ -22,3 +22,28 @@
 dlg.connectCalleeRelayed(string remote_party, string remote_uri)
  like B2B.connectCallee() but for relayed INVITEs, i.e. for executing in 
  invite run (run_invite_event=yes and transition "on INVITE" START - invite -> 
runinvite;)
+
+
+dlg.dialout(string arrayname)
+  dial out a new call
+  simple format/mandatory:
+   arrayname_caller   caller user
+   arrayname_callee   callee user
+   arrayname_domain   domain caller and callee
+   arrayname_app      application to execute
+
+  additional/overwrite:
+   arrayname_r_uri     INVITE request URI
+   arrayname_from      From
+   arrayname_from_uri  From URI (only internally used)
+   arrayname_to        To
+   arrayname_auth_user authentication user
+   arrayname_auth_pwd  authentication pwd
+   arrayname_ltag      ltag for new call
+   arrayname_hdrs      headers for new call
+
+  returns $arrayname_ltag and sets ERRNO.
+   
+
+
+

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

Reply via email to