<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">
<descriptor>
<name>com/emarson/lemonade/examples/mobank/pin/VerifyPinSaveAndRemove</name>
<version>1.0</version>
<description>
This action is invoked after user specified a PIN number.
It does the following things:
- reads the values of PIN and PIN confirmation text fields,
- if any of them is shorter than 4 digits or if they don't match,
shows the error alert and returns,
- stores the value of the PIN in the permanent location, in
'com/emarson/lemonade/examples/mobank/pin/PinValue'
- updates the STARTUP_INSTRUCTION to the one being part
of the package (NewStartupInstruction)
- removes the whole 'pin' package
- removes from the application menu label to run 'pin' package
- forwards user to the mobank main screen
- shows an information alert confirming the PIN has been saved.
The last three of those are achieved by invoking RemovePackage node.
</description>
<vendor>E-MARSON</vendor>
</descriptor>
<path>
<action name="go to the main screen">
<type>general/bluelemon/code</type>
<definition resultTo="cancelAction">
<blue:call node="com/emarson/lemonade/examples/mobank/MainScreen"
location="@com/emarson/lemonade/examples/mobank"/>
</definition>
</action>
<action name="verify pin numbers and save">
<type>general/bluelemon/code</type>
<definition resultTo="verifyAndSavePIN">
<blue:call manager="GeneralManager" method="getCurrent"
toVariable="form"
castTo="com/emarson/lemonade/bluelemon/midp1/Form"/>
<blue:call object="form" method="getItem"
toVariable="pinField"
castTo="com/emarson/lemonade/bluelemon/midp1/TextField">
<blue:argument type="byte" value="0"/>
</blue:call>
<blue:call object="pinField" method="getString"
toVariable="pin"/>
<blue:call object="form" method="getItem"
toVariable="pinConfirmationField"
castTo="com/emarson/lemonade/bluelemon/midp1/TextField">
<blue:argument type="byte" value="1"/>
</blue:call>
<blue:call object="pinConfirmationField" method="getString"
toVariable="pinConfirmation"/>
<blue:call manager="UtilsManager" method="length"
toVariable="pinLength">
<blue:argument type="variable" name="pin"/>
</blue:call>
<blue:call manager="UtilsManager" method="length"
toVariable="pinConfirmationLength">
<blue:argument type="variable" name="pinConfirmation"/>
</blue:call>
<blue:call manager="UtilsManager" method="lesserThan"
toVariable="pinIsNot4DigitsLong">
<blue:argument type="variable" name="pinLength"/>
<blue:argument type="byte" value="4"/>
</blue:call>
<blue:call manager="UtilsManager" method="lesserThan"
toVariable="pinConfirmationIsNot4DigitsLong">
<blue:argument type="variable" name="pinConfirmationLength"/>
<blue:argument type="byte" value="4"/>
</blue:call>
<blue:call manager="UtilsManager" method="OR"
toVariable="anyStringIsNot4DigitsLong">
<blue:argument type="variable" name="pinIsNot4DigitsLong"/>
<blue:argument type="variable" name="pinConfirmationIsNot4DigitsLong"/>
</blue:call>
<blue:if isTrue="anyStringIsNot4DigitsLong">
<blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Alert"
toVariable="alert"/>
<blue:call object="alert" method="initialize">
<blue:argument type="String" value="Wrong PIN"/>
<blue:argument type="String" value="PIN must be 4 digits long."/>
<blue:argument type="byte" value="AlertType.WARNING"/>
<blue:argument type="short" value="1500"/>
</blue:call>
<blue:call manager="GeneralManager" method="setCurrent">
<blue:argument type="variable" name="alert"/>
</blue:call>
<blue:return/>
</blue:if>
<blue:call manager="UtilsManager" method="equalValues"
toVariable="pinsMatch">
<blue:argument type="variable" name="pin"/>
<blue:argument type="variable" name="pinConfirmation"/>
</blue:call>
<blue:call manager="UtilsManager" method="NOT"
toVariable="pinsDontMatch">
<blue:argument type="variable" name="pinsMatch"/>
</blue:call>
<blue:if isTrue="pinsDontMatch">
<blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Alert"
toVariable="alert"/>
<blue:call object="alert" method="initialize">
<blue:argument type="String" value="Wrong PIN"/>
<blue:argument type="String" value="The numbers you entered don't match."/>
<blue:argument type="byte" value="AlertType.WARNING"/>
<blue:argument type="short" value="1500"/>
</blue:call>
<blue:call manager="GeneralManager" method="setCurrent">
<blue:argument type="variable" name="alert"/>
</blue:call>
<blue:return/>
</blue:if>
<blue:set node="com/emarson/lemonade/examples/mobank/pin/PinValue"
location="permanent">
<blue:argument type="variable" name="pin"/>
</blue:set>
</definition>
</action>
<action name="update startup instruction">
<type>general/bluelemon/code</type>
<definition resultTo="updateStartupInstruction">
<blue:get node="com/emarson/lemonade/examples/mobank/pin/NewStartupInstruction"
location="@com/emarson/lemonade/examples/mobank/pin"
toVariable="newStartupInstruction"/>
<blue:set node="STARTUP_INSTRUCTION" location="permanent">
<blue:argument type="variable" name="newStartupInstruction"/>
</blue:set>
<blue:set node="com/emarson/lemonade/examples/mobank/pin/MistakesCounter"
location="permanent">
<blue:argument type="byte" value="0"/>
</blue:set>
</definition>
</action>
<action name="remove package">
<type>general/bluelemon/code</type>
<definition resultTo="removePackage">
<blue:call node="com/emarson/lemonade/examples/mobank/pin/RemovePackage"
location="@com/emarson/lemonade/examples/mobank/pin"/>
</definition>
</action>
<action name="show confirmation alert">
<type>general/bluelemon/code</type>
<definition resultTo="showConfirmationAlert">
<blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Alert"
toVariable="alert"/>
<blue:call object="alert" method="initialize">
<blue:argument type="String" value="Success"/>
<blue:argument type="String" value="PIN has been set successfully."/>
<blue:argument type="byte" value="AlertType.CONFIRMATION"/>
<blue:argument type="short" value="Alert.FOREVER"/>
</blue:call>
<blue:call manager="GeneralManager" method="setCurrent">
<blue:argument type="variable" name="alert"/>
</blue:call>
</definition>
</action>
<finish name="done">
<return>verifyAndSavePIN + updateStartupInstruction +
removePackage + showConfirmationAlert</return>
</finish>
</path>
</process>