Skip to content

Commit

Permalink
Merge pull request #49 from SenecaCDOT-BigBlueButton/invalid-meeting-url
Browse files Browse the repository at this point in the history
handle case when join meeting url is not valid xml format
  • Loading branch information
capilkey committed Sep 9, 2014
2 parents e5e90c6 + 2b8e44c commit b5d1588
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/locale/en_US/resources.properties
Expand Up @@ -8,6 +8,7 @@ login.error.genericError=It was not possible to join this meeting, please try ag
login.error.invalidMeetingIdentifier=Meeting not found.\nPlease make sure that the meeting is running.
login.error.invalidPassword=Unauthorized access.\nThe provided password for this meeting is invalid.
login.error.noRedirect=Please use the web browser to access a meeting.
login.error.invalidURL=Invalid join URL.\nPlease contact your administrator.
participants.title=Participants
profile.title=Profile
profile.participant=Participant
Expand Down
45 changes: 31 additions & 14 deletions src/org/bigbluebutton/core/JoinService.as
Expand Up @@ -7,56 +7,73 @@ package org.bigbluebutton.core
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
import flash.net.URLRequestMethod;

import mx.graphics.shaderClasses.ExclusionShader;
import mx.utils.ObjectUtil;
import org.flexunit.internals.events.ExecutionCompleteEvent;

import org.bigbluebutton.core.util.URLFetcher;
import org.bigbluebutton.model.Config;
import org.flexunit.internals.events.ExecutionCompleteEvent;
import org.osflash.signals.ISignal;
import org.osflash.signals.Signal;
import org.bigbluebutton.core.util.URLFetcher;

public class JoinService
{
protected var _successSignal:Signal = new Signal();
protected var _unsuccessSignal:Signal = new Signal();


private static const URL_REQUEST_ERROR_TYPE:String = "TypeError";
private static const URL_REQUEST_INVALID_URL_ERROR:String = "invalidURL";
private static const URL_REQUEST_GENERIC_ERROR:String = "genericError";
private static const XML_RETURN_CODE_FAILED:String = "FAILED";
private static const JOIN_URL_EMPTY:String = "emptyJoinUrl";

public function get successSignal():ISignal {
return _successSignal;
}

public function get unsuccessSignal():ISignal {
return _unsuccessSignal;
}

public function join(joinUrl:String):void {
if (joinUrl.length == 0) {
onUnsuccess("emptyJoinUrl");
onUnsuccess(JOIN_URL_EMPTY);
return;
}

var fetcher:URLFetcher = new URLFetcher();
fetcher.successSignal.add(onSuccess);
fetcher.unsuccessSignal.add(onUnsuccess);
fetcher.fetch(joinUrl);
}

protected function onSuccess(data:Object, responseUrl:String, urlRequest:URLRequest):void {
try {
var xml:XML = new XML(data);
if (xml.returncode == "FAILED") {
if (xml.returncode == XML_RETURN_CODE_FAILED) {
onUnsuccess(xml.messageKey);
return;
}
} catch (e:Error) {
trace("The response is probably not a XML, continuing");
switch(e.name)
{
case URL_REQUEST_ERROR_TYPE:
onUnsuccess(URL_REQUEST_INVALID_URL_ERROR);
break;
default:
onUnsuccess(URL_REQUEST_GENERIC_ERROR);
}

trace("The response is probably not a XML. " + e.message);
return;
}
successSignal.dispatch(urlRequest, responseUrl);
}

protected function onUnsuccess(reason:String):void {
unsuccessSignal.dispatch(reason);
}
}
}
}

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<view:NoTabView xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:view="org.bigbluebutton.core.view.*"
>
<view:NoTabView xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:view="org.bigbluebutton.core.view.*"
>
<fx:Script>
<![CDATA[
public static const STATE_BASE:String = "Base";
Expand All @@ -12,6 +12,7 @@
public static const STATE_CHECKSUM_ERROR:String = "ChecksumError";
public static const STATE_INVALID_PASSWORD:String = "InvalidPassword";
public static const STATE_GENERIC_ERROR:String = "GenericError";
public static const STATE_INAVLID_URL:String = "InvalidURL";
]]>
</fx:Script>
<view:states>
Expand All @@ -21,18 +22,21 @@
<s:State name="ChecksumError"/>
<s:State name="InvalidPassword"/>
<s:State name="GenericError"/>
<s:State name="InvalidURL"/>
</view:states>
<s:Group width="100%" height="100%" styleName="pageStyle">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<s:Image styleName="bbbLogoStyle" includeIn="ChecksumError,GenericError,InvalidMeetingIdentifier,InvalidPassword,NoRedirect"/>
<s:Label id="messageText0" width="90%"
includeIn="ChecksumError,GenericError,InvalidMeetingIdentifier,InvalidPassword,NoRedirect"
<s:Image styleName="bbbLogoStyle" includeIn="ChecksumError,GenericError,InvalidMeetingIdentifier,InvalidPassword,NoRedirect,InvalidURL"/>
<s:Label id="messageText0" width="90%"
includeIn="ChecksumError,GenericError,InvalidMeetingIdentifier,InvalidPassword,NoRedirect,InvalidURL"
text.ChecksumError="{resourceManager.getString('resources', 'login.error.checksumError')}"
text.GenericError="{resourceManager.getString('resources', 'login.error.genericError')}"
text.InvalidMeetingIdentifier="{resourceManager.getString('resources', 'login.error.invalidMeetingIdentifier')}"
text.InvalidPassword="{resourceManager.getString('resources', 'login.error.invalidPassword')}"
text.NoRedirect="{resourceManager.getString('resources', 'login.error.noRedirect')}"/>
text.NoRedirect="{resourceManager.getString('resources', 'login.error.noRedirect')}"
text.InvalidURL="{resourceManager.getString('resources', 'login.error.invalidURL')}"/>

