Revision
16602
Author
rupa
Date
2010-02-11 09:01:21 -0600 (Thu, 11 Feb 2010)

Log Message

nobal_amt and lowbal_amt channel vars can override defaults in config

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c (16601 => 16602)


--- freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c	2010-02-11 08:33:03 UTC (rev 16601)
+++ freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c	2010-02-11 15:01:21 UTC (rev 16602)
@@ -360,6 +360,8 @@
 	switch_time_exp_t tm;
 	const char *billrate;
 	const char *billaccount;
+	float nobal_amt = globals.nobal_amt;
+	float lowbal_amt = globals.lowbal_amt;
 	float balance;
 
 	if (!session) {
@@ -377,6 +379,13 @@
 	/* Variables kept in FS but relevant only to this module */
 	billrate = switch_channel_get_variable(channel, "nibble_rate");
 	billaccount = switch_channel_get_variable(channel, "nibble_account");
+	
+	if (!zstr(switch_channel_get_variable(channel, "nobal_amt"))) {
+		nobal_amt = atof(switch_channel_get_variable(channel, "nobal_amt"));
+	}
+	if (!zstr(switch_channel_get_variable(channel, "lowbal_amt"))) {
+		lowbal_amt = atof(switch_channel_get_variable(channel, "lowbal_amt"));
+	}
 
 	/* Return if there's no billing information on this session */
 	if (!billrate || !billaccount) {
@@ -399,11 +408,11 @@
 
 		/* See if this person has enough money left to continue the call */
 		balance = get_balance(billaccount);
-		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Comparing %f to hangup balance of %f\n", balance, globals.nobal_amt);
-		if (balance <= globals.nobal_amt) {
+		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Comparing %f to hangup balance of %f\n", balance, nobal_amt);
+		if (balance <= nobal_amt) {
 			/* Not enough money - reroute call to nobal location */
 			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
-							  balance, globals.nobal_amt, billaccount);
+							  balance, nobal_amt, billaccount);
 
 			transfer_call(session, globals.nobal_action);
 		}
@@ -480,10 +489,10 @@
 
 		/* See if this person has enough money left to continue the call */
 		balance = get_balance(billaccount);
-		if (balance <= globals.nobal_amt) {
+		if (balance <= nobal_amt) {
 			/* Not enough money - reroute call to nobal location */
 			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
-							  balance, globals.nobal_amt, billaccount);
+							  balance, nobal_amt, billaccount);
 
 			/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
 			/* in nibblebill checking the call again in the routing process for an allowed balance! */