Advertisement
Guest User

Main.mxml

a guest
Dec 26th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                xmlns:mx="library://ns.adobe.com/flex/mx"
  4.                xmlns:s="library://ns.adobe.com/flex/spark"
  5.                xmlns:views="org.bigbluebutton.main.views.*"
  6.                xmlns:maps="org.bigbluebutton.main.maps.*"
  7.                xmlns:mate="http://mate.asfusion.com/"
  8.                pageTitle="Cloudpe+"
  9.                preinitialize="init(event)"
  10.                splashScreenImage="@Embed('src/org/bigbluebutton/common/assets/images/logo.png')"
  11.                applicationComplete="appComplete()"
  12.                activate="onActivateApp(event)"
  13.                deactivate="onDeactivateApp(event)">
  14.     <!-- Place non-visual elements (e.g., services, value objects) here -->
  15.     <fx:Declarations>
  16.         <maps:ApplicationEventMap/>
  17.         <mate:Listener type="{BBBEvent.LOGIN_EVENT}"
  18.                        method="handleLoginEvent"/>
  19.         <mate:Listener type="{BBBEvent.FAIL_TO_JOIN_EVENT}"
  20.                        method="handleFailJoinEvent"/>
  21.         <mate:Listener type="{BBBEvent.RECEIVED_PUBLIC_CHAT_MESSAGE_EVENT}"
  22.                        method="handleReceivedPublicChatMessageEvent"/>
  23.         <mate:Listener type="{BBBEvent.ADDED_LISTENER}"
  24.                        method="handleAddedListenerEvent"/>
  25.         <mate:Listener type="{BBBEvent.PRESENTATION_CONVERTED}"
  26.                        method="handlePresentationConversion"/>
  27.         <mate:Listener type="{BBBEvent.VIDEO_STARTED}"
  28.                        method="videoHasStarted"/>
  29.         <mate:Listener type="{BBBEvent.CLOSE_APPLICATION}"
  30.                        method="closeApplication"/>
  31.     </fx:Declarations>
  32.  
  33.     <fx:Script>
  34.         <![CDATA[
  35.         import com.asfusion.mate.events.Dispatcher;
  36.  
  37.         import flash.net.navigateToURL;
  38.  
  39.         import mx.events.FlexEvent;
  40.         import mx.managers.HistoryManager;
  41.         import mx.managers.IDragManager;
  42.  
  43.         import spark.components.Button;
  44.         import spark.components.Label;
  45.  
  46.         import org.bigbluebutton.common.LogUtil;
  47.         import org.bigbluebutton.core.BBB;
  48.         import org.bigbluebutton.core.managers.UserManager;
  49.         import org.bigbluebutton.main.events.BBBEvent;
  50.         import org.bigbluebutton.main.events.BackButtonEvent;
  51.         import org.bigbluebutton.main.events.TryLoginEvent;
  52.         import org.bigbluebutton.main.model.ConfigParameters;
  53.         import org.bigbluebutton.util.i18n.ResourceUtil;
  54.  
  55.         private var module1:ChatModule;
  56.         private var module2:ListenersModule;
  57.         private var module3:PhoneModule;
  58.         private var module4:PresentModule;
  59.         private var module5:ViewersModule;
  60.         private var module6:WhiteboardModule;
  61.         private var configParameters:ConfigParameters = new ConfigParameters(function ():void {
  62.         });
  63.  
  64.         private var langResources:ResourceUtil = ResourceUtil.getInstance();
  65.  
  66.         public var joinUrl:String = "";
  67.         public var logoutUrl:String = "";
  68.  
  69.         /**
  70.          * Thse two lines are workaround for this. (ralam - Nov 8, 2008)
  71.          * http://gregjessup.com/flex-3-advanceddatagrid-cannot-convert-mxmanagersdragmanagerimpl-to-mxmanagersidragmanager/
  72.          * http://butterfliesandbugs.wordpress.com/2007/10/25/workaround-for-error-when-loading-popups-from-modules/
  73.          */
  74.         private var iDragManager:IDragManager;
  75.  
  76.         /** another workaround - for this issue: https://bugs.adobe.com/jira/browse/SDK-13121*/
  77.         private var hist:HistoryManager;
  78.  
  79.         private var globalDispatcher:Dispatcher = new Dispatcher();
  80.  
  81.         // Login test // flag to indicate if we successfully logged in
  82.  
  83.         private static var _applicationHostAddress:String;
  84.  
  85.         // Chat test
  86.  
  87.         // Voice test
  88.         private static var didUserJoin:Boolean = false;
  89.  
  90.         // Presentation test
  91.  
  92.         // Video test
  93.  
  94.         private static var myStage:Stage;
  95.         private static var HOME_PAGE:String = "http://meet.cloudpe.com";
  96.  
  97.         public static function get applicationHostAddress():String {
  98.             return BigBlueButton._applicationHostAddress;
  99.         }
  100.  
  101.         protected function init(event:FlexEvent):void {
  102.             preventBackKeyDown();
  103.  
  104.             this.systemManager.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleFailJoinEvent);
  105.  
  106.             NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
  107.  
  108.             NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
  109.         }
  110.  
  111.         private function onDeactivateApp(event:Event):void {
  112.             mobileShell.handleDeactivateEvent();
  113.         }
  114.  
  115.         private function onActivateApp(event:Event):void {
  116.             mobileShell.activateScreen();
  117.         }
  118.  
  119.         private function preventBackKeyDown():void {
  120.             // Add device event listeners
  121.             systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN, deviceKeyDownHandler);
  122.             systemManager.stage.addEventListener(KeyboardEvent.KEY_UP, deviceKeyUpHandler);
  123.         }
  124.  
  125.         private static function deviceKeyDownHandler(event:KeyboardEvent):void {
  126.             var key:uint = event.keyCode;
  127.  
  128.             // We want to prevent the default down behavior for back key if
  129.             // the navigator has a view to pop back to
  130.             if (key == Keyboard.BACK) {
  131.                 event.preventDefault();
  132.             }
  133.         }
  134.  
  135.         /**
  136.          *  Called when the application's hardware back key is pressed
  137.          *  by the user.
  138.          */
  139.         private function deviceKeyUpHandler(event:KeyboardEvent):void {
  140.             var key:uint = event.keyCode;
  141.  
  142.             if (key == Keyboard.BACK)
  143.                 globalDispatcher.dispatchEvent(new BackButtonEvent(BackButtonEvent.BACK_BUTTON_EVENT));
  144.         }
  145.  
  146.         private static function handleLoginEvent(event:BBBEvent):void {
  147.             LogUtil.debug(" Received loggedin event");
  148.             var isLoggedIn:Boolean = true;
  149.             LogUtil.debug(" Received loggedin event " + isLoggedIn.toString());
  150.         }
  151.  
  152.         private static function handleReceivedPublicChatMessageEvent(event:BBBEvent):void {
  153.             var chatTestSucceeded:Boolean = false;
  154.             var chatMessageSent:String = "";
  155.             if (event.message.search(chatMessageSent) != -1)
  156.                 chatTestSucceeded = true;
  157.         }
  158.  
  159.         private static function handleAddedListenerEvent(event:BBBEvent):void {
  160.             didUserJoin = true;
  161.         }
  162.  
  163.         private static function handlePresentationConversion(event:Event):void {
  164.             var didPresentationConvert:Boolean = true;
  165.         }
  166.  
  167.         private static function appComplete():void {
  168.             // mobileShell.lockOrientation();
  169.  
  170.         }
  171.  
  172.         private static function videoHasStarted(e:Event):void {
  173.             var didVideoStart:Boolean = true;
  174.         }
  175.  
  176.         private function onInvoke(event:InvokeEvent):void {
  177.             if (configParameters.testmode) {
  178.                 // test apk
  179.                 logoutUrl = configParameters.logoutUrl;
  180.                 joinUrl = configParameters.testJoinUrl;
  181.                 setHostAddress(joinUrl);
  182.                 BBB.initConfigManager();
  183.  
  184.                 globalDispatcher.dispatchEvent(new TryLoginEvent(TryLoginEvent.TRY_LOGIN_EVENT));
  185.  
  186.             }
  187.             else {
  188.                 // Production apk
  189.                 if (event.arguments[0]) {
  190.  
  191.                     joinUrl = event.arguments[0].replace("cloudpe://", "http://");
  192.                     setHostAddress(joinUrl);
  193.  
  194.                     BBB.initConfigManager();
  195.  
  196.                     globalDispatcher.dispatchEvent(new TryLoginEvent(TryLoginEvent.TRY_LOGIN_EVENT));
  197.  
  198.                 }
  199.                 else if (!didUserJoin) {
  200.                     navigateToURL(new URLRequest(HOME_PAGE));
  201.                 }
  202.             }
  203.  
  204.         }
  205.  
  206.         private function handleFailJoinEvent(e:Event):void {
  207.  
  208.             //Only handle IOError and BBBEvent.FAIL_TO_JOIN_EVENT
  209.             if (e is UncaughtErrorEvent) {
  210.                 var error:Object = e["error"];
  211.                 LogUtil.error(error.message);
  212.                 return;
  213.             }
  214.  
  215.             meetingEndHandler();
  216.         }
  217.  
  218.         private function meetingEndHandler():void {
  219.             mobileShell.visible = false;
  220.  
  221.             var gap:Number = height / 7;
  222.  
  223.             var notice:Label = new Label();
  224.             notice.setStyle("textAlign", "center");
  225.             notice.setStyle("fontWeight", "bold");
  226.             notice.setStyle("fontSize", 28);
  227.             notice.text = langResources.getString("bbb.logout.meetingended");
  228.             notice.width = width;
  229.             notice.x = width / 2 - notice.width / 2;
  230.             notice.y = height / 2 - gap / 2;
  231.             addElement(notice);
  232.  
  233.             var redirectBtn:Button = new Button();
  234.             redirectBtn.setStyle("fontSize", 28);
  235.             redirectBtn.label = langResources.getString("bbb.logout.selectOtherMeeting");
  236.             redirectBtn.width = notice.width * 3 / 4;
  237.             redirectBtn.height = 50;
  238.             addElement(redirectBtn);
  239.             redirectBtn.x = width / 2 - redirectBtn.width / 2;
  240.             redirectBtn.y = notice.y + redirectBtn.height / 2 + gap / 2;
  241.  
  242.             redirectBtn.addEventListener(MouseEvent.CLICK, function ():void {
  243.                 if (UserManager.getInstance().getConference().logOutUrl != "") {
  244.                     HOME_PAGE = UserManager.getInstance().getConference().logOutUrl;
  245.                 }
  246.  
  247.                 navigateToURL(new URLRequest(HOME_PAGE));
  248.  
  249.                 var delay:Timer = new Timer(100);
  250.                 delay.start();
  251.                 delay.addEventListener(TimerEvent.TIMER, function ():void {
  252.                     delay.stop();
  253.                     NativeApplication.nativeApplication.exit(0);
  254.                 });
  255.             });
  256.         }
  257.  
  258.         private static function setHostAddress(url:String):void {
  259.             var search:Array = url.split("/");
  260.             BigBlueButton._applicationHostAddress = search[2];
  261.         }
  262.  
  263.         private function closeApplication(e:Event):void {
  264.             meetingEndHandler();
  265.         }
  266.         ]]>
  267.     </fx:Script>
  268.  
  269.     <views:MobileApplicationView id="mobileShell"/>
  270. </s:Application>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement