<?xml version="1.0" encoding="utf-8"?>
<!--
//  Copyright (C) 2006 Microsoft Corporation.  All rights reserved.
//  The xml file that describes the finite state machine.
-->
<FiniteStateMachine>
	<FsmModule>
		<!-- Check whether we should wait for source party information or not -->
		<Menu id="callDiscriminator">
			<Transition condition="waitForSourcePartyInfo" event="noKey" refId="getSourcePartyInfoMenu" action="null"/>
			<Transition condition="NOT waitForSourcePartyInfo" event="noKey" refId="100" action="null"/>
		</Menu>
		
		<!-- Check whether the valid diversion received from gateway ================================-->
		<Menu id="100" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<!-- 
			the condition "skipInitialGreetings" should only be true if we get a valid REFERRED-BY header that points to a
			UMEnabled user in the dialplan serviced by this server. 
			-->
			<Transition event="noKey" condition="SkipInitialGreetings" refId="104" action="getName"/>

			<Condition value="NOT SkipInitialGreetings">
				<!-- resolve diversion -->
				<Transition event="noKey" condition="IsNull(ocFeature)" refId="infoGreetingMenu" action="getExtension"/>
				<!-- If we are executing a specific OC feature skip the welcome/announcement greetings -->
				<Transition event="noKey" condition="NOT IsNull(ocFeature)" refId="101" action="getExtension"/>
			</Condition>
			
				<!-- Virtual Number Call -->
			<Transition event="virtualNumberCall" refId="VirtualNumber" action="null"/>
			<!-- diversion found, and it was a call to UM enabled number. Transition to leave voicemail menu -->
			<Transition event="extensionFound" condition="IsNull(ocFeature)" refId="PersonalAutoAttendant" action="null" refInfo="callAnswering"/>
			<Transition event="extensionFound" condition="NOT IsNull(ocFeature) AND ((ocFeature EQ @VoiceMemo) OR (ocFeature EQ @PlayGreeting))" refId="700" action="null" refInfo="callAnswering"/>
			<!-- diversion found, and it was a call to DTMF AA, transition to AA menu -->
			<Transition event="validDtmfAutoAttendant" refId="900" action="null"/>
			<!-- diversion found, and it was a call to Speech Enabled AA, transition to Speech AA -->
			<Transition event="validSpeechAutoAttendant" refId="2000" action="null"/>
			<!-- play-on-phone outbound call, run the transition to PlayOnPhone-->
			<Transition event="playOnPhone" refId="5100" action="null"/>
			<!-- play-on-phone outbound call, run the transition to PlayOnPhone-->
			<Transition event="playOnPhonePAAGreeting" refId="PAAAdmin" action="null"/>
			<!-- A UMDiagnostic Call was detected, run the UmDiagnostic Manager -->
			<Transition event="umdiagnosticCall" refId="6000" action="null"/>
			<!-- A FindMeSubscriber Call was detected, run the FindmeSubscriber Manager -->
			<Transition event="findMeSubscriberCall" refId="findMeSubscriber" action="null"/>
			<!-- The diverted extension is not allowed to accept voice mail -->
			<Transition event ="divertedExtensionNotAllowVoiceMail" action="null" refId="cannotLeaveVoiceMailMenu"/>
		</Menu>

		<!-- 
			Wait up to 4 seconds for source party information. Any dtmf input received
			during this state will be queued by MSS. E.g.: this allows entering a pin
			while we are waiting for source party and diversion data.
		-->
		<Menu id="getSourcePartyInfoMenu" uninterruptible="true">
			<Prompt type="silence" name="4s"/>
			<Transition event="noKey" refId="100" action="null"/>
		</Menu>
		
		<!-- 
			The diverted extension is not allowed to accept voice mail, play prompt and disconnect the call
		-->
		<Menu id="cannotLeaveVoiceMailMenu" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Prompt type="statement" name ="tuiCannotLeaveVoiceMail"/>
			<Transition event="noKey" action="disconnect" refId="cannotLeaveVoiceMailMenu"/>
		</Menu>
	</FsmModule>
</FiniteStateMachine>
