<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">

  <descriptor>
    <name>com/emarson/lemonade/examples/blueSms/_deployment/Installer</name>
    <version>1.0</version>
    <description>
      The result Bluelemon instruction does the following:
       - installs the moBank package,
       - sets a STARTUP_INSTRUCTION to call the AuthenticationScreen node,
       - calls the AuthenticationScreen node.
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>
  
    <!-- ASSOCIATIONS --->
    
    <!-- association to MainScreen in the mobank package --->
    <action name="go to MainScreen">
      <type>general/bluelemon/code</type>
      <definition resultTo="goToMainScreen">
        <blue:call node="com/emarson/lemonade/examples/mobank/MainScreen"
                         location="@com/emarson/lemonade/examples/mobank"/>

      </definition>
    </action>


    <!-- PACKAGES INSTALLATION ---> 

    <subprocess name="mobank">
      <source>com/emarson/lemonade/examples/mobank/_deployment/Package</source>
      <resultTo>package</resultTo>
    </subprocess> 
    
    <subprocess name="moaccount">
      <source>com/emarson/lemonade/examples/mobank/_deployment/InstallerMoAccount</source>
      <resultTo>moaccountService</resultTo>
    </subprocess>    
    
    <subprocess name="mocheers">
      <source>com/emarson/lemonade/examples/mobank/_deployment/InstallerMoCheers</source>
      <resultTo>mocheersService</resultTo>
    </subprocess>


    <!-- 'PERMANENT' AND 'SESSION' UPDATES ---> 

    <!-- update the STARTUP_INSTRUCTION node --->
    <action name="update STARTUP_INSTRUCTION">
      <type>general/bluelemon/code</type>
      <definition resultTo="startupUpdate">

        <blue:set node="STARTUP_INSTRUCTION" location="permanent">
          <blue:argument type="byteArr" contextKey="goToMainScreen"/>
        </blue:set>

      </definition>
    </action>

    <!-- prepare the updating procedure... --->
    <subprocess name="main screen">
      <source>com/emarson/lemonade/examples/blueSms/_deployment/UpdateMessage</source>
      <resultTo>updatingProcedure</resultTo>
    </subprocess>
    
    <!-- ... and store it in the "permanent" location --->
    <action name="store updating procedure">
      <type>general/bluelemon/code</type>
      <definition resultTo="storeUpdatingProcedure">

        <blue:set node="com/emarson/lemonade/examples/mobank/UpdateMessage" 
                  location="permanent">

          <blue:argument type="byteArr" contextKey="updatingProcedure"/>
        </blue:set>

      </definition>
    </action>
    
    <!-- set update number --->
    <action name="set update number">
      <type>general/bluelemon/code</type>
      <definition resultTo="setUpdateNumber">

        <!-- set the update number --->
        <blue:set node="com/emarson/lemonade/examples/mobank/UpdateNo"
                  location="permanent">

          <blue:argument type="byte" value="1"/>
        </blue:set>

      </definition>
    </action>

    <!-- POST-INSTALL INSTRUCTION ---> 
    
    <!-- 
      goToMainScreen will be called as 
      a post-install instruction 
    --->


    <finish name="return the result">
      <return>package + startupUpdate + mocheersService + 
          moaccountService + storeUpdatingProcedure + 
          setUpdateNumber + goToMainScreen</return>
    </finish> 

  </path>

</process>