[asterisk-commits] russell: trunk r60522 - in /trunk: ./ apps/app_meetme.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 6 11:59:42 MST 2007


Author: russell
Date: Fri Apr  6 13:59:42 2007
New Revision: 60522

URL: http://svn.digium.com/view/asterisk?view=rev&rev=60522
Log:
Merged revisions 60521 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r60521 | russell | 2007-04-06 13:58:46 -0500 (Fri, 06 Apr 2007) | 16 lines

Fix a few problems with SLA.  (issue #9459, reported by francesco_r, fixed by me)

* The original behavior was that if one station put a call on hold, another one
  picked it up, and then hung up, the code would still consider the call on
  hold by the first station, so the trunk would not be hung up.  However, to
  better comply with what most people seem to expect it to behave, it will now
  hang up the trunk.

* Fix a problem with "barge=no".  This was only intended to prevent people from
  joining calls that are in progress.  However, it also prevented other people
  from picking up a call that was on hold.  This has been fixed.

* When there are no active stations on a trunk and it is on hold, the code now
  indicates the HOLD and UNHOLD conditions to the trunk channel.  This allows
  music on hold to be played to the trunk when it is on hold.

........

Modified:
    trunk/   (props changed)
    trunk/apps/app_meetme.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?view=diff&rev=60522&r1=60521&r2=60522
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Fri Apr  6 13:59:42 2007
@@ -426,6 +426,9 @@
 	/*! This option uses the values in the sla_hold_access enum and sets the
 	 * access control type for hold on this trunk. */
 	unsigned int hold_access:1;
+	/*! Whether this trunk is currently on hold, meaning that once a station
+	 *  connects to it, the trunk channel needs to have UNHOLD indicated to it. */
+	unsigned int on_hold:1;
 };
 
 struct sla_trunk_ref {
@@ -3141,12 +3144,14 @@
 			continue;
 
 		if ( (trunk_ref->trunk->barge_disabled 
-			&& trunk_ref->state != SLA_TRUNK_STATE_IDLE) ||
+			&& trunk_ref->state == SLA_TRUNK_STATE_UP) ||
 			(trunk_ref->trunk->hold_stations 
 			&& trunk_ref->trunk->hold_access == SLA_HOLD_PRIVATE
 			&& trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) ||
-			sla_check_station_hold_access(trunk_ref->trunk, station) )
+			sla_check_station_hold_access(trunk_ref->trunk, station) ) 
+		{
 			trunk_ref = NULL;
+		}
 
 		break;
 	}
@@ -3235,9 +3240,10 @@
 	}
 	trunk_ref->chan = NULL;
 	if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
-		!trunk_ref->trunk->hold_stations) {
+		trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
 		strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1);
 		admin_exec(NULL, conf_name);
+		trunk_ref->trunk->hold_stations = 0;
 		sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
 	}
 
@@ -3691,7 +3697,14 @@
 		event->station->name, event->trunk_ref->trunk->name);
 	sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD, 
 		INACTIVE_TRUNK_REFS, event->trunk_ref);
-	
+
+	if (event->trunk_ref->trunk->active_stations == 1) {
+		/* The station putting it on hold is the only one on the call, so start
+		 * Music on hold to the trunk. */
+		event->trunk_ref->trunk->on_hold = 1;
+		ast_indicate(event->trunk_ref->trunk->chan, AST_CONTROL_HOLD);
+	}
+
 	ast_softhangup(event->trunk_ref->chan, AST_CAUSE_NORMAL);
 	event->trunk_ref->chan = NULL;
 }
@@ -4053,6 +4066,7 @@
 	sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
 
 	trunk_ref->trunk->chan = NULL;
+	trunk_ref->trunk->on_hold = 0;
 
 	ast_dial_join(dial);
 	ast_dial_destroy(dial);
@@ -4174,7 +4188,12 @@
 		}
 	}
 
-	ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1);
+	if (ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1) == 0 &&
+		trunk_ref->trunk->on_hold) {
+		trunk_ref->trunk->on_hold = 0;
+		ast_indicate(trunk_ref->trunk->chan, AST_CONTROL_UNHOLD);
+	}
+
 	snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name);
 	ast_set_flag(&conf_flags, 
 		CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION);
@@ -4187,9 +4206,10 @@
 	}
 	trunk_ref->chan = NULL;
 	if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
-		!trunk_ref->trunk->hold_stations) {
+		trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
 		strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1);
 		admin_exec(NULL, conf_name);
+		trunk_ref->trunk->hold_stations = 0;
 		sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
 	}
 	
@@ -4276,6 +4296,7 @@
 	dispose_conf(conf);
 	conf = NULL;
 	trunk->chan = NULL;
+	trunk->on_hold = 0;
 
 	pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "SUCCESS");
 



More information about the asterisk-commits mailing list