Finished decoupling the Main app from all other modules.

This commit is contained in:
deniszgonjanin 2010-07-30 23:24:12 +00:00
parent 133c7fdc99
commit 8bf45dc051
17 changed files with 156 additions and 102 deletions

View File

@ -26,7 +26,7 @@
xmlns:mate="http://mate.asfusion.com/"
pageTitle="BigBlueButton"
layout="absolute"
preloader="org.bigbluebutton.main.managers.BigBlueButtonPreloader">
preloader="org.bigbluebutton.main.model.BigBlueButtonPreloader">
<mx:Script>
<![CDATA[

View File

@ -93,7 +93,7 @@
import org.bigbluebutton.main.events.ParticipantJoinEvent;
import org.bigbluebutton.main.events.PortTestEvent;
import org.bigbluebutton.main.events.UserServicesEvent;
import org.bigbluebutton.main.model.ModulesProxy;
import org.bigbluebutton.main.model.modules.ModulesProxy;
import org.bigbluebutton.main.model.PortTestProxy;
import org.bigbluebutton.main.model.users.UserService;
import org.bigbluebutton.main.model.users.events.BroadcastStartedEvent;

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
BigBlueButton - http://www.bigbluebutton.org
Copyright (c) 2008-2009 by respective authors (see below). All rights reserved.
BigBlueButton is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with BigBlueButton; if not, If not, see <http://www.gnu.org/licenses/>.
$Id: $
-->
<!-- The CrossModuleEventMaps sole purpose is to deal with an issue with the Mate framework where events dispatched from one module will throw an error
if they are listenen to in another module without the main having some reference to the event as well. By having a reference here in the main to the event
we get around this error. For reference, the error looks like this:
TypeError: Error #1034: Type Coercion failed: cannot convert org.bigbluebutton.modules.viewers.view.events::ViewCameraEvent@10fadac1 to org.bigbluebutton.modules.viewers.view.events.ViewCameraEvent.
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at org.bigbluebutton.modules.viewers.view.components::StatusItemRenderer/viewCamera()[C:\Users\Snap\Documents\Flex Builder 3\bigbluebutton-client\src\org\bigbluebutton\modules\viewers\view\components\StatusItemRenderer.mxml:39]
at org.bigbluebutton.modules.viewers.view.components::StatusItemRenderer/__streamIcon_doubleClick()[C:\Users\Snap\Documents\Flex Builder 3\bigbluebutton-client\src\org\bigbluebutton\modules\viewers\view\components\StatusItemRenderer.mxml:53] -->
<EventMap xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://mate.asfusion.com/">
<mx:Script>
<![CDATA[
import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.modules.present.events.AddButtonToPresentationEvent;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
import org.bigbluebutton.modules.present.events.AddPresentationToolbarEvent;
import org.bigbluebutton.modules.present.events.NavigationEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.present.events.WindowResizedEvent;
import org.bigbluebutton.modules.viewers.events.StreamStartedEvent;
import org.bigbluebutton.modules.viewers.events.ViewCameraEvent;
]]>
</mx:Script>
<Listener type="{AddOverlayCanvasEvent}" />
<Listener type="{WindowResizedEvent}" />
<Listener type="{MadePresenterEvent}" />
<Listener type="{AddPresentationToolbarEvent}" />
<Listener type="{NavigationEvent}" />
<Listener type="{PresentationEvent}" />
<Listener type="{AddButtonToPresentationEvent}" />
<Listener type="{StreamStartedEvent}" />
<Listener type="{ViewCameraEvent}" />
</EventMap>

View File

@ -1,4 +1,4 @@
package org.bigbluebutton.main.managers
package org.bigbluebutton.main.model
{
import flash.display.Sprite;

View File

@ -0,0 +1,12 @@
package org.bigbluebutton.main.model.modules
{
import mx.modules.ModuleLoader;
public class BigBlueButtonModuleLoader extends ModuleLoader
{
public function BigBlueButtonModuleLoader()
{
super();
}
}
}

View File

@ -17,10 +17,11 @@
*
* $Id: $
*/
package org.bigbluebutton.main.model
package org.bigbluebutton.main.model.modules
{
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.system.ApplicationDomain;
import flash.utils.Dictionary;
import mx.collections.ArrayCollection;
@ -31,12 +32,11 @@ package org.bigbluebutton.main.model
import org.bigbluebutton.common.IBigBlueButtonModule;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.managers.ModuleManager;
public class ModuleDescriptor
{
private var _attributes:Object;
private var _loader:ModuleLoader;
private var _loader:BigBlueButtonModuleLoader;
private var _module:IBigBlueButtonModule;
private var _loaded:Boolean = false;
private var _started:Boolean = false;
@ -47,11 +47,12 @@ package org.bigbluebutton.main.model
public var unresolvedDependencies:ArrayCollection;
public var resolved:Boolean = false;
public function ModuleDescriptor(attributes:XML)
public function ModuleDescriptor(attributes:XML, applicationDomain:ApplicationDomain)
{
unresolvedDependencies = new ArrayCollection();
_attributes = new Object();
_loader = new ModuleLoader();
_loader = new BigBlueButtonModuleLoader();
_loader.applicationDomain = applicationDomain;
parseAttributes(attributes);
}

View File

@ -17,13 +17,14 @@
*
* $Id: $
*/
package org.bigbluebutton.main.managers
package org.bigbluebutton.main.model.modules
{
import com.asfusion.mate.events.Dispatcher;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.utils.Dictionary;
import mx.collections.ArrayCollection;
@ -35,7 +36,6 @@ package org.bigbluebutton.main.managers
import org.bigbluebutton.main.events.ModuleLoadEvent;
import org.bigbluebutton.main.events.UserServicesEvent;
import org.bigbluebutton.main.model.ConferenceParameters;
import org.bigbluebutton.main.model.ModuleDescriptor;
public class ModuleManager
{
@ -50,6 +50,7 @@ package org.bigbluebutton.main.managers
private var _numModules:int = 0;
private var _modules:Dictionary = new Dictionary();
private var sorted:ArrayCollection; //The array of modules sorted by dependencies, with least dependent first
private var _applicationDomain:ApplicationDomain;
private var _parameters:ConferenceParameters;
private var _version:String;
@ -65,6 +66,7 @@ package org.bigbluebutton.main.managers
public function ModuleManager()
{
_applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
_urlLoader = new URLLoader();
_urlLoader.addEventListener(Event.COMPLETE, handleComplete);
globalDispatcher = new Dispatcher();
@ -121,7 +123,7 @@ package org.bigbluebutton.main.managers
var item:XML;
for each(item in list){
var mod:ModuleDescriptor = new ModuleDescriptor(item);
var mod:ModuleDescriptor = new ModuleDescriptor(item, _applicationDomain);
_modules[item.@name] = mod;
_numModules++;
}

View File

@ -17,7 +17,7 @@
*
* $Id: $
*/
package org.bigbluebutton.main.model
package org.bigbluebutton.main.model.modules
{
import com.asfusion.mate.events.Dispatcher;
@ -27,12 +27,12 @@ package org.bigbluebutton.main.model
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.events.SuccessfulLoginEvent;
import org.bigbluebutton.main.events.PortTestEvent;
import org.bigbluebutton.main.managers.ModuleManager;
import org.bigbluebutton.modules.viewers.events.LoginSuccessEvent;
import org.bigbluebutton.main.model.PortTestProxy;
public class ModulesProxy {
private var modulesManager:org.bigbluebutton.main.managers.ModuleManager;
private var modulesManager:org.bigbluebutton.main.model.modules.ModuleManager;
private var portTestProxy:PortTestProxy;
private var _user:Object;
@ -42,7 +42,7 @@ package org.bigbluebutton.main.model
public function ModulesProxy() {
dispatcher = new Dispatcher();
portTestProxy = new PortTestProxy();
modulesManager = new org.bigbluebutton.main.managers.ModuleManager();
modulesManager = new org.bigbluebutton.main.model.modules.ModuleManager();
modulesManager.addInitializedListener(onInitializeComplete);
modulesManager.initialize();
}

View File

@ -42,7 +42,6 @@
<mate:Listener type="{PortTestEvent.TUNNELING_FAILED}" method="rtmptFailed" />
<mate:Listener type="{ModuleLoadEvent.MODULE_LOAD_PROGRESS}" method="updateModuleLoadProgress" />
<maps:CrossModuleEventMap />
<api:APIEventMap />
<mx:Script>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<EventMap xmlns="http://mate.asfusion.com/" xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
</EventMap>

View File

@ -0,0 +1,53 @@
package org.bigbluebutton.modules.present.api
{
import com.asfusion.mate.events.Dispatcher;
import mx.containers.Canvas;
import mx.controls.Button;
import org.bigbluebutton.common.IBbbCanvas;
import org.bigbluebutton.modules.present.events.AddButtonToPresentationEvent;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
public class PresentationAPI
{
private static var instance:PresentationAPI;
private var dispatcher:Dispatcher;
public function PresentationAPI(enforcer:SingletonEnforcer)
{
if (enforcer == null){
throw new Error("There can only be 1 UserManager instance");
}
initialize();
}
private function initialize():void{
dispatcher = new Dispatcher();
}
/**
* Return the single instance of the PresentationAPI class, which is a singleton
*/
public static function getInstance():PresentationAPI{
if (instance == null){
instance = new PresentationAPI(new SingletonEnforcer());
}
return instance;
}
public function addOverlayCanvas(canvas:IBbbCanvas):void{
var overlayEvent:AddOverlayCanvasEvent = new AddOverlayCanvasEvent(AddOverlayCanvasEvent.ADD_OVERLAY_CANVAS);
overlayEvent.canvas = canvas;
dispatcher.dispatchEvent(overlayEvent);
}
public function addButtonToToolbar(button:IPresentationButton):void{
var buttonEvent:AddButtonToPresentationEvent = new AddButtonToPresentationEvent(AddButtonToPresentationEvent.ADD_BUTTON);
buttonEvent.button = button;
dispatcher.dispatchEvent(buttonEvent);
}
}
}
class SingletonEnforcer{}

View File

@ -27,7 +27,9 @@
import mx.events.FlexEvent;
import org.bigbluebutton.main.model.users.events.RoleChangeEvent;
import org.bigbluebutton.modules.present.api.PresentationAPI;
import org.bigbluebutton.modules.present.business.PresentProxy;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
import org.bigbluebutton.modules.present.events.PresentModuleEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.present.events.PresenterCommands;
@ -37,12 +39,18 @@
import org.bigbluebutton.modules.present.managers.PresentManager;
import org.bigbluebutton.modules.present.views.PresentationWindow;
private var apiInstance:PresentationAPI;
private function createAPI():void{
apiInstance = PresentationAPI.getInstance();
}
]]>
</mx:Script>
<EventHandlers type="{FlexEvent.PREINITIALIZE}">
<ObjectBuilder generator="{PresentManager}" cache="global" />
<ObjectBuilder generator="{PresentProxy}" cache="global" />
<InlineInvoker method="createAPI" />
</EventHandlers>
<EventHandlers type="{PresentModuleEvent.START_MODULE}" >
@ -118,4 +126,6 @@
<MethodInvoker generator="{PresentProxy}" method="loadCurrentSlideLocally" arguments="{event}" />
</EventHandlers>
</EventMap>

View File

@ -72,7 +72,6 @@
import org.bigbluebutton.modules.present.api.IPresentationButton;
import org.bigbluebutton.modules.present.events.AddButtonToPresentationEvent;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
import org.bigbluebutton.modules.present.events.AddPresentationToolbarEvent;
import org.bigbluebutton.modules.present.events.DisplaySlideEvent;
import org.bigbluebutton.modules.present.events.MoveEvent;
import org.bigbluebutton.modules.present.events.NavigationEvent;

View File

@ -154,6 +154,12 @@
<InlineInvoker method="mockConnect" />
</EventHandlers>
<Listener type="{ViewCameraEvent.VIEW_CAMERA_EVENT}" method="viewCamera" />
<Listener type="{StreamStartedEvent.STREAM_STARTED}" method="streamStarted" />
<EventHandlers type="{StreamStartedEvent.STREAM_STARTED}">
<InlineInvoker method="streamStarted" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{ViewCameraEvent.VIEW_CAMERA_EVENT}">
<InlineInvoker method="viewCamera" arguments="{event}" />
</EventHandlers>
</EventMap>

View File

@ -6,12 +6,13 @@ package org.bigbluebutton.modules.whiteboard.managers
import flash.utils.Timer;
import org.bigbluebutton.main.events.AddUIComponentToMainCanvas;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardButtonEvent;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardToolbar;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardButton;
import org.bigbluebutton.modules.present.api.PresentationAPI;
import org.bigbluebutton.modules.present.events.AddButtonToPresentationEvent;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardButtonEvent;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardButton;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardToolbar;
public class WhiteboardManager
{
@ -42,15 +43,11 @@ package org.bigbluebutton.modules.whiteboard.managers
}
private function addHighlighterCanvas(e:TimerEvent):void{
var overlayEvent:AddOverlayCanvasEvent = new AddOverlayCanvasEvent(AddOverlayCanvasEvent.ADD_OVERLAY_CANVAS);
overlayEvent.canvas = highlighterCanvas;
globalDispatcher.dispatchEvent(overlayEvent);
PresentationAPI.getInstance().addOverlayCanvas(highlighterCanvas);
}
private function addHighlighterToolbar(e:TimerEvent):void{
var buttonEvent:AddButtonToPresentationEvent = new AddButtonToPresentationEvent(AddButtonToPresentationEvent.ADD_BUTTON);
buttonEvent.button = whiteboardButton;
globalDispatcher.dispatchEvent(buttonEvent);
PresentationAPI.getInstance().addButtonToToolbar(whiteboardButton);
}
public function positionToolbar(e:WhiteboardButtonEvent):void{

View File

@ -2,21 +2,29 @@
<EventMap xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://mate.asfusion.com/" xmlns:mate="org.bigbluebutton.common.mate.*">
<mx:Script>
<![CDATA[
import org.bigbluebutton.modules.whiteboard.events.WhiteboardButtonEvent;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
import mx.controls.Alert;
import org.bigbluebutton.modules.present.events.NavigationEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
import org.bigbluebutton.modules.whiteboard.business.DrawProxy;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import mx.events.FlexEvent;
import org.bigbluebutton.modules.whiteboard.managers.WhiteboardManager;
import org.bigbluebutton.main.events.ModuleStartedEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas;
import org.bigbluebutton.modules.whiteboard.managers.PageManager;
import org.bigbluebutton.modules.present.events.AddButtonToPresentationEvent;
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
import org.bigbluebutton.modules.present.events.NavigationEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.present.events.WindowResizedEvent;
import org.bigbluebutton.modules.whiteboard.business.DrawProxy;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardButtonEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
import org.bigbluebutton.modules.whiteboard.managers.PageManager;
import org.bigbluebutton.modules.whiteboard.managers.WhiteboardManager;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas;
private function dummyMethod():void{
}
]]>
</mx:Script>
@ -79,4 +87,25 @@
<EventHandlers type="{WhiteboardButtonEvent.WHITEBOARD_ADDED_TO_PRESENTATION}" >
<MethodInvoker generator="{WhiteboardManager}" method="positionToolbar" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{AddOverlayCanvasEvent.ADD_OVERLAY_CANVAS}" >
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{WindowResizedEvent.PRESENTATION_WINDOW_RESIZED_EVENT}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{AddButtonToPresentationEvent.ADD_BUTTON}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{NavigationEvent.GOTO_PAGE}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{PresentationEvent.PRESENTATION_LOADED}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
</EventMap>

View File

@ -3,8 +3,8 @@ package org.bigbluebutton.main
import flexunit.framework.TestCase;
import flexunit.framework.TestSuite;
import org.bigbluebutton.main.managers.ModuleManager;
import org.bigbluebutton.main.model.ModuleDescriptor;
import org.bigbluebutton.main.model.modules.ModuleManager;
import org.bigbluebutton.main.model.modules.ModuleDescriptor;
public class BbbModuleManagerTests extends TestCase
{