Author: sayer
Date: 2009-02-01 13:51:06 +0100 (Sun, 01 Feb 2009)
New Revision: 1252

Added:
   trunk/apps/auth_b2b/etc/auth_b2b.conf
Modified:
   trunk/apps/auth_b2b/AuthB2B.cpp
   trunk/apps/auth_b2b/AuthB2B.h
Log:
take account optionally from config file (overrides P-App-Param

Modified: trunk/apps/auth_b2b/AuthB2B.cpp
===================================================================
--- trunk/apps/auth_b2b/AuthB2B.cpp     2009-02-01 12:35:12 UTC (rev 1251)
+++ trunk/apps/auth_b2b/AuthB2B.cpp     2009-02-01 12:51:06 UTC (rev 1252)
@@ -34,9 +34,13 @@
 #include "AmAudio.h"
 #include "AmPlugIn.h"
 #include "AmMediaProcessor.h"
-//#include "AmConfigReader.h"
+#include "AmConfigReader.h"
 #include "AmSessionContainer.h"
 
+string AuthB2BFactory::user;
+string AuthB2BFactory::domain;
+string AuthB2BFactory::pwd;
+
 EXPORT_SESSION_FACTORY(AuthB2BFactory,MOD_NAME);
 
 AuthB2BFactory::AuthB2BFactory(const string& _app_name)
@@ -48,9 +52,16 @@
 
 int AuthB2BFactory::onLoad()
 {
-//   AmConfigReader cfg;
-//   if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
-//     return -1;
+   AmConfigReader cfg;
+   if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
+     INFO("No configuration for auth_b2b present (%s)\n",
+         (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str()
+         );
+   } else {
+     user = cfg.getParameter("user");
+     domain = cfg.getParameter("domain");
+     pwd = cfg.getParameter("pwd");
+   }
 
 //   user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
 //   if(!user_timer_fact) {
@@ -101,16 +112,22 @@
   setReceiving(false);
   AmMediaProcessor::instance()->removeSession(this);
 
-  string app_param = getHeader(req.hdrs, PARAM_HDR);
+  if (AuthB2BFactory::user.empty()) {
+    string app_param = getHeader(req.hdrs, PARAM_HDR);
 
-  if (!app_param.length()) {
-    AmSession::Exception(500, "auth_b2b: parameters not found");
+    if (!app_param.length()) {
+      AmSession::Exception(500, "auth_b2b: parameters not found");
+    }
+    
+    domain = get_header_keyvalue(app_param,"d");
+    user = get_header_keyvalue(app_param,"u");
+    password = get_header_keyvalue(app_param,"p");
+  } else {
+    domain = AuthB2BFactory::domain;
+    user = AuthB2BFactory::user;
+    password = AuthB2BFactory::pwd;
   }
 
-  domain = get_header_keyvalue(app_param,"d");
-  user = get_header_keyvalue(app_param,"u");
-  password = get_header_keyvalue(app_param,"p");
-
   from = "sip:"+user+"@"+domain;
   to = "sip:"+req.user+"@"+domain;
 

Modified: trunk/apps/auth_b2b/AuthB2B.h
===================================================================
--- trunk/apps/auth_b2b/AuthB2B.h       2009-02-01 12:35:12 UTC (rev 1251)
+++ trunk/apps/auth_b2b/AuthB2B.h       2009-02-01 12:51:06 UTC (rev 1252)
@@ -44,6 +44,10 @@
   
   int onLoad();
   AmSession* onInvite(const AmSipRequest& req);
+  static string user;
+  static string domain;
+  static string pwd;
+
 };
 
 class AuthB2BDialog : public AmB2BCallerSession

Added: trunk/apps/auth_b2b/etc/auth_b2b.conf
===================================================================
--- trunk/apps/auth_b2b/etc/auth_b2b.conf       2009-02-01 12:35:12 UTC (rev 
1251)
+++ trunk/apps/auth_b2b/etc/auth_b2b.conf       2009-02-01 12:51:06 UTC (rev 
1252)
@@ -0,0 +1,7 @@
+
+# Account to use on the outgoing call leg. If this is not set,
+# the account is taken from P-App-Param header (see Readme.auth_b2b)
+#
+# user=someuser
+# domain=somedomain.net
+# pwd=sompwd

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

Reply via email to