Module: sems Branch: master Commit: e57526dfc42b04d8bfeb9f15cd96442dffbfd0ab URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=e57526dfc42b04d8bfeb9f15cd96442dffbfd0ab
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Mon Nov 15 17:23:06 2010 +0100 reorganized code --- apps/sbc/SBC.cpp | 38 +++++++++++++++++++++++--------------- apps/sbc/SBC.h | 1 + 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index e066f67..fad0310 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -561,22 +561,8 @@ bool SBCDialog::onOtherReply(const AmSipReply& reply) if(getCalleeStatus() == Connected) { m_state = BB_Connected; - if ((call_profile.call_timer_enabled || call_profile.prepaid_enabled) && - (NULL == m_user_timer)) { - ERROR("internal implementation error: invalid timer reference\n"); - terminateOtherLeg(); - terminateLeg(); + if (!startCallTimer()) return ret; - } - - if (call_profile.call_timer_enabled) { - DBG("SBC: starting call timer of %u seconds\n", call_timer); - AmArg di_args,ret; - di_args.push((int)SBC_TIMER_ID_CALL_TIMER); - di_args.push((int)call_timer); // in seconds - di_args.push(getLocalTag().c_str()); - m_user_timer->invoke("setTimer", di_args, ret); - } startPrepaidAccounting(); } @@ -622,6 +608,28 @@ void SBCDialog::stopCall() { terminateLeg(); } +/** @return whether successful */ +bool SBCDialog::startCallTimer() { + if ((call_profile.call_timer_enabled || call_profile.prepaid_enabled) && + (NULL == m_user_timer)) { + ERROR("internal implementation error: invalid timer reference\n"); + terminateOtherLeg(); + terminateLeg(); + return false; + } + + if (call_profile.call_timer_enabled) { + DBG("SBC: starting call timer of %u seconds\n", call_timer); + AmArg di_args,ret; + di_args.push((int)SBC_TIMER_ID_CALL_TIMER); + di_args.push((int)call_timer); // in seconds + di_args.push(getLocalTag().c_str()); + m_user_timer->invoke("setTimer", di_args, ret); + } + + return true; +} + void SBCDialog::startPrepaidAccounting() { if (!call_profile.prepaid_enabled) return; diff --git a/apps/sbc/SBC.h b/apps/sbc/SBC.h index b5185e2..babbc47 100644 --- a/apps/sbc/SBC.h +++ b/apps/sbc/SBC.h @@ -145,6 +145,7 @@ class SBCDialog : public AmB2BCallerSession SBCCallProfile call_profile; void stopCall(); + bool startCallTimer(); void startPrepaidAccounting(); void stopPrepaidAccounting(); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
