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

  <descriptor>
    <name>com/emarson/lemonade/examples/mobank/_deployment/Package</name>
    <version>1.0</version>
    <description>
      It generates a package containing the following nodes:
       - com/emarson/lemonade/examples/mobank/MainScreen
       - com/emarson/lemonade/examples/mobank/AuthenticationScreen
       - com/emarson/lemonade/examples/mobank/InitializeDownloading
       - com/emarson/lemonade/examples/mobank/FinalizeDownloading
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>
    
    <!-- CONTENT OF THE PACKAGE --->

    <subprocess name="authentication screen">
      <source>com/emarson/lemonade/examples/mobank/AuthenticationScreen</source>
      <resultTo>authenticationScreen</resultTo>
    </subprocess>

    <subprocess name="main screen">
      <source>com/emarson/lemonade/examples/mobank/MainScreen</source>
      <resultTo>mainScreen</resultTo>
    </subprocess>

    <!-- 
      When "new BluelemonArgument()" is specified as a parameter
      to the process which builds a Bluelemon instruction,
      the process will generate a procedure instead of a 
      ready-to-use instruction. The procedure will need to be 
      called with the parameters on the Bluelemon code level.
    --->

    <subprocess name="initialize downloading screen">
      <source>com/emarson/lemonade/templates/downloading/InitializeDownloadingScreen</source>
      <arguments>
        <argument key="title">new BluelemonArgument(1)</argument>
        <argument key="textUnderGauge">new BluelemonArgument(2)</argument>
        <argument key="cancelText">new BluelemonArgument(3)</argument>
        <argument key="cancelAction">new BluelemonArgument(4)</argument>
      </arguments>
      <resultTo>initializeDownloadingScreen</resultTo>
    </subprocess>
    
    <subprocess name="finalize downloading screen">
      <source>com/emarson/lemonade/templates/downloading/FinalizeDownloadingScreen</source>
      <resultTo>finalizeDownloadingScreen</resultTo>
    </subprocess>
    
    
    <!-- INSTALL PACKAGE INSTRUCTION --->
    
    <action name="prepare the arrays with package definitions"> 
      <type>general/bcl</type>
      <definition>
        package = new Array(4);
        package[0] = authenticationScreen;
        package[1] = mainScreen;
        package[2] = initializeDownloadingScreen;
        package[3] = finalizeDownloadingScreen;
        packageNames = new Array(4);
        packageNames[0] = "com/emarson/lemonade/examples/mobank/AuthenticationScreen";
        packageNames[1] = "com/emarson/lemonade/examples/mobank/MainScreen";
        packageNames[2] = "com/emarson/lemonade/examples/mobank/InitializeDownloading";
        packageNames[3] = "com/emarson/lemonade/examples/mobank/FinalizeDownloading";
      </definition>
    </action>

    <action name="create the install package">
      <type>general/bluelemon/package</type>
      <definition resultTo="package" 
                  packageName="com/emarson/lemonade/examples/mobank"
                  valuesContextKey="package" 
                  namesContextKey="packageNames"/>

    </action>
    
    <subprocess name="to be sure it will be processed correctly, wrap it">
      <source>com/emarson/lemonade/templates/ProcessCode</source>
      <arguments>
        <argument key="code">package</argument>
      </arguments>
      <resultTo>wrappedPackage</resultTo>
    </subprocess>

    <finish name="done">
      <return>wrappedPackage</return>
    </finish>

  </path>

</process>