Browse code

pass variables to other DSM call for dlg.dialout()

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1863 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 29/04/2010 23:18:44
Showing 1 changed files
... ...
@@ -226,13 +226,38 @@ EXEC_ACTION_START(DLGDialoutAction) {
226 226
       user.c_str(), app_name.c_str(), r_uri.c_str(), from.c_str(),
227 227
       from_uri.c_str(), to.c_str(), ltag.c_str(), hdrs.c_str(), auth_user.c_str());
228 228
 
229
-  AmArg* sess_params = NULL;
229
+  AmArg* sess_params = new AmArg();
230
+  bool has_auth = false;
230 231
   if (!auth_user.empty() && !auth_pwd.empty()) {
231
-    sess_params = new AmArg();
232
-    sess_params->setBorrowedPointer(new UACAuthCred("", auth_user,auth_pwd));
232
+    AmArg auth_param;
233
+    auth_param.setBorrowedPointer(new UACAuthCred("", auth_user,auth_pwd));
234
+    sess_params->push(auth_param);
235
+    has_auth = true;
233 236
   }
237
+  AmArg var_struct;
238
+  string varprefix = arrayname+"_var.";
239
+  bool has_vars = false;
240
+  map<string, string>::iterator lb = sc_sess->var.lower_bound(varprefix);
241
+  while (lb != sc_sess->var.end()) {
242
+    if ((lb->first.length() < varprefix.length()) ||
243
+	strncmp(lb->first.c_str(), varprefix.c_str(),varprefix.length()))
244
+      break;
245
+    string varname = lb->first.substr(varprefix.length());
246
+    if (!has_auth) // sess_params is variable struct
247
+      (*sess_params)[varname] = lb->second;
248
+    else // variable struct is in sess_params array
249
+      var_struct[lb->first] = lb->second;
250
+
251
+    lb++;
252
+    has_vars = true;
253
+  }
254
+
255
+  if (has_vars && has_auth)
256
+      sess_params->push(var_struct);
234 257
  
235
- AmSession* new_sess = AmUAC::dialout(user, app_name, r_uri, from, from_uri, to, ltag, hdrs, sess_params);
258
+  DBG("sess_params: '%s'\n", AmArg::print(*sess_params).c_str());
259
+
260
+  AmSession* new_sess = AmUAC::dialout(user, app_name, r_uri, from, from_uri, to, ltag, hdrs, sess_params);
236 261
 
237 262
  if (NULL != new_sess) {
238 263
    sc_sess->var[arrayname + "_ltag"] = new_sess->getLocalTag();