Module: sems
Branch: master
Commit: 96addf36be57eeb1dbb1ee8e34d996c536c5c661
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=96addf36be57eeb1dbb1ee8e34d996c536c5c661

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Wed Nov 24 00:05:30 2010 +0100

sbc: moved get user timer/prepaid interface

---

 apps/sbc/SBC.cpp |   58 +++++++++++++++++++++++++++++++++--------------------
 apps/sbc/SBC.h   |    3 ++
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index bc641b2..4003d07 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -250,15 +250,7 @@ void SBCDialog::onInvite(const AmSipRequest& req)
 
   // get timer
   if (call_profile.call_timer_enabled || call_profile.prepaid_enabled) {
-    AmDynInvokeFactory* fact =
-      AmPlugIn::instance()->getFactory4Di("user_timer");
-    if (NULL == fact) {
-      ERROR("load session_timer module for call timers\n");
-      throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
-    }
-    m_user_timer = fact->getInstance();
-    if(NULL == m_user_timer) {
-      ERROR("could not get a timer reference\n");
+    if (!getUserTimer()) {
       throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
     }
   }
@@ -280,20 +272,8 @@ void SBCDialog::onInvite(const AmSipRequest& req)
   if (call_profile.prepaid_enabled) {
     call_profile.prepaid_accmodule =
       replaceParameters(call_profile.prepaid_accmodule, "prepaid_accmodule", 
REPLACE_VALS);
-    if (call_profile.prepaid_accmodule.empty()) {
-      ERROR("using prepaid but empty prepaid_accmodule!\n");
-      throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
-    }
 
-    AmDynInvokeFactory* pp_fact =
-      AmPlugIn::instance()->getFactory4Di(call_profile.prepaid_accmodule);
-    if (NULL == pp_fact) {
-      ERROR("prepaid_accmodule '%s' not loaded\n", 
call_profile.prepaid_accmodule.c_str());
-      throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
-    }
-    prepaid_acc = pp_fact->getInstance();
-    if(NULL == prepaid_acc) {
-      ERROR("could not get a prepaid acc reference\n");
+    if (!getPrepaidInterface()) {
       throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR);
     }
 
@@ -330,6 +310,40 @@ void SBCDialog::onInvite(const AmSipRequest& req)
   connectCallee(to, ruri, true);
 }
 
+bool SBCDialog::getUserTimer() {
+  AmDynInvokeFactory* fact =
+    AmPlugIn::instance()->getFactory4Di("user_timer");
+  if (NULL == fact) {
+    ERROR("load session_timer module for call timers\n");
+  }
+  m_user_timer = fact->getInstance();
+  if(NULL == m_user_timer) {
+    ERROR("could not get a timer reference\n");
+    return false;
+  }
+  return true;
+}
+
+bool SBCDialog::getPrepaidInterface() {
+  if (call_profile.prepaid_accmodule.empty()) {
+    ERROR("using prepaid but empty prepaid_accmodule!\n");
+    return false;
+  }
+  AmDynInvokeFactory* pp_fact =
+    AmPlugIn::instance()->getFactory4Di(call_profile.prepaid_accmodule);
+  if (NULL == pp_fact) {
+    ERROR("prepaid_accmodule '%s' not loaded\n",
+         call_profile.prepaid_accmodule.c_str());
+    return false;
+  }
+  prepaid_acc = pp_fact->getInstance();
+  if(NULL == prepaid_acc) {
+    ERROR("could not get a prepaid acc reference\n");
+    return false;
+  }
+  return true;
+}
+
 void SBCDialog::process(AmEvent* ev)
 {
 
diff --git a/apps/sbc/SBC.h b/apps/sbc/SBC.h
index a2acbb1..1fa0d50 100644
--- a/apps/sbc/SBC.h
+++ b/apps/sbc/SBC.h
@@ -95,6 +95,9 @@ class SBCDialog : public AmB2BCallerSession
   void startPrepaidAccounting();
   void stopPrepaidAccounting();
 
+  bool getUserTimer();
+  bool getPrepaidInterface();
+
  public:
 
   SBCDialog(const SBCCallProfile& call_profile); //AmDynInvoke* user_timer);

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

Reply via email to