</s:Group>
</view:NoTabView>
Expand Up @@ -4,9 +4,9 @@ package org.bigbluebutton.view.navigation.pages.login
import flash.events.InvokeEvent;
import flash.filesystem.File;
import flash.system.Capabilities;

import mx.core.FlexGlobals;

import org.bigbluebutton.command.JoinMeetingSignal;
import org.bigbluebutton.core.ILoginService;
import org.bigbluebutton.model.IUserSession;
Expand All @@ -16,45 +16,45 @@ package org.bigbluebutton.view.navigation.pages.login
import org.bigbluebutton.view.navigation.IPagesNavigatorView;
import org.flexunit.internals.namespaces.classInternal;
import org.osmf.logging.Log;

import robotlegs.bender.bundles.mvcs.Mediator;

import spark.components.Application;

public class LoginPageViewMediator extends Mediator
{
[Inject]
public var view: ILoginPageView;

[Inject]
public var joinMeetingSignal: JoinMeetingSignal;

[Inject]
public var loginService: ILoginService;

[Inject]
public var userSession: IUserSession;

[Inject]
public var userUISession: IUserUISession;


override public function initialize():void
{
Log.getLogger("org.bigbluebutton").info(String(this));

//loginService.unsuccessJoinedSignal.add(onUnsucess);
userUISession.unsuccessJoined.add(onUnsucess);

NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
}

private function onUnsucess(reason:String):void
{
Log.getLogger("org.bigbluebutton").info(String(this) + ":onUnsucess() " + reason);
FlexGlobals.topLevelApplication.topActionBar.visible=false;
FlexGlobals.topLevelApplication.bottomMenu.visible=false;

switch(reason) {
case "emptyJoinUrl":
view.currentState = LoginPageViewBase.STATE_NO_REDIRECT;
Expand All @@ -68,58 +68,65 @@ package org.bigbluebutton.view.navigation.pages.login
case "invalidPassword":
view.currentState = LoginPageViewBase.STATE_INVALID_PASSWORD;
break;
case "invalidURL":
view.currentState = LoginPageViewBase.STATE_INAVLID_URL;
break;
case "genericError":
view.currentState = LoginPageViewBase.STATE_GENERIC_ERROR;
break;
default:
view.currentState = LoginPageViewBase.STATE_GENERIC_ERROR;
break;
}
// view.messageText.text = reason;
}

public function onInvokeEvent(invocation:InvokeEvent):void
{
var url:String = invocation.arguments.toString();

if(Capabilities.isDebugger)
{
// test-install server no longer works with 0.9 mobile client

//url = "bigbluebutton://test-install.blindsidenetworks.com/bigbluebutton/api/join?fullName=Air&meetingID=Demo+Meeting&password=ap&checksum=512620179852dadd6fe0665a48bcb852a3c0afac";
//url = "bigbluebutton://lab1.mconf.org/bigbluebutton/api/join?fullName=Air+client&meetingID=Test+room+4&password=prof123&checksum=5805753edd08fbf9af50f9c28bb676c7e5241349"
}

if (url.lastIndexOf("://") != -1)
{
NativeApplication.nativeApplication.removeEventListener(InvokeEvent.INVOKE, onInvokeEvent);

url = getEndURL(url);
}
else
{

}

joinMeetingSignal.dispatch(url);
}

/**
* Replace the schema with "http"
*/
protected function getEndURL(origin:String):String
{
return origin.replace('bigbluebutton://', 'http://');
}

override public function destroy():void
{
super.destroy();

//loginService.unsuccessJoinedSignal.remove(onUnsucess);
userUISession.unsuccessJoined.remove(onUnsucess);

NativeApplication.nativeApplication.removeEventListener(InvokeEvent.INVOKE, onInvokeEvent);

view.dispose();
view = null;
}
}
}
}

0 comments on commit b5d1588

Please sign in to comment.